index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="auth">
  3. <view>
  4. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="chooseAvatar">
  5. <image class="avatar-image" style="" mode="widthFx" :src="headImage">
  6. </image>
  7. </button>
  8. <view style="width:100%;text-align: center;color: #a8a8a8;margin-bottom: 40rpx;">点击授权使用微信头像</view>
  9. <van-field @blur="changeNickName" :value="nickName" label="用户昵称" type="nickname" placeholder="请输入用户名"
  10. :border="true" />
  11. <view class="buttons">
  12. <van-button @click="sendUserInfo" round custom-style="width:100%" class="confirm"
  13. type="primary">更新个人信息</van-button>
  14. <van-button @click="cancel" custom-style="width:100%" class="cancel" round type="danger">返回</van-button>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import api from '@/api'
  21. export default {
  22. data() {
  23. return {
  24. headImage: "http://tmp/ekMKUCOq9knR5cb11ccf64e25bcec14a65f89951c334.jpeg",
  25. nickName: ""
  26. }
  27. },
  28. methods: {
  29. cancel() {
  30. uni.switchTab({
  31. url: "/pages/carVideo/index"
  32. })
  33. },
  34. chooseAvatar(e) {
  35. const { avatarUrl } = e.detail
  36. this.headImage = avatarUrl
  37. },
  38. changeNickName(e) {
  39. console.log(e)
  40. this.nickName = e.detail.value
  41. },
  42. sendUserInfo() {
  43. api.user.userInfoUserInfo({
  44. nickName: this.nickName,
  45. headImage: this.headImage
  46. }).then(res => {
  47. uni.showToast({
  48. title: "更新成功"
  49. })
  50. setInterval(() => {
  51. uni.switchTab({
  52. url: "/pages/carVideo/index"
  53. })
  54. }, 1500)
  55. })
  56. },
  57. },
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .auth {
  62. position: absolute;
  63. width: 100vw;
  64. height: 100vh;
  65. background: #fff;
  66. z-index: 10;
  67. display: flex;
  68. justify-content: center;
  69. padding-top: 250rpx;
  70. flex-wrap: wrap;
  71. .buttons {
  72. width: 100%;
  73. display: flex;
  74. flex-direction: column;
  75. margin-top: 40rpx;
  76. align-content: center;
  77. align-items: center;
  78. .confirm {
  79. width: 100%;
  80. }
  81. .cancel {
  82. width: 100%;
  83. margin-top: 40rpx;
  84. }
  85. }
  86. }
  87. .avatar-image {
  88. width: 150rpx;
  89. height: 150rpx;
  90. }
  91. .avatar-wrapper {
  92. width: 150rpx;
  93. height: 150rpx;
  94. background: #fff;
  95. padding: 0 !important;
  96. overflow: hidden;
  97. }
  98. button ::after {
  99. padding: 0;
  100. }
  101. </style>