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

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