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.
243 lines
5.5 KiB
243 lines
5.5 KiB
5 years ago
|
import {
|
||
|
getDailyRecordList
|
||
|
} from '../../../../api/myFootPrint'
|
||
|
import regeneratorRuntime from '../../../../utils/runtime.js'
|
||
|
import {
|
||
|
getWeekRecordList,
|
||
|
} from '../../../../api/weeklyIndex'
|
||
|
import {
|
||
|
getMonthRecordList
|
||
|
} from '../../../../api/monthlyReport'
|
||
|
Page({
|
||
|
data: {
|
||
|
loadVisible: true,
|
||
|
loadType: 'more',
|
||
|
isShow: false,
|
||
|
preloadVisible: true,
|
||
|
dailyRecordList: [], //我的足迹列表
|
||
|
datalength: 0,
|
||
|
index: 0,
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
tabs: [{
|
||
|
key: 'tab1',
|
||
|
title: 'Tab 1',
|
||
|
},
|
||
|
{
|
||
|
key: 'tab2',
|
||
|
title: 'Tab 2',
|
||
|
},
|
||
|
{
|
||
|
key: 'tab3',
|
||
|
title: 'Tab 3',
|
||
|
},
|
||
|
],
|
||
|
key: 'tab1',
|
||
|
isShowLoading: true, //true 正在加载中 false 可以切换
|
||
|
},
|
||
|
// tab切换
|
||
|
async onTabsChange(e) {
|
||
|
if (this.data.isShowLoading) {
|
||
|
wx.showToast({
|
||
|
title: '正在加载中请稍后切换', //提示的内容,
|
||
|
icon: 'none', //图标,
|
||
|
duration: 2000, //延迟时间,
|
||
|
mask: true, //显示透明蒙层,防止触摸穿透,
|
||
|
});
|
||
|
return
|
||
|
}
|
||
|
console.log('e', e)
|
||
|
const {
|
||
|
key
|
||
|
} = e.detail
|
||
|
const index = this.data.tabs.map((n) => n.key).indexOf(key)
|
||
|
this.setData({
|
||
|
key,
|
||
|
index,
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
loadVisible: true,
|
||
|
loadType: 'more',
|
||
|
dailyRecordList: []
|
||
|
})
|
||
|
console.log('loadVisible', this.data.loadVisible)
|
||
|
if (this.data.key == 'tab1') {
|
||
|
await this.getList()
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
await this.getWeekRecordList()
|
||
|
} else if (this.data.key == 'tab3') {
|
||
|
await this.getMonthRecordList()
|
||
|
}
|
||
|
// this.setData({
|
||
|
// loadVisible:false
|
||
|
// })
|
||
|
},
|
||
|
onLoad: function (options) {
|
||
|
this.getList()
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 我的足迹列表
|
||
|
*/
|
||
|
async getList() {
|
||
|
let that = this;
|
||
|
that.setData({
|
||
|
loadVisible: true,
|
||
|
loadType: 'more',
|
||
|
isShowLoading: true,
|
||
|
})
|
||
|
let params = {
|
||
|
pageIndex: that.data.pageIndex,
|
||
|
pageSize: that.data.pageSize
|
||
|
}
|
||
|
try {
|
||
|
let res = await getDailyRecordList(params)
|
||
|
if (this.data.pageIndex == 1) {
|
||
|
if (res.data.length > 0) {
|
||
|
that.setData({
|
||
|
datalength: res.data.length,
|
||
|
dailyRecordList: res.data,
|
||
|
preloadVisible: false,
|
||
|
loadType: 'none',
|
||
|
isShow: false,
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
} else {
|
||
|
that.setData({
|
||
|
dailyRecordList: [],
|
||
|
preloadVisible: false,
|
||
|
loadVisible: false,
|
||
|
loadType: 'none',
|
||
|
isShow: true,
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
}
|
||
|
} else if (this.data.pageIndex > 1) {
|
||
|
if (res.data.length > 0) {
|
||
|
that.setData({
|
||
|
datalength: res.data.length,
|
||
|
dailyRecordList: that.data.dailyRecordList.concat(res.data),
|
||
|
preloadVisible: false,
|
||
|
loadType: 'none',
|
||
|
isShow: false,
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
} else {
|
||
|
that.setData({
|
||
|
preloadVisible: false,
|
||
|
loadType: 'none',
|
||
|
loadVisible: true,
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} catch (err) {
|
||
|
that.setData({
|
||
|
dailyRecordList: [],
|
||
|
preloadVisible: false,
|
||
|
loadVisible: false,
|
||
|
loadType: 'none',
|
||
|
isShow: true,
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
// 周报列表--
|
||
|
async getWeekRecordList() {
|
||
|
this.setData({
|
||
|
isShowLoading: true
|
||
|
})
|
||
|
let obj = {
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize
|
||
|
}
|
||
|
let {
|
||
|
data
|
||
|
} = await getWeekRecordList(obj)
|
||
|
if (this.data.pageIndex == 1) {
|
||
|
this.setData({
|
||
|
dailyRecordList: []
|
||
|
})
|
||
|
}
|
||
|
this.setData({
|
||
|
dailyRecordList: this.data.dailyRecordList.concat(data),
|
||
|
datalength: data.length,
|
||
|
loadType: 'none',
|
||
|
isShowLoading: false
|
||
|
})
|
||
|
console.log('data周报列表', data)
|
||
|
},
|
||
|
// 月报列表
|
||
|
async getMonthRecordList() {
|
||
|
this.setData({
|
||
|
isShowLoading: true
|
||
|
})
|
||
|
let obj = {
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize
|
||
|
}
|
||
|
try {
|
||
|
let {
|
||
|
data
|
||
|
} = await getMonthRecordList(obj)
|
||
|
if (this.data.pageIndex == 1) {
|
||
|
this.setData({
|
||
|
dailyRecordList: []
|
||
|
})
|
||
|
}
|
||
|
this.setData({
|
||
|
dailyRecordList: this.data.dailyRecordList.concat(data),
|
||
|
datalength: data.length,
|
||
|
loadType:'none',
|
||
|
isShowLoading:false
|
||
|
})
|
||
|
console.log('月报列表', data)
|
||
|
} catch (err) {
|
||
|
|
||
|
}
|
||
|
},
|
||
|
onReachBottom() {
|
||
|
// 判断是否需要在加载数据
|
||
|
if (this.data.datalength !== this.data.pageSize) {
|
||
|
this.setData({
|
||
|
loadType: 'none',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
this.setData({
|
||
|
loadType: 'more',
|
||
|
})
|
||
|
|
||
|
|
||
|
if (this.data.loadType === 'more') {
|
||
|
this.setData({
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
if (this.data.key == 'tab1') {
|
||
|
this.getList();
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
this.getWeekRecordList()
|
||
|
}else if(this.data.key == 'tab3'){
|
||
|
this.getMonthRecordList()
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
async onPullDownRefresh() {
|
||
|
this.setData({
|
||
|
pageIndex: 1,
|
||
|
// loadVisible: false,
|
||
|
})
|
||
|
if (this.data.key == 'tab1') {
|
||
|
await this.getList()
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
await this.getWeekRecordList()
|
||
|
} else if (this.data.key == 'tab3') {
|
||
|
await this.getMonthRecordList()
|
||
|
}
|
||
|
wx.stopPullDownRefresh();
|
||
|
},
|
||
|
|
||
|
})
|