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.
101 lines
2.2 KiB
101 lines
2.2 KiB
import { getCaseList } from '../../api/index'
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
// 此页面 页面内容距最顶部的距离
|
|
height: app.globalData.navHeight,
|
|
page: 1,
|
|
pageNum: 10,
|
|
caseList: [],
|
|
isShow: false,
|
|
loadVisible: false,
|
|
loadType: 'more',
|
|
dataLength: 0
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function () {
|
|
this.getStartCaseList()
|
|
},
|
|
/****获取最初的数据 ******/
|
|
getStartCaseList() {
|
|
this.setData({
|
|
loadVisible: true
|
|
})
|
|
let obj = {
|
|
pageIndex: this.data.page,
|
|
pageSize: this.data.pageNum
|
|
}
|
|
getCaseList(obj).then((res: any) => {
|
|
this.setData({
|
|
caseList: res.data,
|
|
loadVisible: false,
|
|
isShow: true,
|
|
dataLength: res.data.length
|
|
})
|
|
if (this.data.dataLength < this.data.pageNum) {
|
|
// 说明没有更多的数据了
|
|
this.setData({
|
|
loadVisible: true,
|
|
loadType: 'none',
|
|
isShow: false,
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
loadVisible: false
|
|
})
|
|
})
|
|
},
|
|
/****上拉获取分页数据 ******/
|
|
getBottomCaseList() {
|
|
this.setData({
|
|
loadVisible: true,
|
|
loadType: 'more'
|
|
})
|
|
this.setData({
|
|
page: ++this.data.page,
|
|
})
|
|
let obj = {
|
|
pageIndex: this.data.page,
|
|
pageSize: this.data.pageNum
|
|
}
|
|
getCaseList(obj).then((res: any) => {
|
|
this.setData({
|
|
caseList: this.data.caseList.concat(res.data),
|
|
dataLength: res.data.length
|
|
})
|
|
if (this.data.dataLength < this.data.pageNum) {
|
|
// 说明没有更多的数据了
|
|
this.setData({
|
|
loadVisible: true,
|
|
loadType: 'none',
|
|
isShow: false,
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
loadVisible: false
|
|
})
|
|
})
|
|
|
|
},
|
|
goTypical(e: any) {
|
|
wx.navigateTo({ url: `/pages/typicalCases/typicalCases?id=${e.currentTarget.dataset.id}` });
|
|
},
|
|
onReachBottom() {
|
|
if (this.data.dataLength < this.data.pageNum) {
|
|
return
|
|
}
|
|
this.getBottomCaseList()
|
|
console.log('到底部了')
|
|
}
|
|
})
|