|
@@ -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();
|
|
|
});
|