nieyuge 2 年之前
父节点
当前提交
c2105d38e1
共有 1 个文件被更改,包括 69 次插入51 次删除
  1. 69 51
      pages/payment/index.vue

+ 69 - 51
pages/payment/index.vue

@@ -28,7 +28,7 @@
                         </div>
                     </div>
                     <div class="item" @click="maskPay">
-                        <a class="maskLink" :href="maskUrlLink"></a>
+                        <a class="maskLink" :href="maskUrlLink" v-if="Number(currencyInfoData.balance) < Number(salePlans.price)"></a>
                         <img src="../../static/payment/icon_meta_mask.png" />
                         <span>MetaMask</span>
                     </div>
@@ -213,14 +213,14 @@
                         <div class="neet">You Neet to Pay</div>
                         <div class="money">
                             <FontZoom width="190">
-                                <span class="text">{{ usdAmountData.rechargeAmountValue > 0 ? usdAmountData.rechargeAmountValue : usdAmountData.orderAmountValue }} {{ salePlans.currencyInfo.tokenSymbol }}</span>
+                                <span class="text">{{ Number(usdAmountData.rechargeAmountValue) > 0 ? usdAmountData.rechargeAmountValue : usdAmountData.orderAmountValue }} {{ salePlans.currencyInfo.tokenSymbol }}</span>
                             </FontZoom>
                         </div>
                     </div>
                     <div>
                         <div
                             class="btn"
-                            :class="{ disabled: (usdAmountData.rechargeAmountValue > 0) || payDisabled }"
+                            :class="{ disabled: (Number(usdAmountData.rechargeAmountValue) > 0) || payDisabled }"
                             @click="payUSD">
                             Pay Now
                         </div>
@@ -507,13 +507,14 @@ export default {
         maskUrlToLink() {
             // MetaMask Link
             let url;
+            let price = Number(this.salePlans.price) > Number(this.currencyInfoData.balance) ? Number(this.salePlans.price) - Number(this.currencyInfoData.balance) : Number(this.salePlans.price)
             if (this.salePlans.currencyInfo?.contractAddress) {
                 // 代币
                 url = maskUrl({
                     target_address: this.salePlans.currencyInfo.contractAddress,
                     parameters: {
                         address: this.rechargeAddress,
-                        uint256: `${Number(this.salePlans.price) - Number(this.currencyInfoData.balance)}e${this.salePlans.currencyInfo?.decimalLength || 18}`
+                        uint256: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
                     }
                 }, false)
             } else {
@@ -521,7 +522,7 @@ export default {
                 url = maskUrl({
                     target_address: this.rechargeAddress,
                     parameters: {
-                        value: `${Number(this.salePlans.price) - Number(this.currencyInfoData.balance)}e${this.salePlans.currencyInfo?.decimalLength || 18}`
+                        value: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
                     }
                 })
             }
@@ -557,7 +558,7 @@ export default {
             })
         },
         payUSD() {
-            if (this.usdAmountData.rechargeAmountValue <= 0) {
+            if (Number(this.usdAmountData.rechargeAmountValue) <= 0) {
                 this.pay()
             }
         },
@@ -603,7 +604,14 @@ export default {
         deNetPay() {
             if (!this.salePlans) return;
 
-            if (Number(this.salePlans.price) > Number(this.currencyInfoData.balance)) {
+            let where;
+            if (this.salePlans.currencyCode === 'USD') {
+                where = Number(this.usdAmountData.rechargeAmountValue) > 0
+            } else {
+                where = Number(this.salePlans.price) > Number(this.currencyInfoData.balance)
+            }
+
+            if (where) {
                 // 余额不够
                 this.step = 3;
                 this.currencyInfoTimer();
@@ -613,53 +621,63 @@ export default {
             }
         },
         maskPay() {
-            this.step = 2;
-            this.waitRefresh = true;
-            this.currencyInfoTimer();
-            Dialog({
-                message: `Was the pament successful?`,
-                showCancelButton: true,
-                confirmButtonText: 'YES',
-                confirmButtonColor: '#1D9BF0',
-                cancelButtonText: 'NO',
-                cancelButtonColor: '#1D9BF0',
-            }).then(() => {
-                this.checkWaitInfo()
-            }).catch(() => {
-                this.checkWaitInfo()
-            });
-        },
-        achPay(modifyStep = true) {
-            if (modifyStep) {
+            if (Number(this.salePlans.price) > Number(this.currencyInfoData.balance)) {
+                this.step = 2;
+                this.waitRefresh = true;
+                this.currencyInfoTimer();
+                Dialog({
+                    message: `Was the pament successful?`,
+                    showCancelButton: true,
+                    confirmButtonText: 'YES',
+                    confirmButtonColor: '#1D9BF0',
+                    cancelButtonText: 'NO',
+                    cancelButtonColor: '#1D9BF0',
+                }).then(() => {
+                    this.checkWaitInfo()
+                }).catch(() => {
+                    this.checkWaitInfo()
+                });
+            } else {
                 this.step = 2;
             }
-            this.waitRefresh = true;
-            this.currencyInfoTimer();
-            Dialog({
-                message: `Was the pament successful?`,
-                showCancelButton: true,
-                confirmButtonText: 'YES',
-                confirmButtonColor: '#1D9BF0',
-                cancelButtonText: 'NO',
-                cancelButtonColor: '#1D9BF0',
-            }).then(() => {
-                this.checkWaitInfo()
-            }).catch(() => {
-                this.checkWaitInfo()
-            });
+        },
+        achPay(modifyStep = true) {
+            if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
+                if (modifyStep) {
+                    this.step = 2;
+                }
+                this.waitRefresh = true;
+                this.currencyInfoTimer();
+                Dialog({
+                    message: `Was the pament successful?`,
+                    showCancelButton: true,
+                    confirmButtonText: 'YES',
+                    confirmButtonColor: '#1D9BF0',
+                    cancelButtonText: 'NO',
+                    cancelButtonColor: '#1D9BF0',
+                }).then(() => {
+                    this.checkWaitInfo()
+                }).catch(() => {
+                    this.checkWaitInfo()
+                });
 
-            this.$nextTick(() => {
-                let win = window.open();
-                    win.opener = null;
-                    win.location.href = `${location.protocol}//${location.host}/payment_ach/${this.usdAmountData.rechargeAmountValue}`;
-                this.achTimer = setInterval(() => {
-                    console.log('pay')
-                    if (win && win.closed) {
-                        console.log('done')
-                        clearInterval(this.achTimer);
-                    }
-                }, 500);
-            })
+                this.$nextTick(() => {
+                    let win = window.open();
+                        win.opener = null;
+                        win.location.href = `${location.protocol}//${location.host}/payment_ach/${this.usdAmountData.rechargeAmountValue}`;
+                    this.achTimer = setInterval(() => {
+                        console.log('pay')
+                        if (win && win.closed) {
+                            console.log('done')
+                            clearInterval(this.achTimer);
+                        }
+                    }, 500);
+                })
+            } else {
+                if (modifyStep) {
+                    this.step = 2;
+                }
+            }
         },
     }
 }