index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  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(() => {});
  376. const combineList = computed(() => {
  377. if (recordTab.value === "recharge") {
  378. return recordList.value.map((v) => {
  379. return {
  380. type: "income",
  381. title: v.rechargeType == "bank_transfer" ? "银行卡" : "支付宝",
  382. amount: v.price,
  383. // 是否充值
  384. paid: v.paid,
  385. createTime: v.createTime,
  386. status: v.paid,
  387. statusMsg:
  388. v.rechargeType === "bank_transfer"
  389. ? v.paid
  390. ? "充值成功"
  391. : "审核中"
  392. : v.paid
  393. ? "充值成功"
  394. : "充值失败",
  395. };
  396. });
  397. } else if (recordTab.value === "change") {
  398. const statusMap = {
  399. "-1": "未通过",
  400. 0: "待审核",
  401. 1: "审核成功",
  402. };
  403. return recordList.value.map((v) => {
  404. return {
  405. ...v,
  406. type: "expenditure",
  407. title: v.title,
  408. failMsg: v.failMsg,
  409. amount: v.number,
  410. createTime: v.createTime,
  411. status: v.status,
  412. statusMsg: statusMap[v.status] || "未知状态",
  413. };
  414. });
  415. } else if (recordTab.value === "withdraw") {
  416. const statusMap = {
  417. "-1": "未通过",
  418. 0: "审核中",
  419. 1: "已提现",
  420. };
  421. return recordList.value.map((v) => {
  422. return {
  423. type: "expenditure",
  424. title: "提现记录",
  425. failMsg: v.failMsg,
  426. amount: v.extractPrice,
  427. createTime: v.createTime,
  428. status: v.status,
  429. statusMsg: statusMap[v.status] || "未知状态",
  430. remark: v.mark || "",
  431. transferImg: v.successImage || (v.successImage ? [v.successImage] : []),
  432. };
  433. });
  434. } else if (recordTab.value === "consume") {
  435. const statusMap = {
  436. 1: "存金",
  437. 2: "换款",
  438. 3: "每日一攒",
  439. 4: "买金",
  440. 5: "兑换金条",
  441. 6: "自动买卖",
  442. };
  443. const metalTypeMap = {
  444. 1: "黄金",
  445. 2: "铂金",
  446. 3: "白银",
  447. };
  448. return recordList.value.map((v) => {
  449. return {
  450. type: "expenditure",
  451. title: "消费记录",
  452. amount: v.price,
  453. weight: v.weight,
  454. createTime: v.createTime,
  455. // status: statusMap[v.status] || '未知状态'
  456. status: v.operationType,
  457. statusMsg: statusMap[v.operationType],
  458. metalTypeMsg: metalTypeMap[v.metalType],
  459. };
  460. });
  461. } else if (recordTab.value === "buygold") {
  462. const statusMap = {
  463. // 6: "买料",
  464. };
  465. const metalTypeMap = {
  466. 1: "黄金",
  467. 2: "铂金",
  468. 3: "白银",
  469. };
  470. return recordList.value.map((v) => {
  471. return {
  472. type: "expenditure",
  473. title: v.remark,
  474. amount: v.price,
  475. weight: v.weight,
  476. createTime: v.createTime,
  477. realTimePrice: v.realTimePrice,
  478. comeFor: v.comeFor,
  479. // status: statusMap[v.status] || '未知状态'
  480. status: v.operationType,
  481. statusMsg: statusMap[v.operationType],
  482. metalTypeMsg: metalTypeMap[v.metalType],
  483. };
  484. });
  485. } else if (recordTab.value === "soldgold") {
  486. const statusMap = {
  487. // 6: "卖料",
  488. };
  489. const metalTypeMap = {
  490. 1: "黄金",
  491. 2: "铂金",
  492. 3: "白银",
  493. };
  494. return recordList.value.map((v) => {
  495. return {
  496. type: "expenditure",
  497. title: v.remark,
  498. amount: v.price,
  499. weight: v.weight,
  500. createTime: v.createTime,
  501. realTimePrice: v.realTimePrice,
  502. comeFor: v.comeFor,
  503. // status: statusMap[v.status] || '未知状态'
  504. status: v.operationType,
  505. statusMsg: statusMap[v.operationType],
  506. metalTypeMsg: metalTypeMap[v.metalType],
  507. };
  508. });
  509. } else if (recordTab.value === "savegold") {
  510. const statusMap = {
  511. 0: "待审核",
  512. 1: "已审核",
  513. 6: "驳回",
  514. };
  515. const metalTypeMap = {
  516. 1: "黄金",
  517. 2: "铂金",
  518. 3: "白银",
  519. };
  520. return recordList.value.map((v) => {
  521. return {
  522. ...v,
  523. type: "expenditure",
  524. title: v.comeFor,
  525. amount: v.price,
  526. weight: v.weight,
  527. createTime: v.createTime,
  528. statusMsg: statusMap[v.status] || "未知状态",
  529. metalTypeMsg: metalTypeMap[v.metalType],
  530. };
  531. });
  532. } else if (recordTab.value === "materialdeduction") {
  533. const metalTypeMap = {
  534. 1: "黄金",
  535. 2: "铂金",
  536. 3: "白银",
  537. };
  538. return recordList.value.map((v) => {
  539. return {
  540. title: v.remark,
  541. amount: v.price,
  542. weight: v.weight,
  543. comeFor: v.comeFor,
  544. realTimePrice: v.realTimePrice,
  545. createTime: v.createTime,
  546. metalTypeMsg: metalTypeMap[v.metalType],
  547. };
  548. });
  549. }
  550. return []; // 添加默认返回值
  551. });
  552. // 切换记录tab
  553. const switchRecordTab = (tab) => {
  554. recordTab.value = tab;
  555. // 重新加载数据
  556. recordList.value = [];
  557. pagingRef.value?.reload();
  558. };
  559. // 获取空状态文本
  560. const getEmptyText = () => {
  561. const textMap = {
  562. recharge: "暂无充值记录",
  563. withdraw: "暂无提现记录",
  564. consume: "暂无消费记录",
  565. };
  566. return textMap[recordTab.value] || "暂无数据";
  567. };
  568. // 查询列表数据
  569. const queryList = async (page, pageSize) => {
  570. // 若appStore.uid为空,则请求失败
  571. if (!appStore?.uid) {
  572. Toast({ title: "未登录,请前往登录后访问" });
  573. return;
  574. }
  575. try {
  576. const { data } = await fetchRecordList(page, pageSize);
  577. // 通过组件的complete方法将数据传递给z-paging
  578. pagingRef.value?.complete(data.list);
  579. } catch (error) {
  580. console.error("查询失败:", error);
  581. pagingRef.value?.complete(false);
  582. Toast({ title: "查询失败" });
  583. }
  584. };
  585. async function fetchRecordList(page, pageSize) {
  586. // 若appStore.uid为空,则请求失败
  587. if (!appStore?.uid) {
  588. Toast({ title: "未登录,请前往登录后访问" });
  589. return { data: [] };
  590. }
  591. const params = { page, pageSize, uid: appStore.uid, userId: appStore.uid };
  592. if (recordTab.value === "recharge") {
  593. return await getRechargeList(params);
  594. } else if (recordTab.value === "withdraw") {
  595. return await getWithdrawList(params);
  596. } else if (recordTab.value === "consume") {
  597. return await getConsumeList({ ...params, type: 6 });
  598. } else if (recordTab.value === "buygold") {
  599. const res = await getConsumeList({ ...params, type: 6 });
  600. // 2. 过滤出 operationType == 4 的数据
  601. const filteredList = res.data.list.filter((item) =>
  602. [3, 4].includes(item.operationType)
  603. );
  604. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  605. return {
  606. ...res, // 保留原始响应的其他字段(如 code、message 等)
  607. data: {
  608. list: filteredList, // 替换为过滤后的列表
  609. },
  610. };
  611. } else if (recordTab.value === "soldgold") {
  612. const res = await getConsumeList({ ...params, type: 6 });
  613. // 2. 过滤出 operationType == 4 的数据
  614. const filteredList = res.data.list.filter((item) =>
  615. [6, 3].includes(item.operationType)
  616. );
  617. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  618. return {
  619. ...res, // 保留原始响应的其他字段(如 code、message 等)
  620. data: {
  621. list: filteredList, // 替换为过滤后的列表
  622. },
  623. };
  624. } else if (recordTab.value === "savegold") {
  625. const res = await getConsumeList({ ...params, type: 6 });
  626. // 2. 过滤出 operationType == 4 的数据
  627. const filteredList = res.data.list.filter((item) =>
  628. [1].includes(item.operationType)
  629. );
  630. // 3. 关键:同步更新分页字段,确保格式与其他分支一致
  631. return {
  632. ...res, // 保留原始响应的其他字段(如 code、message 等)
  633. data: {
  634. list: filteredList, // 替换为过滤后的列表
  635. },
  636. };
  637. } else if (recordTab.value === "change") {
  638. const res = await getConsumeList({ ...params, type: 4 });
  639. return res;
  640. // 2. 过滤出 operationType == 4 的数据
  641. } else if (recordTab.value === "materialdeduction") {
  642. const res = await getConsumeList({ ...params, type: 6 });
  643. // 2. 过滤出 operationType == 4 的数据
  644. const filteredList = res.data.list.filter((item) =>
  645. [10].includes(item.operationType)
  646. );
  647. return {
  648. ...res, // 保留原始响应的其他字段(如 code、message 等)
  649. data: {
  650. list: filteredList, // 替换为过滤后的列表
  651. },
  652. };
  653. }
  654. }
  655. async function updateUserInfo() {
  656. const { data } = await getUserInfo();
  657. appStore.UPDATE_USERINFO(data);
  658. }
  659. function refresherTouchend() {
  660. updateUserInfo();
  661. }
  662. // 添加弹窗相关数据
  663. const detailPopup = ref(null);
  664. const currentDetail = ref({
  665. amount: "",
  666. createTime: "",
  667. remark: "",
  668. transferImg: [],
  669. });
  670. // 查看详情方法
  671. const viewDetail = (item) => {
  672. currentDetail.value = {
  673. amount: item.amount,
  674. createTime: item.createTime,
  675. remark: item.remark || "",
  676. transferImg: JSON.parse(item.transferImg) || [],
  677. };
  678. detailPopup.value.open();
  679. };
  680. // 关闭详情弹窗
  681. const closeDetail = () => {
  682. detailPopup.value.close();
  683. };
  684. // 预览图片
  685. const previewImage = (urls, current) => {
  686. uni.previewImage({
  687. urls: urls,
  688. current: current,
  689. });
  690. };
  691. onShow(() => {
  692. updateUserInfo();
  693. fetchMetalBalance();
  694. });
  695. </script>
  696. <style lang="scss" scoped>
  697. $primary-color: #e9c279;
  698. $text-color: #333;
  699. $text-secondary: #666;
  700. $text-light: #999;
  701. $bg-color: #f5f5f5;
  702. $white: #fff;
  703. $border-color: #e5e5e5;
  704. .new-asset-box {
  705. width: 100%;
  706. height: 519rpx;
  707. background-color: #f7ecd8;
  708. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
  709. border-radius: 20rpx;
  710. display: flex;
  711. flex-direction: column;
  712. align-items: center;
  713. margin-top: 20rpx;
  714. .new-asset-title {
  715. flex: 1;
  716. display: flex;
  717. justify-content: center;
  718. align-items: center;
  719. image {
  720. width: 25rpx;
  721. margin: 0 15rpx;
  722. }
  723. text {
  724. font-size: 26rpx;
  725. // color: #cc9933;
  726. color: #f8c007;
  727. }
  728. }
  729. .new-asset-content {
  730. width: 100%;
  731. height: 453rpx;
  732. background-color: #ffffff;
  733. // border-top-left-radius: 20rpx;
  734. // border-top-right-radius: 20rpx;
  735. border-radius: 20rpx;
  736. display: flex;
  737. flex-direction: column;
  738. padding: 0 30rpx;
  739. box-sizing: border-box;
  740. .asset-content-item {
  741. flex: 1;
  742. display: flex;
  743. justify-content: space-between;
  744. align-items: center;
  745. border-bottom: 2rpx dashed #979797;
  746. &:last-child {
  747. border-bottom: none;
  748. }
  749. .content-item-left {
  750. display: flex;
  751. align-items: center;
  752. font-size: 28rpx;
  753. font-weight: bold;
  754. color: #000000;
  755. image {
  756. width: 50rpx;
  757. margin: 0rpx 20rpx 0 10rpx;
  758. }
  759. }
  760. .content-item-right {
  761. font-size: 22rpx;
  762. // color: #cc9933;
  763. color: $txt-color;
  764. margin-right: 20rpx;
  765. }
  766. }
  767. }
  768. }
  769. .container {
  770. min-height: 90vh;
  771. overflow: hidden;
  772. position: relative;
  773. background: $uni-bg-primary;
  774. }
  775. .asset-tips {
  776. width: 684rpx;
  777. height: 231rpx;
  778. background-color: #ffffff;
  779. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
  780. border-radius: 20rpx;
  781. box-sizing: border-box;
  782. margin: 20rpx 0;
  783. padding: 10rpx 45rpx;
  784. font-size: 26rpx;
  785. display: flex;
  786. flex-direction: column;
  787. justify-content: center;
  788. .zc {
  789. margin-bottom: 20rpx;
  790. }
  791. }
  792. .record-container {
  793. background: #fff;
  794. border-radius: 20rpx;
  795. box-sizing: border-box;
  796. padding: 30rpx 45rpx;
  797. // 记录tab样式
  798. .record-title {
  799. font-weight: bold;
  800. font-size: 26rpx;
  801. }
  802. .record-tabs {
  803. display: flex;
  804. width: 100%;
  805. text-align: center;
  806. font-size: 28rpx;
  807. color: #000000;
  808. transition: all 0.3s;
  809. .record-tab {
  810. flex: 1;
  811. display: flex;
  812. font-size: 26rpx;
  813. color: #767676;
  814. justify-content: center;
  815. margin: 32rpx 0;
  816. position: relative;
  817. &.active {
  818. color: #000;
  819. }
  820. &.active::after {
  821. content: "";
  822. position: absolute;
  823. bottom: -10rpx;
  824. left: 50%;
  825. transform: translateX(-50%);
  826. width: 55rpx;
  827. height: 4rpx;
  828. background-color: $theme-color;
  829. border-radius: 3rpx;
  830. }
  831. }
  832. }
  833. }
  834. // 钱包页面样式
  835. .wallet-page {
  836. position: relative;
  837. padding: 32rpx;
  838. }
  839. .balance-card {
  840. background: $white;
  841. border-radius: 24rpx;
  842. padding: 48rpx 32rpx;
  843. margin-bottom: 32rpx;
  844. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  845. .balance-label {
  846. font-size: 28rpx;
  847. color: $text-secondary;
  848. margin-bottom: 16rpx;
  849. }
  850. .balance-amount {
  851. display: flex;
  852. align-items: baseline;
  853. margin-bottom: 48rpx;
  854. .currency {
  855. font-size: 32rpx;
  856. color: $primary-color;
  857. margin-right: 8rpx;
  858. }
  859. .amount {
  860. font-size: 58rpx;
  861. // font-weight: bold;
  862. color: $primary-color;
  863. }
  864. .unit {
  865. font-size: 28rpx;
  866. color: $text-secondary;
  867. margin-left: 8rpx;
  868. }
  869. }
  870. .action-buttons {
  871. display: flex;
  872. gap: 24rpx;
  873. .action-btn {
  874. flex: 1;
  875. text-align: center;
  876. padding: 28rpx 0;
  877. border-radius: 16rpx;
  878. font-size: 32rpx;
  879. background: #f0f0f0;
  880. color: $text-color;
  881. &.primary {
  882. background: $primary-color;
  883. color: $white;
  884. }
  885. }
  886. }
  887. }
  888. .paging-box {
  889. min-height: 45vh;
  890. }
  891. .record-tip {
  892. text-align: center;
  893. font-size: 24rpx;
  894. color: $text-light;
  895. margin-bottom: 32rpx;
  896. }
  897. // 列表样式
  898. .list-item {
  899. background: $white;
  900. display: flex;
  901. align-items: center;
  902. justify-content: space-between;
  903. padding: 32rpx 0;
  904. margin-bottom: 16rpx;
  905. border-radius: 16rpx;
  906. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  907. .item-left {
  908. flex: 1;
  909. .item-title {
  910. font-size: 22rpx;
  911. color: $text-color;
  912. margin-bottom: 8rpx;
  913. font-weight: 500;
  914. .status {
  915. background-color: $header-color;
  916. font-size: 22rpx;
  917. color: #fff;
  918. padding: 2rpx 8rpx;
  919. border-radius: 10rpx;
  920. margin-left: 15rpx;
  921. }
  922. }
  923. .item-status {
  924. display: inline-block;
  925. background: $primary-color;
  926. color: $white;
  927. font-size: 22rpx;
  928. padding: 6rpx 16rpx;
  929. border-radius: 12rpx;
  930. margin-bottom: 12rpx;
  931. }
  932. .item-detail {
  933. margin-bottom: 12rpx;
  934. .detail-label {
  935. font-size: 22rpx;
  936. color: $text-secondary;
  937. }
  938. .detail-value {
  939. font-size: 22rpx;
  940. color: $text-color;
  941. }
  942. }
  943. .item-time {
  944. font-size: 22rpx;
  945. color: $text-light;
  946. }
  947. }
  948. .item-right {
  949. min-width: 180rpx;
  950. // flex: 1;
  951. // flex: 0 0 150rpx; // 不允许伸缩
  952. text-align: right;
  953. height: 100%;
  954. display: flex;
  955. flex-direction: column;
  956. align-items: flex-end;
  957. justify-content: center;
  958. margin-left: 24rpx;
  959. .item-amount {
  960. font-size: 22rpx;
  961. font-weight: bold;
  962. color: #000;
  963. text-align: right;
  964. &.positive {
  965. color: #e9c279;
  966. }
  967. &.fail {
  968. color: #ccc;
  969. }
  970. .fail-msg {
  971. font-size: 22rpx;
  972. }
  973. }
  974. .metalTypeMsg {
  975. font-size: 22rpx;
  976. color: #cc9933 !important;
  977. }
  978. .detail-btn {
  979. font-size: 22rpx;
  980. color: #e9c279;
  981. margin-top: 10rpx;
  982. padding: 6rpx 16rpx;
  983. border: 1px solid #e9c279;
  984. border-radius: 8rpx;
  985. }
  986. }
  987. }
  988. // 贵金属页面样式
  989. .precious-page {
  990. position: relative;
  991. padding: 32rpx;
  992. .metals-list {
  993. .metal-card-border {
  994. padding: 3px; // 边框宽度
  995. border-radius: 24rpx; // 比metal-card略大
  996. background: linear-gradient(135deg, #f7d08a, #e9c279, #fff6e0, #c49b47);
  997. // 可根据需要调整渐变色
  998. margin-bottom: 30rpx;
  999. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  1000. }
  1001. .metal-card {
  1002. background-image: linear-gradient(to bottom, #fdf8ee, #fcefdc);
  1003. border-radius: 20rpx;
  1004. overflow: hidden;
  1005. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  1006. .card-top {
  1007. display: flex;
  1008. justify-content: space-between;
  1009. padding: 40rpx 30rpx;
  1010. }
  1011. .info-section {
  1012. .metal-name {
  1013. font-size: 22rpx;
  1014. color: $text-color;
  1015. font-weight: bold;
  1016. }
  1017. .balance {
  1018. margin-top: 20rpx;
  1019. display: flex;
  1020. align-items: baseline;
  1021. .amount {
  1022. font-size: 22rpx;
  1023. font-weight: bold;
  1024. color: #c49b47;
  1025. }
  1026. .unit {
  1027. font-size: 22rpx;
  1028. color: $text-secondary;
  1029. margin-left: 10rpx;
  1030. }
  1031. }
  1032. }
  1033. .action-section {
  1034. display: flex;
  1035. flex-direction: column;
  1036. justify-content: space-around;
  1037. .action-btn {
  1038. margin: 0;
  1039. padding: 0 40rpx;
  1040. font-size: 22rpx;
  1041. height: 64rpx;
  1042. line-height: 64rpx;
  1043. border-radius: 32rpx;
  1044. color: $white;
  1045. &::after {
  1046. border: none;
  1047. }
  1048. &.deposit-btn {
  1049. background-color: #fae2a6;
  1050. color: #958255;
  1051. margin-bottom: 20rpx;
  1052. }
  1053. &.withdraw-btn {
  1054. background-color: $primary-color;
  1055. }
  1056. }
  1057. }
  1058. .card-bottom {
  1059. display: flex;
  1060. justify-content: space-between;
  1061. align-items: center;
  1062. background-color: $primary-color;
  1063. color: $white;
  1064. padding: 20rpx 30rpx;
  1065. font-size: 22rpx;
  1066. .arrow {
  1067. font-family: "Courier New", Courier, monospace;
  1068. font-weight: bold;
  1069. font-size: 22rpx;
  1070. }
  1071. }
  1072. }
  1073. }
  1074. .asset-description {
  1075. background-color: $white;
  1076. padding: 30rpx;
  1077. border-radius: 20rpx;
  1078. font-size: 22rpx;
  1079. line-height: 1.7;
  1080. color: $text-secondary;
  1081. .desc-title {
  1082. color: $text-color;
  1083. font-weight: bold;
  1084. display: block;
  1085. margin-bottom: 10rpx;
  1086. }
  1087. }
  1088. }
  1089. .detail-popup {
  1090. width: 600rpx;
  1091. background: #fff;
  1092. border-radius: 20rpx;
  1093. overflow: hidden;
  1094. }
  1095. .popup-header {
  1096. display: flex;
  1097. justify-content: space-between;
  1098. align-items: center;
  1099. padding: 30rpx;
  1100. border-bottom: 1px solid #eee;
  1101. }
  1102. .popup-title {
  1103. font-size: 32rpx;
  1104. font-weight: bold;
  1105. color: #333;
  1106. }
  1107. .close-btn {
  1108. font-size: 40rpx;
  1109. color: #999;
  1110. line-height: 1;
  1111. }
  1112. .popup-content {
  1113. padding: 30rpx;
  1114. max-height: 600rpx;
  1115. overflow-y: auto;
  1116. }
  1117. .detail-item {
  1118. display: flex;
  1119. align-items: flex-start;
  1120. margin-bottom: 24rpx;
  1121. font-size: 28rpx;
  1122. .label {
  1123. color: #666;
  1124. min-width: 160rpx;
  1125. flex-shrink: 0;
  1126. }
  1127. .value {
  1128. color: #333;
  1129. flex: 1;
  1130. word-break: break-all;
  1131. }
  1132. }
  1133. .image-list {
  1134. display: flex;
  1135. flex-wrap: wrap;
  1136. gap: 20rpx;
  1137. margin-top: 16rpx;
  1138. }
  1139. .transfer-image {
  1140. width: 200rpx;
  1141. height: 200rpx;
  1142. border-radius: 12rpx;
  1143. border: 1px solid #eee;
  1144. }
  1145. </style>