171 lines
3.4 KiB
JavaScript
171 lines
3.4 KiB
JavaScript
// packageH/AppointmentExtends/AppointmentExtends.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
page: 1, //分页数,当前页数
|
|
isLoadMore: true, //判断是否要加载更多的标志
|
|
total_page: 0, //总页数
|
|
listData: [],
|
|
networkLoading: false,
|
|
|
|
activeName:0,
|
|
|
|
details:{}
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getDetails();
|
|
this.getListData();
|
|
},
|
|
|
|
tabChange(evt){
|
|
this.setData({
|
|
activeName:evt.detail.index,
|
|
});
|
|
this.getListData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
getDetails(){
|
|
let urlStr = app.getNetAddresss("plugin.appointment.frontend.income.index");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
this.setData({details:res.data});
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if (this.data.isLoadMore) {
|
|
console.log("111111111111111");
|
|
this.getMoreData();
|
|
} else {
|
|
console.log('没有更多数据');
|
|
}
|
|
},
|
|
|
|
initPage() {
|
|
this.setData({
|
|
listData: [],
|
|
networkLoading: false
|
|
});
|
|
this.data.page = 1;
|
|
this.data.total_page = 0;
|
|
this.data.isLoadMore = true;
|
|
},
|
|
|
|
getListData() {
|
|
this.initPage();
|
|
let urlStr = app.getNetAddresss("plugin.appointment.frontend.income.get-list");
|
|
let json = {page:this.data.page,income_type:this.data.activeName};
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
this.setData({
|
|
isLoadMore: true,
|
|
total_page: res.data.last_page,
|
|
listData: res.data.data,
|
|
networkLoading: true
|
|
});
|
|
if (!this.data.total_page) {
|
|
this.data.total_page = 0;
|
|
}
|
|
|
|
}
|
|
});
|
|
},
|
|
//获取更多数据
|
|
getMoreData() {
|
|
let urlStr = app.getNetAddresss("plugin.appointment.frontend.income.get-list");
|
|
// 防止多次请求分页数据
|
|
this.data.isLoadMore = false;
|
|
if (this.data.page >= this.data.total_page) {
|
|
console.log("111111111111111", this.data.page, this.data.total_page);
|
|
return;
|
|
} else {
|
|
this.data.page++;
|
|
let json = {
|
|
page: this.data.page,
|
|
income_type:this.data.activeName
|
|
};
|
|
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data:json,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
|
|
if (res.result == 1) {
|
|
this.data.isLoadMore = true;
|
|
var myData = res.data.data;
|
|
this.setData({
|
|
listData: this.data.listData.concat(myData)
|
|
});
|
|
} else {
|
|
this.data.isLoadMore = false;
|
|
this.data.page--;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}); |