From 668daa50bc63ed6eac8a6b937b9824fae82ffb32 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=AD=E4=B9=B0nft?= =?UTF-8?q?=E7=9A=84=E7=99=BB=E5=BD=95=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/market/NftItem.vue | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/market/NftItem.vue b/src/components/market/NftItem.vue index c386614..c814a44 100644 --- a/src/components/market/NftItem.vue +++ b/src/components/market/NftItem.vue @@ -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({