修改购买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 { buyBox } from '@/api/Mall'
|
||||||
import { Message } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
import { EventBus, NEED_LOGIN, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET } from '@/utils/event-bus'
|
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' {
|
declare module 'vue/types/vue' {
|
||||||
interface Vue {
|
interface Vue {
|
||||||
@ -68,9 +69,13 @@ export default class extends Vue {
|
|||||||
return AppModule.accountId
|
return AppModule.accountId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get logined() {
|
||||||
|
return !!UserModule.token
|
||||||
|
}
|
||||||
|
|
||||||
async buyItem() {
|
async buyItem() {
|
||||||
console.log('on click item: ', this.data.id)
|
console.log('on click item: ', this.data.id)
|
||||||
if (!this.accountId) {
|
if (!this.logined) {
|
||||||
EventBus.$emit(NEED_LOGIN)
|
EventBus.$emit(NEED_LOGIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -82,8 +87,23 @@ export default class extends Vue {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.accountId) {
|
if (!this.logined) {
|
||||||
return await this.bc.connect()
|
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) {
|
if (!AppModule.canBuy) {
|
||||||
Message({
|
Message({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user