// subpages/house/pages/housePortrait/housePortrait.js import api from "../../../../utils/api" import { getComplainList, getShengList, getPunchRecord, getShequList, getshijianList, getxuqiuList, getfuwuList, getMultiLogList } from "../../../../utils/businessRecords.js"; Page({ /** * 页面的初始数据 */ data: { houseId: '', detail: {}, logs: [], residIds: [], ywData: {}, ywVisible: false, houseName:null }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ houseId: options.resiId, }) this.getData() }, getData() { api.getClearHouseDeatilById(this.data.houseId).then((res) => { this.setData({ detail: res.data, houseName: res.data.houseName }) }).catch((error) => { }); api.houseResidentChangeRecord({ houseId: this.data.houseId }).then((res) => { this.setData({ logs: res.data }) }).catch((error) => { console.error("发生错误:", error); }); api.getResiList({ homeId: this.data.houseId, pageNo: 1, pageSize: 1000 }).then(res => { const arr = res.data.list.map(item => { return item.resiId }) this.setData({ residIds: arr, }) this.getTabData() }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, gotopage({ currentTarget: { dataset } }) { const { url } = dataset wx.navigateTo({ url }) }, async getTabData() { if (this.data.residIds.length === 0) { this.setData({ ywVisible: true, ywData: { "12345": [], "provinceSurvey": [], "selfSurvey": [], "event": [], "need": [], "serve": [], "punchRecord": [] } }) return } let params1 = { "residList": this.data.residIds, "eventType": "3" } await getComplainList(params1).then(res => { this.data.ywData['12345'] = res.data.list.map(item => { return { ...item, categorycode: item.categorycode || '--', eventcontent: item.eventcontent || '--' } }); this.setData({ data: this.data.ywData }) }) let params = { "residList": this.data.residIds } await getShengList(params).then(res => { if (res.data && res.data.length > 0) { let renamedArray = []; res.data.forEach(item => { let renamedItem = { categorycode: item.scope || '--', eventcontent: item.problemDesc || '--' }; renamedArray.push(renamedItem); }); this.data.ywData['provinceSurvey'] = renamedArray; this.setData({ ywData: this.data.ywData }) } else { this.data.ywData['provinceSurvey'] = []; this.setData({ ywData: this.data.ywData }) } }) await getShequList(params).then(res => { if (res.data && res.data.length > 0) { let renamedArray = []; res.data.forEach(item => { let renamedItem = { categorycode: item.scope || '--', eventcontent: item.problemDesc || '--' }; renamedArray.push(renamedItem); }); this.data.ywData['selfSurvey'] = renamedArray; this.setData({ ywData: this.data.ywData }) } else { this.data.ywData['selfSurvey'] = []; this.setData({ ywData: this.data.ywData }) } }) await getshijianList(params).then(res => { if (res.data && res.data.length > 0) { let renamedArray = []; res.data.forEach(item => { let renamedItem = { categorycode: item.categorycode || '--', eventcontent: item.eventcontent || '--' }; renamedArray.push(renamedItem); }); this.data.ywData['event'] = renamedArray; this.setData({ ywData: this.data.ywData }) } else { this.data.ywData['event'] = []; this.setData({ ywData: this.data.ywData }) } }) await getxuqiuList(params).then(res => { if (res.data && res.data.length > 0) { let renamedArray = []; res.data.forEach(item => { let renamedItem = { categorycode: item.parentName || '--', eventcontent: item.content || '--' }; renamedArray.push(renamedItem); }); this.data.ywData['need'] = renamedArray; this.setData({ ywData: this.data.ywData }) } else { this.data.ywData['need'] = []; this.setData({ ywData: this.data.ywData }) } }) await getfuwuList(params).then(res => { if (res.data && res.data.length > 0) { let renamedArray = []; res.data.forEach(item => { let renamedItem = { categorycode: item.serviceCategoryKey || '--', eventcontent: item.serviceName || '--' }; renamedArray.push(renamedItem); }); this.data.ywData['serve'] = renamedArray; this.setData({ ywData: this.data.ywData }) } else { this.data.ywData['serve'] = []; this.setData({ ywData: this.data.ywData }) } }) const residIds = this.data.residIds.map(function(item) { return encodeURIComponent(item); }).join(','); const params2 = { "resiIdList": residIds, pageNo: 1, pageSize: 1000, } await getMultiLogList(params2).then(res => { if (res.data && res.data.length > 0) { let arr = []; res.data.forEach(item => { item.list.forEach(item1=>{ arr.push(item1) }) }) this.data.ywData['punchRecord'] = arr; this.setData({ ywData: this.data.ywData, }) } else { this.data.ywData['punchRecord'] = []; this.setData({ ywData: this.data.ywData }) } }) this.setData({ ywVisible: true }) }, })