154 lines
3.0 KiB
JavaScript
154 lines
3.0 KiB
JavaScript
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
keyword: "",
|
|
isLoadMore: true,
|
|
total_page: 0,
|
|
page: 1,
|
|
list: []
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getData();
|
|
},
|
|
onSearch(){
|
|
this.getData();
|
|
},
|
|
getData() {
|
|
let urlStr = app.getNetAddresss("plugin.diy-form-prove.frontend.controllers.prove.formDataLg");
|
|
urlStr += "&page=" + 1;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result == 1) {
|
|
this.data.total_page = res.data.list.last_page;
|
|
this.data.page = 1;
|
|
this.data.isLoadMore = true;
|
|
this.setData({
|
|
list: res.data.list.data
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1000,
|
|
});
|
|
}
|
|
},
|
|
fail: (res) => {
|
|
console.log(res);
|
|
},
|
|
});
|
|
|
|
},
|
|
// 获取更多数据
|
|
getMoreData() {
|
|
if (this.data.page >= this.data.total_page) {
|
|
this.setData({
|
|
isLoadMore: false
|
|
});
|
|
return;
|
|
}
|
|
if (!this.data.isLoadMore) {
|
|
return;
|
|
}
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
this.data.page = this.data.page + 1;
|
|
this.data.isLoadMore = false;
|
|
let urlStr = app.getNetAddresss("plugin.diy-form-prove.frontend.controllers.prove.formDataLg");
|
|
urlStr += "&page=" + this.data.page;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading();
|
|
this.data.isLoadMore = true;
|
|
if (res.result == 1) {
|
|
let nextarr = res.data.list.data;
|
|
this.setData({
|
|
list: this.data.list.concat(nextarr)
|
|
});
|
|
} else {
|
|
this.setData({
|
|
page: this.data.page - 1
|
|
});
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
changeKeyword(e) {
|
|
this.setData({
|
|
keyword: e.detail,
|
|
});
|
|
},
|
|
toUrl(e){
|
|
let _id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({url: '/packageI/diyRormProve/diyRormProveDetail/diyRormProveDetail?id=' + _id });
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getMoreData();
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}); |