修改从首页跳转的登陆结果跳转页

This commit is contained in:
cebgcontract 2022-11-17 16:40:17 +08:00
parent 6ee0f0aeb9
commit 8d47cc97c9
2 changed files with 49 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<img class="imgs" src="../../assets/mobile/logo.png" alt="" />
</div>
<div class="header-login" @click="header">
<span>WALLET CONNECT</span>
<span id="top_title">{{header_title}}</span>
<div v-show="hide" class="dropdown-content">
<a href="javascript:void(0)" @click.stop="toQuest">Quest Info</a>
<a href="javascript:void(0);" @click="logout">Log out</a>
@ -16,18 +16,30 @@
</template>
<script>
import { AppModule } from "@/store/modules/app";
import { isMobile } from "@/utils/resize";
export default {
name: "Header",
data() {
return {
hide:false
hide:false,
header_title: 'WALLET CONNECT'
};
},
created() {
chain.chainManager.init().then(() => {
console.log("header wallet init");
if (AppModule.account) {
this.header_title = this.formatAddress(AppModule.account);
} else {
this.header_title = 'WALLET CONNECT'
}
});
if (AppModule.account) {
this.header_title = this.formatAddress(AppModule.account);
} else {
this.header_title = 'WALLET CONNECT'
}
window.addEventListener('account_change', function() {
localStorage.removeItem('userinfo');
localStorage.removeItem('invite_code');
@ -52,6 +64,19 @@ export default {
this.$router.push("rankinglist");
this.hide = false
},
formatAddress(address) {
if (address.length >= 10) {
return (
address.substring(0, 6) +
"......" +
address.substring(address.length - 4)
);
} else if (address.length > 0 && address.length < 10) {
return address;
} else {
return "-";
}
}
},
};
</script>

View File

@ -26,6 +26,7 @@
import { AppModule } from "@/store/modules/app";
import { isMobile } from "@/utils/resize";
import Header from "../layout/Header.vue";
import {checkStatus} from '@/api/webapi'
export default {
components: {
Header,
@ -92,16 +93,34 @@ export default {
cancelable: false,
});
window.dispatchEvent(event);
if (!this.redirect) {
location.href = isMobile() ? '/mobile.html' : '/desktop.html'
if (!this.redirect || this.redirect == '/mobile.html' || this.redirect == '/desktop.html') {
this.checkStatus()
} else {
this.$router.push({
path: this.redirect || isMobile() ? '/mobile.html' : '/desktop.html',
path: this.redirect,
query: this.otherQuery
})
}
},
async checkStatus(cb) {
let res = await checkStatus(AppModule.account)
if (res.errcode) {
Message.info('Error get User state')
return;
}
if (cb && res.status == 0 ) {
cb(res.errmsg);
} else {
if (res.status === 4) {
this.$router.push("rankinglist")
} else if (res.status === 1) {
this.$router.push("recommend")
} else {
this.$router.push("signup")
}
}
},
chainLogin(cb) {
window.logincb = cb;
this.chain.login().then(this.logSuccess.bind(window));