// pages/valveList/valveList.js 开关阀记录
|
const {
|
get,
|
post
|
} = require('../../api/request.js');
|
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
listVirtualData: [],
|
listPhysicalData: [],
|
currentTab: 0,
|
isVirtualRefreshing: false, //虚拟卡刷新中
|
isPhysicalRefreshing: false, //实体卡刷新中
|
physicalPageCurr: 1, //实体卡当前页数
|
pageSize: 20,
|
virtualPageCurr: 1, //虚拟卡当前页数
|
virtualhasMore: true,
|
physicalHasMore: true,
|
virtualIsLoding: false,
|
physicalIsLoding: false,
|
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad(options) {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady() {
|
this.getPhysicalListData();
|
this.getVirtualListData();
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload() {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh() {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom() {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage() {
|
|
},
|
switchTab(e) {
|
const tab = parseInt(e.currentTarget.dataset.tab);
|
this.setData({
|
currentTab: tab
|
});
|
},
|
//虚拟卡刷新
|
onPullVirtualDownRefresh() {
|
this.setData({
|
isVirtualRefreshing: true,
|
})
|
this.getVirtualListData(true);
|
},
|
//实体卡刷新
|
onPullPhysicalDownRefresh() {
|
this.setData({
|
isPhysicalRefreshing: true,
|
})
|
this.getPhysicalListData(true);
|
},
|
//获取实体卡列表
|
getPhysicalListData(isRefresh) {
|
get({
|
url: 'wx/intake/getCardOpenClose',
|
data: {
|
clientId: getApp().globalData.clientId,
|
pageCurr: this.data.physicalPageCurr,
|
pageSize: this.data.pageSize
|
}
|
})
|
.then((data) => {
|
this.setData({
|
isPhysicalRefreshing: false,
|
physicalIsLoding: false
|
});
|
if (data.success && data.code === "0001") {
|
const filteredData = data.content.obj.filter(item => item.openTime !== null && item.closeTime !== null);
|
this.setData({
|
listPhysicalData: isRefresh ? filteredData : this.data.listPhysicalData.concat(filteredData),
|
physicalHasMore: this.data.physicalPageCurr < data.content.pageTotal,
|
});
|
} else {
|
wx.showToast({
|
title: data.msg,
|
})
|
}
|
console.log('Failed to add item:');
|
})
|
.catch((error) => {
|
this.setData({
|
isWXRefreshing: false
|
});
|
console.error('Failed to add item:', error);
|
});
|
},
|
//获取虚拟卡开关阀记录
|
getVirtualListData(isRefresh) {
|
get({
|
url: 'wx/intake/getVcCardOpenClose',
|
data: {
|
clientId: getApp().globalData.clientId,
|
pageCurr: this.data.physicalPageCurr,
|
pageSize: this.data.pageSize
|
}
|
})
|
.then((data) => {
|
this.setData({
|
isVirtualRefreshing: false,
|
virtualIsLoding: false
|
});
|
if (data.success && data.code === "0001") {
|
const filteredData = data.content.obj.filter(item => item.openTime !== null && item.closeTime !== null);
|
this.setData({
|
listVirtualData: isRefresh ?filteredData : this.data.listVirtualData.concat(filteredData),
|
virtualhasMore: this.data.virtualPageCurr < data.content.pageTotal,
|
});
|
} else {
|
wx.showToast({
|
title: data.msg,
|
})
|
}
|
console.log('Failed to add item:');
|
})
|
.catch((error) => {
|
this.setData({
|
isWXRefreshing: false
|
});
|
console.error('Failed to add item:', error);
|
});
|
},
|
//加载更多的实体卡
|
loadPhysicalMore() {
|
if (this.data.physicalHasMore) {
|
this.setData({
|
physicalIsLoding: true,
|
physicalPageCurr: this.data.physicalPageCurr + 1
|
})
|
this.getPhysicalListData();
|
}
|
},
|
//加载更多的虚拟卡
|
loadVirtualMore() {
|
if (this.data.virtualhasMore) {
|
this.setData({
|
virtualIsLoding: true,
|
virtualPageCurr: this.data.virtualPageCurr + 1
|
})
|
this.getVirtualListData();
|
}
|
|
}
|
|
})
|