You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.7 KiB
84 lines
1.7 KiB
const app = getApp()
|
|
import {message} from "../../api/index"
|
|
Page({
|
|
data: {
|
|
pageSize:10,
|
|
pageNo:1,
|
|
tableData:[],
|
|
lowerThreshold:'5',
|
|
loadMoreVisible:false,
|
|
loadMoreType: "none",
|
|
nodata:false,
|
|
},
|
|
// 事件处理函数
|
|
onLoad: async function () {
|
|
|
|
},
|
|
onShow(){
|
|
|
|
this.getIntelligentMessage()
|
|
},
|
|
onPullDownRefresh() {
|
|
this.setData({
|
|
pageNo:1,
|
|
tableData:[]
|
|
})
|
|
this.getIntelligentMessage()
|
|
},
|
|
|
|
onScrollToLower(e){
|
|
if (this.data.loadMoreType === 'more') {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
})
|
|
this.data.pageNo += 1
|
|
this.getIntelligentMessage()
|
|
}
|
|
},
|
|
getIntelligentMessage(){
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
nodata: false,
|
|
loadMoreType: "more",
|
|
})
|
|
const parm = {
|
|
pageSize:this.data.pageSize,
|
|
pageNum:this.data.pageNo
|
|
}
|
|
if(!parm.type) delete parm.type
|
|
message(parm).then(res=>{
|
|
this.setData({
|
|
loadMoreType: res.data.records.length === this.data.pageSize ? 'more' : 'none',
|
|
tableData: this.data.tableData.concat(res.data.records),
|
|
})
|
|
if (this.data.tableData.length == 0) {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true
|
|
})
|
|
}
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true,
|
|
})
|
|
})
|
|
},
|
|
|
|
|
|
|
|
handelClickClear(){
|
|
clearMessage().then(res=>{
|
|
this.setData({
|
|
tableData:[],
|
|
pageNo:1
|
|
})
|
|
this.getIntelligentMessage()
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
})
|
|
|
|
|
|
|