修改购买nft的登录流程
This commit is contained in:
parent
8f497723ab
commit
668daa50bc
@ -26,6 +26,7 @@ import { AppModule } from '@/store/modules/app'
|
||||
import { buyBox } from '@/api/Mall'
|
||||
import { Message } from 'element-ui'
|
||||
import { EventBus, NEED_LOGIN, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET } from '@/utils/event-bus'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
@ -68,9 +69,13 @@ export default class extends Vue {
|
||||
return AppModule.accountId
|
||||
}
|
||||
|
||||
get logined() {
|
||||
return !!UserModule.token
|
||||
}
|
||||
|
||||
async buyItem() {
|
||||
console.log('on click item: ', this.data.id)
|
||||
if (!this.accountId) {
|
||||
if (!this.logined) {
|
||||
EventBus.$emit(NEED_LOGIN)
|
||||
return
|
||||
}
|
||||
@ -82,8 +87,23 @@ export default class extends Vue {
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!this.accountId) {
|
||||
return await this.bc.connect()
|
||||
if (!this.logined) {
|
||||
try {
|
||||
await this.bc.connect()
|
||||
} catch (err) {
|
||||
Message({
|
||||
message: err.message,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
return await UserModule.Login({
|
||||
bcInstance: this.bc,
|
||||
account: AppModule.accountId,
|
||||
chainId: AppModule.chainId
|
||||
})
|
||||
}
|
||||
if (!AppModule.canBuy) {
|
||||
Message({
|
||||
|
Loading…
x
Reference in New Issue
Block a user