// pages/my_record/my_record.js const axios = require('../../api/index') Page({ /** * 页面的初始数据 */ data: { triggered: false, currentPage:1, pageSize:10, list_total:0, // 商品列表 showlist: [], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.get_list() }, // 上拉刷新 onScrolltolower() { let { list_total, showlist } = this.data; if (list_total == showlist.length) return this.setData({ currentPage: this.data.currentPage + 1, }, () => { this.get_list() }) }, // 下拉加载 onRefresh() { this.setData({ currentPage: 1, refresh: true, showlist: [] }, () => { this.get_list() }) // setTimeout(() => { // this.setData({ // triggered: false // }) // }, 1000) }, // 获取设备列表 get_list() { console.log(123) var data = { currentPage: this.data.currentPage, pageSize: this.data.pageSize } axios.getCollectionSearch(data).then(res => { console.log(res) var list_total = res.data.total var list = [...this.data.showlist, ...res.data.list] this.setData({ showlist: list, list_total, triggered: false }) }).catch(err => { console.log(err) }) // getEquipmentSearch }, onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ // onShareAppMessage: function () { // } })