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.
99 lines
2.2 KiB
99 lines
2.2 KiB
5 years ago
|
import { getEndByselfList } from '../../../../api/reality'
|
||
|
|
||
|
Page({
|
||
|
data: {
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
total: 0,
|
||
|
itemList: [],
|
||
|
timeList: [
|
||
|
{time: '最近一个月', id: '1', select: true },
|
||
|
{time: '最近三个月', id: '2', select: false },
|
||
|
{time: '最近六个月', id: '3', select: false },
|
||
|
{time: '最近一年', id: '4', select: false}
|
||
|
],
|
||
|
timePickerVisible: false,
|
||
|
choosedTime: {
|
||
|
time: '最近一个月',
|
||
|
id: '1'
|
||
|
},
|
||
|
loadType: 'none',
|
||
|
loadVisible: false,
|
||
|
preloadVsible: true
|
||
|
},
|
||
|
onLoad() {
|
||
|
this.getEndByselfList()
|
||
|
},
|
||
|
onReachBottom () {
|
||
|
this.loadmore()
|
||
|
},
|
||
|
loadmore() {
|
||
|
this.setData({
|
||
|
loadVisible: true
|
||
|
})
|
||
|
if (this.data.loadType === 'more') {
|
||
|
this.setData({
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
this.getEndByselfList()
|
||
|
}
|
||
|
},
|
||
|
// 点击显示 timepicker
|
||
|
onChangeTimePicker () {
|
||
|
this.setData({
|
||
|
timePickerVisible: !this.data.timePickerVisible
|
||
|
})
|
||
|
},
|
||
|
// 选择时间范围
|
||
|
onChooseTime (e: AnyObject) {
|
||
|
const list = this.data.timeList
|
||
|
list.forEach(item => {
|
||
|
if (item.id === e.currentTarget.dataset.id) {
|
||
|
item.select = true
|
||
|
this.setData({
|
||
|
'choosedTime.time': item.time,
|
||
|
'choosedTime.id': item.id
|
||
|
})
|
||
|
} else {
|
||
|
item.select = false
|
||
|
}
|
||
|
})
|
||
|
this.setData({
|
||
|
timeList: list,
|
||
|
pageIndex: 1,
|
||
|
itemList: [],
|
||
|
loadVisible: false,
|
||
|
preloadVsible: true
|
||
|
})
|
||
|
this.getEndByselfList()
|
||
|
},
|
||
|
// 获取列表
|
||
|
getEndByselfList() {
|
||
|
let params = {
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize,
|
||
|
someMonthsType: this.data.choosedTime.id,
|
||
|
deptId: ''
|
||
|
}
|
||
|
getEndByselfList(params).then( (res: any) => {
|
||
|
this.setData({
|
||
|
total: res.data.total,
|
||
|
itemList: this.data.itemList.concat(res.data.list),
|
||
|
loadType: res.data.list.length === 10 ? 'more' : 'none',
|
||
|
preloadVsible: false
|
||
|
})
|
||
|
}).catch((err: any) => {
|
||
|
console.log(err)
|
||
|
this.setData({
|
||
|
preloadVsible: false
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
onTapDetail(){
|
||
|
console.log('tap')
|
||
|
this.setData({
|
||
|
timePickerVisible: false
|
||
|
})
|
||
|
}
|
||
|
})
|