import { getUserSituationList } from '../../../../api/userNum' Page({ data: { loadType: 'none', loadVisible: false, orderType: 'asc', conditionList: [ { title: '按照注册用户排名', id: '1', select: true }, { title: '按照党员总数排名', id: '2', select: false }, { title: '按照大于50岁党员排名', id: '3', select: false }, { title: '按照小于50岁党员排名', id: '4', select: false } ], conditionVisible: false, choosedCondition: { title: '按照注册用户排名', id: '1' }, preloadVisible: true, userAnalysisList: [], pageNo: 1, pageSize: 10, deptId: '', deptName: '', streetTotalDetail: { userTotal: 0, partyNumber: 0, userNumber: 0, partyNumberRatio: 0, userNumberRatio: 0, companyRepresentTotal: 0, companyRepresentTotalRatio: 0 }, deadline: '' }, onLoad (options) { this.setData({ deptId: options.deptId, deptName: options.deptName }) this.initLoad() }, onReachBottom () { this.setData({ loadVisible: true }) if (this.data.loadType === 'more') { this.setData({ pageNo: this.data.pageNo + 1 }) this.initLoad() } }, navigateToDetail () { return false }, // 正序倒序切换 changeOrder () { let type = 'asc' if (this.data.orderType === 'asc') { type = 'desc' } else if (this.data.orderType === 'desc') { type = 'asc' } this.setData({ orderType: type, userAnalysisList: [], preloadVisible: true, loadType: 'none', loadVisible: false, pageNo: 1 }) this.initLoad() }, // 改变查询项 onChnageCondition (e: AnyObject) { const list = this.data.conditionList list.forEach(item => { if (item.id === e.currentTarget.dataset.id) { item.select = true this.setData({ 'choosedCondition.title': item.title, 'choosedCondition.id': item.id }) } else { item.select = false } }) this.setData({ conditionList: list, userAnalysisList: [], preloadVisible: true, loadType: 'none', loadVisible: false, pageNo: 1 }) this.initLoad() }, // 显示条件下拉框 showCondition () { this.setData({ conditionVisible: !this.data.conditionVisible }) }, // 加载列表 async initLoad () { let orderStyle = '2' if (this.data.orderType === 'asc') { orderStyle = '2' } else if (this.data.orderType === 'desc') { orderStyle = '1' } try { const para = { pageIndex: this.data.pageNo, pageSize: this.data.pageSize, deptId: this.data.deptId, deptType: '3', orderType: this.data.choosedCondition.id, orderStyle } const res: any = await getUserSituationList(para) console.log('用户分析,一级列表', res) const streetTotalDetail = this.data.streetTotalDetail for(const key in this.data.streetTotalDetail) { streetTotalDetail[key] = res.data.totalDTO[key] } this.setData({ userAnalysisList: this.data.userAnalysisList.concat(res.data.listDTO), preloadVisible: false, loadType: res.data.listDTO.length === 10 ? 'more' : 'none', streetTotalDetail: streetTotalDetail, deadline: res.data.deadline }) } catch (err) { console.log(err) this.setData({ userAnalysisList: [], preloadVisible: false, loadType: 'none' }) } } })