瀏覽代碼

[edit] ach pay

wenliming 2 年之前
父節點
當前提交
fb4bcdedb1
共有 2 個文件被更改,包括 50 次插入51 次删除
  1. 39 33
      src/view/iframe/publish/components/pay-button.vue
  2. 11 18
      src/view/iframe/publish/give-dialog.vue

+ 39 - 33
src/view/iframe/publish/components/pay-button.vue

@@ -5,8 +5,9 @@
         <div class="pay-btn">
             <div class="iframe-pay"
                 v-show="currentCurrencyInfo.currencyCode == 'USD'">
-                <div class="ach-pay" style="background: blue" @click="jumpAchPay">
-                    ACH Pay
+                <div class="token-pay" 
+                    @click="clickPayUSD">
+                    Pay {{finalAmountData.rechargeAmountValue > 0 ? finalAmountData.rechargeAmountValue : finalAmountData.orderAmountValue}} {{currentCurrencyInfo.tokenSymbol}}
                 </div>
 
                 <!-- <iframe
@@ -17,7 +18,7 @@
             <div class="token-pay" 
                 :class="{ disabled: Number(currentCurrencyInfo.balance) < Number(payConfig.amount) }"
                 v-if="currentCurrencyInfo.currencyCode != 'USD'"
-                @click="tokenPay">
+                @click="balancePay">
                 Pay {{payConfig.amount || 0}} {{currentCurrencyInfo.tokenSymbol}}
             </div>
         </div>
@@ -36,10 +37,11 @@ const props = defineProps({
         type: Object,
         default: () => {
             return {
-                currencyCode: "",
+                balance: "",
                 feeAmountValue: 0,
-                finalAmountValue: 0,
-                requestAmountValue: 0
+                feeDesc: 0,
+                orderAmountValue: 0,
+                rechargeAmountValue: 0
             }
         },
     },
@@ -66,11 +68,11 @@ let payIng = false;
 watch(
     () => props.finalAmountData.finalAmountValue,
     (newVal) => {
-        iframe.value.contentWindow.postMessage({ 
-            actionType: "setAmount", amount: newVal
-        },
-            "*"
-        );
+        // iframe.value.contentWindow.postMessage({ 
+        //     actionType: "setAmount", amount: newVal
+        // },
+        //     "*"
+        // );
     },
     {
         deep: true
@@ -79,7 +81,7 @@ watch(
 
 const emits = defineEmits(["payFinish"]);
 
-const tokenPay = () => {  
+const balancePay = () => {  
     Report.reportLog({
         pageSource: Report.pageSource.previewPage,
         businessType: Report.businessType.buttonClick,
@@ -98,7 +100,7 @@ const tokenPay = () => {
         }
     }).then(res => {
         if(res.code == 0) {
-            emits("payFinish", {...res.data, payNetwork: 'token'});
+            emits("payFinish", {...res.data});
         }
         payIng = false;
     }).catch(() => {
@@ -106,29 +108,33 @@ const tokenPay = () => {
     })
 }
 
-const jumpAchPay = () => {
-    let guideUrl = chrome.runtime.getURL('/iframe/ach-cashier.html');
-    setChromeStorage({ achPayInfo : JSON.stringify({'amountValue': 1})})    
-    chrome.tabs.create({
-        url: guideUrl
-    });
+const clickPayUSD = () => {
+    if(finalAmountData.rechargeAmountValue > 0) {
+        let guideUrl = chrome.runtime.getURL('/iframe/ach-cashier.html');
+        setChromeStorage({ achPayInfo : JSON.stringify({'amountValue': props.finalAmountData.rechargeAmountValue})})    
+        chrome.tabs.create({
+            url: guideUrl
+        });
+    } else {
+        balancePay();
+    }
 }
 
 onMounted(() => {
-    window.addEventListener("message", function (event) {
-        if (event.data && event.data.actionType) {
-            switch (event.data.actionType) {
-                case "payCallBack":
-                    console.log(
-                        "payCallBack",
-                        event.data.orderData,
-                        event.data.transaction
-                    );
-                    emits("payFinish", {...event.data, payNetwork: 'pay'});
-                    break;
-            }
-        }
-    });
+    // window.addEventListener("message", function (event) {
+    //     if (event.data && event.data.actionType) {
+    //         switch (event.data.actionType) {
+    //             case "payCallBack":
+    //                 console.log(
+    //                     "payCallBack",
+    //                     event.data.orderData,
+    //                     event.data.transaction
+    //                 );
+    //                 emits("payFinish", {...event.data, payNetwork: 'pay'});
+    //                 break;
+    //         }
+    //     }
+    // });
 });
 
 </script>

+ 11 - 18
src/view/iframe/publish/give-dialog.vue

@@ -1218,9 +1218,11 @@ const submitRequest = async () => {
     // 法币支付需要计算费率
     if(formData.amountCurrencyCode == "USD") { 
         // 获取充值金额
-
-        // let payAmountRes = await getPayAmount(amountValue);
-        // formData["payAmountValue"] = payAmountRes.finalAmountValue;
+        await calcRechPayAmount({
+            currencyCode: currentCurrencyInfo.value.currencyCode,
+            orderAmountValue: baseFormData.amountValue,
+            payChannel: 'ach'
+        });
     }
     let data = {
         params: {
@@ -1292,17 +1294,13 @@ const setDiscordIptTxt = ({text}) => {
 
 const calcRechPayAmount = async (params) => {
     let res = await calcRechargePayAmount({
-        params : {
-            
-        }
+        params : params
     })
 
     if (res.code == 0) {
-        let { finalAmountValue, feeDesc } = res.data;
+        let { feeDesc } = res.data;
         payConfig.value.feeDesc = feeDesc;
-        if (finalAmountValue > 0) {
-            finalAmountData.value = res.data;
-        }
+        finalAmountData.value = res.data;
     }
     return res.data;
 }
@@ -1311,14 +1309,9 @@ const calcRechPayAmount = async (params) => {
  * 支付完成回调
  */
 const payFinish = (params) => {
-    let {payNetwork, payStatus} = params;
-    // token 支付
-    if(payNetwork == 'token') {
-        payStatusHandle(payStatus);
-    } else {
-        // 法币支付
-        payStatusHandle(1);
-    }
+    let {payStatus} = params;
+    // 余额支付
+    payStatusHandle(payStatus);
 };
 
 const payStatusHandle = (payStatus) => {