userinfo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="content">
  3. <view class="listBox">
  4. <view class="row flex" @click="imgsub">
  5. <text class="tit">头像</text>
  6. <view>
  7. <image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill">
  8. </image>
  9. </view>
  10. </view>
  11. <view class="list">
  12. <view class="flex listItem">
  13. <view class="flex titleBox">
  14. <text class="title">昵称</text>
  15. </view>
  16. <view class="right flex">
  17. <input class="input" type="text" v-model="userInfo.nickname" placeholder="请输入昵称" placeholder-class="placeholder" />
  18. </view>
  19. </view>
  20. <view class="flex listItem">
  21. <view class="flex titleBox">
  22. <text class="title">ID</text>
  23. </view>
  24. <view class="right flex">
  25. <text>{{userInfo.uid}}</text>
  26. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  27. </view>
  28. </view>
  29. <!-- <view class="flex listItem">
  30. <view class="flex titleBox">
  31. <text class="title">账户</text>
  32. </view>
  33. <view class="right flex">
  34. <text>{{userInfo.account}}</text>
  35. </view>
  36. </view> -->
  37. </view>
  38. </view>
  39. <view class="base-buttom" @click="confirm">提交</view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapState,
  45. } from 'vuex';
  46. import {
  47. upload
  48. } from '@/api/order.js';
  49. import {
  50. userEdit,
  51. } from '@/api/set.js';
  52. export default {
  53. data() {
  54. return {
  55. }
  56. },
  57. onLoad() {
  58. console.log(this.userInfo)
  59. },
  60. computed: {
  61. ...mapState('user', ['userInfo'])
  62. },
  63. methods: {
  64. imgsub() {
  65. console.log('上传头像')
  66. upload({
  67. filename: ''
  68. }).then(data => {
  69. console.log("data", data);
  70. this.userInfo.avatar = data[0].url;
  71. })
  72. },
  73. confirm() {
  74. userEdit({
  75. avatar: this.userInfo.avatar,
  76. nickname: this.userInfo.nickname
  77. })
  78. .then(e => {
  79. uni.showToast({
  80. title:"修改成功",
  81. icon:"success"
  82. })
  83. setTimeout(() => {
  84. uni.switchTab({
  85. url: '/pages/user/user'
  86. });
  87. }, 1000);
  88. console.log(e);
  89. })
  90. .catch(e => {
  91. console.log(e);
  92. });
  93. },
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .content {
  99. padding-top: 30rpx;
  100. }
  101. .listBox {
  102. margin: 0 $page-row-spacing;
  103. border-radius: 20rpx;
  104. overflow: hidden;
  105. background-color: #FFFFFF;
  106. }
  107. .list {
  108. .listItem {
  109. padding: 35rpx 40rpx;
  110. border-bottom: 1px solid $page-color-light;
  111. }
  112. .listIconImg {
  113. width: 36rpx;
  114. }
  115. .right {
  116. color: $font-color-light;
  117. font-size: $font-base;
  118. flex-grow: 1;
  119. justify-content: flex-end;
  120. .img {
  121. width: 26rpx;
  122. }
  123. }
  124. .input {
  125. flex-grow: 1;
  126. text-align: right;
  127. font-size: $font-base;
  128. color: $color-gray;
  129. }
  130. .titleBox {
  131. .title {
  132. color: $font-color-base;
  133. font-size: $font-base;
  134. }
  135. }
  136. }
  137. .row {
  138. display: flex;
  139. align-items: center;
  140. padding: 35rpx 40rpx;
  141. background: #fff;
  142. border-bottom: 1px solid $page-color-light;
  143. .background-img {
  144. width: 80rpx;
  145. height: 80rpx;
  146. border-radius: 50%;
  147. background: #f2f2f2;
  148. }
  149. .tit {
  150. flex-shrink: 0;
  151. width: 120upx;
  152. font-size: $font-base;
  153. color: $font-color-base;
  154. }
  155. }
  156. </style>