diff --git a/src/components/market/mall/OneBox.vue b/src/components/market/mall/OneBox.vue index 2310d3f..48945d1 100644 --- a/src/components/market/mall/OneBox.vue +++ b/src/components/market/mall/OneBox.vue @@ -61,6 +61,9 @@ import { UserModule } from '@/store/modules/user' import ChainManager from '@/chain/ChainManager' import { EventBus, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET } from '@/utils/event-bus' import { buyBox } from '@/api/Mall' +import { buyShopBox } from '@/api/Market' + +export const TMP_SHOP_ORDER_ID = 'tmp_presale_order_id' export interface IBoxData{ level: string @@ -79,6 +82,8 @@ export interface IBoxData{ }) export default class OneBox extends Vue { @Prop() private boxData: IBoxData + @Prop() private preSale: boolean + chainManger = new ChainManager() formatPriceShow(price: number|string, decimals?: number, fixed = 2) { @@ -134,9 +139,14 @@ export default class OneBox extends Vue { signature } await this.chainManger.bc.increaseAllowance(priceData.contract_address, price) - const res: any = await buyBox(buyData) + let res: any + if (this.preSale) { + res = await buyBox(buyData) + } else { + res = await buyShopBox(buyData) + } const orderId = res.order_id - localStorage.setItem('tmp_presale_order_id', orderId) + localStorage.setItem(TMP_SHOP_ORDER_ID, orderId) EventBus.$emit(PRESALE_ORDER_GET, orderId) } catch (err) { console.log('buy error: ', err) diff --git a/src/views/desktop/Mall.vue b/src/views/desktop/Mall.vue index 6485c4c..e2cfb56 100644 --- a/src/views/desktop/Mall.vue +++ b/src/views/desktop/Mall.vue @@ -26,7 +26,7 @@
- +
') - // this.buyed = !!res.presale_info.buyed - this.presaleStatus = res.presale_info.state || 0 - this.presaleTitle = res.presale_info.title - this.countdown = res.presale_info.countdown - if (this.presaleStatus === 1 && this.countdown > 0) { - 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 && buySet.size > 0 - ) - for (let i = 0, l = this.boxDatas.length; i < l; i++) { - const data = this.boxDatas[i] - if (!buySet.has(data.id)) { - data.open = 0 - data.title = 'UNAVAILABLE' - data.desc = 'ALREADY BOUGHT' - } else { - data.open = 1 - } - Vue.set(this.boxDatas, i, data) - } - // for (const data of this.boxDatas) { - // Vue.set(data, 'open', buySet.has(data.id) ? 0 : 1) - // } - } - } - async queryPresaleList(pageNo = 0) { const reqData = { - account: '', + account: this.accountId, page: pageNo } this.boxDatas.length = 0 - const res: any = await searchBox(reqData) + const res: any = await queryShopList(reqData) if (res.page) { this.currentPage = (parseInt(res.page.current_page || 0)) + 1 this.totalPage = res.page.total_pages || 1 diff --git a/src/views/desktop/Presale.vue b/src/views/desktop/Presale.vue index 874590a..a02b1f9 100644 --- a/src/views/desktop/Presale.vue +++ b/src/views/desktop/Presale.vue @@ -26,7 +26,7 @@
- +