From c1927d940ac533a90c4636799d34200f7604160b Mon Sep 17 00:00:00 2001
From: queenwuli <942534046@qq.com>
Date: Fri, 25 Mar 2022 11:07:32 +0800
Subject: [PATCH] gx

---
 src/pages/index/account.vue |   64 +++++++++++++++----------------
 1 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/src/pages/index/account.vue b/src/pages/index/account.vue
index 513fce7..97568ae 100644
--- a/src/pages/index/account.vue
+++ b/src/pages/index/account.vue
@@ -40,7 +40,7 @@
                             </div>
                         </div>
                         <span class="all" style="color: #3D8AF2" @click="allExchange">{{$t("message.RedeemAll")}}</span>
-                        <button class="btn" :disabled="!ethAmount" @click="submitExchange">{{$t("message.Exchange")}}</button>
+                        <button class="btn" :disabled="!ethAmount || isRequesting" @click="submitExchange">{{$t("message.Exchange")}}</button>
                         <div class="tips">
                             <p>{{$t("message.Price")}}:1ETH ≈ {{info.newPrice}}USDT</p>
                             <p>{{$t("message.Tip1")}}</p>
@@ -142,6 +142,7 @@
     let info = ref({});
     let ethAmount = ref();
     let usdtAmount = ref();
+    let isRequesting = ref(false);
     let ethToUsdtAmount = computed(() => {
         if (!ethAmount.value || isNaN(ethAmount.value)) {
             return '0.0000'
@@ -170,11 +171,7 @@
             this.$toast(this.$t('message.NOETH2'));
             return;
         }
-        this.$toast.loading({
-            message: this.$t('message.Submitting'),
-            overlay: true,
-            duration: 0
-        });
+        proxy.isRequesting = true;
         this.$axios({
           url: '/dapi/member/change',
           method: 'post',
@@ -182,17 +179,19 @@
               amount: ethAmount.value
           }
         }).then((res) => {
-          if(res.code == 200) {
-              ethAmount.value = '';
-              this.$toast(this.$t('message.ExchangeSuc'));
-              getWalletInfo()
-              getRecordList(1)
-          }else{
-              this.$toast(res.message);
-          }
-          this.$toast.clear(true)
-        }).catch(() => {
-            this.$toast.clear(true)
+            ethAmount.value = '';
+            proxy.isRequesting = false;
+            if (res.code == 200) {
+                this.$toast(this.$t('message.ExchangeSuc'));
+                getWalletInfo()
+                getRecordList(1)
+            } else if(res.code == 401){
+                this.$toast(this.$t('message.ApproveTip'));
+            } else {
+                this.$toast(res.message);
+            }
+        }).catch((err) => {
+            proxy.isRequesting = false;
         })
     }
     function submitWithdraw () {
@@ -204,11 +203,7 @@
             this.$toast(this.$t('message.NOETH2'));
             return;
         }
-        this.$toast.loading({
-            message: this.$t('message.Submitting'),
-            overlay: true,
-            duration: 0
-        });
+        proxy.isRequesting = true;
         this.$axios({
           url: '/dapi/member/withdraw',
           method: 'post',
@@ -216,17 +211,19 @@
               amount: usdtAmount.value
           }
         }).then((res) => {
-          if(res.code == 200) {
-              usdtAmount.value = '';
-              this.$toast(this.$t('message.Withdrawing2'));
-              getWalletInfo()
-              getRecordList(2)
-          }else{
-              this.$toast(res.message);
-          }
-          this.$toast.clear(true)
+            usdtAmount.value = '';
+            proxy.isRequesting = false;
+            if(res.code == 200) {
+                this.$toast(this.$t('message.Withdrawing2'));
+                getWalletInfo()
+                getRecordList(2)
+            } else if(res.code == 401){
+                this.$toast(this.$t('message.ApproveTip'));
+            } else {
+                this.$toast(res.message);
+            }
         }).catch(() => {
-            this.$toast.clear(true)
+            proxy.isRequesting = false;
         })
     }
     function getRecordList (type) {
@@ -279,7 +276,8 @@
         allExchange,
         submitExchange,
         submitWithdraw,
-        onClickTab
+        onClickTab,
+        isRequesting
     };
   },
   methods: {

--
Gitblit v1.9.1