import { getStreetList, getOfficerEvaTop10 } from '../../../../api/leaderComment' Page({ data: { isClick: 'good',//默认解决中 orderType: '1',//1点赞最多 2吐槽最多 showTimePicker: false, showAllPicker: false, someMonthsType: 1, timeList: [ { time: '最近一个月', id: 1 }, { time: '最近三个月', id: 2 }, { time: '最近六个月', id: 3 }, { time: '最近一年', id: 4 }], streetName: '全部街道', streeList: [ { deptId: '', deptName: '全部街道' }, ], deptId: '', ListTop10: [], loadVisible: false, loadType: 'more', isShow:false, isShowLoading: true, //true 正在加载中 false 可以切换 }, async onLoad() { await this.getStreetList() await this.getOfficerEvaTop10() }, // 页面切换 triggle(e: any) { if (this.data.isShowLoading) { wx.showToast({ title: '正在加载中请稍后切换', //提示的内容, icon: 'none', //图标, duration: 2000, //延迟时间, mask: true, //显示透明蒙层,防止触摸穿透, }); return } this.setData({ ListTop10: [], showTimePicker:false,//关闭时间选择器 showAllPicker:false, }) let { currentTarget } = e if (currentTarget.dataset.index == "吐槽最多") { this.setData({ isClick: 'bad', orderType: '2' }) this.getOfficerEvaTop10() } else if (currentTarget.dataset.index == "获赞最多") { this.setData({ isClick: 'good', orderType: '1' }) this.getOfficerEvaTop10() } }, // 显示隐藏时间选择框 chooseTimePicker() { if (this.data.isShowLoading) { wx.showToast({ title: '正在加载中请稍后切换', //提示的内容, icon: 'none', //图标, duration: 2000, //延迟时间, mask: true, //显示透明蒙层,防止触摸穿透, }); return } this.setData({ showTimePicker: !this.data.showTimePicker, showAllPicker:false, }) }, // 选择时间 onTimeChange(e: any) { this.setData({ someMonthsType: e.currentTarget.dataset.time, showTimePicker: false, ListTop10:[] }) this.getOfficerEvaTop10() }, // 街道下拉框 chooseAll() { if (this.data.isShowLoading) { wx.showToast({ title: '正在加载中请稍后切换', //提示的内容, icon: 'none', //图标, duration: 2000, //延迟时间, mask: true, //显示透明蒙层,防止触摸穿透, }); return } this.setData({ showAllPicker: !this.data.showAllPicker, showTimePicker:false }) }, // 选择时间 AllStreeChange(e: any) { this.setData({ deptId: e.currentTarget.dataset.time, showAllPicker: false, streetName: e.currentTarget.dataset.name, ListTop10:[], }) this.getOfficerEvaTop10() }, async getStreetList() { this.setData({ loadVisible:true }) try{ let res: any = await getStreetList() console.log(res) this.setData({ streeList: this.data.streeList.concat(res.data), loadVisible:false }) }catch{ this.setData({ loadVisible: false }) } }, async getOfficerEvaTop10() { this.setData({ loadVisible: true, isShow:false, isShowLoading: true, }) let obj = { deptId: this.data.deptId, orderType: this.data.orderType, someMonthsType: this.data.someMonthsType } try { let res: any = await getOfficerEvaTop10(obj) this.setData({ ListTop10: res.data, loadVisible: false, isShowLoading: false }) if(this.data.ListTop10.length==0){ this.setData({ isShow:true, isShowLoading: false }) } } catch{ this.setData({ loadVisible: false, isShowLoading: false }) } } })