149 lines
3.2 KiB
JavaScript
149 lines
3.2 KiB
JavaScript
// pages/taskWarning/taskWarning.js
|
|
const {API: $api} = require("../../utils/api");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
//所有数据
|
|
list: [],
|
|
head:null,
|
|
isRefreshing:false,//下拉刷新
|
|
isFinish:false,//下拉加载,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
},
|
|
|
|
//上拉加载
|
|
onLoadMore(){
|
|
let _num = this.data.pageNum+1;
|
|
this.setData({
|
|
pageNum:_num
|
|
});
|
|
this.loadListData();
|
|
},
|
|
//下拉刷新
|
|
onRefresh(){
|
|
this.setData({
|
|
list:[],
|
|
pageNum:1,
|
|
isFinish:false
|
|
});
|
|
this.loadListData();
|
|
},
|
|
|
|
//上传资料
|
|
handleSubmitFile(e){
|
|
let _data = e.currentTarget.dataset.item;
|
|
wx.navigateTo({
|
|
url:'../workReport/workReport?type='+_data.type+'&isRadio=true'+'&id='+_data.id
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 列表接口
|
|
*/
|
|
loadListData() {
|
|
let that = this; // //防止this指向问题
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let _param = {
|
|
pageSize:that.data.pageSize,
|
|
pageNum:that.data.pageNum,
|
|
head:that.data.head
|
|
}
|
|
$api.warnList(_param).then(res => {
|
|
if(res.code === 0){
|
|
wx.hideLoading();
|
|
let _data = res.rows;
|
|
if(that.data.pageNum > 1){ //上拉加载的逻辑
|
|
if(_data.length == 0){
|
|
that.setData({
|
|
isFinish:true
|
|
})
|
|
}
|
|
_data = that.data.list.concat(_data); //数据合并
|
|
that.setData({
|
|
list:_data
|
|
})
|
|
}else{
|
|
if(_data.length < that.data.pageSize){
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
isFinish:true
|
|
})
|
|
}else{
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
if (wx.getStorageSync('userInfo').loginName !== 'admin'){
|
|
this.setData({
|
|
head:wx.getStorageSync('perInfo').id
|
|
})
|
|
}
|
|
this.loadListData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |