增加用于native登陆的页面

This commit is contained in:
cebgcontract 2022-04-01 11:21:08 +08:00
parent b5fb647dd0
commit cbc746914a
3 changed files with 86 additions and 2 deletions

View File

@ -7,7 +7,6 @@ import { Message } from 'element-ui'
import { Chain } from '@/chain/Chain'
import { AVAILABLE_CHAINS, IChainData } from '@/configs/config_chain'
import { AllChains } from '@/configs/allchain'
import { parsePrice } from '@/utils/chain.util'
@singleton
export default class ChainManager {
@ -22,7 +21,6 @@ export default class ChainManager {
for (const data of AllChains) {
this.chainMap.set(data.id, data)
}
// EventBus.$on(NEED_NONCE, this.checkNance.bind(this))
}
get availableChains() {
@ -67,6 +65,7 @@ export default class ChainManager {
type: 'error',
duration: 5 * 1000
})
await Promise.reject(err)
}
}
}
@ -91,6 +90,7 @@ export default class ChainManager {
AppModule.updateStep(1)
} catch (err) {
console.log(err)
await Promise.reject(err)
}
}

View File

@ -166,6 +166,14 @@ const routes: Array<RouteConfig> = [
}
]
}
},
{
path: '/nativelogin',
name: 'NativeLogin',
component: resolve => require(['@/views/mobile/NativeLogin.vue'], resolve),
meta: {
title: 'NativeLogin'
}
}
]

View File

@ -0,0 +1,76 @@
<template>
<div class="container">
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import ChainManager from '@/chain/ChainManager'
import { UserModule } from '@/store/modules/user'
import { AppModule } from '@/store/modules/app'
export const COCOS_SCHEMA = 'nativechain'
@Component({
name: 'NativeLogin',
components: {
}
})
export default class NativeLogin extends Vue {
chainManager = new ChainManager()
async created() {
await this.chainManager.init()
}
mounted() {
const act = this.$route.query.a
console.log('act: ', act)
switch (act) {
case 'login':
this.collectToWallet()
break
}
}
response(data: any) {
document.location.href = `${COCOS_SCHEMA}://${encodeURIComponent(JSON.stringify(data))}`
}
async collectToWallet() {
try {
await this.chainManager.login()
const data: any = {
act: 'login',
account: AppModule.accountId,
chainid: AppModule.chainId,
token: UserModule.token
}
this.response(data)
} catch (err) {
console.log(err)
const data: any = {
act: 'login',
errcode: 1,
errmsg: 'login error'
}
this.response(data)
}
}
get logined() {
return !!UserModule.token && !!AppModule.step
}
get account() {
return AppModule.accountId
}
}
</script>
<style lang="scss" scoped>
.container{
width: 100vw;
margin: 10.4vw auto 0;
background-color: #2E2E2E;
}
</style>