100 lines
1.8 KiB
JavaScript
100 lines
1.8 KiB
JavaScript
// pages/miss/miss.js
|
||
const api = require("../../utils/request.js");
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
query:{
|
||
a:'listall',
|
||
page:1,
|
||
rows:10
|
||
},
|
||
wslist:[]
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad: function (options) {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow: function () {
|
||
var that = this;
|
||
that.onPullDownRefresh();
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh: function () {
|
||
var that = this;
|
||
this.data.query.page = 1;
|
||
that.getWslist();
|
||
wx.stopPullDownRefresh();
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom: function () {
|
||
//上拉分页,将页码加1,然后调用分页函数
|
||
var that = this
|
||
if (that.data.total <= that.data.query.page * that.data.query.rows) {
|
||
wx.showToast({
|
||
title: '没有更多了',
|
||
icon: 'none'
|
||
})
|
||
} else {
|
||
that.data.query.page = that.data.query.page + 1
|
||
that.getWslist()
|
||
}
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage: function () {
|
||
|
||
},
|
||
getWslist: function () {
|
||
var that = this
|
||
api.request('api/miss', 'GET', that.data.query).then(res => {
|
||
if (that.data.query.page == 1) {
|
||
that.data.wslist = res.rows
|
||
} else {
|
||
that.data.wslist = that.data.wslist.concat(res.rows)
|
||
}
|
||
that.setData({
|
||
wslist: that.data.wslist,
|
||
total: res.total
|
||
})
|
||
})
|
||
},
|
||
}) |