This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/pages/points/log/index.js

83 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-25 22:59:04 +08:00
const App = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
list: [], // 充值记录
isLoading: true, // 是否正在加载中
page: 1, // 当前页码
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let _this = this;
// 设置列表容器高度
_this.setListHeight();
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let _this = this;
// 获取积分明细列表
_this.getPointsLog();
},
/**
* 获取积分明细列表
*/
getPointsLog(isPage, page) {
let _this = this;
App._get('points.log/index', {
page: page || 1
}, result => {
let resList = result.data.list,
dataList = _this.data.list;
if (isPage == true) {
_this.setData({
'list.data': dataList.data.concat(resList.data),
isLoading: false,
});
} else {
_this.setData({
list: resList,
isLoading: false,
});
}
});
},
/**
* 设置列表容器高度
*/
setListHeight() {
let _this = this,
systemInfo = wx.getSystemInfoSync();
_this.setData({
scrollHeight: systemInfo.windowHeight * 0.98
});
},
/**
* 下拉到底加载数据
*/
onPageDown() {
let _this = this;
// 已经是最后一页
if (_this.data.page >= _this.data.list.last_page) {
_this.setData({
no_more: true
});
return false;
}
// 加载下一页列表
_this.getPointsLog(true, ++_this.data.page);
},
})