nieyuge 2 years ago
parent
commit
ed19b96715
2 changed files with 53 additions and 3 deletions
  1. 43 3
      src/view/iframe/buy-nft/buy/home.vue
  2. 10 0
      src/view/iframe/buy-nft/buy/pay.vue

+ 43 - 3
src/view/iframe/buy-nft/buy/home.vue

@@ -28,8 +28,11 @@
                 </template>
 
                 <template v-for="item in state.data.salePlans.slice(0, 2).reverse()">
-                    <div class="buy1" @click="clickJump(item)" v-if="item.itemCount == 1 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 1
-                    && (state.data.itemTotalCount - state.data.itemSoldCount) >= 1">
+                    <div
+                        class="buy1"
+                        :class="{ grey: payNext }"
+                        @click="clickJump(item)"
+                        v-if="item.itemCount == 1 && (state.data.perUserBuyLimit - state.data.userBuyCount) >= 1 && (state.data.itemTotalCount - state.data.itemSoldCount) >= 1">
                         <template v-if="(item.price.length + item.currencyInfo.tokenSymbol.length) > 30">
                             <div class="left">Buy 1</div>
                             <div class="right">
@@ -112,6 +115,8 @@ import { getNftMysteryBoxSaleInfo, redeemNft } from "@/http/nft";
 import BtnLoading from '../components/btn-loading.vue'
 import Report from "@/log-center/log"
 import { getQueryString } from "@/uilts/help";
+import { calcRechargePayAmount } from "@/http/account";
+import { getCurrencyInfoByCode } from "@/http/publishApi";
 import { sendChromeTabMessage } from '@/uilts/chromeExtension.js';
 let postId = inject('post_Id');
 let pay_info = inject('pay_info');
@@ -119,6 +124,7 @@ let router = useRouter()
 let showDesc = ref(true)
 let showRedeem = ref(false)
 let redeemNext = ref(false)
+let payNext = ref(false)
 let redeemStr = ref('')
 let refInput = ref('')
 let groupId = ref('')
@@ -155,7 +161,41 @@ const clickClose = () => {
 }
 const clickJump = (item) => {
     pay_info.home.sale_plan = item
-    router.push({ path: '/pay' });
+    payNext.value = true;
+    if (item.currencyCode === 'USD') {
+        const p1 = calcRechargePayAmount({
+            params: {
+                currencyCode: item.currencyCode,
+                orderAmountValue: item.price,
+                payChannel: 'ach'
+            }
+        });
+
+        const p2 = getCurrencyInfoByCode({
+            params: {
+                currencyCode: item.currencyCode,
+            }
+        })
+        
+        Promise.all([p1, p2]).then(([res1, res2]) => {
+            if (res1.code == 0 && res2.code == 0) {
+                router.push({
+                    path: '/pay',
+                    query: {
+                        finalAmount: JSON.stringify(res1.data),
+                        currentCurrencyInfo: JSON.stringify(res2.data),
+                    }
+                });
+            } else {
+                router.push({ path: '/pay' });
+            }
+        }).finally(() => {
+            payNext.value = false;
+        })
+    } else {
+        router.push({ path: '/pay' });
+        payNext.value = false;
+    }
     // report
     Report.reportLog({
         pageSource: Report.pageSource.nftShopPage,

+ 10 - 0
src/view/iframe/buy-nft/buy/pay.vue

@@ -373,6 +373,16 @@ onMounted(() => {
     currentCurrencyInfo.currencyCode = pay_info.home.sale_plan.currencyCode
     getLocalCurrencyInfoByCode();
     setDialogStyle()
+
+    // setParams
+    if (router.currentRoute.value?.query?.finalAmount) {
+        finalAmountData.value = JSON.parse(router.currentRoute.value.query.finalAmount);
+    }
+
+    if (router.currentRoute.value?.query?.currentCurrencyInfo) {
+        tempCurrentCurrencyInfo.value = JSON.parse(router.currentRoute.value.query.currentCurrencyInfo);
+    }
+
     // report
     Report.reportLog({
         pageSource: Report.pageSource.nftPreviewPage,