me.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <script lang="ts" setup>
  2. import { storeToRefs } from 'pinia'
  3. import { ref } from 'vue'
  4. import { LOGIN_PAGE } from '@/router/config'
  5. import { useUserStore } from '@/store'
  6. import { useTokenStore } from '@/store/token'
  7. definePage({
  8. style: {
  9. navigationBarTitleText: '我的',
  10. navigationStyle: 'custom',
  11. },
  12. })
  13. const userStore = useUserStore()
  14. const tokenStore = useTokenStore()
  15. // 使用storeToRefs解构userInfo
  16. const { userInfo } = storeToRefs(userStore)
  17. // 微信小程序下登录
  18. async function handleLogin() {
  19. // #ifdef MP-WEIXIN
  20. // 微信登录
  21. await tokenStore.wxLogin()
  22. // #endif
  23. // #ifndef MP-WEIXIN
  24. uni.navigateTo({
  25. url: `${LOGIN_PAGE}`,
  26. })
  27. // #endif
  28. }
  29. function handleLogout() {
  30. uni.showModal({
  31. title: '提示',
  32. content: '确定要退出登录吗?',
  33. success: (res) => {
  34. if (res.confirm) {
  35. // 清空用户信息
  36. useTokenStore().logout()
  37. // 执行退出登录逻辑
  38. uni.showToast({
  39. title: '退出登录成功',
  40. icon: 'success',
  41. })
  42. // #ifdef MP-WEIXIN
  43. // 微信小程序,去首页
  44. // uni.reLaunch({ url: '/pages/index/index' })
  45. // #endif
  46. // #ifndef MP-WEIXIN
  47. // 非微信小程序,去登录页
  48. // uni.navigateTo({ url: LOGIN_PAGE })
  49. // #endif
  50. }
  51. },
  52. })
  53. }
  54. // 顶部导航栏高度,设置banner位置
  55. const navigationBarHeight = ref(0)
  56. // #ifdef MP-WEIXIN
  57. function getNavigationBarHeight() {
  58. uni.getSystemInfo({
  59. success: (res) => {
  60. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  61. console.log('顶部导航栏高度:', res.statusBarHeight, menuButtonInfo)
  62. // 顶部导航栏高度 = 状态栏高度 + 胶囊的高度
  63. navigationBarHeight.value = res.statusBarHeight + menuButtonInfo.height + 12
  64. },
  65. })
  66. }
  67. getNavigationBarHeight()
  68. // #endif
  69. const show = ref(true)
  70. function close() {
  71. show.value = false
  72. }
  73. function open() {
  74. show.value = true
  75. }
  76. function menuClick(page) {
  77. uni.navigateTo({
  78. url: `/pages-A/${page}/index`,
  79. })
  80. }
  81. </script>
  82. <template>
  83. <view class="profile-container">
  84. <!-- 顶部区域 -->
  85. <view class="me-header" style="background: url('../../static/images/me/me-bg.png') no-repeat center center; background-size: cover;">
  86. <view class="me-header-avatar-info" :style="{ paddingTop: `${navigationBarHeight}px` }">
  87. <view class="me-header-avatar">
  88. <image src="https://picsum.photos/200/200" mode="" />
  89. </view>
  90. <view class="me-header-info">
  91. <view class="me-header-name">
  92. {{ userInfo.value?.nickName || '用户' }}
  93. </view>
  94. </view>
  95. </view>
  96. <view class="me-header-tips">
  97. <view class="me-header-tips-item">
  98. <view class="me-header-tips-item-num">
  99. 1,125
  100. </view>
  101. <view class="me-header-tips-item-des">
  102. 已领取
  103. </view>
  104. </view>
  105. <view class="me-header-tips-item">
  106. <view class="me-header-tips-item-num">
  107. 1,125
  108. </view>
  109. <view class="me-header-tips-item-des">
  110. 已使用
  111. </view>
  112. </view>
  113. <view class="me-header-tips-item">
  114. <view class="me-header-tips-item-num">
  115. 1,125
  116. </view>
  117. <view class="me-header-tips-item-des">
  118. 已过期
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. <!-- 菜单 -->
  124. <view class="me-header-menu">
  125. <view class="me-header-menu-item" @click="menuClick('applyForm')">
  126. <view class="me-header-menu-icon">
  127. <image src="@/static/images/me/coupon-need.png" mode="" />
  128. <view class="me-header-menu-text">
  129. 发券人申请
  130. </view>
  131. </view>
  132. <view class="me-header-menu-left">
  133. <up-icon name="arrow-right" color="#979797" size="12" />
  134. </view>
  135. </view>
  136. <view class="me-header-menu-item" @click="handleLogout">
  137. <view class="me-header-menu-icon">
  138. <image src="@/static/images/me/loginOut.png" mode="" />
  139. <view class="me-header-menu-text">
  140. 退出登录
  141. </view>
  142. </view>
  143. <view class="me-header-menu-left">
  144. <up-icon name="arrow-right" color="#979797" size="12" />
  145. </view>
  146. </view>
  147. </view>
  148. <!-- 申请中的提示框 -->
  149. <up-modal
  150. content="您已提交申请,请耐心等待!"
  151. title="提示"
  152. :show="show"
  153. >
  154. <template #confirmButton>
  155. <view class="rounded" style="margin-top: 20rpx;" @click="show = false">
  156. 我知道了
  157. </view>
  158. </template>
  159. </up-modal>
  160. </view>
  161. </template>
  162. <style lang="scss" scoped>
  163. // 提示框
  164. ::v-deep .u-modal {
  165. width: 580rpx !important;
  166. // height: 376rpx !important;
  167. border-radius: 20rpx !important;
  168. }
  169. ::v-deep .u-modal__title {
  170. font-weight: 500 !important;
  171. font-size: 34rpx !important;
  172. color: #333333 !important;
  173. padding-top: 29rpx !important;
  174. padding-bottom: 28rpx !important;
  175. }
  176. ::v-deep .u-modal__content {
  177. border-top: 1px solid #eeeeee;
  178. border-bottom: 1px solid #eeeeee;
  179. padding-top: 82rpx !important;
  180. padding-bottom: 64rpx !important;
  181. }
  182. ::v-deep .u-modal__content__text {
  183. font-weight: 500 !important;
  184. font-size: 32rpx !important;
  185. color: #333333 !important;
  186. text-align: center !important;
  187. }
  188. .rounded {
  189. width: 300rpx;
  190. line-height: 69rpx;
  191. background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
  192. border-radius: 35rpx;
  193. font-weight: 400;
  194. font-size: 30rpx;
  195. color: #ffffff;
  196. text-align: center;
  197. margin: 0 auto;
  198. }
  199. .profile-container {
  200. font-family: Alibaba PuHuiTi;
  201. .me-header {
  202. height: 575rpx;
  203. .me-header-avatar-info {
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: center;
  207. align-items: center;
  208. gap: 24rpx;
  209. .me-header-avatar {
  210. width: 128rpx;
  211. height: 128rpx;
  212. border-radius: 50%;
  213. overflow: hidden;
  214. image {
  215. width: 100%;
  216. height: 100%;
  217. object-fit: cover;
  218. }
  219. }
  220. .me-header-info {
  221. .me-header-name {
  222. font-weight: 500;
  223. font-size: 30rpx;
  224. color: #ffffff;
  225. }
  226. }
  227. }
  228. .me-header-tips {
  229. display: flex;
  230. margin-top: 49rpx;
  231. .me-header-tips-item {
  232. flex: 1;
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: center;
  236. align-items: center;
  237. gap: 15rpx;
  238. font-weight: 500;
  239. font-size: 34rpx;
  240. color: #ffffff;
  241. line-height: 1;
  242. .me-header-tips-item-num {
  243. font-weight: bold;
  244. }
  245. .me-header-tips-item-des {
  246. font-weight: 400;
  247. font-size: 24rpx;
  248. color: #ffffff;
  249. }
  250. }
  251. }
  252. }
  253. .me-header-menu {
  254. background: #ffffff;
  255. border-radius: 10rpx 10rpx 0rpx 0rpx;
  256. margin: -50rpx 24rpx 0;
  257. padding: 0 20rpx;
  258. .me-header-menu-item {
  259. height: 88rpx;
  260. display: flex;
  261. justify-content: space-between;
  262. align-items: center;
  263. border-bottom: 1px solid #eeeeee;
  264. &:last-child {
  265. border-bottom: none;
  266. }
  267. .me-header-menu-icon {
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. gap: 13rpx;
  272. image {
  273. width: 40rpx;
  274. height: 40rpx;
  275. }
  276. .me-header-menu-text {
  277. font-weight: 400;
  278. font-size: 26rpx;
  279. color: #333333;
  280. }
  281. }
  282. .me-header-menu-left {
  283. }
  284. }
  285. }
  286. }
  287. </style>