index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="my-page">
  3. <!-- 顶部背景墙 -->
  4. <view class="header-curve">
  5. <view class="user-block" @click="goToLogin">
  6. <image class="user-avatar" :src="userInfo?.avatarUrl || '/static/images/default-avatar.png'"
  7. mode="aspectFill"></image>
  8. <view class="user-info">
  9. <text class="user-name">{{ userInfo ? userInfo.nickName : '点击登录' }}</text>
  10. <text class="user-desc-text">{{ userInfo ? (userInfo.remark || '这位用户很懒,什么都没写 🐾') : '登录后享受更多权益 🐾'
  11. }}</text>
  12. </view>
  13. <uni-icons v-if="!userInfo" type="right" size="16" color="rgba(100, 70, 20, 0.4)"></uni-icons>
  14. </view>
  15. <view class="wave-shape"></view>
  16. </view>
  17. <!-- 我的服务订单区 -->
  18. <view class="cute-card order-wrap">
  19. <view class="card-head">
  20. <text class="card-title">我的服务订单</text>
  21. <view class="card-more" @click="goToOrder('all')">
  22. <text>查看全部</text>
  23. <uni-icons type="right" size="12" color="#a39686"></uni-icons>
  24. </view>
  25. </view>
  26. <view class="order-nav">
  27. <view class="nav-item" v-for="item in orderItems" :key="item.key" @click="goToOrder(item.key)">
  28. <view class="icon-bulb">
  29. <image class="custom-icon" :src="item.icon" mode="aspectFit"></image>
  30. </view>
  31. <text class="nav-label">{{ item.label }}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 主功能网格 -->
  36. <view class="menu-grid">
  37. <view class="menu-box" v-for="item in menuItems" :key="item.path" @click="goToMenu(item)">
  38. <view class="menu-icon-wrap">
  39. <image class="custom-icon" :src="item.icon" mode="aspectFit"></image>
  40. </view>
  41. <text class="menu-text">{{ item.title }}</text>
  42. </view>
  43. </view>
  44. <view class="footer-msg">
  45. <text>~ 感谢您的陪伴 ~</text>
  46. </view>
  47. <custom-tabbar></custom-tabbar>
  48. </view>
  49. </template>
  50. <script setup>
  51. import { ref } from 'vue'
  52. import { onShow } from '@dcloudio/uni-app'
  53. import { getInfo } from '@/api/system/user'
  54. import customTabbar from '@/components/custom-tabbar/index.vue'
  55. import orderStatusData from '@/json/orderStatus.json'
  56. const userInfo = ref(null)
  57. const fetchUserInfo = async () => {
  58. const token = uni.getStorageSync('token')
  59. if (token) {
  60. try {
  61. const res = await getInfo()
  62. if (res && res.user) {
  63. userInfo.value = res.user
  64. }
  65. } catch (error) {
  66. console.error('获取用户信息失败', error)
  67. }
  68. } else {
  69. userInfo.value = null
  70. }
  71. }
  72. onShow(() => {
  73. fetchUserInfo()
  74. })
  75. const goToLogin = () => {
  76. if (!userInfo.value) {
  77. uni.navigateTo({ url: '/pages/login/index' })
  78. }
  79. }
  80. const goToOrder = (statusValue) => {
  81. // statusValue 可以是 'all' 或枚举值
  82. if (statusValue === 'all') {
  83. uni.reLaunch({ url: '/pages/order/list/index' })
  84. } else {
  85. uni.reLaunch({ url: `/pages/order/list/index?status=${statusValue}` })
  86. }
  87. }
  88. const goToMenu = (item) => {
  89. if (item.path) {
  90. uni.navigateTo({ url: item.path })
  91. }
  92. }
  93. // 订单图标 - 从 orderStatus.json 生成
  94. const iconMap = {
  95. 0: '/static/icon/order-wait.svg',
  96. 1: '/static/icon/order-accept.svg',
  97. 2: '/static/icon/order-service.svg',
  98. 3: '/static/icon/order-service.svg',
  99. 4: '/static/icon/order-done.svg',
  100. 5: '/static/icon/order-cancel.svg'
  101. }
  102. const orderItems = orderStatusData.map(item => ({
  103. key: item.value,
  104. label: item.label,
  105. icon: iconMap[item.value] || '/static/icon/order-service.svg'
  106. }))
  107. // 功能菜单
  108. const menuItems = [
  109. { title: '宠物档案', icon: '/static/icon/pet-archive.svg', path: '/pages/my/pet/list/index' },
  110. { title: '用户管理', icon: '/static/icon/user-manage.svg', path: '/pages/my/user/list/index' },
  111. { title: '投诉管理', icon: '/static/icon/review.svg', path: '/pages/my/complaint/list/index' },
  112. { title: '服务费统计', icon: '/static/icon/service-fee.svg', path: '/pages/my/fee/statistics/index' },
  113. { title: '客服中心', icon: '/static/icon/service-center.svg', path: '' },
  114. { title: '协议中心', icon: '/static/icon/agreement.svg', path: '/pages/my/agreement/list/index' },
  115. { title: '系统设置', icon: '/static/icon/settings.svg', path: '/pages/my/settings/index' }
  116. ]
  117. </script>
  118. <style lang="scss" scoped>
  119. .my-page {
  120. min-height: 100vh;
  121. background-color: #fcfaf5;
  122. padding-bottom: 140rpx;
  123. }
  124. .header-curve {
  125. position: relative;
  126. background: #f7ca3e;
  127. padding: 120rpx 40rpx 160rpx;
  128. overflow: hidden;
  129. }
  130. .user-block {
  131. display: flex;
  132. align-items: center;
  133. position: relative;
  134. z-index: 2;
  135. }
  136. .user-avatar {
  137. width: 140rpx;
  138. height: 140rpx;
  139. border: 8rpx solid #fff;
  140. border-radius: 50%;
  141. background-color: #fff;
  142. }
  143. .user-info {
  144. flex: 1;
  145. margin-left: 32rpx;
  146. }
  147. .user-name {
  148. display: block;
  149. font-size: 40rpx;
  150. font-weight: 800;
  151. color: #5c4314;
  152. margin-bottom: 12rpx;
  153. letter-spacing: 2rpx;
  154. }
  155. .user-desc-text {
  156. display: block;
  157. font-size: 24rpx;
  158. color: #5c4314;
  159. opacity: 0.85;
  160. font-weight: 600;
  161. }
  162. .wave-shape {
  163. position: absolute;
  164. bottom: -80rpx;
  165. left: 0;
  166. width: 100%;
  167. height: 160rpx;
  168. background: #fcfaf5;
  169. border-radius: 50%;
  170. transform: scaleX(1.5);
  171. }
  172. .cute-card {
  173. background: #fff;
  174. border-radius: 40rpx;
  175. padding: 40rpx;
  176. margin: 0 32rpx;
  177. box-shadow: 0 12rpx 40rpx rgba(220, 212, 196, 0.4);
  178. position: relative;
  179. z-index: 3;
  180. }
  181. .order-wrap {
  182. margin-top: -60rpx;
  183. border: 4rpx solid #fffdfa;
  184. }
  185. .card-head {
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. margin-bottom: 32rpx;
  190. }
  191. .card-title {
  192. font-size: 30rpx;
  193. font-weight: 800;
  194. color: #4a3e2e;
  195. }
  196. .card-more {
  197. display: flex;
  198. align-items: center;
  199. gap: 4rpx;
  200. font-size: 24rpx;
  201. color: #a39686;
  202. font-weight: 600;
  203. }
  204. .order-nav {
  205. display: flex;
  206. justify-content: space-between;
  207. }
  208. .nav-item {
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. gap: 16rpx;
  213. }
  214. .icon-bulb {
  215. width: 92rpx;
  216. height: 92rpx;
  217. background: #fef6df;
  218. border-radius: 32rpx;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. }
  223. .menu-grid {
  224. display: grid;
  225. grid-template-columns: repeat(4, 1fr);
  226. gap: 24rpx;
  227. padding: 0 32rpx;
  228. margin-top: 40rpx;
  229. }
  230. .menu-box {
  231. background: #fff;
  232. border-radius: 36rpx;
  233. padding: 36rpx 12rpx;
  234. display: flex;
  235. flex-direction: column;
  236. align-items: center;
  237. justify-content: center;
  238. gap: 24rpx;
  239. box-shadow: 0 8rpx 24rpx rgba(220, 212, 196, 0.3);
  240. }
  241. .menu-icon-wrap {
  242. width: 80rpx;
  243. height: 80rpx;
  244. border-radius: 50%;
  245. background: #fef6df;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. }
  250. .custom-icon {
  251. width: 44rpx;
  252. height: 44rpx;
  253. }
  254. .nav-label,
  255. .menu-text {
  256. font-size: 22rpx;
  257. font-weight: 700;
  258. color: #6d5b45;
  259. text-align: center;
  260. }
  261. .nav-label {
  262. font-weight: 600;
  263. }
  264. .footer-msg {
  265. text-align: center;
  266. margin-top: 60rpx;
  267. margin-bottom: 40rpx;
  268. font-size: 24rpx;
  269. font-weight: 600;
  270. color: #d1c5b4;
  271. letter-spacing: 4rpx;
  272. }
  273. </style>