// pages/resiAndHouse/resiAndHouse.js import api, { getAllOrgCategoryCount, getResidentBaseInfo, getCommunityHouse } from "../../utils/api" const App = getApp() Page({ /** * 页面的初始数据 */ data: { activeType: 0, tabList: [], tableData: [], resiList: [{ name: '', resiTags: [''], nationalityName: '', nationName: '', mobile: '', idNum: '', agencyName: '', homeName: '', updatedTime: '' } ], pageNo: 1, pageSize: 10, lowerThreshold: '10', loadMoreVisible: false, loadMoreType: "none", nodata:false, selectVale: 'resi', keyWord: '', angencyId: null, category: null, searchOrgIdPath: '', angencyList: [], //组织树 showAngenCascader: false, agencyName:'', fieldName: { text: 'agencyName', value: 'agencyId', children: 'subAgencyList' } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ searchOrgIdPath: App.globalData.user.agencyId, cascaderName: App.globalData.user.agencyName, agencyName: App.globalData.user.agencyName }) this.getAgencygridtree() this.getAllOrgCategoryCount() this.getTableData() }, // /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ 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, category: e.currentTarget.dataset.category, tableData:[] }) this.getTableData() }, handelBlurKeyWord(e) { this.setData({ keyWord: e.detail.value }) }, handelClickSearchType(e) { this.setData({ selectVale: e.currentTarget.dataset.type }) }, handelClickShowTree() { this.setData({ showAngenCascader: true }) }, // 组织树 getAgencygridtree() { api.getAgencygridtree().then(res => { this.setData({ angencyList: [res.data], }) }).catch(err => { console.log(err); }) }, async handelClickSearch() { this.setData({ pageNo:1, tableData:[] }) this.getAllOrgCategoryCount() this.getTableData() }, handelClickToOcr() { wx.navigateTo({ url: '/subpages/OCRCard/pages/index/index', }) }, // 获取居民概览 getAllOrgCategoryCount() { let parm = { residentInfo: this.data.keyWord, agencyId:App.globalData.user.agencyId, orgId: this.data.searchOrgIdPath, level: 'agency' } api.getAllOrgCategoryCount(parm).then(res => { if (res.code == 0) { res.data.forEach(item => { if (item.categoryName === '党员') { item.category = 'party' } else if (item.categoryName === '关注人群') { item.category = 'attention' } else if (item.categoryName === '特殊人群') { item.category = 'special' } else if (item.categoryName === '非健康人群') { item.category = 'health' } }) this.setData({ tabList: res.data.filter(item => item.categoryName == '党员' || item.categoryName == '关注人群' || item.categoryName == '特殊人群' || item.categoryName == '非健康人群' || item.categoryName == '居民').reverse() }) } }).catch(err => { console.log(err); }) }, toResiDetail(e) { // '1765976717767618562' console.log(e); wx.navigateTo({ url: `/subpages/searchResult/pages/resiInfo/resiInfo?resiId=${e.currentTarget.dataset.resiid}`, }) }, onFinish(e) { this.setData({ pageNo: 1, searchOrgIdPath:e.detail.selectedOptions[e.detail.selectedOptions.length-1].agencyId, cascaderName:e.detail.selectedOptions.map(item=>item.agencyName).join(','), tableData:[] }) this.getAllOrgCategoryCount() this.getTableData() }, onClose() { this.setData({ showAngenCascader: false }) }, onScrollToLower(e) { if (this.data.loadMoreType === 'more') { this.setData({ loadMoreVisible: true, }) this.data.pageNo += 1 this.getTableData() } }, getTableData: async function() { try{ this.setData({ loadMoreVisible: true, nodata: false, loadMoreType: "more", }) let parm = { searchKey: this.data.keyWord, pageSize: this.data.pageSize, pageNo: this.data.pageNo, category:this.data.category, searchOrgIdPath:this.data.searchOrgIdPath } let { data, code, msg } = await getResidentBaseInfo(parm) if (code == 0) { 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, loadMoreType:'none' }) } } catch(err) { console.log(err); this.setData({ loadMoreVisible: false, nodata: true, loadMoreType:'none' }) } }, })