import { observable, action, reaction } from 'mobx'; import fetch from '../lib/api'; import { apiParam } from '../lib/api'; import { loadShopComponent, loadDealComponent } from '@dp/templates-tuan-shop'; class IndexStore { @observable list = []; @observable isLoading = false; @observable shopComponent = null; @observable dealComponent = null; @observable data = ''; constructor() {} @action async loadComponents() { this.shopComponent = await loadShopComponent(); this.dealComponent = await loadDealComponent(); } @action fetchList(ob?: apiParam) { this.isLoading = true; fetch.getListData(ob).then(res => { this.data = res; if (res && res.code == 200) { let { list, config, priceTag } = res; if (config && ob && ob.pageNo == 0) { } if (list && list.length > 0) { this.list = list; } else { } if (list && list.length < 20) { } } }); } } export default IndexStore;