set.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="set-page zx-container">
  3. <image @click="editAvatarFn" :src="userInfo.headimg || defaultHeadImg" class="head-img" />
  4. <view class="list-wrap">
  5. <view
  6. v-for="(item, index) in list"
  7. :key="index"
  8. class="item"
  9. @tap="routerLink(item.url)"
  10. >
  11. <view class="title">{{ item.title }}</view>
  12. <view :class="['text-right', item.hideArrow && 'hide-arrow']">
  13. <input class="inp" @blur="inpfn" v-if="item.textProp == 'nickname'" v-model="userInfo[item.textProp]" type="text" />
  14. <block v-else>
  15. {{ userInfo[item.textProp] || '' }}
  16. </block>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="zx-form-btn fix-bottom-btn logout-btn" @tap="handleQuit">退出登录</view>
  21. </view>
  22. </template>
  23. <script>
  24. const storage = require('@/common/storage.js')
  25. import { QINIU_URL, defaultHeadImg } from '@/common/constant'
  26. var config = require('../../common/config_gyq.js');
  27. var http = require('../../common/request');
  28. const common = require('../../common/common.js');
  29. export default {
  30. data() {
  31. return {
  32. QINIU_URL,
  33. defaultHeadImg,
  34. userInfo: {},
  35. list: [
  36. { title: '昵称', url: '', textProp: 'nickname' },
  37. { title: '注册时间', textProp: 'registrationTime', hideArrow: true },
  38. { title: '修改密码', url: '/pages/loginRegister/changePassword' },
  39. { title: '关于我们', url: '/pages/aboutMy/aboutMy', textProp: 'version' },
  40. { title: '隐私协议', url: '/pages/contract/contract?contract_id=270' },
  41. { title: '用户条款', url: '/pages/contract/contract?contract_id=102' }
  42. ]
  43. }
  44. },
  45. onShow() {
  46. const user_token = storage.getUserToken()
  47. user_token && this.loadUserInfo()
  48. },
  49. methods: {
  50. inpfn(e){
  51. console.log(e.detail.value)
  52. this.editUserInfoFn()
  53. },
  54. editAvatarFn(){
  55. let _this = this
  56. common.upLoadImgQiNiu((imgUrl)=> {
  57. _this.userInfo.headimg = imgUrl
  58. _this.editUserInfoFn()
  59. });
  60. },
  61. async editUserInfoFn(){
  62. let {data} = await http.postApi(config.API_USER_MODIFY_USER_INFO,{
  63. nickname:this.userInfo.nickname,
  64. head_img:this.userInfo.headimg,
  65. })
  66. storage.setUserInfoData(this.userInfo)
  67. },
  68. loadUserInfo() {
  69. const userInfo = storage.getUserInfoData()
  70. this.setData({ userInfo })
  71. },
  72. routerLink(url) {
  73. uni.navigateTo({ url })
  74. },
  75. handleQuit() {
  76. uni.showModal({
  77. title: '提示',
  78. content: '您确定要退出当前账号吗?',
  79. showCancel: true,
  80. cancelText: '取消',
  81. confirmText: '确定',
  82. success: function(res) {
  83. if (res.confirm) {
  84. storage.clearStorage()
  85. uni.reLaunch({
  86. url: '/pages/index/index'
  87. })
  88. }
  89. }
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. @import "@/libs/css/layout.scss";
  97. .inp{
  98. font-size: 30rpx;
  99. color: #060809;
  100. text-align: right;
  101. }
  102. .set-page {
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. padding: 66rpx 32rpx 48rpx;
  107. .head-img {
  108. width: 174rpx;
  109. height: 174rpx;
  110. margin: 0 auto 40rpx;
  111. border-radius: 50%;
  112. }
  113. .list-wrap {
  114. width: 100%;
  115. background: #FFFFFF;
  116. border-radius: 40rpx;
  117. padding: 8rpx 32rpx;
  118. .item {
  119. padding: 40rpx 0;
  120. display: flex;
  121. justify-content: space-between;
  122. border-bottom: 2px solid #F1F4F5;
  123. &:last-child {
  124. border-bottom: 0;
  125. }
  126. .title {
  127. font-family: PingFangSC, PingFang SC;
  128. font-weight: bold;
  129. font-size: 32rpx;
  130. color: #060809;
  131. }
  132. .text-right {
  133. font-family: Futura, Futura;
  134. font-weight: 500;
  135. font-size: 30rpx;
  136. color: #060809;
  137. display: flex;
  138. align-items: center;
  139. &::after {
  140. content: "";
  141. width: 28rpx;
  142. height: 28rpx;
  143. margin-left: 12rpx;
  144. background: url('https://qiniu.bms16.com/FtGhNkwKlhR7hOZsaj0gmRl9KjPx');
  145. background-size: 100%;
  146. }
  147. &.hide-arrow {
  148. &::after {
  149. display: none;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. .logout-btn {
  156. color: #FA2918;
  157. background: #E4E7EC;
  158. }
  159. }
  160. </style>