85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
|
// pages/mine/income/incomelist.js
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
curPage: 1,
|
||
|
isRefreshing: false, //是否在刷新中
|
||
|
hasMore: true, //是否有更多数据
|
||
|
isLoadMore: false, //是否正在加载更多
|
||
|
recordList: []
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.getList()
|
||
|
},
|
||
|
getList() {
|
||
|
var _self = this
|
||
|
wx.showLoading({
|
||
|
title: '加载中...',
|
||
|
})
|
||
|
app.http.get(app.urls.getIncomeList, {
|
||
|
header: {
|
||
|
token: app.globalData.token
|
||
|
},
|
||
|
data: {
|
||
|
page: _self.data.curPage,
|
||
|
rows: '10'
|
||
|
}
|
||
|
})
|
||
|
.then(res => {
|
||
|
wx.stopPullDownRefresh({})
|
||
|
wx.hideLoading({})
|
||
|
_self.data.recordList = _self.data.recordList.concat(res.data.rows)
|
||
|
var more = _self.data.recordList.length < res.data.total
|
||
|
_self.setData({
|
||
|
recordList: _self.data.recordList,
|
||
|
isRefreshing: false,
|
||
|
isLoadMore: false,
|
||
|
hasMore: more
|
||
|
})
|
||
|
})
|
||
|
.catch(err => {
|
||
|
wx.stopPullDownRefresh({})
|
||
|
_self.setData({
|
||
|
isRefreshing: false,
|
||
|
isLoadMore: false,
|
||
|
hasMore: true
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
//加载更多
|
||
|
doLoadMore() {
|
||
|
var _self = this
|
||
|
if (_self.data.hasMore) {
|
||
|
if (_self.data.isLoadMore) {
|
||
|
return
|
||
|
}
|
||
|
this.setData({
|
||
|
isLoadMore: true,
|
||
|
curPage: ++_self.data.curPage
|
||
|
})
|
||
|
this.getList()
|
||
|
}
|
||
|
},
|
||
|
onReachBottom() {
|
||
|
this.doLoadMore()
|
||
|
},
|
||
|
//下拉刷新
|
||
|
onPullDownRefresh() {
|
||
|
this.setData({
|
||
|
isLoadMore: false,
|
||
|
isRefreshing: true,
|
||
|
hasMore: true,
|
||
|
recordList: [],
|
||
|
curPage: 1
|
||
|
})
|
||
|
this.getList()
|
||
|
}
|
||
|
})
|