index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. <!-- 客服中心弹窗 @Author: Antigravity -->
  48. <view class="service-popup-mask" v-if="showServicePopup" @click="closeServicePopup">
  49. <view class="service-popup" @click.stop>
  50. <view class="service-header">
  51. <text class="service-title">联系客服</text>
  52. <uni-icons type="closeempty" size="20" color="#999" @click="closeServicePopup"></uni-icons>
  53. </view>
  54. <view class="qr-section">
  55. <text class="qr-title">客服二维码</text>
  56. <image class="qr-img" :src="customerSetting.qrCodeUrl || '/static/images/logo.png'" mode="aspectFit" @click="previewQRCode">
  57. </image>
  58. <text class="qr-desc">点击查看大图</text>
  59. </view>
  60. <view class="service-list">
  61. <view class="service-row" @click="openOnlineService">
  62. <view class="service-row-icon-box green">
  63. <uni-icons type="chat-filled" size="24" color="#fff"></uni-icons>
  64. </view>
  65. <view class="service-info">
  66. <text class="service-name">在线客服</text>
  67. <text class="service-desc">{{ customerSetting.wechatAccount || '企业微信专属客服在线解答' }}</text>
  68. </view>
  69. <view class="call-btn-mini green-btn">
  70. <text>去咨询</text>
  71. </view>
  72. </view>
  73. <view class="service-row" @click="callServicePhone">
  74. <view class="service-row-icon-box orange">
  75. <uni-icons type="phone-filled" size="24" color="#fff"></uni-icons>
  76. </view>
  77. <view class="service-info">
  78. <text class="service-name">客服电话</text>
  79. <text class="service-desc">{{ customerSetting.phoneNumber || '暂无电话' }}</text>
  80. </view>
  81. <view class="call-btn-mini orange-btn">
  82. <text>拨打</text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <custom-tabbar></custom-tabbar>
  89. </view>
  90. </template>
  91. <script setup>
  92. // @Author: Antigravity
  93. import { ref, reactive } from 'vue'
  94. import { onShow } from '@dcloudio/uni-app'
  95. import { getInfo } from '@/api/system/user'
  96. import { getCustomerServiceSetting } from '@/api/system/customerServiceSetting'
  97. import customTabbar from '@/components/custom-tabbar/index.vue'
  98. import orderStatusData from '@/json/orderStatus.json'
  99. const userInfo = ref(null)
  100. const showServicePopup = ref(false)
  101. const customerSetting = reactive({
  102. wechatAccount: '',
  103. phoneNumber: '',
  104. qrCode: '',
  105. qrCodeUrl: '',
  106. enterpriseWechatLink: ''
  107. })
  108. const fetchUserInfo = async () => {
  109. const token = uni.getStorageSync('token')
  110. if (token) {
  111. try {
  112. const res = await getInfo()
  113. if (res && res.user) {
  114. userInfo.value = res.user
  115. }
  116. } catch (error) {
  117. console.error('获取用户信息失败', error)
  118. }
  119. } else {
  120. userInfo.value = null
  121. }
  122. }
  123. // 获取客服配置 (ID=2)
  124. const fetchCustomerSetting = async () => {
  125. try {
  126. const res = await getCustomerServiceSetting(2)
  127. if (res) {
  128. Object.assign(customerSetting, res)
  129. }
  130. } catch (error) {
  131. console.error('获取客服配置失败', error)
  132. }
  133. }
  134. onShow(() => {
  135. fetchUserInfo()
  136. fetchCustomerSetting()
  137. })
  138. const goToLogin = () => {
  139. if (!userInfo.value) {
  140. uni.navigateTo({ url: '/pages/login/index' })
  141. }
  142. }
  143. const goToOrder = (statusValue) => {
  144. if (statusValue === 'all') {
  145. uni.reLaunch({ url: '/pages/order/list/index' })
  146. } else {
  147. uni.reLaunch({ url: `/pages/order/list/index?status=${statusValue}` })
  148. }
  149. }
  150. const goToMenu = (item) => {
  151. if (item.title === '客服中心') {
  152. showServicePopup.value = true
  153. return
  154. }
  155. if (item.path) {
  156. uni.navigateTo({ url: item.path })
  157. }
  158. }
  159. const closeServicePopup = () => {
  160. showServicePopup.value = false
  161. }
  162. const previewQRCode = () => {
  163. if (!customerSetting.qrCodeUrl) return
  164. uni.previewImage({
  165. urls: [customerSetting.qrCodeUrl]
  166. })
  167. }
  168. const openOnlineService = () => {
  169. if (customerSetting.enterpriseWechatLink) {
  170. // #ifdef H5
  171. window.location.href = customerSetting.enterpriseWechatLink
  172. // #endif
  173. // #ifndef H5
  174. uni.setClipboardData({
  175. data: customerSetting.wechatAccount || customerSetting.enterpriseWechatLink,
  176. success: () => {
  177. uni.showToast({ title: '客服账号已复制,请在微信中添加', icon: 'none' })
  178. }
  179. })
  180. // #endif
  181. } else {
  182. uni.showToast({ title: '在线客服暂未配置', icon: 'none' })
  183. }
  184. }
  185. const callServicePhone = () => {
  186. if (!customerSetting.phoneNumber) {
  187. uni.showToast({ title: '暂无客服电话', icon: 'none' })
  188. return
  189. }
  190. uni.makePhoneCall({
  191. phoneNumber: customerSetting.phoneNumber
  192. })
  193. }
  194. // 订单图标 - 从 orderStatus.json 生成
  195. const iconMap = {
  196. 0: '/static/icon/order-wait.svg',
  197. 1: '/static/icon/order-accept.svg',
  198. 2: '/static/icon/order-service.svg',
  199. 3: '/static/icon/order-service.svg',
  200. 4: '/static/icon/order-done.svg',
  201. 5: '/static/icon/order-cancel.svg'
  202. }
  203. const orderItems = orderStatusData.map(item => ({
  204. key: item.value,
  205. label: item.label,
  206. icon: iconMap[item.value] || '/static/icon/order-service.svg'
  207. }))
  208. // 功能菜单
  209. const menuItems = [
  210. { title: '宠物档案', icon: '/static/icon/pet-archive.svg', path: '/pages/my/pet/list/index' },
  211. { title: '用户管理', icon: '/static/icon/user-manage.svg', path: '/pages/my/user/list/index' },
  212. { title: '投诉管理', icon: '/static/icon/review.svg', path: '/pages/my/complaint/list/index' },
  213. { title: '服务费统计', icon: '/static/icon/service-fee.svg', path: '/pages/my/fee/statistics/index' },
  214. { title: '客服中心', icon: '/static/icon/service-center.svg', path: '' },
  215. { title: '协议中心', icon: '/static/icon/agreement.svg', path: '/pages/my/agreement/list/index' },
  216. { title: '系统设置', icon: '/static/icon/settings.svg', path: '/pages/my/settings/index' }
  217. ]
  218. </script>
  219. <style lang="scss" scoped>
  220. /* 保持原有样式并添加弹窗样式 @Author: Antigravity */
  221. .my-page {
  222. min-height: 100vh;
  223. background-color: #fcfaf5;
  224. padding-bottom: 140rpx;
  225. }
  226. /* ... 之前的样式保留,下文补充新样式 ... */
  227. .service-popup-mask {
  228. position: fixed;
  229. top: 0;
  230. left: 0;
  231. right: 0;
  232. bottom: 0;
  233. background-color: rgba(0, 0, 0, 0.6);
  234. z-index: 999;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. backdrop-filter: blur(4px);
  239. }
  240. .service-popup {
  241. width: 620rpx;
  242. background-color: #fff;
  243. border-radius: 48rpx;
  244. padding: 0;
  245. overflow: hidden;
  246. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.1);
  247. animation: slide-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  248. }
  249. @keyframes slide-in {
  250. from { transform: scale(0.85); opacity: 0; }
  251. to { transform: scale(1); opacity: 1; }
  252. }
  253. .service-header {
  254. display: flex;
  255. justify-content: space-between;
  256. align-items: center;
  257. padding: 40rpx;
  258. border-bottom: 2rpx solid #faf8f5;
  259. }
  260. .service-title {
  261. font-size: 32rpx;
  262. font-weight: 800;
  263. color: #4a3e2e;
  264. }
  265. .qr-section {
  266. padding: 48rpx 0;
  267. display: flex;
  268. flex-direction: column;
  269. align-items: center;
  270. background: linear-gradient(180deg, #fff 0%, #fffbf2 100%);
  271. }
  272. .qr-title {
  273. font-size: 28rpx;
  274. font-weight: 700;
  275. color: #6d5b45;
  276. margin-bottom: 30rpx;
  277. }
  278. .qr-img {
  279. width: 320rpx;
  280. height: 320rpx;
  281. border-radius: 32rpx;
  282. padding: 16rpx;
  283. background: #fff;
  284. box-shadow: 0 8rpx 32rpx rgba(247, 202, 62, 0.15);
  285. margin-bottom: 20rpx;
  286. }
  287. .qr-desc {
  288. font-size: 24rpx;
  289. color: #a39686;
  290. font-weight: 600;
  291. }
  292. .service-list {
  293. padding: 20rpx 40rpx 40rpx;
  294. }
  295. .service-row {
  296. display: flex;
  297. align-items: center;
  298. padding: 32rpx 0;
  299. border-bottom: 2rpx solid #fcfaf5;
  300. &:last-child { border-bottom: none; }
  301. }
  302. .service-row-icon-box {
  303. width: 88rpx;
  304. height: 88rpx;
  305. border-radius: 28rpx;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. margin-right: 24rpx;
  310. &.green { background: #5ec686; box-shadow: 0 8rpx 16rpx rgba(94, 198, 134, 0.2); }
  311. &.orange { background: #f7ca3e; box-shadow: 0 8rpx 16rpx rgba(247, 202, 62, 0.2); }
  312. }
  313. .service-info {
  314. flex: 1;
  315. }
  316. .service-name {
  317. display: block;
  318. font-size: 28rpx;
  319. font-weight: 800;
  320. color: #4a3e2e;
  321. margin-bottom: 4rpx;
  322. }
  323. .service-desc {
  324. display: block;
  325. font-size: 22rpx;
  326. color: #a39686;
  327. font-weight: 600;
  328. }
  329. .call-btn-mini {
  330. padding: 12rpx 28rpx;
  331. border-radius: 20rpx;
  332. font-size: 24rpx;
  333. font-weight: 700;
  334. transition: transform 0.2s;
  335. &:active { transform: scale(0.95); }
  336. &.green-btn { background: #eef9f2; color: #5ec686; }
  337. &.orange-btn { background: #fef6df; color: #f7ca3e; }
  338. }
  339. .header-curve {
  340. position: relative;
  341. background: #f7ca3e;
  342. padding: 120rpx 40rpx 160rpx;
  343. overflow: hidden;
  344. }
  345. .user-block {
  346. display: flex;
  347. align-items: center;
  348. position: relative;
  349. z-index: 2;
  350. }
  351. .user-avatar {
  352. width: 140rpx;
  353. height: 140rpx;
  354. border: 8rpx solid #fff;
  355. border-radius: 50%;
  356. background-color: #fff;
  357. }
  358. .user-info {
  359. flex: 1;
  360. margin-left: 32rpx;
  361. }
  362. .user-name {
  363. display: block;
  364. font-size: 40rpx;
  365. font-weight: 800;
  366. color: #5c4314;
  367. margin-bottom: 12rpx;
  368. letter-spacing: 2rpx;
  369. }
  370. .user-desc-text {
  371. display: block;
  372. font-size: 24rpx;
  373. color: #5c4314;
  374. opacity: 0.85;
  375. font-weight: 600;
  376. }
  377. .wave-shape {
  378. position: absolute;
  379. bottom: -80rpx;
  380. left: 0;
  381. width: 100%;
  382. height: 160rpx;
  383. background: #fcfaf5;
  384. border-radius: 50%;
  385. transform: scaleX(1.5);
  386. }
  387. .cute-card {
  388. background: #fff;
  389. border-radius: 40rpx;
  390. padding: 40rpx;
  391. margin: 0 32rpx;
  392. box-shadow: 0 12rpx 40rpx rgba(220, 212, 196, 0.4);
  393. position: relative;
  394. z-index: 3;
  395. }
  396. .order-wrap {
  397. margin-top: -60rpx;
  398. border: 4rpx solid #fffdfa;
  399. }
  400. .card-head {
  401. display: flex;
  402. justify-content: space-between;
  403. align-items: center;
  404. margin-bottom: 32rpx;
  405. }
  406. .card-title {
  407. font-size: 30rpx;
  408. font-weight: 800;
  409. color: #4a3e2e;
  410. }
  411. .card-more {
  412. display: flex;
  413. align-items: center;
  414. gap: 4rpx;
  415. font-size: 24rpx;
  416. color: #a39686;
  417. font-weight: 600;
  418. }
  419. .order-nav {
  420. display: flex;
  421. justify-content: space-between;
  422. }
  423. .nav-item {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. gap: 16rpx;
  428. }
  429. .icon-bulb {
  430. width: 92rpx;
  431. height: 92rpx;
  432. background: #fef6df;
  433. border-radius: 32rpx;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. }
  438. .menu-grid {
  439. display: grid;
  440. grid-template-columns: repeat(4, 1fr);
  441. gap: 24rpx;
  442. padding: 0 32rpx;
  443. margin-top: 40rpx;
  444. }
  445. .menu-box {
  446. background: #fff;
  447. border-radius: 36rpx;
  448. padding: 36rpx 12rpx;
  449. display: flex;
  450. flex-direction: column;
  451. align-items: center;
  452. justify-content: center;
  453. gap: 24rpx;
  454. box-shadow: 0 8rpx 24rpx rgba(220, 212, 196, 0.3);
  455. }
  456. .menu-icon-wrap {
  457. width: 80rpx;
  458. height: 80rpx;
  459. border-radius: 50%;
  460. background: #fef6df;
  461. display: flex;
  462. align-items: center;
  463. justify-content: center;
  464. }
  465. .custom-icon {
  466. width: 44rpx;
  467. height: 44rpx;
  468. }
  469. .nav-label,
  470. .menu-text {
  471. font-size: 22rpx;
  472. font-weight: 700;
  473. color: #6d5b45;
  474. text-align: center;
  475. }
  476. .nav-label {
  477. font-weight: 600;
  478. }
  479. .footer-msg {
  480. text-align: center;
  481. margin-top: 60rpx;
  482. margin-bottom: 40rpx;
  483. font-size: 24rpx;
  484. font-weight: 600;
  485. color: #d1c5b4;
  486. letter-spacing: 4rpx;
  487. }
  488. </style>