展品维保小程序前端代码接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
5.9 KiB

  1. <template>
  2. <view class="user-container">
  3. <!-- 顶部背景区域 -->
  4. <view class="header-bg" @click="goLogin">
  5. <!-- 用户信息区域 -->
  6. <view class="user-info">
  7. <view class="avatar-section">
  8. <image class="avatar" :src="userInfo.headImage || '/static/默认头像.png'" mode="aspectFill"></image>
  9. </view>
  10. <view class="info-section">
  11. <text class="username">{{userInfo.nickName}}</text>
  12. <text class="user-id">ID:{{userInfo.id}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 常用功能模块 -->
  17. <view class="function-card">
  18. <view class="card-title">
  19. <text class="title-text" >常用功能</text>
  20. </view>
  21. <view class="function-list">
  22. <!-- 基本信息 -->
  23. <view class="function-item" @click="goToBasicInfo">
  24. <view class="item-left">
  25. <uv-icon name="account" size="28" color="#C70019"></uv-icon>
  26. <text class="item-text">基本信息</text>
  27. </view>
  28. <uv-icon name="arrow-right" size="24" color="#000"></uv-icon>
  29. </view>
  30. <!-- 用户协议和隐私政策 -->
  31. <view class="function-item" @click="showPrivacyPolicy">
  32. <view class="item-left">
  33. <uv-icon name="file-text" size="28" color="#C70019"></uv-icon>
  34. <text class="item-text">用户协议和隐私政策</text>
  35. </view>
  36. <uv-icon name="arrow-right" size="24" color="#000"></uv-icon>
  37. </view>
  38. <!-- 退出登录 -->
  39. <view class="function-item" @click="logout">
  40. <view class="item-left">
  41. <uv-icon name="minus-circle" size="24" color="#C70019"></uv-icon>
  42. <text class="item-text">退出登录</text>
  43. </view>
  44. <uv-icon name="arrow-right" size="24" color="#000"></uv-icon>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 用户协议和隐私政策弹窗 -->
  49. <uv-modal ref="privacyModal" title="用户协议和隐私政策" :show-cancel-button="false" confirm-text="我知道了" confirm-color="#C70019">
  50. <view class="privacy-content">
  51. <!-- 如果是富文本 -->
  52. <rich-text :nodes="configParamTextarea('app_agreement')">
  53. </rich-text>
  54. </view>
  55. </uv-modal>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. userInfo: {
  63. headImage: '/static/默认头像.png',
  64. nickName: '请先登录',
  65. id: 'XXXXX'
  66. }
  67. }
  68. },
  69. onShow() {
  70. // 如果没登陆过 就别登了
  71. if (uni.getStorageSync('token')) {
  72. this.getUserInfo();
  73. }
  74. },
  75. methods: {
  76. // 跳转登录页面
  77. goLogin() {
  78. uni.navigateTo({
  79. url: '/subPages/login/login'
  80. })
  81. },
  82. // 跳转到基本信息页面
  83. goToBasicInfo() {
  84. uni.navigateTo({
  85. url: '/subPages/user/profile'
  86. })
  87. },
  88. // 获取用户信息
  89. async getUserInfo() {
  90. const res = await this.$api.user.queryUser();
  91. if (res.code === 200) {
  92. this.userInfo = res.result;
  93. }
  94. },
  95. // 显示隐私政策弹窗
  96. showPrivacyPolicy() {
  97. this.$refs.privacyModal.open()
  98. },
  99. // 退出登录
  100. logout() {
  101. uni.showModal({
  102. title: '提示',
  103. content: '确定要退出登录吗?',
  104. confirmColor: '#C70019',
  105. success: (res) => {
  106. if (res.confirm) {
  107. // 清除本地存储的用户信息
  108. uni.removeStorageSync('token')
  109. // uni.removeStorageSync('userInfo')
  110. // 重置用户信息
  111. this.userInfo = {
  112. headImage: '/static/默认头像.png',
  113. nickName: '请先登录',
  114. id: 'XXXXX'
  115. }
  116. // 显示退出成功提示
  117. uni.showToast({
  118. title: '退出成功',
  119. icon: 'success'
  120. })
  121. }
  122. }
  123. })
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .privacy-content {
  130. padding: 20rpx;
  131. .privacy-section {
  132. margin-bottom: 30rpx;
  133. .section-title {
  134. font-size: 32rpx;
  135. font-weight: bold;
  136. color: #333;
  137. display: block;
  138. margin-bottom: 20rpx;
  139. }
  140. .section-text {
  141. font-size: 28rpx;
  142. color: #666;
  143. line-height: 1.6;
  144. display: block;
  145. margin-bottom: 15rpx;
  146. }
  147. }
  148. }
  149. .user-container {
  150. min-height: 100vh;
  151. background: #f5f5f5;
  152. position: relative;
  153. }
  154. .header-bg {
  155. height: 513rpx;
  156. background: linear-gradient(156deg, #f56073 15%, #c70019 61%, #ffacb6 100%);
  157. position: relative;
  158. padding: 0 46rpx;
  159. .user-info {
  160. display: flex;
  161. align-items: center;
  162. padding-top: 177rpx;
  163. .avatar-section {
  164. margin-right: 22rpx;
  165. .avatar {
  166. width: 120rpx;
  167. height: 120rpx;
  168. border-radius: 60rpx;
  169. // border: 4rpx solid rgba(255, 255, 255, 0.3);
  170. }
  171. }
  172. .info-section {
  173. flex: 1;
  174. .username {
  175. display: block;
  176. font-size: 30rpx;
  177. // font-weight: bold;
  178. color: #fff;
  179. margin-bottom: 12rpx;
  180. }
  181. .user-id {
  182. font-size: 28rpx;
  183. color: #fff;
  184. }
  185. }
  186. }
  187. }
  188. .function-card {
  189. width: 88%;
  190. height: 709rpx;
  191. background: #ffffff;
  192. border-radius: 16rpx;
  193. margin: -152rpx auto 0;
  194. position: relative;
  195. z-index: 2;
  196. padding: 57rpx 28rpx;
  197. .card-title {
  198. // margin-bottom: 40rpx;
  199. .title-text {
  200. font-size: 32rpx;
  201. font-weight: bold;
  202. color: $primary-text-color;
  203. }
  204. }
  205. .function-list {
  206. .function-item {
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. margin-top:44rpx ;
  211. border-bottom: 1rpx solid #f0f0f0;
  212. .item-left {
  213. display: flex;
  214. align-items: center;
  215. .item-text {
  216. font-size: 28rpx;
  217. color: $primary-text-color;
  218. margin-left: 14rpx;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>