diff --git a/.env.development b/.env.development index bc82b1a..d037843 100644 --- a/.env.development +++ b/.env.development @@ -1,9 +1,9 @@ VUE_APP_WALLET_INFURAID='e7743d46923911fa8850619b7a7f6d9d' -VUE_APP_BASE_API='http://game2006api-test.kingsome.cn' -VUE_APP_CHAIN_ID=97 -VUE_APP_CHAIN_RPC='https://data-seed-prebsc-1-s1.binance.org:8545' -VUE_APP_CHAIN_NAME='Smart Chain - Testnet' -VUE_APP_CHAIN_EXPLORERURL='https://testnet.bscscan.com' +VUE_APP_BASE_API='https://market-test.kingsome.cn' +VUE_APP_CHAIN_ID=322 +VUE_APP_CHAIN_RPC='https://rpc-testnet.kcc.network' +VUE_APP_CHAIN_NAME='KCC-TESTNET' +VUE_APP_CHAIN_EXPLORERURL='https://scan-testnet.kcc.network VUE_APP_CHAIN_CURRENCY_NAME='name' -VUE_APP_CHAIN_CURRENCY_SYMBOL='BNB' +VUE_APP_CHAIN_CURRENCY_SYMBOL='KCS' VUE_APP_CHAIN_CURRENCY_DECIMALS=18 diff --git a/.env.production b/.env.production index 9a5223b..d037843 100644 --- a/.env.production +++ b/.env.production @@ -1,9 +1,9 @@ VUE_APP_WALLET_INFURAID='e7743d46923911fa8850619b7a7f6d9d' -VUE_APP_BASE_API='https://market.cebg.games' -VUE_APP_CHAIN_ID=97 -VUE_APP_CHAIN_RPC='https://data-seed-prebsc-1-s1.binance.org:8545' -VUE_APP_CHAIN_NAME='Smart Chain - Testnet' -VUE_APP_CHAIN_EXPLORERURL='https://testnet.bscscan.com' +VUE_APP_BASE_API='https://market-test.kingsome.cn' +VUE_APP_CHAIN_ID=322 +VUE_APP_CHAIN_RPC='https://rpc-testnet.kcc.network' +VUE_APP_CHAIN_NAME='KCC-TESTNET' +VUE_APP_CHAIN_EXPLORERURL='https://scan-testnet.kcc.network VUE_APP_CHAIN_CURRENCY_NAME='name' -VUE_APP_CHAIN_CURRENCY_SYMBOL='BNB' +VUE_APP_CHAIN_CURRENCY_SYMBOL='KCS' VUE_APP_CHAIN_CURRENCY_DECIMALS=18 diff --git a/src/components/main/MainHeader.vue b/src/components/main/MainHeader.vue index 58dc958..afb6c73 100644 --- a/src/components/main/MainHeader.vue +++ b/src/components/main/MainHeader.vue @@ -58,7 +58,7 @@
  • Logout
  • -
  • +
  • Connect Wallet
  • @@ -100,6 +100,10 @@ export default class extends Vue { return this.bc.disconnect() } + async collectToWallet() { + return this.bc.connect() + } + toggleDrop() { this.dropShow = !this.dropShow } diff --git a/src/components/main/NftSection.vue b/src/components/main/NftSection.vue index bdd9cdf..797f8f5 100644 --- a/src/components/main/NftSection.vue +++ b/src/components/main/NftSection.vue @@ -71,6 +71,7 @@ export default class extends Vue { async fetchData() { await this.queryPresaleList() + await this.getPresaleInfo() } subscribeToEvents() { @@ -173,12 +174,19 @@ export default class extends Vue { this.beginCountdown() } AppModule.updatePresaleStat(this.presaleStatus) + + const buySet: Set = new Set() + if (res.presale_info.buyable_list) { + for (const sub of res.presale_info.buyable_list) { + buySet.add(sub.box_id) + } + } AppModule.updateCanBuy(this.presaleStatus === 2 && - this.numberRest > 0 && - !this.buyed + this.numberRest > 0 && buySet.size > 0 ) + for (const data of this.heroDatas) { - Vue.set(data, 'stopBuy', this.buyed) + Vue.set(data, 'stopBuy', !buySet.has(data.id!)) } } } diff --git a/src/components/market/NftItem.vue b/src/components/market/NftItem.vue index 049ca53..b7fe8d1 100644 --- a/src/components/market/NftItem.vue +++ b/src/components/market/NftItem.vue @@ -4,7 +4,7 @@
    {{data.name}}
    -
    +
    {{priceDiscountShow}} {{data.currency}} @@ -25,7 +25,7 @@ import { BlockChain } from '@/utils/blockchain' import { AppModule } from '@/store/modules/app' import { buyBox } from '@/api/Mall' import { Message } from 'element-ui' -import { EventBus, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET, PRESALE_SUCCESS } from '@/utils/event-bus' +import { EventBus, NEED_LOGIN, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET } from '@/utils/event-bus' declare module 'vue/types/vue' { interface Vue { @@ -46,8 +46,12 @@ export default class extends Vue { return AppModule.walletConnected } + get showLight() { + return !this.accountId || this.canBuy + } + get canBuy() { - return !this.data.showBuy && AppModule.presaleStatus === 2 + return !this.data.stopBuy && AppModule.presaleStatus === 2 } get priceDiscountShow() { @@ -65,6 +69,11 @@ export default class extends Vue { } async buyItem() { + console.log('on click item: ', this.data.id) + if (!this.accountId) { + EventBus.$emit(NEED_LOGIN) + return + } if (!this.canBuy) { Message({ message: 'Can`t buy current time', @@ -108,8 +117,8 @@ export default class extends Vue { nonce, signature } - await this.bc.increaseAllowance(this.data.coinAddress!, price) const res: any = await buyBox(buyData) + await this.bc.increaseAllowance(this.data.coinAddress!, price) const orderId = res.order_id localStorage.setItem('tmp_presale_order_id', orderId) EventBus.$emit(PRESALE_ORDER_GET, orderId) diff --git a/src/utils/blockchain.ts b/src/utils/blockchain.ts index 39e5c43..1003f09 100644 --- a/src/utils/blockchain.ts +++ b/src/utils/blockchain.ts @@ -5,6 +5,7 @@ import { AppModule } from '@/store/modules/app' import Web3 from 'web3' import { MessageBox } from 'element-ui' import { ERC20ABI, MALL_ADDRESS } from '@/utils/config_chain' +import { EventBus, NEED_LOGIN } from '@/utils/event-bus' @singleton export class BlockChain { @@ -42,6 +43,7 @@ export class BlockChain { if (this.isWalletConnect) { this.connect() } + EventBus.$on(NEED_LOGIN, this.connect.bind(this)) } loadJson(url: string) { @@ -68,7 +70,7 @@ export class BlockChain { 'You need to connect to supported network', 'Wrong Network', { - confirmButtonText: 'Switch to BSC network', + confirmButtonText: `Switch to ${process.env.VUE_APP_CHAIN_NAME} network`, cancelButtonText: 'Cancel', type: 'warning' } @@ -136,7 +138,7 @@ export class BlockChain { 'You need to connect to supported network', 'Wrong Network', { - confirmButtonText: 'Switch to BSC network', + confirmButtonText: `Switch to ${process.env.VUE_APP_CHAIN_NAME} network`, cancelButtonText: 'Cancel', type: 'warning' } diff --git a/src/utils/event-bus.ts b/src/utils/event-bus.ts index a41a905..c68f17b 100644 --- a/src/utils/event-bus.ts +++ b/src/utils/event-bus.ts @@ -8,3 +8,5 @@ export const PRESALE_ORDER_GET = 'presale_order_get' export const PRESALE_SUCCESS = 'presale_success' export const PRESALE_ERROR = 'presale_error' + +export const NEED_LOGIN = 'need_login'