userinfo.vue 2.9 KB

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