|
|
|
// index.js
|
|
|
|
// 获取应用实例
|
|
|
|
const app = getApp()
|
|
|
|
import {getIntelligentMessage,getToken,getStaffbasicinfo} from "../../utils/api"
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
selectList:['全部信息','居民信息采集','房屋信息采集','社区满意度自查'],
|
|
|
|
selectValue:0,
|
|
|
|
pageSize:10,
|
|
|
|
pageNo:1,
|
|
|
|
tableData:[],
|
|
|
|
lowerThreshold:'10',
|
|
|
|
loadMoreVisible:false,
|
|
|
|
loadMoreType: "none",
|
|
|
|
nodata:false
|
|
|
|
},
|
|
|
|
// 事件处理函数
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
this.setData({
|
|
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
|
|
share:app.globalData.share
|
|
|
|
})
|
|
|
|
this.getToken()
|
|
|
|
this.getIntelligentMessage()
|
|
|
|
this.getStaffbasicinfo()
|
|
|
|
},
|
|
|
|
|
|
|
|
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 = {
|
|
|
|
type:this.data.selectValue == 0? null :this.data.selectValue - 1,
|
|
|
|
readFlag:0,
|
|
|
|
limit:this.data.pageSize,
|
|
|
|
page:this.data.pageNo
|
|
|
|
}
|
|
|
|
if(!parm.type) delete parm.type
|
|
|
|
getIntelligentMessage(parm).then(res=>{
|
|
|
|
this.setData({
|
|
|
|
loadMoreType: res.data.list.length === this.data.pageSize ? 'more' : 'none',
|
|
|
|
tableData: this.data.tableData.concat(res.data.list),
|
|
|
|
})
|
|
|
|
if (this.data.tableData.length == 0) {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: false,
|
|
|
|
nodata: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err=>{
|
|
|
|
console.log(err);
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: false,
|
|
|
|
nodata: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getToken(){
|
|
|
|
const parm = {
|
|
|
|
wxCode:'',
|
|
|
|
app:'gov',
|
|
|
|
client:'wxmp',
|
|
|
|
appId:'wxaf87b420b87e2d79'
|
|
|
|
}
|
|
|
|
wx.showLoading({
|
|
|
|
title: '加载中...',
|
|
|
|
})
|
|
|
|
wx.login({
|
|
|
|
success: (res) => {
|
|
|
|
parm.wxCode = res.code
|
|
|
|
getToken(parm).then(res=>{
|
|
|
|
console.log(res);
|
|
|
|
wx.hideLoading()
|
|
|
|
if(res.code === 0){
|
|
|
|
wx.setStorageSync('token', res.data.token)
|
|
|
|
}else{
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login.wxml',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err=>{
|
|
|
|
console.log(err);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getStaffbasicinfo(){
|
|
|
|
getStaffbasicinfo().then(res=>{
|
|
|
|
app.globalData.user = res.data
|
|
|
|
}).catch(err=>{
|
|
|
|
console.log(err);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleChangeFilter(e){
|
|
|
|
this.setData({
|
|
|
|
selectValue:e.detail.value,
|
|
|
|
tableData:[],
|
|
|
|
})
|
|
|
|
this.getIntelligentMessage()
|
|
|
|
}
|
|
|
|
})
|