const reqInterface = require("../../../api/models"); import { toLink } from '../../../utils/nav'; Page({ /** * 页面的初始数据 */ data: { tabs: [{ title: '全部', icon: '/icons/all.png' }, { title: '待审核', icon: '/icons/daishenhe.png' }, { title: '已审核', icon: '/icons/yishenhe.png' }, { title: '已公示', icon: '/icons/yigongshi.png' }, { title: '已发放', icon: '/icons/yifafang.png' }], applyForList: [], active: 0, isRefreshing: false, searchParams: { current: 1, size: 9, status: '', }, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { let self = this; self.setData({ applyForList: [] }) self.getApplyForList(self.data.searchParams); }, getApplyForList(val) { let self = this; reqInterface.GetConsumerinfoDetail(val).then(res => { if (!res.records || res.records.length == 0) { wx.showToast({ title: '没有更多数据', icon: 'none' }) } self.setData({ applyForList: res.records ? self.data.applyForList.concat(res.records) : self.data.applyForList.concat([]), isRefreshing: false }) }).catch(err => { self.setData({ isRefreshing: false }) }) }, changeTab(e) { let self = this; if (e.currentTarget.dataset.idx == 0) { self.setData({ applyForList: [], searchParams: { current: 1, size: 9, status: '', }, active: e.currentTarget.dataset.idx }) } else { self.setData({ searchParams: { current: 1, size: 9, status: e.currentTarget.dataset.idx, }, applyForList: [], active: e.currentTarget.dataset.idx }) } self.getApplyForList(self.data.searchParams) }, toApplyFor(e) { toLink('/pages/info/index/index', { id: e.currentTarget.dataset.id }) }, // 加载更多 onLoadMore() { let self = this; let page = self.data.searchParams.current + 1; //获取当前页数并+1 self.setData({ 'searchParams.current': page, //更新当前页数 }) self.getApplyForList(self.data.searchParams); //重新调用请求获取下一页数据 }, // 下拉刷新 onRefresherPulling(e) { this.setData({ isRefreshing: true }); }, onRefresherRefresh(e) { this.getRefresh() }, getRefresh() { let self = this; self.setData({ applyForList: [], searchParams: { current: 1, status: self.data.searchParams.status, size: 9 }, active: self.data.active }) self.getApplyForList(this.data.searchParams); }, })