榆山数据端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

84 lines
2.0 KiB

import { getStatisticsByCategory } from '../../../../api/reality'
Page({
data: {
colorList: ['#FD8227', '#F19D0D', '#BD5FFE', '#29B9A5'],
attentionlist: [],
totalCount: 0,
categoryList: [
{ title: '一级类目', id: '1', select: true },
{ title: '二级类目', id: '2', select: false },
{ title: '三级类目', id: '3', select: false }
],
selectCategory: {
title: '一级类目',
id: '1'
},
categoryVisible: false,
deadline: '',
preloadVisible: true
},
onLoad () {
this.initLoad()
},
// 显示类目picker
showCategoryPicker () {
this.setData({
categoryVisible: !this.data.categoryVisible
})
},
// 改变类目
onChangeCategory (e: AnyObject) {
this.data.categoryList.forEach(item => {
if (item.id === e.currentTarget.dataset.id) {
item.select = true
this.setData({
'selectCategory.title': item.title,
'selectCategory.id': item.id
})
} else {
item.select = false
}
})
this.setData({
categoryList: this.data.categoryList
})
this.initLoad()
},
// 初始化加载
async initLoad () {
this.resetData()
const para = {
cotegoryType: this.data.selectCategory.id
}
try {
const res: any = await getStatisticsByCategory(para)
console.log('群众关注的问题', res)
res.data.list.forEach((item: any, index: number) => {
if (index === 0) {
this.data.totalCount = item.count * 1.2
}
})
this.setData({
attentionlist: res.data.list,
totalCount: this.data.totalCount,
deadline: res.data.deadline,
preloadVisible: false
})
} catch (err) {
this.resetData()
this.setData({
preloadVisible: false
})
console.log(err)
}
},
// 重置数据
resetData () {
this.setData({
attentionlist: [],
totalCount: 0,
preloadVisible: true
})
}
})