// pages/resiAndHouse/resiAndHouse.js import api, {getAllOrgCategoryCount,getResidentBaseInfo,getCommunityHouse} from "../../utils/api" const App = getApp() Page({ /** * 页面的初始数据 */ data: { selectValue:0, activeType:0, tabList:[], tableData:[], resiList:[ { name:'', resiTags:[''], nationalityName:'', nationName:'', mobile:'', idNum:'', agencyName:'', homeName:'', updatedTime:'' } ], selectedText:[], pageNo:1, pageSize:10, lowerThreshold:'10', cascaderValue:'同德路社区居委会', loadMoreVisible:false, loadMoreType: "none", selectVale:'resi', keyWord:'', angencyId:null, category:'', searchOrgIdPath:'', angencyList:[],//组织树 showAngenCascader:false, fieldName:{text: 'agencyName', value: 'agencyId', children: 'subAgencyList' } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ angencyId:App.globalData.user.agencyId, angencyName:App.globalData.user.angencyName, }) this.getAgencygridtree() this.getAllOrgCategoryCount() this.onSearchMessage() }, // /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.onAllSearchMessage() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { this.getIntelligentMessage() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, toOCRCard(){ wx.navigateTo({ url: '/subpages/OCRCard/pages/index/index', }) }, handelClickTab(e){ this.setData({ activeType: e.currentTarget.dataset.index }) }, handelBlurKeyWord(e){ this.setData({ keyWord:e.detail.value }) }, handelClickSearchType(e){ this.setData({ selectVale:e.currentTarget.dataset.type }) }, handelClickShowTree(){ this.setData({ showAngenCascader:true }) }, // 组织树 getAgencygridtree() { // let parm ={ // agencyId:this.data.angencyId, // purpose:'query' // } api.getAgencygridtree().then(res => { this.setData({ angencyList: [res.data], }) console.log('zuzhishu',angencyList) }).catch(err => { console.log(err); }) }, async handelClickSearch(){ this.setData({ loadMoreVisible: true, nodata: false, loadMoreType: "more", }) let parm ={ searchKey:this.data.keyWord, pageSize:this.data.pageSize, pageNo:this.data.pageNo } let {data,code,msg} = await getResidentBaseInfo(parm) if(code == 0){ console.log(this.data.tableData), this.setData({ loadMoreType:data.list.length === this.data.pageSize ? 'more' : 'none', tableData: this.data.tableData.concat(data.list), }) if (this.data.tableData.length == 0) { this.setData({ loadMoreVisible: false, nodata: true }) } }else{ this.setData({ loadMoreVisible: false, nodata: true, }) } }, handelClickToOcr(){ wx.navigateTo({ url: '/subpages/OCRCard/pages/index/index', }) }, getAllOrgCategoryCount(){ let parm ={ residentInfo:this.data.keyWord, agencyId: this.data.searchOrgIdPath, orgId:'e723c89ee5ed0cc382576833e7c6a220', level:'community' } api.getAllOrgCategoryCount(parm).then(res=>{ if(res.code == 0){ this.setData({ tabList:res.data.filter(item=>item.categoryName =='党员'||item.categoryName =='关注人群' || item.categoryName =='特殊人群'||item.categoryName =='非健康人群'||item.categoryName =='居民') }) } }).catch(err=>{ console.log(err); }) }, toResiDetail(e){ // '1765976717767618562' console.log(e); wx.navigateTo({ url: `/subpages/searchResult/pages/punchCard/punchCard?resiId=${e.currentTarget.dataset.resiid}`, }) }, onFinish(e){ const selectedValues = e.detail.type console.log("123",selectedValues) this.setData({ cascaderValue:selectedValues, showAngenCascader: false }); let parm={ searchOrgIdPath:e.detail.value, searchKey:this.data.keyWord, pageSize:this.data.pageSize, pageNo:this.data.pageNo } getResidentBaseInfo(parm).then(res=>{ this.setData({ 'resiList':res.data.list }) }) }, onClose(){ this.setData({ showAngenCascader:false }) }, onSearchMessage(){ let parm ={ searchKey:this.data.keyWord, pageSize:this.data.pageSize, pageNo:this.data.pageNo } getResidentBaseInfo(parm).then(res=>{ console.log("11111",res); this.setData({ 'resiList':res.data.list }) console.log("123",this.resiList); }).catch(err=>{ console.log(err); }) }, onAllSearchMessage(){ let parm ={ searchKey:this.data.keyWord, pageSize:this.data.pageSize, pageNo:this.data.pageNo, category:this.data.category, searchOrgIdPath:this.data.searchOrgIdPath } getResidentBaseInfo(parm).then(res=>{ this.setData({ 'resiList':res.data.list }) }).catch(err=>{ console.log(err); }) }, onScrollToLower(e){ console.log("111"+e) if (this.data.loadMoreType === 'more') { this.setData({ loadMoreVisible: true, }) this.data.pageNo += 1 this.onAllSearchMessage() } }, onAllSearchMessage(){ this.setData({ // 加载更多为true loadMoreVisible: true, nodata: false, loadMoreType: "more", }) const parm={ searchKey:this.data.keyWord, pageSize:this.data.pageSize, pageNo:this.data.pageNo, category:this.data.category, searchOrgIdPath:this.data.searchOrgIdPat } getResidentBaseInfo(parm).then(res=>{ res.data.resiList = res.data.resiList.map(item => { if (item.createdByName && item.createdByName.length >= 3) { item.createdByName = item.createdByName.slice(1,3); } return item; }); this.setData({ loadMoreType: res.data.resiList.length === this.data.pageSize ? 'more' : 'none', resiList: this.data.resiList.concat(res.data.list), }) if(TouchList) console.log(resiList) if (this.data.resiList.length == 0) { this.setData({ loadMoreVisible: false, nodata: true }) } }).catch(err=>{ console.log(err); this.setData({ loadMoreVisible: false, nodata: true, }) }) }, })