userinfo.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. userEdit,
  48. upload
  49. } from '@/api/set.js';
  50. export default {
  51. data() {
  52. return {
  53. }
  54. },
  55. onLoad() {
  56. console.log(this.userInfo)
  57. },
  58. computed: {
  59. ...mapState('user', ['userInfo'])
  60. },
  61. methods: {
  62. imgsub() {
  63. console.log('上传头像')
  64. upload({
  65. filename: ''
  66. }).then(data => {
  67. console.log("data", data);
  68. this.userInfo.avatar = data[0].img;
  69. })
  70. },
  71. confirm() {
  72. userEdit({
  73. avatar: this.userInfo.avatar,
  74. nickname: this.userInfo.nickname
  75. })
  76. .then(e => {
  77. this.$api.msg('修改成功');
  78. setTimeout(() => {
  79. uni.switchTab({
  80. url: '/pages/userhome/user'
  81. });
  82. }, 1000);
  83. console.log(e);
  84. })
  85. .catch(e => {
  86. console.log(e);
  87. });
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .content {
  94. padding-top: 30rpx;
  95. }
  96. .listBox {
  97. margin: 0 $page-row-spacing;
  98. border-radius: 20rpx;
  99. overflow: hidden;
  100. background-color: #FFFFFF;
  101. }
  102. .list {
  103. .listItem {
  104. padding: 35rpx 40rpx;
  105. border-bottom: 1px solid $page-color-light;
  106. }
  107. .listIconImg {
  108. width: 36rpx;
  109. }
  110. .right {
  111. color: $font-color-light;
  112. font-size: $font-base;
  113. flex-grow: 1;
  114. justify-content: flex-end;
  115. .img {
  116. width: 26rpx;
  117. }
  118. }
  119. .input {
  120. flex-grow: 1;
  121. text-align: right;
  122. font-size: $font-base;
  123. color: $color-gray;
  124. }
  125. .titleBox {
  126. .title {
  127. color: $font-color-base;
  128. font-size: $font-base;
  129. }
  130. }
  131. }
  132. .row {
  133. display: flex;
  134. align-items: center;
  135. padding: 35rpx 40rpx;
  136. background: #fff;
  137. border-bottom: 1px solid $page-color-light;
  138. .background-img {
  139. width: 80rpx;
  140. height: 80rpx;
  141. border-radius: 50%;
  142. background: #f2f2f2;
  143. }
  144. .tit {
  145. flex-shrink: 0;
  146. width: 120upx;
  147. font-size: $font-base;
  148. color: $font-color-base;
  149. }
  150. }
  151. </style>