index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. <template>
  2. <view class="container">
  3. <view v-if="currentTab === 'wallet'" class="wallet-page">
  4. <!-- <view class="new-asset-box">-->
  5. <!-- <view class="new-asset-title">-->
  6. <!-- <image-->
  7. <!-- src="https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/an_20251011162829_903_6.png"-->
  8. <!-- mode="widthFix"-->
  9. <!-- ></image>-->
  10. <!-- <text>资金安全有保障</text>-->
  11. <!-- </view>-->
  12. <!-- <view class="new-asset-content">-->
  13. <!-- <view-->
  14. <!-- class="asset-content-item"-->
  15. <!-- v-for="item in metals"-->
  16. <!-- :key="item.id"-->
  17. <!-- >-->
  18. <!-- <view class="content-item-left">-->
  19. <!-- <image :src="item.icon" mode="widthFix"></image>-->
  20. <!-- <text>{{ item.name }}</text>-->
  21. <!-- </view>-->
  22. <!-- <view class="content-item-right">{{ item.balance }}</view>-->
  23. <!-- </view>-->
  24. <!-- </view>-->
  25. <!-- </view>-->
  26. <!-- <view class="asset-tips">-->
  27. <!-- <view class="zc">资产说明:</view>-->
  28. <!-- <view-->
  29. <!-- >贵金属账户里的金料随时可以在本平台内选购商品并抵扣金重,或以实时金价出售给本平台转换成现金</view-->
  30. <!-- >-->
  31. <!-- </view>-->
  32. <view class="record-container">
  33. <!-- <view class="record-title">交易记录</view>-->
  34. <view class="record-tabs">
  35. <view
  36. class="record-tab"
  37. :class="{ active: recordTab === 'change' }"
  38. @click="switchRecordTab('change')"
  39. >
  40. 交易
  41. </view>
  42. <view
  43. class="record-tab"
  44. :class="{ active: recordTab === 'recharge' }"
  45. @click="switchRecordTab('recharge')"
  46. >
  47. 充值
  48. </view>
  49. <view
  50. class="record-tab"
  51. :class="{ active: recordTab === 'withdraw' }"
  52. @click="switchRecordTab('withdraw')"
  53. >
  54. 提现
  55. </view>
  56. <!-- <view
  57. class="record-tab"
  58. :class="{ active: recordTab === 'consume' }"
  59. @click="switchRecordTab('consume')"
  60. >
  61. 消费
  62. </view> -->
  63. <view
  64. class="record-tab"
  65. :class="{ active: recordTab === 'buygold' }"
  66. @click="switchRecordTab('buygold')"
  67. >
  68. 买料
  69. </view>
  70. <view
  71. class="record-tab"
  72. :class="{ active: recordTab === 'soldgold' }"
  73. @click="switchRecordTab('soldgold')"
  74. >
  75. 卖料
  76. </view>
  77. <view
  78. class="record-tab"
  79. :class="{ active: recordTab === 'savegold' }"
  80. @click="switchRecordTab('savegold')"
  81. >
  82. 存料
  83. </view>
  84. <view
  85. class="record-tab"
  86. :class="{ active: recordTab === 'materialdeduction' }"
  87. @click="switchRecordTab('materialdeduction')"
  88. >
  89. 扣料
  90. </view>
  91. </view>
  92. <z-paging
  93. class="paging-box"
  94. ref="pagingRef"
  95. use-page-scroll
  96. v-model="recordList"
  97. @query="queryList"
  98. @refresherTouchend="refresherTouchend"
  99. :fixed="false"
  100. :empty-view-text="getEmptyText()"
  101. >
  102. <view
  103. class="list-item"
  104. v-for="(item, index) in combineList"
  105. :key="index"
  106. >
  107. <view class="item-left">
  108. <view class="item-title">
  109. <text class="title">{{ item.title || item.comeFor }}</text>
  110. <text class="status" v-if="item.statusMsg">
  111. {{ item.statusMsg }}
  112. </text>
  113. </view>
  114. <view
  115. class="item-title"
  116. v-if="
  117. item?.realTimePrice &&
  118. ['buygold', 'soldgold'].includes(recordTab)
  119. "
  120. >
  121. <!-- <text class="title">金价:{{ item.realTimePrice }}</text> -->
  122. </view>
  123. <view
  124. class="item-detail"
  125. v-if="
  126. Number(item.amount) != 0 && recordTab !== 'materialdeduction'
  127. "
  128. >
  129. <text
  130. class="detail-label"
  131. v-if="
  132. item?.realTimePrice &&
  133. ['buygold', 'soldgold'].includes(recordTab)
  134. "
  135. >
  136. 金价:{{ item.realTimePrice }}
  137. </text>
  138. <text class="detail-label"> 金额: </text>
  139. <text class="detail-value">{{ item.amount }}</text>
  140. </view>
  141. <!-- 扣料显示扣料克重 -->
  142. <view
  143. class="item-detail"
  144. v-if="recordTab === 'materialdeduction'"
  145. >
  146. <view class="detail-label">
  147. 贵金属类型:{{ item.metalTypeMsg }}
  148. </view>
  149. <text class="detail-label"> 金重: </text>
  150. <text class="detail-value">{{ item.weight }}</text>
  151. </view>
  152. <view class="item-time">
  153. {{ recordTab === "change" ? item.add_time : item.createTime }}
  154. </view>
  155. </view>
  156. <view class="item-right">
  157. <template v-if="recordTab === 'recharge'">
  158. <view
  159. class="item-amount"
  160. :class="{
  161. positive: item.paid,
  162. fail: !item.paid,
  163. }"
  164. >
  165. <text v-if="item.paid"
  166. >{{ item.type === "income" ? "+" : "-"
  167. }}{{ item.amount }}</text
  168. >
  169. <text v-else>0</text>
  170. </view>
  171. </template>
  172. <template v-else-if="recordTab === 'withdraw'">
  173. <view
  174. class="item-amount"
  175. :class="{
  176. positive: item.status === 1,
  177. fail: item.status !== 1,
  178. }"
  179. >
  180. <text v-if="item.status !== -1">-{{ item.amount }}</text>
  181. <text v-else class="fail-msg">{{ item.failMsg }}</text>
  182. </view>
  183. <!-- 添加查看详情按钮 -->
  184. <view
  185. v-if="item.status === 1"
  186. class="detail-btn"
  187. @click="viewDetail(item)"
  188. >
  189. 查看详情
  190. </view>
  191. </template>
  192. <template v-else-if="recordTab == 'consume'">
  193. <view class="item-amount"> -{{ item.amount }}</view>
  194. <view class="flex-center-flex-end gray metalTypeMsg"
  195. >{{ item.metalTypeMsg }}({{ item.weight }}g)</view
  196. >
  197. </template>
  198. <template v-else-if="recordTab == 'buygold'">
  199. <view class="item-amount" v-if="item.amount !== '0.00'">
  200. -{{ item.amount }}
  201. </view>
  202. <view class="flex-center-flex-end gray metalTypeMsg"
  203. >{{ item.metalTypeMsg }}+({{ item.weight }}g)</view
  204. >
  205. </template>
  206. <template v-else-if="recordTab == 'soldgold'">
  207. <view class="item-amount" v-if="item.amount !== '0.00'">
  208. +{{ item.amount }}
  209. </view>
  210. <view class="flex-center-flex-end gray metalTypeMsg"
  211. >{{ item.metalTypeMsg }}-({{ item.weight }}g)</view
  212. >
  213. </template>
  214. <template v-else-if="recordTab == 'savegold'">
  215. <view
  216. class="item-amount"
  217. :class="{
  218. positive: item.status === 1,
  219. fail: item.status !== 1,
  220. }"
  221. style="margin-top: 10px"
  222. >
  223. {{ item.metalTypeMsg }}+({{ item.weight }}g)
  224. </view>
  225. <view
  226. class="flex-center-flex-end gray metalTypeMsg"
  227. v-if="item.status == 6"
  228. >
  229. 驳回理由: {{ item.remark }}</view
  230. >
  231. <!-- <view class="flex-center-flex-end gray metalTypeMsg"
  232. >驳回理由:{{ item.status }}</view
  233. > -->
  234. </template>
  235. <template v-else-if="recordTab == 'change'">
  236. <view
  237. class="item-amount"
  238. :class="{
  239. positive: item.status === 1,
  240. fail: item.status !== 1,
  241. }"
  242. style="margin-top: 10px"
  243. >
  244. {{ item.pm == 0 ? "-" : "+" }} {{ item.amount }}
  245. </view>
  246. <!-- <view class="flex-center-flex-end gray metalTypeMsg"
  247. >驳回理由:{{ item.status }}</view
  248. > -->
  249. </template>
  250. </view>
  251. </view>
  252. </z-paging>
  253. </view>
  254. </view>
  255. <!-- 提现详情弹窗 -->
  256. <uni-popup
  257. ref="detailPopup"
  258. type="center"
  259. :safeArea="false"
  260. backgroundColor="rgba(0,0,0,0.5)"
  261. >
  262. <view class="detail-popup">
  263. <view class="popup-header">
  264. <text class="popup-title">提现详情</text>
  265. <view class="close-btn" @click="closeDetail">✕</view>
  266. </view>
  267. <view class="popup-content">
  268. <view class="detail-item">
  269. <text class="label">提现金额:</text>
  270. <text class="value">¥{{ currentDetail.amount }}</text>
  271. </view>
  272. <view class="detail-item" v-if="currentDetail.createTime">
  273. <text class="label">提现时间:</text>
  274. <text class="value">{{ currentDetail.createTime }}</text>
  275. </view>
  276. <view
  277. class="detail-item"
  278. v-if="
  279. currentDetail.transferImg && currentDetail.transferImg.length > 0
  280. "
  281. >
  282. <text class="label">转账凭证:</text>
  283. <view class="image-list">
  284. <image
  285. v-for="(img, index) in currentDetail.transferImg"
  286. :key="index"
  287. :src="img"
  288. mode="aspectFill"
  289. class="transfer-image"
  290. @click="previewImage(currentDetail.transferImg, index)"
  291. ></image>
  292. </view>
  293. </view>
  294. <view class="detail-item" v-if="currentDetail.remark">
  295. <text class="label">备注:</text>
  296. <text class="value">{{ currentDetail.remark }}</text>
  297. </view>
  298. </view>
  299. </view>
  300. </uni-popup>
  301. </view>
  302. </template>
  303. <script setup>
  304. import { ref, onMounted, computed } from "vue";
  305. import { onLoad, onShow } from "@dcloudio/uni-app";
  306. import useZPaging from "@/uni_modules/z-paging/components/z-paging/js/hooks/useZPaging.js";
  307. import { useAppStore } from "@/stores/app";
  308. import { useToast } from "@/hooks/useToast";
  309. import { getUserInfo } from "@/api/user";
  310. import {
  311. getWithdrawList,
  312. getRechargeList,
  313. getConsumeList,
  314. getMetalBalance,
  315. } from "@/api/vault";
  316. const appStore = useAppStore();
  317. const { Toast } = useToast();
  318. const pagingRef = ref(null);
  319. useZPaging(pagingRef);
  320. // 当前tab
  321. const currentTab = ref("wallet");
  322. // 记录tab
  323. const recordTab = ref("change");
  324. // 列表数据
  325. const recordList = ref([]);
  326. // metals 初始值 balance 设为 0
  327. const metals = ref([
  328. {
  329. id: 0,
  330. type: -1,
  331. name: "余额 (¥)",
  332. balance: appStore.userInfo?.nowMoney || 0,
  333. unit: "g",
  334. icon: "https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/qian_20250929211527_562_6.png",
  335. },
  336. {
  337. id: 1,
  338. type: 1,
  339. name: "黄金 (g)",
  340. balance: 0,
  341. unit: "g",
  342. icon: "https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/au_20250929211527_561_6.png",
  343. },
  344. {
  345. id: 2,
  346. type: 2,
  347. name: "铂金 (g)",
  348. balance: 0,
  349. unit: "g",
  350. icon: "https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/pt_20250929211527_564_6.png",
  351. },
  352. {
  353. id: 3,
  354. type: 3,
  355. name: "白银 (g)",
  356. balance: 0,
  357. unit: "g",
  358. icon: "https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/ag_20250929211527_565_6.png",
  359. },
  360. ]);
  361. async function fetchMetalBalance() {
  362. // 若appStore.uid为空,则请求失败
  363. if (!appStore?.uid) {
  364. Toast({ title: "未登录,请前往登录后访问" });
  365. return;
  366. }
  367. const params = { userId: appStore.uid };
  368. const { data } = await getMetalBalance(params);
  369. metals.value = metals.value.map((metal) => {
  370. const metalValue = data[metal.type];
  371. return metalValue !== undefined ? { ...metal, balance: metalValue } : metal;
  372. });
  373. }
  374. // 不要在 onLoad 里请求 fetchMetalBalance
  375. onLoad((options) => {
  376. console.log('options==============')
  377. console.log(options)
  378. if(options.type){
  379. switchRecordTab(options.type)
  380. }
  381. });
  382. const combineList = computed(() => {
  383. if (recordTab.value === "recharge") {
  384. return recordList.value.map((v) => {
  385. return {
  386. type: "income",
  387. title: v.rechargeType == "bank_transfer" ? "银行卡" : "支付宝",
  388. amount: v.price,
  389. // 是否充值
  390. paid: v.paid,
  391. createTime: v.createTime,
  392. status: v.paid,
  393. statusMsg:
  394. v.rechargeType === "bank_transfer"
  395. ? v.paid
  396. ? "充值成功"
  397. : "审核中"
  398. : v.paid
  399. ? "充值成功"
  400. : "充值失败",
  401. };
  402. });
  403. } else if (recordTab.value === "change") {
  404. const statusMap = {
  405. "-1": "未通过",
  406. 0: "待审核",
  407. 1: "审核成功",
  408. };
  409. return recordList.value.map((v) => {
  410. return {
  411. ...v,
  412. type: "expenditure",
  413. title: v.title,
  414. failMsg: v.failMsg,
  415. amount: v.number,
  416. createTime: v.createTime,
  417. status: v.status,
  418. statusMsg: statusMap[v.status] || "未知状态",
  419. };
  420. });
  421. } else if (recordTab.value === "withdraw") {
  422. const statusMap = {
  423. "-1": "未通过",
  424. 0: "审核中",
  425. 1: "已提现",
  426. };
  427. return recordList.value.map((v) => {
  428. return {
  429. type: "expenditure",
  430. title: "提现记录",
  431. failMsg: v.failMsg,
  432. amount: v.extractPrice,
  433. createTime: v.createTime,
  434. status: v.status,
  435. statusMsg: statusMap[v.status] || "未知状态",
  436. remark: v.mark || "",
  437. transferImg: v.successImage || (v.successImage ? [v.successImage] : []),
  438. };
  439. });
  440. } else if (recordTab.value === "consume") {
  441. const statusMap = {
  442. 1: "存金",
  443. 2: "换款",
  444. 3: "每日一攒",
  445. 4: "买金",
  446. 5: "兑换金条",
  447. 6: "自动买卖",
  448. };
  449. const metalTypeMap = {
  450. 1: "黄金",
  451. 2: "铂金",
  452. 3: "白银",
  453. };
  454. return recordList.value.map((v) => {
  455. return {
  456. type: "expenditure",
  457. title: "消费记录",
  458. amount: v.price,
  459. weight: v.weight,
  460. createTime: v.createTime,
  461. // status: statusMap[v.status] || '未知状态'
  462. status: v.operationType,
  463. statusMsg: statusMap[v.operationType],
  464. metalTypeMsg: metalTypeMap[v.metalType],
  465. };
  466. });
  467. } else if (recordTab.value === "buygold") {
  468. const statusMap = {
  469. // 6: "买料",
  470. };
  471. const metalTypeMap = {
  472. 1: "黄金",
  473. 2: "铂金",
  474. 3: "白银",
  475. };
  476. return recordList.value.map((v) => {
  477. return {
  478. type: "expenditure",
  479. title: v.remark,
  480. amount: v.price,
  481. weight: v.weight,
  482. createTime: v.createTime,
  483. realTimePrice: v.realTimePrice,
  484. comeFor: v.comeFor,
  485. // status: statusMap[v.status] || '未知状态'
  486. status: v.operationType,
  487. statusMsg: statusMap[v.operationType],
  488. metalTypeMsg: metalTypeMap[v.metalType],
  489. };
  490. });
  491. } else if (recordTab.value === "soldgold") {
  492. const statusMap = {
  493. // 6: "卖料",
  494. };
  495. const metalTypeMap = {
  496. 1: "黄金",
  497. 2: "铂金",
  498. 3: "白银",
  499. };
  500. return recordList.value.map((v) => {
  501. return {
  502. type: "expenditure",
  503. title: v.remark,
  504. amount: v.price,
  505. weight: v.weight,
  506. createTime: v.createTime,
  507. realTimePrice: v.realTimePrice,
  508. comeFor: v.comeFor,
  509. // status: statusMap[v.status] || '未知状态'
  510. status: v.operationType,
  511. statusMsg: statusMap[v.operationType],
  512. metalTypeMsg: metalTypeMap[v.metalType],
  513. };
  514. });
  515. } else if (recordTab.value === "savegold") {
  516. const statusMap = {
  517. 0: "待审核",
  518. 1: "已审核",
  519. 6: "驳回",
  520. };
  521. const metalTypeMap = {
  522. 1: "黄金",
  523. 2: "铂金",
  524. 3: "白银",
  525. };
  526. return recordList.value.map((v) => {
  527. return {
  528. ...v,
  529. type: "expenditure",
  530. title: v.comeFor,
  531. amount: v.price,
  532. weight: v.weight,
  533. createTime: v.createTime,
  534. statusMsg: statusMap[v.status] || "未知状态",
  535. metalTypeMsg: metalTypeMap[v.metalType],
  536. };
  537. });
  538. } else if (recordTab.value === "materialdeduction") {
  539. const metalTypeMap = {
  540. 1: "黄金",
  541. 2: "铂金",
  542. 3: "白银",
  543. };
  544. return recordList.value.map((v) => {
  545. return {
  546. title: v.remark,
  547. amount: v.price,
  548. weight: v.weight,
  549. comeFor: v.comeFor,
  550. realTimePrice: v.realTimePrice,
  551. createTime: v.createTime,
  552. metalTypeMsg: metalTypeMap[v.metalType],
  553. };
  554. });
  555. }
  556. return []; // 添加默认返回值
  557. });
  558. // 切换记录tab
  559. const switchRecordTab = (tab) => {
  560. recordTab.value = tab;
  561. // 重新加载数据
  562. recordList.value = [];
  563. pagingRef.value?.reload();
  564. };
  565. // 获取空状态文本
  566. const getEmptyText = () => {
  567. const textMap = {
  568. recharge: "暂无充值记录",
  569. withdraw: "暂无提现记录",
  570. consume: "暂无消费记录",
  571. };
  572. return textMap[recordTab.value] || "暂无数据";
  573. };
  574. // 查询列表数据
  575. const queryList = async (page, pageSize) => {
  576. // 若appStore.uid为空,则请求失败
  577. if (!appStore?.uid) {
  578. Toast({ title: "未登录,请前往登录后访问" });
  579. return;
  580. }
  581. try {
  582. const { data } = await fetchRecordList(page, pageSize);
  583. // 通过组件的complete方法将数据传递给z-paging
  584. pagingRef.value?.complete(data.list);
  585. } catch (error) {
  586. console.error("查询失败:", error);
  587. pagingRef.value?.complete(false);
  588. Toast({ title: "查询失败" });
  589. }
  590. };
  591. async function fetchRecordList(page, pageSize) {
  592. // 若appStore.uid为空,则请求失败
  593. if (!appStore?.uid) {
  594. Toast({ title: "未登录,请前往登录后访问" });
  595. return { data: [] };
  596. }
  597. const params = { page, pageSize, uid: appStore.uid, userId: appStore.uid };
  598. if (recordTab.value === "recharge") {
  599. return await getRechargeList(params);
  600. } else if (recordTab.value === "withdraw") {
  601. return await getWithdrawList(params);
  602. } else if (recordTab.value === "consume") {
  603. return await getConsumeList({ ...params, type: 6 });
  604. } else if (recordTab.value === "buygold") {
  605. const res = await getConsumeList({ ...params, type: 6 });
  606. // 2. 过滤出 operationType == 4 的数据
  607. const filteredList = res.data.list.filter((item) =>
  608. [3, 4].includes(item.operationType)
  609. );
  610. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  611. return {
  612. ...res, // 保留原始响应的其他字段(如 code、message 等)
  613. data: {
  614. list: filteredList, // 替换为过滤后的列表
  615. },
  616. };
  617. } else if (recordTab.value === "soldgold") {
  618. const res = await getConsumeList({ ...params, type: 6 });
  619. // 2. 过滤出 operationType == 4 的数据
  620. const filteredList = res.data.list.filter((item) =>
  621. [6, 3].includes(item.operationType)
  622. );
  623. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  624. return {
  625. ...res, // 保留原始响应的其他字段(如 code、message 等)
  626. data: {
  627. list: filteredList, // 替换为过滤后的列表
  628. },
  629. };
  630. } else if (recordTab.value === "savegold") {
  631. const res = await getConsumeList({ ...params, type: 6 });
  632. // 2. 过滤出 operationType == 4 的数据
  633. const filteredList = res.data.list.filter((item) =>
  634. [1].includes(item.operationType)
  635. );
  636. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  637. return {
  638. ...res, // 保留原始响应的其他字段(如 code、message 等)
  639. data: {
  640. list: filteredList, // 替换为过滤后的列表
  641. },
  642. };
  643. } else if (recordTab.value === "change") {
  644. const res = await getConsumeList({ ...params, type: 4 });
  645. return res;
  646. // 2. 过滤出 operationType == 4 的数据
  647. } else if (recordTab.value === "materialdeduction") {
  648. const res = await getConsumeList({ ...params, type: 6 });
  649. // 2. 过滤出 operationType == 4 的数据
  650. const filteredList = res.data.list.filter((item) =>
  651. [10].includes(item.operationType)
  652. );
  653. return {
  654. ...res, // 保留原始响应的其他字段(如 code、message 等)
  655. data: {
  656. list: filteredList, // 替换为过滤后的列表
  657. },
  658. };
  659. }
  660. }
  661. async function updateUserInfo() {
  662. const { data } = await getUserInfo();
  663. appStore.UPDATE_USERINFO(data);
  664. }
  665. function refresherTouchend() {
  666. updateUserInfo();
  667. }
  668. // 添加弹窗相关数据
  669. const detailPopup = ref(null);
  670. const currentDetail = ref({
  671. amount: "",
  672. createTime: "",
  673. remark: "",
  674. transferImg: [],
  675. });
  676. // 查看详情方法
  677. const viewDetail = (item) => {
  678. currentDetail.value = {
  679. amount: item.amount,
  680. createTime: item.createTime,
  681. remark: item.remark || "",
  682. transferImg: JSON.parse(item.transferImg) || [],
  683. };
  684. detailPopup.value.open();
  685. };
  686. // 关闭详情弹窗
  687. const closeDetail = () => {
  688. detailPopup.value.close();
  689. };
  690. // 预览图片
  691. const previewImage = (urls, current) => {
  692. uni.previewImage({
  693. urls: urls,
  694. current: current,
  695. });
  696. };
  697. onShow(() => {
  698. updateUserInfo();
  699. fetchMetalBalance();
  700. });
  701. </script>
  702. <style lang="scss" scoped>
  703. $primary-color: #e9c279;
  704. $text-color: #333;
  705. $text-secondary: #666;
  706. $text-light: #999;
  707. $bg-color: #f5f5f5;
  708. $white: #fff;
  709. $border-color: #e5e5e5;
  710. .new-asset-box {
  711. width: 100%;
  712. height: 519rpx;
  713. background-color: #f7ecd8;
  714. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
  715. border-radius: 20rpx;
  716. display: flex;
  717. flex-direction: column;
  718. align-items: center;
  719. margin-top: 20rpx;
  720. .new-asset-title {
  721. flex: 1;
  722. display: flex;
  723. justify-content: center;
  724. align-items: center;
  725. image {
  726. width: 25rpx;
  727. margin: 0 15rpx;
  728. }
  729. text {
  730. font-size: 26rpx;
  731. // color: #cc9933;
  732. color: #f8c007;
  733. }
  734. }
  735. .new-asset-content {
  736. width: 100%;
  737. height: 453rpx;
  738. background-color: #ffffff;
  739. // border-top-left-radius: 20rpx;
  740. // border-top-right-radius: 20rpx;
  741. border-radius: 20rpx;
  742. display: flex;
  743. flex-direction: column;
  744. padding: 0 30rpx;
  745. box-sizing: border-box;
  746. .asset-content-item {
  747. flex: 1;
  748. display: flex;
  749. justify-content: space-between;
  750. align-items: center;
  751. border-bottom: 2rpx dashed #979797;
  752. &:last-child {
  753. border-bottom: none;
  754. }
  755. .content-item-left {
  756. display: flex;
  757. align-items: center;
  758. font-size: 28rpx;
  759. font-weight: bold;
  760. color: #000000;
  761. image {
  762. width: 50rpx;
  763. margin: 0rpx 20rpx 0 10rpx;
  764. }
  765. }
  766. .content-item-right {
  767. font-size: 22rpx;
  768. // color: #cc9933;
  769. color: $txt-color;
  770. margin-right: 20rpx;
  771. }
  772. }
  773. }
  774. }
  775. .container {
  776. min-height: 90vh;
  777. overflow: hidden;
  778. position: relative;
  779. background: $uni-bg-primary;
  780. }
  781. .asset-tips {
  782. width: 684rpx;
  783. height: 231rpx;
  784. background-color: #ffffff;
  785. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
  786. border-radius: 20rpx;
  787. box-sizing: border-box;
  788. margin: 20rpx 0;
  789. padding: 10rpx 45rpx;
  790. font-size: 26rpx;
  791. display: flex;
  792. flex-direction: column;
  793. justify-content: center;
  794. .zc {
  795. margin-bottom: 20rpx;
  796. }
  797. }
  798. .record-container {
  799. background: #fff;
  800. border-radius: 20rpx;
  801. box-sizing: border-box;
  802. padding: 30rpx 45rpx;
  803. // 记录tab样式
  804. .record-title {
  805. font-weight: bold;
  806. font-size: 26rpx;
  807. }
  808. .record-tabs {
  809. display: flex;
  810. width: 100%;
  811. text-align: center;
  812. font-size: 28rpx;
  813. color: #000000;
  814. transition: all 0.3s;
  815. .record-tab {
  816. flex: 1;
  817. display: flex;
  818. font-size: 26rpx;
  819. color: #767676;
  820. justify-content: center;
  821. margin: 32rpx 0;
  822. position: relative;
  823. &.active {
  824. color: #000;
  825. }
  826. &.active::after {
  827. content: "";
  828. position: absolute;
  829. bottom: -10rpx;
  830. left: 50%;
  831. transform: translateX(-50%);
  832. width: 55rpx;
  833. height: 4rpx;
  834. background-color: $theme-color;
  835. border-radius: 3rpx;
  836. }
  837. }
  838. }
  839. }
  840. // 钱包页面样式
  841. .wallet-page {
  842. position: relative;
  843. padding: 32rpx;
  844. }
  845. .balance-card {
  846. background: $white;
  847. border-radius: 24rpx;
  848. padding: 48rpx 32rpx;
  849. margin-bottom: 32rpx;
  850. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  851. .balance-label {
  852. font-size: 28rpx;
  853. color: $text-secondary;
  854. margin-bottom: 16rpx;
  855. }
  856. .balance-amount {
  857. display: flex;
  858. align-items: baseline;
  859. margin-bottom: 48rpx;
  860. .currency {
  861. font-size: 32rpx;
  862. color: $primary-color;
  863. margin-right: 8rpx;
  864. }
  865. .amount {
  866. font-size: 58rpx;
  867. // font-weight: bold;
  868. color: $primary-color;
  869. }
  870. .unit {
  871. font-size: 28rpx;
  872. color: $text-secondary;
  873. margin-left: 8rpx;
  874. }
  875. }
  876. .action-buttons {
  877. display: flex;
  878. gap: 24rpx;
  879. .action-btn {
  880. flex: 1;
  881. text-align: center;
  882. padding: 28rpx 0;
  883. border-radius: 16rpx;
  884. font-size: 32rpx;
  885. background: #f0f0f0;
  886. color: $text-color;
  887. &.primary {
  888. background: $primary-color;
  889. color: $white;
  890. }
  891. }
  892. }
  893. }
  894. .paging-box {
  895. min-height: 45vh;
  896. }
  897. .record-tip {
  898. text-align: center;
  899. font-size: 24rpx;
  900. color: $text-light;
  901. margin-bottom: 32rpx;
  902. }
  903. // 列表样式
  904. .list-item {
  905. background: $white;
  906. display: flex;
  907. align-items: center;
  908. justify-content: space-between;
  909. padding: 32rpx 0;
  910. margin-bottom: 16rpx;
  911. border-radius: 16rpx;
  912. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  913. .item-left {
  914. flex: 1;
  915. .item-title {
  916. font-size: 22rpx;
  917. color: $text-color;
  918. margin-bottom: 8rpx;
  919. font-weight: 500;
  920. .status {
  921. background-color: $header-color;
  922. font-size: 22rpx;
  923. color: #fff;
  924. padding: 2rpx 8rpx;
  925. border-radius: 10rpx;
  926. margin-left: 15rpx;
  927. }
  928. }
  929. .item-status {
  930. display: inline-block;
  931. background: $primary-color;
  932. color: $white;
  933. font-size: 22rpx;
  934. padding: 6rpx 16rpx;
  935. border-radius: 12rpx;
  936. margin-bottom: 12rpx;
  937. }
  938. .item-detail {
  939. margin-bottom: 12rpx;
  940. .detail-label {
  941. font-size: 22rpx;
  942. color: $text-secondary;
  943. }
  944. .detail-value {
  945. font-size: 22rpx;
  946. color: $text-color;
  947. }
  948. }
  949. .item-time {
  950. font-size: 22rpx;
  951. color: $text-light;
  952. }
  953. }
  954. .item-right {
  955. min-width: 180rpx;
  956. // flex: 1;
  957. // flex: 0 0 150rpx; // 不允许伸缩
  958. text-align: right;
  959. height: 100%;
  960. display: flex;
  961. flex-direction: column;
  962. align-items: flex-end;
  963. justify-content: center;
  964. margin-left: 24rpx;
  965. .item-amount {
  966. font-size: 22rpx;
  967. font-weight: bold;
  968. color: #000;
  969. text-align: right;
  970. &.positive {
  971. color: #e9c279;
  972. }
  973. &.fail {
  974. color: #ccc;
  975. }
  976. .fail-msg {
  977. font-size: 22rpx;
  978. }
  979. }
  980. .metalTypeMsg {
  981. font-size: 22rpx;
  982. color: #cc9933 !important;
  983. }
  984. .detail-btn {
  985. font-size: 22rpx;
  986. color: #e9c279;
  987. margin-top: 10rpx;
  988. padding: 6rpx 16rpx;
  989. border: 1px solid #e9c279;
  990. border-radius: 8rpx;
  991. }
  992. }
  993. }
  994. // 贵金属页面样式
  995. .precious-page {
  996. position: relative;
  997. padding: 32rpx;
  998. .metals-list {
  999. .metal-card-border {
  1000. padding: 3px; // 边框宽度
  1001. border-radius: 24rpx; // 比metal-card略大
  1002. background: linear-gradient(135deg, #f7d08a, #e9c279, #fff6e0, #c49b47);
  1003. // 可根据需要调整渐变色
  1004. margin-bottom: 30rpx;
  1005. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  1006. }
  1007. .metal-card {
  1008. background-image: linear-gradient(to bottom, #fdf8ee, #fcefdc);
  1009. border-radius: 20rpx;
  1010. overflow: hidden;
  1011. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  1012. .card-top {
  1013. display: flex;
  1014. justify-content: space-between;
  1015. padding: 40rpx 30rpx;
  1016. }
  1017. .info-section {
  1018. .metal-name {
  1019. font-size: 22rpx;
  1020. color: $text-color;
  1021. font-weight: bold;
  1022. }
  1023. .balance {
  1024. margin-top: 20rpx;
  1025. display: flex;
  1026. align-items: baseline;
  1027. .amount {
  1028. font-size: 22rpx;
  1029. font-weight: bold;
  1030. color: #c49b47;
  1031. }
  1032. .unit {
  1033. font-size: 22rpx;
  1034. color: $text-secondary;
  1035. margin-left: 10rpx;
  1036. }
  1037. }
  1038. }
  1039. .action-section {
  1040. display: flex;
  1041. flex-direction: column;
  1042. justify-content: space-around;
  1043. .action-btn {
  1044. margin: 0;
  1045. padding: 0 40rpx;
  1046. font-size: 22rpx;
  1047. height: 64rpx;
  1048. line-height: 64rpx;
  1049. border-radius: 32rpx;
  1050. color: $white;
  1051. &::after {
  1052. border: none;
  1053. }
  1054. &.deposit-btn {
  1055. background-color: #fae2a6;
  1056. color: #958255;
  1057. margin-bottom: 20rpx;
  1058. }
  1059. &.withdraw-btn {
  1060. background-color: $primary-color;
  1061. }
  1062. }
  1063. }
  1064. .card-bottom {
  1065. display: flex;
  1066. justify-content: space-between;
  1067. align-items: center;
  1068. background-color: $primary-color;
  1069. color: $white;
  1070. padding: 20rpx 30rpx;
  1071. font-size: 22rpx;
  1072. .arrow {
  1073. font-family: "Courier New", Courier, monospace;
  1074. font-weight: bold;
  1075. font-size: 22rpx;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. .asset-description {
  1081. background-color: $white;
  1082. padding: 30rpx;
  1083. border-radius: 20rpx;
  1084. font-size: 22rpx;
  1085. line-height: 1.7;
  1086. color: $text-secondary;
  1087. .desc-title {
  1088. color: $text-color;
  1089. font-weight: bold;
  1090. display: block;
  1091. margin-bottom: 10rpx;
  1092. }
  1093. }
  1094. }
  1095. .detail-popup {
  1096. width: 600rpx;
  1097. background: #fff;
  1098. border-radius: 20rpx;
  1099. overflow: hidden;
  1100. }
  1101. .popup-header {
  1102. display: flex;
  1103. justify-content: space-between;
  1104. align-items: center;
  1105. padding: 30rpx;
  1106. border-bottom: 1px solid #eee;
  1107. }
  1108. .popup-title {
  1109. font-size: 32rpx;
  1110. font-weight: bold;
  1111. color: #333;
  1112. }
  1113. .close-btn {
  1114. font-size: 40rpx;
  1115. color: #999;
  1116. line-height: 1;
  1117. }
  1118. .popup-content {
  1119. padding: 30rpx;
  1120. max-height: 600rpx;
  1121. overflow-y: auto;
  1122. }
  1123. .detail-item {
  1124. display: flex;
  1125. align-items: flex-start;
  1126. margin-bottom: 24rpx;
  1127. font-size: 28rpx;
  1128. .label {
  1129. color: #666;
  1130. min-width: 160rpx;
  1131. flex-shrink: 0;
  1132. }
  1133. .value {
  1134. color: #333;
  1135. flex: 1;
  1136. word-break: break-all;
  1137. }
  1138. }
  1139. .image-list {
  1140. display: flex;
  1141. flex-wrap: wrap;
  1142. gap: 20rpx;
  1143. margin-top: 16rpx;
  1144. }
  1145. .transfer-image {
  1146. width: 200rpx;
  1147. height: 200rpx;
  1148. border-radius: 12rpx;
  1149. border: 1px solid #eee;
  1150. }
  1151. </style>