personal.vue 3.1 KB

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