index.vue 12 KB

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