my.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view class="container">
  3. <!-- 用户信息区域 -->
  4. <view class="user-info">
  5. <view class="avatar">
  6. <image class="avatar-icon" src="/static/icons/user.svg"></image>
  7. </view>
  8. <view class="user-details">
  9. <view class="user-name">微信用户</view>
  10. <view class="user-phone">130****1579</view>
  11. </view>
  12. </view>
  13. <!-- 菜单列表 -->
  14. <view class="menu-list">
  15. <view class="menu-item" @click="goToOrders">
  16. <view class="menu-icon">
  17. <image class="menu-svg-icon" src="/static/icons/orders.svg"></image>
  18. </view>
  19. <view class="menu-text">我的订单</view>
  20. <view class="menu-arrow"></view>
  21. </view>
  22. <view class="menu-item" @click="goToCoupons">
  23. <view class="menu-icon">
  24. <image class="menu-svg-icon" src="/static/icons/coupon.svg"></image>
  25. </view>
  26. <view class="menu-text">我的优惠券</view>
  27. <view v-if="availableCouponCount > 0" class="menu-badge">{{ availableCouponCount }}</view>
  28. <view class="menu-arrow"></view>
  29. </view>
  30. <view class="menu-item" @click="goToCouponCenter">
  31. <view class="menu-icon">
  32. <image class="menu-svg-icon" src="/static/icons/coupon.svg"></image>
  33. </view>
  34. <view class="menu-text">领券中心</view>
  35. <view class="menu-arrow"></view>
  36. </view>
  37. <view class="menu-item" @click="goToMembership">
  38. <view class="menu-icon">
  39. <image class="menu-svg-icon" src="/static/icons/membership.svg"></image>
  40. </view>
  41. <view class="menu-text">我的会员卡</view>
  42. <view class="menu-arrow"></view>
  43. </view>
  44. <view class="menu-item" @click="goToCards">
  45. <view class="menu-icon">
  46. <image class="menu-svg-icon" src="/static/icons/wallet.svg"></image>
  47. </view>
  48. <view class="menu-text">我的卡片</view>
  49. <view class="menu-arrow"></view>
  50. </view>
  51. <view class="menu-item" @click="goToInvoice">
  52. <view class="menu-icon">
  53. <image class="menu-svg-icon" src="/static/icons/invoice.svg"></image>
  54. </view>
  55. <view class="menu-text">发票管理</view>
  56. <view class="menu-arrow"></view>
  57. </view>
  58. <view class="menu-item" @click="goToFAQ">
  59. <view class="menu-icon">
  60. <image class="menu-svg-icon" src="/static/icons/faq.svg"></image>
  61. </view>
  62. <view class="menu-text">常见问题</view>
  63. <view class="menu-arrow"></view>
  64. </view>
  65. <view class="menu-item" @click="callService">
  66. <view class="menu-icon">
  67. <image class="menu-svg-icon" src="/static/icons/service.svg"></image>
  68. </view>
  69. <view class="menu-text">联系客服</view>
  70. <view class="service-phone">400-0755-315</view>
  71. </view>
  72. <view class="menu-item" @click="goToOfficialAccount">
  73. <view class="menu-icon">
  74. <image class="menu-svg-icon" src="/static/icons/official.svg"></image>
  75. </view>
  76. <view class="menu-text">公众号信息</view>
  77. <view class="menu-arrow"></view>
  78. </view>
  79. </view>
  80. <!-- 退出登录按钮 -->
  81. <view class="logout-section">
  82. <button class="logout-btn" @click="handleLogout">退出登录</button>
  83. </view>
  84. <!-- 版本信息 -->
  85. <view class="version-info">
  86. v1.62.11
  87. </view>
  88. </view>
  89. </template>
  90. <script setup lang="ts">
  91. import { ref, onMounted } from 'vue';
  92. import { mockApi } from '../../utils/mock';
  93. import { logout as logoutApi } from '../../api/user';
  94. import { getCouponCount } from '../../api/coupon';
  95. import { clearAuth } from '../../utils/auth';
  96. const userInfo = ref<any>(null);
  97. const availableCouponCount = ref(0);
  98. onMounted(async () => {
  99. const response = await mockApi.getUserInfo();
  100. if (response.success) {
  101. userInfo.value = response.data;
  102. }
  103. // 加载可用优惠券数量
  104. try {
  105. const result = await getCouponCount();
  106. availableCouponCount.value = result.availableCount || 0;
  107. } catch (e) {
  108. console.log('获取优惠券数量失败', e);
  109. }
  110. });
  111. const goBack = () => {
  112. uni.navigateBack();
  113. };
  114. const goToOrders = () => {
  115. uni.navigateTo({
  116. url: '/pages/orders/orders'
  117. });
  118. };
  119. const goToCoupons = () => {
  120. uni.navigateTo({
  121. url: '/pages/coupons/coupons'
  122. });
  123. };
  124. const goToCouponCenter = () => {
  125. uni.navigateTo({
  126. url: '/pages/couponCenter/couponCenter'
  127. });
  128. };
  129. const goToMembership = () => {
  130. uni.showToast({
  131. title: '会员卡功能开发中',
  132. icon: 'none'
  133. });
  134. };
  135. const goToCards = () => {
  136. uni.showToast({
  137. title: '卡片功能开发中',
  138. icon: 'none'
  139. });
  140. };
  141. const goToInvoice = () => {
  142. uni.showToast({
  143. title: '发票管理功能开发中',
  144. icon: 'none'
  145. });
  146. };
  147. const goToFAQ = () => {
  148. uni.showToast({
  149. title: '常见问题功能开发中',
  150. icon: 'none'
  151. });
  152. };
  153. const callService = () => {
  154. uni.makePhoneCall({
  155. phoneNumber: '18371997424'
  156. });
  157. };
  158. const goToOfficialAccount = () => {
  159. uni.showToast({
  160. title: '公众号信息功能开发中',
  161. icon: 'none'
  162. });
  163. };
  164. const goToSettings = () => {
  165. uni.showToast({
  166. title: '设置功能开发中',
  167. icon: 'none'
  168. });
  169. };
  170. const handleLogout = () => {
  171. uni.showModal({
  172. title: '提示',
  173. content: '确定要退出登录吗?',
  174. success: async (res) => {
  175. if (res.confirm) {
  176. try {
  177. await logoutApi();
  178. } catch (e) {
  179. console.log('退出登录接口调用失败', e);
  180. } finally {
  181. clearAuth();
  182. uni.reLaunch({
  183. url: '/pages/login/login'
  184. });
  185. }
  186. }
  187. }
  188. });
  189. };
  190. </script>
  191. <style>
  192. .container {
  193. min-height: 100vh;
  194. background-color: #ffffff;
  195. display: flex;
  196. flex-direction: column;
  197. }
  198. /* 用户信息区域 */
  199. .user-info {
  200. display: flex;
  201. align-items: center;
  202. padding: 20rpx 32rpx 40rpx;
  203. background-color: #FFD700;
  204. margin-top: 0;
  205. }
  206. .avatar {
  207. width: 120rpx;
  208. height: 120rpx;
  209. border-radius: 50%;
  210. background-color: #ffffff;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. margin-right: 32rpx;
  215. }
  216. .avatar-icon {
  217. width: 90rpx;
  218. height: 90rpx;
  219. }
  220. .user-details {
  221. flex: 1;
  222. }
  223. .user-name {
  224. font-size: 34rpx;
  225. font-weight: 600;
  226. margin-bottom: 8rpx;
  227. color: #000000;
  228. }
  229. .user-phone {
  230. font-size: 24rpx;
  231. color: #333333;
  232. }
  233. /* 菜单列表 */
  234. .menu-list {
  235. background-color: #ffffff;
  236. margin-top: 0;
  237. border-top: 1rpx solid #f0f0f0;
  238. border-bottom: 1rpx solid #f0f0f0;
  239. }
  240. .menu-item {
  241. display: flex;
  242. align-items: center;
  243. padding: 32rpx 32rpx;
  244. border-bottom: 1rpx solid #f0f0f0;
  245. }
  246. .menu-item:last-child {
  247. border-bottom: none;
  248. }
  249. .menu-item:active {
  250. background-color: #f9f9f9;
  251. }
  252. .menu-icon {
  253. width: 48rpx;
  254. height: 48rpx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. margin-right: 24rpx;
  259. }
  260. .menu-svg-icon {
  261. width: 32rpx;
  262. height: 32rpx;
  263. }
  264. .menu-text {
  265. flex: 1;
  266. font-size: 28rpx;
  267. color: #333333;
  268. }
  269. .menu-arrow {
  270. width: 16rpx;
  271. height: 16rpx;
  272. border-top: 2rpx solid #999999;
  273. border-right: 2rpx solid #999999;
  274. transform: rotate(45deg);
  275. }
  276. .menu-badge {
  277. background-color: #FF4D4F;
  278. color: #ffffff;
  279. font-size: 20rpx;
  280. min-width: 32rpx;
  281. height: 32rpx;
  282. line-height: 32rpx;
  283. text-align: center;
  284. border-radius: 16rpx;
  285. padding: 0 8rpx;
  286. margin-right: 12rpx;
  287. }
  288. .service-phone {
  289. font-size: 24rpx;
  290. color: #666666;
  291. }
  292. /* 退出登录区域 */
  293. .logout-section {
  294. padding: 60rpx 32rpx 20rpx;
  295. background-color: #ffffff;
  296. display: flex;
  297. justify-content: center;
  298. }
  299. .logout-btn {
  300. width: 60%;
  301. height: 80rpx;
  302. line-height: 80rpx;
  303. background-color: #FFD700;
  304. border: none;
  305. border-radius: 40rpx;
  306. color: #333333;
  307. font-size: 28rpx;
  308. font-weight: 500;
  309. }
  310. .logout-btn:active {
  311. background-color: #E6C200;
  312. }
  313. /* 版本信息 */
  314. .version-info {
  315. padding: 40rpx 0;
  316. text-align: center;
  317. font-size: 22rpx;
  318. color: #999999;
  319. background-color: #ffffff;
  320. }
  321. </style>