index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <cwg-page-wrapper :isHeaderFixed="true">
  3. <view class="page">
  4. <cwg-header class="wallet-header" :title="t('wallet1.title')" />
  5. <view class="wallet-banner">
  6. <view class="balance">
  7. <view class="balance-item">
  8. <view class="r l" @click="setModelValue1">
  9. <image :src="imageSrc(balance)" alt="" srcset="" />
  10. <text>{{ balance }}</text>
  11. <cwg-icon name="icon_dropdown" :size="24" />
  12. </view>
  13. <view class="r">
  14. <text>$ {{ currencyList[0]?.amount }}</text>
  15. <text class="decimal">{{ currencyList[0]?.decimal }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="wallet-actions">
  21. <view class="cwg-button two-btn">
  22. <u-button type="primary" block @click="goToVaultody">{{ t('pages.wallet.vaultody') }}</u-button>
  23. <u-button plain block class="prev-btn" @click="goToWithdraw">{{ t('pages.wallet.withdraw') }}</u-button>
  24. </view>
  25. </view>
  26. <view class="wallet-page">
  27. <view class="global-title">{{ t("global.title1") }}</view>
  28. <view class="global-con">
  29. <view class="global-con-l">
  30. <image src="/static/images/currency/USD.png" alt="" srcset="" />
  31. <view class="r">
  32. <view>USD</view>
  33. </view>
  34. </view>
  35. <cwg-icon name="icon_transfer" :size="23" color="#1a1a1a" />
  36. <view class="global-con-r" @click="setModelValue">
  37. <image :src="imageSrc(currency)" alt="" srcset="" />
  38. <view class="r">
  39. <view>{{ currency }}</view>
  40. </view>
  41. <cwg-icon name="icon_dropdown" :size="24" />
  42. </view>
  43. </view>
  44. <view class="cwg-button">
  45. <u-button type="primary" block @click="goToGlobalRemit">{{
  46. t("global.title1")
  47. }}</u-button>
  48. </view>
  49. <view class="trans-header">
  50. <view class="record-title">{{ t("global.title") }} </view>
  51. <view class="all" @click="goRechargeRecord">{{
  52. t("card.Status.t22")
  53. }}</view>
  54. </view>
  55. <view class="transaction-list">
  56. <template v-if="globalOrdersList.length > 0">
  57. <view v-for="item in globalOrdersList" :key="item.id" class="transaction-item"
  58. @click="goToDeductionDetail(item)">
  59. <view class="transaction-left">
  60. <view class="transaction-icon">
  61. <text class="icon-text"><cwg-icon name="icon_transfer" :size="23" color="#1a1a1a" /></text>
  62. </view>
  63. <view class="transaction-info">
  64. <text class="transaction-status">{{ item.merchantOrderNo }}</text>
  65. <text class="transaction-time">{{ item.addTime }}</text>
  66. </view>
  67. </view>
  68. <view class="transaction-right">
  69. <text class="transaction-amount">{{ item.deductionAmount }} {{ item.sendCurrency }}</text>
  70. </view>
  71. </view>
  72. </template>
  73. <cwg-empty-state v-if="globalOrdersList.length == 0" />
  74. </view>
  75. </view>
  76. <cwg-currency-select v-model="modelValue" :show-search="true" :options="globalCurrenciesDropdown"
  77. @select="changeSelect" :placeholder="t('common.country')" />
  78. <cwg-currency-select v-model="modelValue1" :show-search="true" :options="globalCurrenciesDropdown"
  79. @select="changeSelect1" />
  80. </view>
  81. </cwg-page-wrapper>
  82. </template>
  83. <script setup lang="ts">
  84. import { ref, onMounted, watch, computed } from "vue";
  85. import { showToast } from "@/utils/toast";
  86. import { onLoad } from '@dcloudio/uni-app'
  87. import useRouter from "@/hooks/useRouter";
  88. import { useI18n } from "vue-i18n";
  89. import { ucardApi } from "@/api/ucard";
  90. import _ from "lodash";
  91. import useCardStore from "@/stores/use-card-store";
  92. const cardStore = useCardStore();
  93. const { t } = useI18n();
  94. const router = useRouter();
  95. onLoad((options) => {
  96. // id.value = options.id
  97. // type.value = options.type
  98. })
  99. const currency = ref("EUR");
  100. const balance = ref("USD");
  101. const modelValue = ref(false);
  102. const modelValue1 = ref(false);
  103. const currencyList = ref([]);
  104. const allAmount = ref(0);
  105. async function getBalance() {
  106. try {
  107. const res = await ucardApi.walletBalance();
  108. const n = Number.parseFloat(res.data.balance).toFixed(2);
  109. const { amount, decimal } = splitNumber(n);
  110. allAmount.value = n;
  111. currencyList.value.push({
  112. name: "USD",
  113. amount,
  114. decimal,
  115. });
  116. } catch (error) { }
  117. }
  118. async function getGlobalFieldParams() {
  119. try {
  120. const res = await ucardApi.getGlobalFieldParams();
  121. const sorted = res.data
  122. .sort((a, b) => {
  123. return (a.sorting || 0) - (b.sorting || 0);
  124. }).map((item) => {
  125. return { fieldUserType: item.fieldUserType, fieldName: item.fieldName, fieldType: item.fieldType }
  126. });
  127. cardStore.saveGlobalFieldParams(sorted);
  128. } catch (error) { }
  129. }
  130. function imageSrc(currency: string) {
  131. return `/static/images/currency/${currency}.png`;
  132. }
  133. const goToDeductionDetail = (record: RecordItem) => {
  134. console.log(record, 1212);
  135. cardStore.saveOrderDetail(record);
  136. router.push({
  137. path: '/pages/wallet/global-detail',
  138. query: { id: record.id }
  139. });
  140. };
  141. function splitNumber(n) {
  142. if (
  143. n === undefined ||
  144. n === null ||
  145. n === 0 ||
  146. (typeof n !== "number" && typeof n !== "string") ||
  147. (typeof n === "string" && !/^\d+(\.\d+)?$/.test(n))
  148. ) {
  149. return { amount: 0, decimal: "" };
  150. }
  151. const str = n.toString();
  152. if (!str.includes(".")) {
  153. return { amount: str, decimal: "" };
  154. }
  155. const [int, dec] = str.split(".");
  156. return {
  157. amount: `${int}.`,
  158. decimal: dec || "",
  159. };
  160. }
  161. function setModelValue() {
  162. modelValue.value = true;
  163. }
  164. function setModelValue1() {
  165. return;
  166. // modelValue1.value = true
  167. }
  168. function goRechargeRecord() {
  169. router.push(`/pages/wallet/global-list`);
  170. }
  171. function goToGlobalRemit() {
  172. router.push(
  173. `/pages/wallet/global-order?currency=${currency.value}`
  174. );
  175. }
  176. function goToVaultody() {
  177. router.push(`/pages/wallet/vaultody`);
  178. }
  179. function goToWithdraw() {
  180. router.push(`/pages/wallet/withdraw?allAmount=${allAmount.value}`);
  181. }
  182. function changeSelect(e) {
  183. currency.value = e.value;
  184. }
  185. function changeSelect1(e) {
  186. balance.value = e.value;
  187. }
  188. const globalCurrenciesDropdown = ref([]);
  189. const getGlobalCurrenciesDropdown = async () => {
  190. const res = await ucardApi.globalCurrenciesDropdown({ code: "", status: 'online' });
  191. if (res.code === 200 || res.code === 0) {
  192. globalCurrenciesDropdown.value = res.data.map((i) => {
  193. return { currency: i.payoutCurrency, text: i.country, value: i.payoutCurrency };
  194. }) || [];
  195. const data = _.cloneDeep(res.data);
  196. cardStore.saveCurrencyList(data)
  197. }
  198. };
  199. const globalOrdersList = ref<TransferInfo[]>([]);
  200. async function getGlobalOrdersList() {
  201. try {
  202. const res = await ucardApi.globalOrdersList({ page: { current: 1, row: 5 } });
  203. if (res.code === 200) {
  204. globalOrdersList.value = res.data;
  205. } else {
  206. globalOrdersList.value = [];
  207. }
  208. } catch (error) {
  209. showToast(t("common.error"));
  210. }
  211. }
  212. function goToTransferDetail(id: string) {
  213. router.push(`/transfer/detail?id=${id}`);
  214. }
  215. onMounted(() => {
  216. getGlobalCurrenciesDropdown()
  217. getGlobalOrdersList()
  218. getBalance();
  219. getGlobalFieldParams()
  220. });
  221. </script>
  222. <style scoped lang="scss">
  223. @import "@/uni.scss";
  224. .page-wrapper {
  225. padding-left: 0 !important;
  226. padding-right: 0 !important;
  227. border: 0 !important;
  228. }
  229. .page {
  230. box-sizing: border-box;
  231. background: var(--main-bg);
  232. }
  233. .wallet-page {
  234. padding: 0 px2rpx(24);
  235. box-sizing: border-box;
  236. }
  237. .wallet-header {
  238. position: fixed;
  239. top: 0;
  240. left: 0;
  241. width: 100%;
  242. background: linear-gradient(90deg, #ea002a 0%, #eb4e6b 100%);
  243. text-align: left;
  244. font-size: var(--font-size-22);
  245. color: #fff !important;
  246. font-weight: 700;
  247. display: flex;
  248. align-items: center;
  249. z-index: 1113;
  250. }
  251. .banner-title {
  252. color: #fff;
  253. font-family: Roboto;
  254. font-size: px2rpx(22);
  255. font-style: normal;
  256. font-weight: 600;
  257. line-height: px2rpx(28);
  258. padding: px2rpx(12) 0 px2rpx(31) 0;
  259. }
  260. .wallet-banner {
  261. background: linear-gradient(90deg, #ea002a 0%, #eb4e6b 100%);
  262. margin-bottom: px2rpx(20);
  263. padding: 0 px2rpx(31) px2rpx(62) px2rpx(31);
  264. color: #fff;
  265. .balance {
  266. display: flex;
  267. width: 100%;
  268. justify-content: space-between;
  269. align-items: center;
  270. }
  271. .balance-item {
  272. width: 100%;
  273. display: flex;
  274. padding: px2rpx(16) px2rpx(24);
  275. justify-content: center;
  276. align-items: center;
  277. gap: px2rpx(31);
  278. border-radius: px2rpx(8);
  279. border: 1px solid var(--Netural-color-content-color-stoke, #f4f4f4);
  280. background: #fff;
  281. color: var(--white);
  282. flex-direction: column;
  283. .r {
  284. display: flex;
  285. justify-content: center;
  286. align-items: flex-end;
  287. }
  288. .l {
  289. align-items: center;
  290. }
  291. text {
  292. color: #000;
  293. font-family: Roboto;
  294. font-size: px2rpx(44);
  295. font-style: normal;
  296. font-weight: 600;
  297. text-align: left;
  298. }
  299. .decimal {
  300. color: #1a1a1a;
  301. font-family: Roboto;
  302. font-size: px2rpx(14);
  303. font-style: normal;
  304. font-weight: 600;
  305. letter-spacing: px2rpx(0.07);
  306. }
  307. .l {
  308. text {
  309. color: #474747;
  310. font-size: px2rpx(31);
  311. line-height: px2rpx(44);
  312. }
  313. }
  314. image {
  315. width: px2rpx(28);
  316. height: px2rpx(28);
  317. margin-right: px2rpx(12);
  318. display: inline-block;
  319. }
  320. }
  321. }
  322. .global-title {
  323. margin: px2rpx(44) 0 px2rpx(36) 0;
  324. color: #000;
  325. font-family: Roboto;
  326. font-size: px2rpx(22);
  327. font-style: normal;
  328. font-weight: 600;
  329. line-height: px2rpx(28);
  330. }
  331. .global-con {
  332. display: flex;
  333. width: 100%;
  334. margin: px2rpx(44) 0;
  335. align-items: center;
  336. gap: px2rpx(12);
  337. color: #1a1a1a;
  338. .global-con-l,
  339. .global-con-r {
  340. display: flex;
  341. flex: 1;
  342. padding: px2rpx(12) px2rpx(8);
  343. align-items: center;
  344. gap: px2rpx(6);
  345. border-radius: px2rpx(12);
  346. box-shadow: 0px px2rpx(10) px2rpx(30) 0px rgba(5, 0, 1, 0.1);
  347. color: var(--white);
  348. view {
  349. color: #000;
  350. font-family: Roboto;
  351. font-size: px2rpx(24);
  352. font-style: normal;
  353. font-weight: 600;
  354. line-height: px2rpx(44);
  355. }
  356. image {
  357. width: px2rpx(36);
  358. height: px2rpx(36);
  359. border: 1px solid #f4f4f4;
  360. border-radius: 50%;
  361. }
  362. }
  363. }
  364. .trans-header {
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. }
  369. .record-title {
  370. margin: px2rpx(44) 0 px2rpx(44) 0;
  371. color: #000;
  372. font-family: Roboto;
  373. font-size: px2rpx(22);
  374. font-style: normal;
  375. font-weight: 600;
  376. line-height: px2rpx(28);
  377. }
  378. .transaction-list {
  379. display: flex;
  380. flex-direction: column;
  381. .transaction-item {
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. padding: px2rpx(16) 0;
  386. border-bottom: 1px solid #f3f4f6;
  387. }
  388. .transaction-item:last-child {
  389. border-bottom: none;
  390. }
  391. .transaction-left {
  392. display: flex;
  393. align-items: center;
  394. gap: px2rpx(12);
  395. }
  396. .transaction-icon {
  397. width: px2rpx(40);
  398. height: px2rpx(40);
  399. background-color: #f9fafb;
  400. border-radius: 50%;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. }
  405. .icon-text {
  406. font-size: px2rpx(20);
  407. color: #6b7280;
  408. }
  409. .transaction-info {
  410. display: flex;
  411. flex-direction: column;
  412. gap: px2rpx(4);
  413. }
  414. .transaction-status {
  415. font-size: px2rpx(14);
  416. color: #111827;
  417. }
  418. .transaction-time {
  419. font-size: px2rpx(12);
  420. color: #9ca3af;
  421. }
  422. .transaction-right {
  423. display: flex;
  424. flex-direction: column;
  425. align-items: flex-end;
  426. }
  427. .transaction-amount {
  428. font-size: px2rpx(16);
  429. font-weight: 600;
  430. color: #111827;
  431. }
  432. .transaction-amount.negative {
  433. color: #ef4444;
  434. }
  435. }
  436. .wallet-actions {
  437. padding: px2rpx(16) px2rpx(24);
  438. }
  439. .wallet-actions .two-btn {
  440. display: flex;
  441. gap: px2rpx(16);
  442. }
  443. .wallet-actions .prev-btn {
  444. border: 1px solid var(--main-yellow) !important;
  445. color: #fff !important;
  446. background: transparent;
  447. }
  448. </style>