set.vue 3.9 KB

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