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

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

View File

@ -26,6 +26,7 @@
import { AppModule } from "@/store/modules/app"; import { AppModule } from "@/store/modules/app";
import { isMobile } from "@/utils/resize"; import { isMobile } from "@/utils/resize";
import Header from "../layout/Header.vue"; import Header from "../layout/Header.vue";
import {checkStatus} from '@/api/webapi'
export default { export default {
components: { components: {
Header, Header,
@ -92,16 +93,34 @@ export default {
cancelable: false, cancelable: false,
}); });
window.dispatchEvent(event); window.dispatchEvent(event);
if (!this.redirect) { if (!this.redirect || this.redirect == '/mobile.html' || this.redirect == '/desktop.html') {
location.href = isMobile() ? '/mobile.html' : '/desktop.html' this.checkStatus()
} else { } else {
this.$router.push({ this.$router.push({
path: this.redirect || isMobile() ? '/mobile.html' : '/desktop.html', path: this.redirect,
query: this.otherQuery 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) { chainLogin(cb) {
window.logincb = cb; window.logincb = cb;
this.chain.login().then(this.logSuccess.bind(window)); this.chain.login().then(this.logSuccess.bind(window));