index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <!-- 个人中心页面 -->
  3. <view class="content">
  4. <!-- 顶部 -->
  5. <view class="topBox">
  6. <image :src="getFileUrl('img/personal/bg.png')" mode="widthFix" class="top-Bg"></image>
  7. <image :src="getFileUrl('img/personal/uBg.png')" mode="widthFix" class="top-uBg"></image>
  8. <view class='top-title'>个人中心</view>
  9. </view>
  10. <!-- 内容 -->
  11. <view class="content-box">
  12. <view class="card">
  13. <view class="card-header">
  14. <image :src="getFileUrl('img/personal/userDemo.png')" mode="widthFix" class="card-header-icon">
  15. </image>
  16. <view class="card-header-title" hover-class="none" @click="handleLoginClick">{{ userStore.getToken ?
  17. (userStore.getUserInfo?.nickname || '用户') : '立即登录' }}</view>
  18. </view>
  19. <!-- 列表 -->
  20. <view class="card-list-container">
  21. <view class="card-list" hover-class="hover-active" @click='go("/pages/personal/userInfo")'>
  22. <view class='left'>
  23. <image :src="getFileUrl('img/personal/wszl.png')" mode="widthFix" class="card-icon"></image>
  24. <view class="title">完善资料</view>
  25. </view>
  26. <view class='right'>
  27. <image :src="getFileUrl('img/personal/right.png')" mode="widthFix" class="icon-right">
  28. </image>
  29. </view>
  30. </view>
  31. <view class="card-list" hover-class="hover-active" @click='go("/pages/orderInfo/index")'>
  32. <view class='left'>
  33. <image :src="getFileUrl('img/personal/wddd.png')" mode="widthFix" class="card-icon"></image>
  34. <view class="title">我的订单</view>
  35. </view>
  36. <view class='right'>
  37. <image :src="getFileUrl('img/personal/right.png')" mode="widthFix" class="icon-right">
  38. </image>
  39. </view>
  40. </view>
  41. <view class="card-list" hover-class="hover-active" @click='go("/pages/coupon/index")'>
  42. <view class='left'>
  43. <image :src="getFileUrl('img/personal/wdqb.png')" mode="widthFix" class="card-icon"></image>
  44. <view class="title">我的券包</view>
  45. </view>
  46. <view class='right'>
  47. <image :src="getFileUrl('img/personal/right.png')" mode="widthFix" class="icon-right">
  48. </image>
  49. </view>
  50. </view>
  51. <view class="card-list" hover-class="hover-active">
  52. <view class='left'>
  53. <image :src="getFileUrl('img/personal/yhxy.png')" mode="widthFix" class="card-icon"></image>
  54. <view class="title">用户协议</view>
  55. </view>
  56. <view class='right'>
  57. <image :src="getFileUrl('img/personal/right.png')" mode="widthFix" class="icon-right">
  58. </image>
  59. </view>
  60. </view>
  61. <view class="card-list" hover-class="hover-active">
  62. <view class='left'>
  63. <image :src="getFileUrl('img/personal/ysxy.png')" mode="widthFix" class="card-icon"></image>
  64. <view class="title">隐私政策</view>
  65. </view>
  66. <view class='right'>
  67. <image :src="getFileUrl('img/personal/right.png')" mode="widthFix" class="icon-right">
  68. </image>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 登录弹窗组件 -->
  75. <LoginModal v-model:open="showLoginModal" @success="handleLoginSuccess" @cancel="handleLoginCancel" />
  76. <!-- 底部导航 -->
  77. <TabBar />
  78. </view>
  79. </template>
  80. <script setup>
  81. import { ref } from 'vue';
  82. import TabBar from '@/components/TabBar.vue';
  83. import LoginModal from '@/pages/components/LoginModal.vue';
  84. import { getFileUrl } from '@/utils/file.js';
  85. import { useUserStore } from '@/store/user.js';
  86. import { go } from '@/utils/utils.js';
  87. const userStore = useUserStore();
  88. const showLoginModal = ref(false);
  89. // 处理登录点击
  90. const handleLoginClick = () => {
  91. if (!userStore.getToken) {
  92. showLoginModal.value = true;
  93. }
  94. };
  95. // 登录成功回调
  96. const handleLoginSuccess = (res) => {
  97. console.log('登录成功:', res);
  98. // 登录成功后可以刷新用户信息等操作
  99. };
  100. // 取消登录回调
  101. const handleLoginCancel = () => {
  102. console.log('用户取消登录');
  103. };
  104. </script>
  105. <style scoped lang="scss">
  106. .topBox {
  107. width: 100%;
  108. height: 400rpx;
  109. position: relative;
  110. .top-Bg {
  111. width: 100%;
  112. height: 100%;
  113. }
  114. .top-uBg {
  115. width: 360rpx;
  116. height: 360rpx;
  117. position: absolute;
  118. top: 50rpx;
  119. left: 40%;
  120. z-index: 1;
  121. transform: translateX(-50%);
  122. }
  123. .top-title {
  124. position: absolute;
  125. top: 0;
  126. left: 0;
  127. width: 100%;
  128. text-align: center;
  129. line-height: 280rpx;
  130. font-size: 34rpx;
  131. color: #FFFFFF;
  132. }
  133. }
  134. .content-box {
  135. width: 100%;
  136. height: 100%;
  137. box-sizing: border-box;
  138. padding: 0 30rpx;
  139. margin-top: -100rpx;
  140. position: relative;
  141. z-index: 2;
  142. .card {
  143. width: 100%;
  144. height: 100%;
  145. background-color: #fff;
  146. border-radius: 20rpx;
  147. box-shadow: 0rpx 0rpx 11rpx 0rpx rgba(0, 0, 0, 0.06);
  148. padding: 30rpx;
  149. }
  150. .card-header {
  151. display: flex;
  152. align-items: center;
  153. margin-top: -50rpx;
  154. .card-header-icon {
  155. width: 132rpx;
  156. height: 132rpx;
  157. }
  158. .card-header-title {
  159. font-weight: bold;
  160. font-size: 38rpx;
  161. color: #151515;
  162. margin-left: 20rpx;
  163. }
  164. }
  165. .hover-active {
  166. opacity: 0.7;
  167. }
  168. .card-list-container {
  169. margin-top: 40rpx;
  170. }
  171. .card-list {
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-between;
  175. padding: 30rpx 0;
  176. border-bottom: 1rpx solid #F5F5F5;
  177. &:last-child {
  178. border-bottom: none;
  179. }
  180. .left {
  181. display: flex;
  182. align-items: center;
  183. flex: 1;
  184. .card-icon {
  185. width: 34rpx;
  186. height: 34rpx;
  187. margin-right: 20rpx;
  188. }
  189. .title {
  190. font-size: 32rpx;
  191. color: #151515;
  192. }
  193. }
  194. .right {
  195. .icon-right {
  196. width: 18rpx;
  197. height: 30rpx;
  198. }
  199. }
  200. }
  201. }
  202. </style>