const app = getApp(); const api = require('../../../utils/api'); const cloudApi = require('../../../utils/cloudApi') Page({ data: { page: 'pages/tabBar/count/countDetail', statusBarHeight: '', examParams: { pageNum: 1, pageSize: 10, }, examList: [], totalPage: 0 }, onLoad() { console.log('跳转完成'); this.setData({ statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'] }); this.getList(); }, goBack() { const url = wx.getStorageSync("prevPage"); console.log(url,'Fanhui') if(url) { wx.reLaunch({ url: url }); } else { wx.reLaunch({ url: '/pages/tabBar/count/count' }); } }, getList() { // cloudApi const userId = wx.getStorageSync('user').id wx.cloud.callFunction({ name: 'getHazmatFlowByPage', data: {...this.data.examParams,userId: userId} }).then(res=>{ if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){ let list = cloudApi.changeKey(res.result.list) if (this.data.examParams.pageNum != 1) { this.setData({ examList: this.data.examList.concat(list), totalPage: Math.ceil(res.result.total / res.result.pageSize) }); } else { this.setData({ examList: list, totalPage: Math.ceil(res.result.total / res.result.pageSize) }); } }else{ this.setData({ examList: [], totalPage: 0 }); } }) // api请求 // api.getHazmatFlowByUser(this.data.examParams).then(res => { // if(res.code == 200) { // let list = res.data.list ? res.data.list : []; // if (this.data.examParams.pageNum != 1) { // this.setData({ // examList: this.data.examList.concat(list) // }); // } else { // this.setData({ // examList: res.data.list, // totalPage: res.data.totalPage // }); // } // } else { // wx.showToast({ // title: res.message, // icon: 'none' // }); // } // }); }, upper(e) { // console.log(e) }, lower(e) { if (this.data.examParams.pageNum >= this.data.totalPage) { wx.showToast({ title: '已加载全部数据', icon: 'none' }); return; } this.setData({ 'examParams.pageNum': this.data.examParams.pageNum + 1 }); this.getList(); }, scrollView(e) { // console.log(e) } });