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: '', }, onShow() { this.getTabBar().init(); this.fetchList(1); }, onLoad(options) { }, goCreate(e) { wx.navigateTo({ url: `/pages/createpay/createpay` }); }, fetchList(page) { const { status } = this.data; // money_flag R.get('/index.php/api/v1/share_list', { page, status }).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(); }, onPullDownRefresh() { this.fetchList(1); wx.stopPullDownRefresh(); }, editRemark(e) { const { id, remark } = e.currentTarget.dataset.detail; const that = this; wx.showModal({ title: '备注', content: remark || '', editable: true, success(re) { const remark2 = re.content || ''; R.post('/index.php/api/v1/mark', { id, remark: remark2 }).then(() => { that.data.list.find(o => o.id == id).remark = remark2; that.setData({ list: [...that.data.list], }) }) } }) } })