import R from '../../utils/request'; import C from '../../utils/constant'; import * as F from '../../utils/func'; Page({ data: { cdnHost: C.cdnHost, list: [], page: 1, status: '', // money_flag: 'send', listEndText: '', }, onLoad(options) { const {from} = options; if(from == 'sharebuy') { R.post('/index.php/api/v1/configs',{ks:['payed_tip','payed_vip_link']}).then(({model})=>{ if(model.payed_tip && model.payed_vip_link) { wx.showModal({ title: '提示', content: model.payed_tip, complete: (res) => { if (res.confirm) { wx.navigateTo({ url: '/pages/webview/webview?url=' + encodeURIComponent(model.payed_vip_link), }) } } }) } }) } this.fetchList(1); }, goDetail(e) { const { detail } = e.currentTarget.dataset; if (!detail.phone && detail.status == 'payed') { wx.navigateTo({ url: `/pages/sharebuy/sharebuy?id=${detail.share_id}&orderNo=${detail.order_no}`, }); } }, fetchList(page) { const { status } = this.data; // money_flag R.get('/index.php/api/v1/order_list', { page }).then(({ model }) => { const list = []; model.forEach(item => { list.push({ ...item, price: F.formatePrice(item.price), }); }); if (list.length == 0) { this.setData({ listEndText: '没有更多了' }); } else { this.setData({ listEndText: '点击加载更多。。。' }); } if (page == 1) { this.setData({ list,page }); } else { const list2 = this.data.list.concat(list); this.setData({ list: list2,page }); } }); // for (let i = 0; i < 20; i++) { // list.push({ // id: i, // title: '自动热重载] 已开启代码文件保存后自动热重载自动热重载] 已开启代码文件保存后自动热重载', // image: `${imageCdn}/swiper2.png`, // createTime: '09-12 12:21', // viewCnt: 1922 + i, // }); // } // this.setData({ // list // }) }, loadMore() { const { page, listEndText } = this.data; if (listEndText == '点击加载更多。。。') { this.fetchList(page + 1); } }, onTabsChange(event) { const v = event.detail.value; this.data.status = v; this.fetchList(1); }, // handleSwitchChange(e) { // const { value } = e.detail; // if (value) { // this.data.money_flag = 'send'; // } else { // this.data.money_flag = ''; // } // this.fetchList(1); // }, onReachBottom() { this.loadMore(); }, onShareAppMessage() { } })