From 89a8db4b2d92087b588e7b57cce5b3b339ba2057 Mon Sep 17 00:00:00 2001
From: queenwuli <942534046@qq.com>
Date: Fri, 25 Mar 2022 17:29:18 +0800
Subject: [PATCH] gx

---
 src/pages/index/account.vue |   83 ++++++++++++++++++++++-------------------
 1 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/src/pages/index/account.vue b/src/pages/index/account.vue
index 80d2510..4d679c5 100644
--- a/src/pages/index/account.vue
+++ b/src/pages/index/account.vue
@@ -5,15 +5,15 @@
             <div class="box-content">
                 <div class="row flex align-center justify-between">
                     <span class="name">{{$t("message.TotalOutput")}}</span>
-                    <span class="count">{{myAccountInfo.totalMine}} ETH</span>
+                    <span class="count">{{myAccountInfo.totalMine || 0}} ETH</span>
                 </div>
                 <div class="row flex align-center justify-between">
                     <span class="name">{{$t("message.IncomeBalance")}}</span>
-                    <span class="count">{{myAccountInfo.availableWallet}} USDT</span>
+                    <span class="count">{{myAccountInfo.availableWallet || 0}} USDT</span>
                 </div>
                 <div class="row flex align-center justify-between">
                     <span class="name">{{$t("message.Exchangeable")}}</span>
-                    <span class="count">{{myAccountInfo.availableMine}} ETH</span>
+                    <span class="count">{{myAccountInfo.availableMine || 0}} ETH</span>
                 </div>
             </div>
         </div>
@@ -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>
@@ -59,14 +59,14 @@
                                     <span>USDT</span>
                                 </div>
                                 <input placeholder="0.000" type="number" v-model.number="usdtAmount"/>
-                                <span class="all">{{$t("message.WithdrawalAmount")}}</span>
+                                <span class="all" style="color: #3D8AF2" @click="allWithdraw">{{$t("message.WithdrawalAll")}}</span>
                             </div>
                             <div class="item flex-1 flex align-end flex-v">
                                 <div>
                                     <img src="../../assets/images/icon5.png"/>
                                     <span>USDT</span>
                                 </div>
-                                <span class="amount">{{myAccountInfo.availableWallet}}</span>
+                                <span class="amount">{{myAccountInfo.availableWallet || 0}}</span>
                                 <span class="all">{{$t("message.TotalBalance")}}</span>
                             </div>
                         </div>
@@ -78,7 +78,7 @@
                 </div>
             </van-tab>
             <van-tab :title='$t("message.Record")'>
-                <div class="box">
+                <div class="box" style="min-height: 320px">
                     <h3 class="title">{{$t("message.Record")}}</h3>
                     <div class="box-content">
                         <div class="tab-wrap">
@@ -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,18 +179,26 @@
               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 allWithdraw () {
+        if(!proxy.myAccountInfo.availableWallet) {
+            return;
+        }
+        usdtAmount.value = proxy.myAccountInfo.availableWallet
     }
     function submitWithdraw () {
         if(Number(usdtAmount.value) < 100) {
@@ -204,11 +209,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 +217,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) {
@@ -278,8 +281,10 @@
         getWalletInfo,
         allExchange,
         submitExchange,
+        allWithdraw,
         submitWithdraw,
-        onClickTab
+        onClickTab,
+        isRequesting
     };
   },
   methods: {

--
Gitblit v1.9.1