展品维保小程序前端代码接口
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.

264 lines
6.1 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" v-if="isLogin">
  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. isLogin: uni.getStorageSync('token')
  68. }
  69. },
  70. computed: {
  71. // 检查是否已登录
  72. },
  73. onShow() {
  74. this.isLogin = uni.getStorageSync('token')
  75. // 如果没登陆过 就别登了
  76. if (uni.getStorageSync('token')) {
  77. this.getUserInfo();
  78. }
  79. },
  80. methods: {
  81. // 跳转登录页面
  82. goLogin() {
  83. uni.navigateTo({
  84. url: '/subPages/login/login'
  85. })
  86. },
  87. // 跳转到基本信息页面
  88. goToBasicInfo() {
  89. uni.navigateTo({
  90. url: '/subPages/user/profile'
  91. })
  92. },
  93. // 获取用户信息
  94. async getUserInfo() {
  95. const res = await this.$api.user.queryUser();
  96. if (res.code === 200) {
  97. this.userInfo = res.result;
  98. }
  99. },
  100. // 显示隐私政策弹窗
  101. showPrivacyPolicy() {
  102. this.$refs.privacyModal.open()
  103. },
  104. // 退出登录
  105. logout() {
  106. uni.showModal({
  107. title: '提示',
  108. content: '确定要退出登录吗?',
  109. confirmColor: '#C70019',
  110. success: (res) => {
  111. if (res.confirm) {
  112. // 清除本地存储的用户信息
  113. uni.removeStorageSync('token')
  114. // 重置用户信息
  115. this.userInfo = {
  116. headImage: '/static/默认头像.png',
  117. nickName: '请先登录',
  118. id: 'XXXXX'
  119. }
  120. this.isLogin = false;
  121. // 显示退出成功提示
  122. uni.showToast({
  123. title: '退出成功',
  124. icon: 'success'
  125. })
  126. }
  127. }
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .privacy-content {
  135. padding: 20rpx;
  136. .privacy-section {
  137. margin-bottom: 30rpx;
  138. .section-title {
  139. font-size: 32rpx;
  140. font-weight: bold;
  141. color: #333;
  142. display: block;
  143. margin-bottom: 20rpx;
  144. }
  145. .section-text {
  146. font-size: 28rpx;
  147. color: #666;
  148. line-height: 1.6;
  149. display: block;
  150. margin-bottom: 15rpx;
  151. }
  152. }
  153. }
  154. .user-container {
  155. min-height: 100vh;
  156. background: #f5f5f5;
  157. position: relative;
  158. }
  159. .header-bg {
  160. height: 513rpx;
  161. background: linear-gradient(156deg, #f56073 15%, #c70019 61%, #ffacb6 100%);
  162. position: relative;
  163. padding: 0 46rpx;
  164. .user-info {
  165. display: flex;
  166. align-items: center;
  167. padding-top: 177rpx;
  168. .avatar-section {
  169. margin-right: 22rpx;
  170. .avatar {
  171. width: 120rpx;
  172. height: 120rpx;
  173. border-radius: 60rpx;
  174. // border: 4rpx solid rgba(255, 255, 255, 0.3);
  175. }
  176. }
  177. .info-section {
  178. flex: 1;
  179. .username {
  180. display: block;
  181. font-size: 30rpx;
  182. // font-weight: bold;
  183. color: #fff;
  184. margin-bottom: 12rpx;
  185. }
  186. .user-id {
  187. font-size: 28rpx;
  188. color: #fff;
  189. }
  190. }
  191. }
  192. }
  193. .function-card {
  194. width: 88%;
  195. height: 709rpx;
  196. background: #ffffff;
  197. border-radius: 16rpx;
  198. margin: -152rpx auto 0;
  199. position: relative;
  200. z-index: 2;
  201. padding: 57rpx 28rpx;
  202. .card-title {
  203. // margin-bottom: 40rpx;
  204. .title-text {
  205. font-size: 32rpx;
  206. font-weight: bold;
  207. color: $primary-text-color;
  208. }
  209. }
  210. .function-list {
  211. .function-item {
  212. display: flex;
  213. align-items: center;
  214. justify-content: space-between;
  215. margin-top:44rpx ;
  216. border-bottom: 1rpx solid #f0f0f0;
  217. .item-left {
  218. display: flex;
  219. align-items: center;
  220. .item-text {
  221. font-size: 28rpx;
  222. color: $primary-text-color;
  223. margin-left: 14rpx;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. </style>