my.nvue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="page">
  3. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  4. <!-- 用户信息区 -->
  5. <view class="user-header">
  6. <view class="user-info">
  7. <text class="user-name">{{nickname || '未登录'}}</text>
  8. <text class="user-detail">AppId:{{appId}}</text>
  9. <text class="user-detail">手机号:{{phone}}</text>
  10. </view>
  11. <image class="avatar" :src="avatar" mode="aspectFill" @click="toInfo"></image>
  12. </view>
  13. <!-- 菜单列表 -->
  14. <view class="menu-list">
  15. <view class="menu-item" @click="goPage('/pages/device/mycases/mycases')">
  16. <image class="menu-icon" src="/static/my/icon3.png" mode="aspectFill"></image>
  17. <text class="menu-text">个性化方案</text>
  18. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  19. </view>
  20. <view class="menu-item" @click="goPage('/pages/my/msg/msg')">
  21. <image class="menu-icon" src="/static/my/icon6.png" mode="aspectFill"></image>
  22. <view class="menu-text-wrap">
  23. <text class="menu-text" style="margin-left:0;">系统消息</text>
  24. <view class="msg-dot" v-if="msgNum > 0"></view>
  25. </view>
  26. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  27. </view>
  28. <view class="menu-item" @click="goPage('/pages/my/version/version')">
  29. <image class="menu-icon" src="/static/my/icon2.png" mode="aspectFill"></image>
  30. <text class="menu-text">版本升级</text>
  31. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  32. </view>
  33. <view class="menu-item" @click="goPage('/pages/my/questions/questions')">
  34. <image class="menu-icon" src="/static/my/icon5.png" mode="aspectFill"></image>
  35. <text class="menu-text">帮助</text>
  36. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  37. </view>
  38. <view class="menu-item" @click="goPage('/pages/my/history/history')">
  39. <image class="menu-icon" src="/static/my/icon1.png" mode="aspectFill"></image>
  40. <text class="menu-text">使用记录</text>
  41. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  42. </view>
  43. <view class="menu-item" @click="onLogout">
  44. <image class="menu-icon" src="/static/my/icon4.png" mode="aspectFill"></image>
  45. <text class="menu-text">退出登录</text>
  46. <image class="menu-arrow" src="/static/my/arrowright.png" mode="aspectFill"></image>
  47. </view>
  48. </view>
  49. <!-- 退出确认弹窗 -->
  50. <customPopup :isShow="isShowDrawer" @closePop="isShowDrawer=false">
  51. <view class="popup-content">
  52. <text class="popup-title">确定退出登录?</text>
  53. <view class="popup-btns">
  54. <text class="btn-cancel" @click="isShowDrawer=false">取消</text>
  55. <text class="btn-confirm" @click="logoutConfirm">退出登录</text>
  56. </view>
  57. </view>
  58. </customPopup>
  59. </view>
  60. </template>
  61. <script>
  62. import customPopup from '@/components/customPopup/customPopup.nvue'
  63. export default {
  64. components: {
  65. customPopup
  66. },
  67. data() {
  68. return {
  69. statusBarHeight: 44,
  70. isShowDrawer: false,
  71. nickname: '用户',
  72. phone: '138****8888',
  73. appId: '',
  74. avatar: '/static/144x144.png',
  75. msgNum: 0
  76. }
  77. },
  78. onShow() {
  79. const sysInfo = uni.getSystemInfoSync()
  80. this.statusBarHeight = sysInfo.statusBarHeight || 44
  81. this.init()
  82. },
  83. methods: {
  84. init() {
  85. // 从本地存储读取用户信息(登录时已存入)
  86. const phone = uni.getStorageSync('phone') || ''
  87. const nickname = uni.getStorageSync('nickname') || '用户'
  88. const appId = uni.getStorageSync('appId') || ''
  89. const avatar = uni.getStorageSync('avatar') || '/static/144x144.png'
  90. if (phone) this.phone = phone
  91. this.nickname = nickname
  92. this.appId = appId
  93. this.avatar = avatar
  94. },
  95. toInfo() {
  96. uni.navigateTo({ url: '/pages/my/info/info' })
  97. },
  98. goPage(url) {
  99. uni.navigateTo({ url })
  100. },
  101. onLogout() {
  102. this.isShowDrawer = true
  103. },
  104. logoutConfirm() {
  105. // 清除用户会话数据,保留隐私政策同意状态
  106. uni.removeStorageSync('user_token')
  107. uni.removeStorageSync('user_info')
  108. this.isShowDrawer = false
  109. uni.reLaunch({ url: '/pages/login/login' })
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. .page {
  116. flex: 1;
  117. background-image: linear-gradient(to bottom, #389588, #38958800);
  118. }
  119. .status-bar {
  120. background-color: rgba(0,0,0,0);
  121. }
  122. /* 用户头部 */
  123. .user-header {
  124. flex-direction: row;
  125. justify-content: space-between;
  126. padding-left: 38rpx;
  127. padding-right: 38rpx;
  128. padding-top: 62rpx;
  129. padding-bottom: 62rpx;
  130. }
  131. .user-info {
  132. flex: 1;
  133. }
  134. .user-name {
  135. font-size: 48rpx;
  136. color: #FFFFFF;
  137. margin-bottom: 8rpx;
  138. }
  139. .user-detail {
  140. font-size: 32rpx;
  141. color: #FFFFFF;
  142. padding-left: 30rpx;
  143. line-height: 66rpx;
  144. }
  145. .avatar {
  146. width: 150rpx;
  147. height: 150rpx;
  148. border-radius: 150rpx;
  149. }
  150. /* 菜单列表 */
  151. .menu-list {
  152. background-color: #FFFFFF;
  153. border-top-left-radius: 30rpx;
  154. border-top-right-radius: 30rpx;
  155. padding-top: 40rpx;
  156. flex: 1;
  157. border-bottom: 1rpx solid #EEF1F4;
  158. }
  159. .menu-item {
  160. flex-direction: row;
  161. align-items: center;
  162. height: 104rpx;
  163. margin-left: 38rpx;
  164. margin-right: 38rpx;
  165. border-bottom-width: 1px;
  166. border-bottom-color: #EEF1F4;
  167. border-bottom-style: solid;
  168. }
  169. .menu-icon {
  170. width: 48rpx;
  171. height: 48rpx;
  172. margin-left: 32rpx;
  173. }
  174. .menu-text {
  175. flex: 1;
  176. font-size: 32rpx;
  177. color: #545F71;
  178. margin-left: 40rpx;
  179. }
  180. .menu-text-wrap {
  181. flex: 1;
  182. flex-direction: row;
  183. align-items: center;
  184. margin-left: 40rpx;
  185. }
  186. .msg-dot {
  187. width: 16rpx;
  188. height: 16rpx;
  189. background-color: #F65252;
  190. border-radius: 16rpx;
  191. margin-left: 10rpx;
  192. }
  193. .menu-arrow {
  194. width: 40rpx;
  195. height: 40rpx;
  196. margin-right: 16rpx;
  197. }
  198. /* 弹窗 */
  199. .popup-content {
  200. align-items: center;
  201. }
  202. .popup-title {
  203. font-size: 32rpx;
  204. color: #545F71;
  205. text-align: center;
  206. margin-top: 80rpx;
  207. margin-bottom: 80rpx;
  208. }
  209. .popup-btns {
  210. flex-direction: row;
  211. justify-content: space-around;
  212. width: 680rpx;
  213. }
  214. .btn-cancel {
  215. width: 306rpx;
  216. height: 88rpx;
  217. background-color: #F3F3F3;
  218. border-radius: 20rpx;
  219. font-size: 32rpx;
  220. color: #545F71;
  221. text-align: center;
  222. line-height: 88rpx;
  223. }
  224. .btn-confirm {
  225. width: 306rpx;
  226. height: 88rpx;
  227. background-color: #F65252;
  228. border-radius: 20rpx;
  229. font-size: 32rpx;
  230. color: #FFFFFF;
  231. text-align: center;
  232. line-height: 88rpx;
  233. }
  234. </style>