4 Commits 73d420b0ea ... c077f55ace

Autor SHA1 Mensaje Fecha
  panmeiyu c077f55ace Merge branch 'dev' of http://120.92.132.192:23541/web/mymymoba_vue into dev hace 3 años
  panmeiyu 1d3cfe3899 1 hace 3 años
  panmeiyu 96069d45f6 Merge branch 'dev' of http://120.92.132.192:23541/web/mymymoba_vue into dev hace 3 años
  panmeiyu 33ad29d848 1 hace 3 años
Se han modificado 3 ficheros con 41 adiciones y 43 borrados
  1. 37 35
      src/components/Header.vue
  2. 4 3
      src/store.js
  3. 0 5
      src/views/Hero.vue

+ 37 - 35
src/components/Header.vue

@@ -41,10 +41,9 @@
             <a
               href="javascript:void(0);"
               v-if="isconnected"
-              @click="gotoMynft"
               class="connect_wallet connected"
             >
-              <span>0xdf8…6f9he</span>
+              <span>{{contractAddress}}</span>
             </a>
           </div>
 
@@ -119,7 +118,7 @@ export default {
   name: "Header",
   data() {
     return {
-      contractShow: false,
+      contractAddress: '',
       isconnected: false,
       dialogTableVisible: false,
       isphone: false,
@@ -147,11 +146,11 @@ export default {
       ],
     };
   },
-  watch: {
-    isconnected: function (newVal) {
-      this.$store.commit("user/setIsConnected", newVal);
-    },
-  },
+  // watch: {
+  //   isconnected: function (newVal) {
+  //     this.$store.commit("setIsConnected", newVal);
+  //   },
+  // },
   methods: {
     toggleBodyClass() {
       let e = document.querySelector("body");
@@ -180,39 +179,40 @@ export default {
       this.dialogTableVisible = true
     },
     checkWalletStatus() {
-      let $this = this;
-      // 检查钱包是否已登录
-      if (this.$walletMgr.checkWalletType()) {
-        let authdata = JSON.parse(localStorage.getItem("authdata"));
-        if (authdata[this.$walletMgr.currentAccount] != null) {
-          $this.isconnected = true;
-          localStorage.setItem("authaddress", this.$walletMgr.currentAccount);
-        } else {
-          $this.isconnected = false;
-        }
-        console.log($this.isconnected);
-      } else {
-        $this.isconnected = false;
+      let $this = this
+      let walletdata = JSON.parse(localStorage.getItem('walletdata'))
+      if(walletdata!=null){
+        walletMgr.changeWalletType(walletdata.type,(x)=>{
+          if(x.code==0){
+            $this.isconnected = true
+            $this.contractAddress = walletdata.contractAddress
+          }
+        });
+      }else{
+        $this.isconnected = false
       }
     },
     // 连接钱包按钮点击
     ConnectWalletChoice(_i) {
-      let $this = this;
-      if (_i == 1) {
-        // 连接钱包
-        walletMgr.changeWalletType(1,(x)=>{
+      let $this = this
+      walletMgr.changeWalletType(_i,(x)=>{
           console.log(x)
+          if(x.code==0){
+            $this.isconnected = true
+            let contractAddress = x.data[0]
+            $this.contractAddress = contractAddress.substr(0, 5) + '...' + contractAddress.substr(contractAddress.length - 5, 5)
+            console.log($this.contractAddress)
+            let obj = {}
+            obj.connect = $this.isconnected
+            obj.type = _i
+            obj.contractAddress = $this.contractAddress
+            obj = JSON.stringify(obj)
+            localStorage.setItem('walletdata', obj)
+          }else{
+            $this.isconnected = false
+          }
         });
-      } else if (_i == 2) {
-        walletMgr.changeWalletType(2,(x)=>{
-          console.log(x)
-        });
-      } else if (_i == 3) {
-        walletMgr.changeWalletType(3,(x)=>{
-          console.log(x)
-        });
-      }
-      this.dialogTableVisible = false;
+      this.dialogTableVisible = false
     },
   },
   beforeDestroy() {
@@ -220,6 +220,8 @@ export default {
   },
   mounted() {
     let $this = this;
+    // localStorage.setItem('walletdata', null)
+    this.checkWalletStatus()
     window.addEventListener("scroll", () => {
       $this.toggleBodyClass();
     });

+ 4 - 3
src/store.js

@@ -5,12 +5,13 @@ Vue.use(Vuex)
 
 export default new Vuex.Store({
   state: {
-
+    isconnected: false
   },
   mutations: {
-
+    setIsConnected (state, data) {
+      state.isconnected = data
+    }
   },
   actions: {
-
   }
 })

+ 0 - 5
src/views/Hero.vue

@@ -953,11 +953,6 @@ img {
   bottom: 0;
   z-index: 3;
 }
-.phoneshow,
-.tokenphoneshow {
-  display: none;
-}
-
 
 @media screen and (max-width: 1200px) {
   .boxThree .container .hero_nav {