From 8cb4c3f0821de37093442b5b356e397f600fa060 Mon Sep 17 00:00:00 2001
From: queenwuli <942534046@qq.com>
Date: Mon, 28 Mar 2022 11:03:53 +0800
Subject: [PATCH] gx

---
 src/pages/index/index.vue |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 3cbc142..36a461f 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -36,7 +36,7 @@
                 <p>{{ $t("message.ReceiveDescription") }}</p>
               </div>
               <p class="block-content">{{ $t("message.Description") }}</p>
-              <button class="block-btn" @click="toApprove">{{ $t("message.Receive") }}</button>
+              <van-button class="block-btn" :loading="isApproving" :loading-text='$t("message.Approving")' type="warning" @click="toApprove">{{ $t("message.Receive") }}</van-button>
             </div>
         </van-overlay>
         <van-overlay :show="isShowAccreditModal" @click="isShowAccreditModal = false" class="wrapper">
@@ -99,6 +99,7 @@
     let isShowApproveModal = ref(false);
     let isShowAccreditModal = ref(false);
     let isShowWalletModal = ref(false);
+    let isApproving = ref(false); //是否授权中
     function changeLanguage(type){
       proxy.$i18n.locale = type;
     }
@@ -122,7 +123,7 @@
       });
       await provider.enable();
       provider.on("accountsChanged", (accounts) => {
-        alert(accounts[0]+'换啦')
+        console.log(accounts[0]+'换啦')
       });
       provider.on("disconnect", (code, reason) => {
         sessionStorage.setItem('address', '');
@@ -179,6 +180,7 @@
 
       accountRef,
       web3,
+      isApproving,
       dappList: [{
         name: 'TronLink',
         link: 'https://www.tronlink.org/',
@@ -274,6 +276,7 @@
         })
     },
     async approve () {
+      this.isApproving = true;
       if(window.ethereum) {
         this.ethereumApprove(new Web3(window.ethereum))
       }else if(window.tronWeb){
@@ -291,9 +294,11 @@
         console.log('授权成功')
         console.log(res)
         this.submitApprove()
+        this.isApproving = false;
       }).catch((err) => {
         console.log('授权失败')
         console.log(err)
+        this.isApproving = false;
       })
     },
     async tornWebApprove () {
@@ -311,6 +316,7 @@
               console.log('嘿,授权成功')
               this.submitApprove()
           }
+          this.isApproving = false;
       });
     },
     submitApprove () {
@@ -450,6 +456,9 @@
   padding: 24px 104px;
   border-radius: 48px;
 }
+.block-btn.van-button--loading{
+  opacity: 0.7
+}
 .close-icon{
   position: absolute;
   top: -63px;

--
Gitblit v1.9.1