personal.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="content">
  3. <view class="box" style="margin-top: 60rpx;">
  4. <view class="left">
  5. 头像
  6. </view>
  7. <view class="right" @click="chooseImg" v-if="img==''">
  8. <image class="img" :src="userInfo.avatar" mode=""></image>
  9. </view>
  10. <view class="right" v-else @click="chooseImg">
  11. <image class="img" :src="img" mode=""></image>
  12. </view>
  13. </view>
  14. <view class="box">
  15. <view class="left">
  16. 昵称
  17. </view>
  18. <input class="right" type="text" v-model="name" placeholder="修改昵称" placeholder-class="placeholder" />
  19. </view>
  20. <view class="box">
  21. <view class="left">
  22. 手机号
  23. </view>
  24. <view class="right" style="color: #999;">
  25. {{phone}}
  26. </view>
  27. </view>
  28. <view class="box">
  29. <view class="left">
  30. 实名认证
  31. </view>
  32. <view class="right" @click="navTo('/pages/user/realName')" v-if="userInfo.real_name_check.status==2">
  33. 未认证 >
  34. </view>
  35. <view class="right" v-else>
  36. {{userInfo.real_name_check.status==1?"已认证":"审批中"}} >
  37. </view>
  38. </view>
  39. <button class="button" @click="confirm">提交</button>
  40. </view>
  41. </template>
  42. <script>
  43. import { userEdit } from '@/api/set.js';
  44. import {realname} from '@/api/index.js'
  45. import {
  46. mapState,
  47. mapMutations
  48. } from 'vuex';
  49. import {
  50. upload
  51. } from '@/api/order.js'
  52. export default {
  53. data() {
  54. return {
  55. name: '',
  56. phone: '',
  57. img: '',
  58. };
  59. },
  60. computed: {
  61. ...mapState('user', ['userInfo'])
  62. },
  63. onLoad() {
  64. console.log(this.userInfo);
  65. this.name = this.userInfo.nickname
  66. this.phone = this.userInfo.phone
  67. // console.log(this.userInfo)
  68. },
  69. methods: {
  70. chooseImg() {
  71. let obj = this
  72. uni.chooseImage({
  73. count: 1,
  74. sourceType: ['album'], //从相册选择
  75. success: (e) => {
  76. obj.img = e.tempFilePaths[0]
  77. // upload({
  78. // filename: ''
  79. // }).then(res=>{
  80. // console.log(res,'res');
  81. // obj.img = res[0].url
  82. // })
  83. }
  84. })
  85. },
  86. navTo(url) {
  87. uni.navigateTo({
  88. url
  89. })
  90. },
  91. confirm() {
  92. userEdit({ nickname: this.name, avatar: this.img})
  93. .then(e => {
  94. this.$api.msg('修改成功');
  95. setTimeout(()=> {
  96. uni.switchTab({
  97. url:'/pages/user/user'
  98. });
  99. }, 1000);
  100. console.log(e);
  101. })
  102. .catch(e => {
  103. console.log(e);
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. page,
  111. .content {
  112. background: #111111;
  113. width: 750rpx;
  114. height: 100%;
  115. .box {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. margin: 0 30rpx;
  120. border-bottom: 2rpx solid #AEAEAE;
  121. padding: 30rpx 40rpx;
  122. .left {
  123. font-size: 26rpx;
  124. font-weight: 500;
  125. color: #FFFFFF;
  126. }
  127. .right {
  128. font-size: 26rpx;
  129. font-weight: 400;
  130. color: #FFFFFF;
  131. text-align: right;
  132. .img {
  133. width: 80rpx;
  134. height: 80rpx;
  135. border-radius: 50%;
  136. overflow: hidden;
  137. }
  138. }
  139. }
  140. .button {
  141. margin-top: 160rpx;
  142. width: 690rpx;
  143. height: 80rpx;
  144. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  145. border-radius: 10rpx;
  146. font-size: 30rpx;
  147. font-weight: 500;
  148. color: #FFFFFF;
  149. line-height: 80rpx;
  150. }
  151. }
  152. </style>