userinfo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. this.$api.msg('修改成功');
  80. setTimeout(() => {
  81. uni.switchTab({
  82. url: '/pages/user/user'
  83. });
  84. }, 1000);
  85. console.log(e);
  86. })
  87. .catch(e => {
  88. console.log(e);
  89. });
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. .content {
  96. padding-top: 30rpx;
  97. }
  98. .listBox {
  99. margin: 0 $page-row-spacing;
  100. border-radius: 20rpx;
  101. overflow: hidden;
  102. background-color: #FFFFFF;
  103. }
  104. .list {
  105. .listItem {
  106. padding: 35rpx 40rpx;
  107. border-bottom: 1px solid $page-color-light;
  108. }
  109. .listIconImg {
  110. width: 36rpx;
  111. }
  112. .right {
  113. color: $font-color-light;
  114. font-size: $font-base;
  115. flex-grow: 1;
  116. justify-content: flex-end;
  117. .img {
  118. width: 26rpx;
  119. }
  120. }
  121. .input {
  122. flex-grow: 1;
  123. text-align: right;
  124. font-size: $font-base;
  125. color: $color-gray;
  126. }
  127. .titleBox {
  128. .title {
  129. color: $font-color-base;
  130. font-size: $font-base;
  131. }
  132. }
  133. }
  134. .row {
  135. display: flex;
  136. align-items: center;
  137. padding: 35rpx 40rpx;
  138. background: #fff;
  139. border-bottom: 1px solid $page-color-light;
  140. .background-img {
  141. width: 80rpx;
  142. height: 80rpx;
  143. border-radius: 50%;
  144. background: #f2f2f2;
  145. }
  146. .tit {
  147. flex-shrink: 0;
  148. width: 120upx;
  149. font-size: $font-base;
  150. color: $font-color-base;
  151. }
  152. }
  153. </style>