index.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <template>
  2. <view class="container">
  3. <up-navbar class="inde-nav-bar" :bgColor="navBgColor">
  4. <template #left>
  5. <view></view>
  6. </template>
  7. <template #center>
  8. <view class="page-title">我的</view>
  9. </template>
  10. </up-navbar>
  11. <!-- 顶部用户信息 -->
  12. <view class="user-header jianbianBG">
  13. <view class="user-info">
  14. <view class="user-main">
  15. <view>
  16. <image
  17. class="avatar"
  18. :src="isHttpsImage(appStore.$userInfo?.avatar)"
  19. ></image>
  20. </view>
  21. <view class="user-detail">
  22. <view class="name-vip" v-if="appStore.isLogin">
  23. <text class="name">{{ appStore.$userInfo?.nickname }}</text>
  24. <image
  25. class="vip-tag"
  26. v-if="
  27. appStore.$userInfo?.svip &&
  28. !appStore?.$wxConfig?.storeAuditModeEnabled
  29. "
  30. mode="widthFix"
  31. :src="HTTP_REQUEST_URL_IMG + 'sviplogo.png'"
  32. ></image>
  33. </view>
  34. <view
  35. class="name-vip"
  36. v-else
  37. @click="navigateTo('/pages/users/login/index')"
  38. >
  39. <text class="name">未登录</text>
  40. </view>
  41. <text class="vip-expire" v-if="appStore.$userInfo?.svip"
  42. >到期时间:{{ appStore.$userInfo?.svipExpireTime }}</text
  43. >
  44. <view class="intro">
  45. <view class="item" @click="handleFaceDetect">
  46. {{ appStore.$userInfo?.realNameVerified ? "已实名" : "未实名" }}
  47. </view>
  48. <view class="item" v-if="userInfoAddres !== ''"
  49. >IP:
  50. {{ userInfoAddres }}
  51. </view>
  52. <view
  53. class="item"
  54. v-if="appStore.$userInfo?.sex && appStore.$userInfo?.sex !== 0"
  55. >{{ sexMap[appStore.$userInfo?.sex] }}·{{
  56. appStore.$userInfo?.age
  57. }}岁</view
  58. >
  59. </view>
  60. </view>
  61. </view>
  62. <view class="btn-content" @click="handleEdit()">
  63. <image
  64. class="setting"
  65. :src="HTTP_REQUEST_URL_IMG + 'setting.png'"
  66. mode="widthFix"
  67. ></image>
  68. <text class="btn-text">编辑资料</text>
  69. </view>
  70. </view>
  71. <!-- 会员开通提示 v-if="!userInfo.isVip"-->
  72. <view class="vip-promote" v-if="!appStore?.$wxConfig?.storeAuditModeEnabled">
  73. <image
  74. class="vipBG"
  75. :src="HTTP_REQUEST_URL_IMG + 'vipBG.png'"
  76. mode="scaleToFill"
  77. ></image>
  78. <view class="vip-text">
  79. <view class="title">
  80. <image
  81. class="vipIcon"
  82. :src="HTTP_REQUEST_URL_IMG + 'setting/vipIcon.png'"
  83. mode="widthFix"
  84. ></image>
  85. <text v-if="!appStore.$userInfo?.svip"
  86. >开通<text class="bigText">会员</text>享受更多<text
  87. class="bigText"
  88. >权益</text
  89. ></text
  90. >
  91. <text v-else>前往查看<text class="bigText">权益</text></text>
  92. </view>
  93. <button class="open-vip" @click="goVIP">
  94. {{ appStore.$userInfo?.svip ? "去查看" : "去开通"
  95. }}<image
  96. class="bofang"
  97. :src="HTTP_REQUEST_URL_IMG + 'setting/bofang.png'"
  98. mode="widthFix"
  99. ></image>
  100. </button>
  101. </view>
  102. </view>
  103. </view>
  104. <!-- 钱包余额 -->
  105. <view class="wallet-section" v-if="!appStore?.$wxConfig?.storeAuditModeEnabled">
  106. <view class="wallet-header">
  107. <view>
  108. <view class="wallet-title">钱包余额(元)</view>
  109. <view class="balance">{{ wallet.balance }}</view>
  110. </view>
  111. <view
  112. class="transaction-detail"
  113. @click="viewTransactionDetail"
  114. >
  115. <text style="margin-right: 10rpx">进入钱包</text>
  116. <uni-icons type="right" size="16" color="#666666"></uni-icons>
  117. </view>
  118. </view>
  119. <up-line color="#F1F3F8"></up-line>
  120. <view class="assets">
  121. <view
  122. v-for="(asset, index) in wallet.assets"
  123. :key="asset.name"
  124. class="asset-container"
  125. >
  126. <view class="asset-item">
  127. <text class="asset-name">{{ asset.name }}</text>
  128. <text class="asset-amount"
  129. >{{ asset.balance }}{{ asset.unit }}</text
  130. >
  131. </view>
  132. <!-- 在每个资产项后面添加垂直分隔线,除了最后一个 -->
  133. <up-line
  134. v-if="index < wallet.assets.length - 1"
  135. color="#F1F3F8"
  136. direction="col"
  137. length="80rpx"
  138. style="margin: 0 20rpx"
  139. ></up-line>
  140. </view>
  141. </view>
  142. <!-- <view
  143. class="wallet-actions"
  144. v-if="tradeList && tradeList.length > 0 && showIcons"
  145. >
  146. <view
  147. class="wallet-btn withdraw"
  148. @click="goDetail(tradeList[0].jumpUrl)"
  149. >{{ tradeList[0].iconName }}</view
  150. >
  151. <view
  152. class="wallet-btn recharge"
  153. @click="goDetail(tradeList[1].jumpUrl)"
  154. >{{ tradeList[1].iconName }}</view
  155. >
  156. </view> -->
  157. <view class="functions" v-if="useList && useList.length > 0">
  158. <view
  159. class="function-item"
  160. v-for="item in useList"
  161. :key="item.iconName"
  162. @click="goDetail(item.jumpUrl)"
  163. >
  164. <view class="function-icon">
  165. <image
  166. :src="item.iconUrl"
  167. mode="widthFix"
  168. :style="{ width: (item.iconSize || '60') + 'rpx',height: (item.iconSize || '60') + 'rpx' }"
  169. ></image>
  170. </view>
  171. <text class="function-name">{{ item.iconName }}</text>
  172. </view>
  173. </view>
  174. </view>
  175. <!-- 最近访问 -->
  176. <view class="recent-visit" v-if="recentStores.length > 0">
  177. <view class="section-header">
  178. <text class="section-title">最近访问</text>
  179. <view
  180. class="more"
  181. @click="
  182. handleFunctionClick({
  183. pageUrl: '/pages/users/browsing_history/index',
  184. })
  185. "
  186. >查看更多<uni-icons
  187. style="margin-left: 10rpx"
  188. type="right"
  189. size="16"
  190. color="#666666"
  191. ></uni-icons
  192. ></view>
  193. </view>
  194. <view class="store-list">
  195. <template v-for="(store, storeIndex) in recentStores" :key="store.id">
  196. <view
  197. class="store-item"
  198. v-if="storeIndex == 0"
  199. @click="viewStore(store)"
  200. >
  201. <view class="store-logo">
  202. <image
  203. class="img"
  204. :src="store.merchantLogo"
  205. mode="aspectFill"
  206. ></image>
  207. </view>
  208. <view class="store-info">
  209. <text class="store-name">{{ store.merchantName }}</text>
  210. <text class="store-desc">{{ store.merchantDescribe }}</text>
  211. </view>
  212. <uni-icons
  213. style="margin-left: auto"
  214. type="right"
  215. size="16"
  216. color="#666666"
  217. ></uni-icons>
  218. </view>
  219. </template>
  220. </view>
  221. </view>
  222. <!-- 订单状态 -->
  223. <view class="order-section">
  224. <view class="section-header">
  225. <text class="section-title">我的订单</text>
  226. <view class="more" @click="viewAllOrders"
  227. >全部订单<uni-icons
  228. style="margin-left: 10rpx"
  229. type="right"
  230. size="16"
  231. color="#666666"
  232. ></uni-icons
  233. ></view>
  234. </view>
  235. <view class="order-status">
  236. <view
  237. class="status-item"
  238. v-for="order in orderStatus"
  239. :key="order.name"
  240. @click="viewOrders(order.id)"
  241. >
  242. <view class="status-icon">
  243. <image class="img" :src="order.src"></image>
  244. </view>
  245. <text class="status-name">{{ order.name }}</text>
  246. </view>
  247. </view>
  248. </view>
  249. <!-- 常用功能 -->
  250. <view class="common-functions">
  251. <view class="section-header">
  252. <text class="section-title">常用功能</text>
  253. </view>
  254. <view class="functions">
  255. <template v-for="func in commonFunctions" :key="func.name">
  256. <view
  257. class="function-item"
  258. @click="handleFunctionClick(func)"
  259. v-if="func.show"
  260. >
  261. <view class="function-icon">
  262. <image class="img" :src="func.src" mode="widthFix"></image>
  263. </view>
  264. <text class="function-name">{{ func.name }}</text>
  265. </view>
  266. </template>
  267. </view>
  268. </view>
  269. <!-- 企微客服弹窗 -->
  270. <up-popup
  271. :show="showCallList"
  272. closeOnClickOverlay
  273. mode="bottom"
  274. @close="showCallList = false"
  275. >
  276. <view class="callService">
  277. <view class="list-box">
  278. <view
  279. v-for="(item, index) in callList"
  280. :key="index"
  281. class="list-item"
  282. @click="callService(item)"
  283. >
  284. <view class="item-left">
  285. <view class="item-name">{{ item.serviceName }}</view>
  286. </view>
  287. </view>
  288. </view>
  289. </view>
  290. </up-popup>
  291. <!-- 自定义 tabBar -->
  292. <customTabBar :current="3" :showBackTop="false" />
  293. </view>
  294. </template>
  295. <script setup>
  296. import { ref, reactive, watch, computed } from "vue";
  297. import { onLoad, onShow, onPageScroll } from "@dcloudio/uni-app";
  298. import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
  299. import { HTTP_REQUEST_URL_IMG } from "@/config/app";
  300. import { isHttpsImage } from "@/utils/util";
  301. import { useAppStore } from "@/stores/app";
  302. import { useToast } from "@/hooks/useToast";
  303. import { getMetalBalance } from "@/api/vault";
  304. import { footprintList } from "@/api/merchant.js";
  305. import { getCustomerServiceList } from "@/api/user";
  306. import { toLogin } from "@/libs/login.js";
  307. import customTabBar from "@/components/customTabBar/index.vue";
  308. const showIcons = ref(false);
  309. const appStore = useAppStore();
  310. const { Toast } = useToast();
  311. const isLogin = appStore.isLogin;
  312. const callList = ref([]);
  313. const showCallList = ref(false);
  314. const navBgColor = ref("rgba(255,255,255,0)");
  315. // 钱包信息
  316. const wallet = ref({
  317. balance: appStore.userInfo?.nowMoney || "0.00",
  318. assets: [
  319. { name: "黄金资产", balance: "0.00", unit: "g", type: 1 },
  320. { name: "铂金资产", balance: "0.00", unit: "g", type: 2 },
  321. { name: "白银资产", balance: "0.00", unit: "g", type: 3 },
  322. ],
  323. });
  324. // 主要功能列表
  325. const mainFunctions = ref([
  326. {
  327. src: `${HTTP_REQUEST_URL_IMG}setting/mailiao.png`,
  328. name: "买料",
  329. pageUrl: "/pages/users/vault/rechargeGold",
  330. },
  331. {
  332. src: `${HTTP_REQUEST_URL_IMG}setting/mailiao2.png`,
  333. name: "卖料",
  334. pageUrl: "/pages/users/vault/storeMetal/index",
  335. },
  336. {
  337. src: `${HTTP_REQUEST_URL_IMG}setting/cunliao.png`,
  338. name: "存料",
  339. pageUrl: "/pages/users/vault/storeMetal/goldBullionStock",
  340. },
  341. {
  342. src: `${HTTP_REQUEST_URL_IMG}setting/tiliao.png`,
  343. name: "提料",
  344. pageUrl: "/pages/users/vault/storeMetal/metalExchange",
  345. },
  346. ]);
  347. // 最近访问的商家
  348. const recentStores = ref([]);
  349. // 订单状态
  350. const orderStatus = ref([
  351. {
  352. src: `${HTTP_REQUEST_URL_IMG}setting/daifukuan.png`,
  353. name: "待付款",
  354. id: 0,
  355. },
  356. { src: `${HTTP_REQUEST_URL_IMG}setting/daifahuo.png`, name: "待发货", id: 1 },
  357. {
  358. src: `${HTTP_REQUEST_URL_IMG}setting/daishouhuo.png`,
  359. name: "待收货",
  360. id: 2,
  361. },
  362. {
  363. src: `${HTTP_REQUEST_URL_IMG}setting/tuikuan.png`,
  364. name: "退款/换货",
  365. id: -3,
  366. },
  367. {
  368. src: `${HTTP_REQUEST_URL_IMG}setting/yiwancheng.png`,
  369. name: "已完成",
  370. id: 4,
  371. },
  372. ]);
  373. const merchantZYShow = ref(false);
  374. const lxsjShow = ref(false);
  375. const logoutShow = ref(false);
  376. // 常用功能
  377. const commonFunctions = computed(() => {
  378. const baseFunctions = [
  379. {
  380. src: `${HTTP_REQUEST_URL_IMG}setting/zuji.png`,
  381. name: "浏览足迹",
  382. pageUrl: "/pages/users/browsing_history/index",
  383. show: true,
  384. },
  385. {
  386. src: `${HTTP_REQUEST_URL_IMG}setting/shoucang.png`,
  387. name: "我的收藏",
  388. pageUrl: "/pages/users/user_goods_collection/index",
  389. show: true,
  390. },
  391. {
  392. src: `${HTTP_REQUEST_URL_IMG}setting/dingwei.png`,
  393. name: "收货地址",
  394. pageUrl: "/pages/users/user_address_list/index",
  395. show: true,
  396. },
  397. {
  398. src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`,
  399. name: "联系商家",
  400. pageUrl: "/pages/users/my_merchant/index",
  401. show: lxsjShow.value,
  402. },
  403. {
  404. src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`,
  405. name: "门店主页",
  406. pageUrl: "/pages/merchantCenter/index",
  407. show: merchantZYShow.value,
  408. },
  409. // { src: `${HTTP_REQUEST_URL_IMG}setting/xiazaiapp.png`, name: '下载APP', pageUrl: 'download', show: true },
  410. {
  411. src: `${HTTP_REQUEST_URL_IMG}setting/lianxikefu.png`,
  412. name: "平台客服",
  413. show: true,
  414. },
  415. {
  416. src: `${HTTP_REQUEST_URL_IMG}setting/logout.png`,
  417. name: "退出登录",
  418. pageUrl: "logout",
  419. show: logoutShow.value,
  420. },
  421. ];
  422. // 根据 show 值过滤
  423. return baseFunctions.filter((func) => func.show);
  424. });
  425. const params = ref({
  426. page: 1,
  427. limit: 10,
  428. });
  429. const sexMap = {
  430. 0: "未知",
  431. 1: "男",
  432. 2: "女",
  433. 3: "保密",
  434. };
  435. const userInfoAddres = computed(() => {
  436. let address = appStore.userInfo?.addres || "";
  437. const list = address.split("-");
  438. return list[0] || "";
  439. });
  440. // 页面加载
  441. onShow(async () => {
  442. // 隐藏原生 tabBar
  443. uni.hideTabBar();
  444. if (appStore.isLogin) {
  445. await appStore.USERINFO();
  446. logoutShow.value = true;
  447. wallet.value.balance = appStore.userInfo?.nowMoney || "0.00";
  448. if (appStore.userInfo?.merchant?.id) {
  449. merchantZYShow.value = true;
  450. } else {
  451. merchantZYShow.value = false;
  452. }
  453. if (appStore.merchantId || appStore.userInfo?.merchant?.id) {
  454. lxsjShow.value = true;
  455. } else {
  456. lxsjShow.value = false;
  457. }
  458. } else {
  459. logoutShow.value = false;
  460. }
  461. fetchMetalBalance();
  462. getHistoryList();
  463. });
  464. onLoad(async () => {
  465. await getServiceList();
  466. });
  467. onPageScroll((e) => {
  468. if (e.scrollTop > 0) {
  469. navBgColor.value = "#ffe079";
  470. } else {
  471. navBgColor.value = "rgba(252,255,255,0)";
  472. }
  473. });
  474. const wxConfig = ref({});
  475. const tradeList = ref([]);
  476. const useList = ref([]);
  477. const isOwner = ref(true);
  478. watch(
  479. () => appStore.wxConfig,
  480. (newVal) => {
  481. const configDate = newVal || appStore.$wxConfig;
  482. wxConfig.value = configDate;
  483. const list = JSON.parse(configDate.storeCommonTools || "[]");
  484. console.log("list", list);
  485. useList.value = list;
  486. // if (list[0].status == false) {
  487. // showIcons.value = false;
  488. // } else {
  489. // showIcons.value = true;
  490. // }
  491. // tradeList.value = [list[0], list[1]];
  492. // useList.value = [
  493. // {
  494. // ...list[2],
  495. // src: `${HTTP_REQUEST_URL_IMG}setting/mailiao.png`,
  496. // },
  497. // {
  498. // ...list[3],
  499. // src: `${HTTP_REQUEST_URL_IMG}setting/mailiao2.png`,
  500. // },
  501. // {
  502. // ...list[4],
  503. // src: `${HTTP_REQUEST_URL_IMG}setting/cunliao.png`,
  504. // iconName: "存料",
  505. // },
  506. // {
  507. // ...list[5],
  508. // src: `${HTTP_REQUEST_URL_IMG}setting/tiliao.png`,
  509. // },
  510. // ];
  511. console.log(tradeList.value);
  512. },
  513. { deep: true, immediate: true },
  514. );
  515. // 编辑资料
  516. const editProfile = () => {
  517. uni.showToast({
  518. title: "编辑资料",
  519. icon: "none",
  520. });
  521. };
  522. // 开通会员
  523. const openVip = () => {
  524. uni.showToast({
  525. title: "开通会员",
  526. icon: "none",
  527. });
  528. };
  529. // 查看会员权益
  530. const goVIP = () => {
  531. // uni.navigateTo({ url: "/pages/users/VIP/VIP" });
  532. goDetail("/pages/users/VIP/VIP");
  533. };
  534. // 查看交易明细
  535. const viewTransactionDetail = () => {
  536. console.log(isLogin);
  537. if (!appStore.isLogin) {
  538. toLogin();
  539. } else {
  540. // uni.navigateTo({ url: "/pages/users/vault/index" });
  541. goDetail("/pages/users/vault/index1");
  542. }
  543. };
  544. // 充值
  545. const recharge = () => {
  546. if (!appStore.isLogin) {
  547. toLogin();
  548. } else {
  549. uni.navigateTo({
  550. url: `/pages/webview/index?path=${"/pages/users/vault/rechargeRmb"}`,
  551. });
  552. }
  553. };
  554. // 提现
  555. const withdraw = () => {
  556. if (!appStore.isLogin) {
  557. toLogin();
  558. } else {
  559. uni.navigateTo({
  560. url: `/pages/webview/index?path=${"/pages/users/vault/withdraw"}`,
  561. });
  562. }
  563. };
  564. const goDetail = (url) => {
  565. console.log(url);
  566. const webviewPageUrl = `/pages/webview/index?path=${url}`;
  567. uni.navigateTo({
  568. url: webviewPageUrl,
  569. fail: (err) => {
  570. console.error("跳转到webview页面失败:", err);
  571. uni.showToast({
  572. title: "跳转失败,请重试",
  573. icon: "none",
  574. duration: 1500,
  575. });
  576. },
  577. });
  578. };
  579. function handleLogOut() {
  580. uni.showModal({
  581. title: "提示",
  582. content: "确认退出登录吗?",
  583. success: function (res) {
  584. if (res.confirm) {
  585. // 清除全局定时器
  586. if (getApp().globalData?.messageTimer) {
  587. clearInterval(getApp().globalData.messageTimer);
  588. getApp().globalData.messageTimer = null;
  589. }
  590. appStore.LOGOUT();
  591. uni.reLaunch({ url: "/pages/users/login/index" });
  592. }
  593. },
  594. });
  595. }
  596. // 功能点击
  597. const handleFunctionClick = (item) => {
  598. const url = item.pageUrl;
  599. console.log(url);
  600. if (item.name === "平台客服") return (showCallList.value = true);
  601. if (!url) return;
  602. // 买料、卖料、消费需要通过webview跳转
  603. if (
  604. [
  605. "/pages/users/vault/rechargeGold",
  606. "/pages/users/vault/storeMetal/index",
  607. "/pages/users/vault/storeMetal/order",
  608. ].includes(url)
  609. ) {
  610. const webviewPageUrl = `/pages/webview/index?path=${url}`;
  611. uni.navigateTo({
  612. url: webviewPageUrl,
  613. fail: (err) => {
  614. console.error("跳转到webview页面失败:", err);
  615. uni.showToast({
  616. title: "跳转失败,请重试",
  617. icon: "none",
  618. duration: 1500,
  619. });
  620. },
  621. });
  622. return; // 阻止继续执行后续跳转逻辑
  623. } else if (url === "download") {
  624. uni.setClipboardData({
  625. data: "https://a.app.qq.com/o/simple.jsp?pkgname=uni.app.UNI9DE338F",
  626. showToast: false,
  627. success: function () {
  628. uni.showToast({
  629. title: "下载链接复制成功,请打开内置手机浏览器访问下载。",
  630. icon: "none",
  631. });
  632. console.log("success");
  633. },
  634. });
  635. return;
  636. } else if (url === "logout") {
  637. handleLogOut();
  638. } else {
  639. console.log(url);
  640. uni.navigateTo({ url });
  641. }
  642. };
  643. // 获取客服列表
  644. const getServiceList = async (url) => {
  645. const res = await getCustomerServiceList();
  646. callList.value = res.data.list;
  647. };
  648. // 跳转企微客服
  649. const callService = async (item) => {
  650. wx.openCustomerServiceChat({
  651. corpId: item.enterpriseId,
  652. extInfo: {
  653. url: item.serviceLink,
  654. },
  655. });
  656. };
  657. // 查看商家
  658. const viewStore = (store) => {
  659. if (!store.merchantId) {
  660. return;
  661. }
  662. uni.navigateTo({
  663. url: "/pages/merchantCenters/merchant?merchantId=" + store.merchantId,
  664. });
  665. };
  666. // 查看全部订单
  667. const viewAllOrders = () => {
  668. uni.navigateTo({ url: "/pages/order_list/index" });
  669. };
  670. // 查看订单
  671. const viewOrders = (status) => {
  672. uni.navigateTo({ url: "/pages/order_list/index?status=" + status });
  673. };
  674. const navigateTo = (url) => {
  675. if (!url) return;
  676. uni.navigateTo({ url });
  677. };
  678. // 用户面板事件处理
  679. function handleEdit() {
  680. // console.log("编辑资料");
  681. uni.navigateTo({ url: "/pages/users/personal_info/personal_info" });
  682. }
  683. async function fetchMetalBalance() {
  684. // 若appStore.uid为空,则请求失败
  685. if (!appStore?.uid) {
  686. // Toast({ title: "未登录,请前往登录后访问" });
  687. return;
  688. }
  689. const params = { userId: appStore.uid };
  690. const { data } = await getMetalBalance(params);
  691. wallet.value.assets = wallet.value.assets.map((metal) => {
  692. const metalValue = data[metal.type];
  693. return metalValue !== undefined ? { ...metal, balance: metalValue } : metal;
  694. });
  695. }
  696. const getHistoryList = async () => {
  697. const { data } = await footprintList(params.value);
  698. recentStores.value = data.records;
  699. };
  700. //人脸识别
  701. function handleFaceDetect() {
  702. // #ifndef APP-PLUS
  703. if (appStore.userInfo.realNameVerified || !isOwner.value) return;
  704. uni.navigateTo({
  705. url: "/pages/users/face_detect/index",
  706. });
  707. // #endif
  708. }
  709. </script>
  710. <style scoped lang="scss">
  711. .container {
  712. background-color: #f5f5f5;
  713. min-height: 100vh;
  714. padding-bottom: 180rpx;
  715. }
  716. /* 顶部用户信息 */
  717. .user-header {
  718. height: 600rpx;
  719. //background-image: linear-gradient(200deg, #fcd965 0%, #ffffff 90%) !important;
  720. background-size: 100% 100%;
  721. padding: 150rpx 20rpx 20rpx;
  722. color: #fff;
  723. border-radius: 0 0 20rpx 20rpx;
  724. box-sizing: border-box;
  725. }
  726. .user-info {
  727. display: flex;
  728. justify-content: space-between;
  729. align-items: center;
  730. margin: 24rpx 0;
  731. }
  732. .user-detail {
  733. display: flex;
  734. flex-direction: column;
  735. justify-content: center;
  736. }
  737. .user-main {
  738. display: flex;
  739. align-items: center;
  740. }
  741. .avatar {
  742. width: 140rpx;
  743. height: 140rpx;
  744. border-radius: 50%;
  745. background-color: #fff;
  746. margin-right: 30rpx;
  747. }
  748. .name-vip {
  749. display: flex;
  750. align-items: center;
  751. margin-bottom: 14rpx;
  752. }
  753. .name {
  754. font-size: 32rpx;
  755. color: #333;
  756. }
  757. .vip-tag {
  758. width: 100rpx;
  759. height: 36rpx;
  760. margin-left: 16rpx;
  761. }
  762. .vip-expire {
  763. font-size: 28rpx;
  764. color: #666;
  765. margin-bottom: 14rpx;
  766. }
  767. .btn-content {
  768. display: flex;
  769. flex-direction: column;
  770. align-items: center;
  771. justify-content: center;
  772. .setting {
  773. width: 40rpx;
  774. height: 40rpx;
  775. }
  776. .btn-text {
  777. font-size: 24rpx;
  778. color: #333;
  779. line-height: 1.5;
  780. }
  781. }
  782. /* 会员开通提示 */
  783. .vip-promote {
  784. height: 108rpx;
  785. width: 100%;
  786. height: 108rpx;
  787. padding: 0 30rpx;
  788. box-sizing: border-box;
  789. .vipBG {
  790. width: 100%;
  791. height: 100%;
  792. border-radius: 48rpx 48rpx 0 0;
  793. }
  794. .vip-text {
  795. margin-top: -108rpx;
  796. display: flex;
  797. width: 100%;
  798. justify-content: space-between;
  799. align-items: center;
  800. padding: 20rpx;
  801. box-sizing: border-box;
  802. .title {
  803. font-size: 28rpx;
  804. color: #bdad8e;
  805. display: flex;
  806. justify-content: flex-start;
  807. align-items: center;
  808. .vipIcon {
  809. width: 70rpx;
  810. height: 60rpx;
  811. margin-right: 10rpx;
  812. }
  813. .bigText {
  814. font-size: 32rpx;
  815. color: #facd8d;
  816. margin: 0 10rpx;
  817. }
  818. }
  819. .open-vip {
  820. width: 144rpx;
  821. height: 60rpx;
  822. font-size: 24rpx;
  823. color: #5d3d03;
  824. background: linear-gradient(270deg, #fee2a3 0%, #fdebcc 100%);
  825. border-radius: 16rpx 16rpx 16rpx 16rpx;
  826. display: flex;
  827. justify-content: center;
  828. align-items: center;
  829. .bofang {
  830. width: 24rpx;
  831. height: 24rpx;
  832. margin-left: 10rpx;
  833. }
  834. }
  835. }
  836. }
  837. .desc {
  838. font-size: 22rpx;
  839. opacity: 0.9;
  840. }
  841. /* 钱包余额 */
  842. .wallet-section {
  843. background: #fff;
  844. margin: -150rpx 20rpx 20rpx;
  845. border-radius: 24rpx;
  846. padding: 32rpx;
  847. }
  848. .wallet-header {
  849. display: flex;
  850. justify-content: space-between;
  851. align-items: center;
  852. margin-bottom: 20rpx;
  853. }
  854. .wallet-title {
  855. font-size: 28rpx;
  856. color: #333;
  857. }
  858. .transaction-detail {
  859. color: #666;
  860. font-size: 24rpx;
  861. display: flex;
  862. align-items: center;
  863. }
  864. .balance {
  865. font-size: 48rpx;
  866. font-weight: bold;
  867. text-align: center;
  868. margin: 10rpx 0;
  869. color: #333;
  870. }
  871. .assets {
  872. display: flex;
  873. justify-content: space-between;
  874. align-items: center;
  875. margin-top: 40rpx;
  876. flex-wrap: nowrap; /* 确保不换行 */
  877. }
  878. .asset-container {
  879. display: flex;
  880. align-items: center;
  881. flex: 1;
  882. justify-content: center;
  883. position: relative;
  884. }
  885. .asset-item {
  886. display: flex;
  887. flex-direction: column;
  888. align-items: center;
  889. flex: 1;
  890. padding: 0 20rpx;
  891. }
  892. .asset-name {
  893. font-size: 24rpx;
  894. color: #333;
  895. margin-bottom: 16rpx;
  896. text-align: center;
  897. }
  898. .asset-amount {
  899. font-size: 40rpx;
  900. font-weight: bold;
  901. color: #333;
  902. text-align: center;
  903. }
  904. .wallet-actions {
  905. display: flex;
  906. justify-content: space-between;
  907. margin-top: 50rpx;
  908. }
  909. .wallet-btn {
  910. flex: 1;
  911. font-weight: bold;
  912. text-align: center;
  913. height: 88rpx;
  914. line-height: 88rpx;
  915. margin: 0 10rpx;
  916. border-radius: 16rpx;
  917. font-size: 32rpx;
  918. }
  919. .recharge {
  920. background: #f8c008;
  921. color: #333;
  922. }
  923. .withdraw {
  924. background: rgba(248, 192, 8, 0.1);
  925. color: #333;
  926. }
  927. /* 功能入口 */
  928. .function-grid {
  929. background: #fff;
  930. margin: 30rpx;
  931. border-radius: 24rpx;
  932. padding: 40rpx;
  933. }
  934. .functions {
  935. display: grid;
  936. grid-template-columns: repeat(4, 1fr);
  937. gap: 40rpx;
  938. margin-top: 40rpx;
  939. }
  940. .function-item {
  941. text-align: center;
  942. }
  943. .function-icon {
  944. .img {
  945. width: 60rpx;
  946. height: 60rpx;
  947. }
  948. }
  949. .function-name {
  950. font-size: 24rpx;
  951. color: #333;
  952. }
  953. /* 最近访问 */
  954. .recent-visit,
  955. .order-section,
  956. .common-functions {
  957. background: #fff;
  958. margin: 16rpx;
  959. border-radius: 16rpx;
  960. padding: 20rpx;
  961. }
  962. .section-header {
  963. display: flex;
  964. justify-content: space-between;
  965. align-items: center;
  966. margin-bottom: 20rpx;
  967. }
  968. .section-title {
  969. font-size: 32rpx;
  970. color: #333;
  971. }
  972. .more {
  973. font-size: 24rpx;
  974. color: #666;
  975. }
  976. .store-item {
  977. display: flex;
  978. align-items: center;
  979. justify-content: flex-start;
  980. padding: 16rpx;
  981. // border-bottom: 2rpx solid #f0f0f0;
  982. background-color: #f9f7f0;
  983. border-radius: 16rpx;
  984. }
  985. .store-item:last-child {
  986. border-bottom: none;
  987. }
  988. .store-logo {
  989. width: 100rpx;
  990. height: 100rpx;
  991. margin-right: 16rpx;
  992. .img {
  993. width: 100rpx;
  994. height: 100rpx;
  995. border-radius: 8rpx;
  996. }
  997. }
  998. .store-name {
  999. font-size: 32rpx;
  1000. font-weight: bold;
  1001. color: #333;
  1002. margin-bottom: 10rpx;
  1003. display: block;
  1004. }
  1005. .store-desc {
  1006. font-size: 24rpx;
  1007. color: #666;
  1008. display: block;
  1009. }
  1010. /* 订单状态 */
  1011. .order-status {
  1012. display: flex;
  1013. justify-content: space-between;
  1014. }
  1015. .status-item {
  1016. text-align: center;
  1017. flex: 1;
  1018. }
  1019. .status-icon {
  1020. .img {
  1021. width: 60rpx;
  1022. height: 60rpx;
  1023. }
  1024. }
  1025. .status-name {
  1026. font-size: 24rpx;
  1027. color: #333;
  1028. }
  1029. /* 常用功能 */
  1030. .common-functions .functions {
  1031. grid-template-columns: repeat(4, 1fr);
  1032. }
  1033. .page-title {
  1034. font-size: 36rpx;
  1035. color: #333;
  1036. }
  1037. .callService {
  1038. padding: 20px 10px 0px;
  1039. // background-color: #ddcca3;
  1040. display: flex;
  1041. justify-content: center;
  1042. flex-direction: column;
  1043. font-size: 16px;
  1044. margin-bottom: 30rpx;
  1045. .list-box {
  1046. background: #fff;
  1047. border-radius: 20px;
  1048. .list-item {
  1049. width: 100%;
  1050. height: 100rpx;
  1051. display: flex;
  1052. justify-content: center;
  1053. align-items: center;
  1054. border-bottom: 1px solid #e1e1e1;
  1055. }
  1056. }
  1057. }
  1058. .intro {
  1059. display: flex;
  1060. align-items: center;
  1061. .item {
  1062. color: #333;
  1063. font-size: 24rpx;
  1064. padding: 0 16rpx;
  1065. line-height: 40rpx;
  1066. margin-right: 16rpx;
  1067. background: #fef8e6;
  1068. border-radius: 8rpx;
  1069. &:last-child {
  1070. margin-right: 0;
  1071. }
  1072. }
  1073. }
  1074. </style>