nantai-erp-wechat-mobile/driver/pages/record/record.js

120 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2024-10-31 21:29:57 +08:00
// driver/pages/record/record.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
isIPX: app.globalData.isIPX,
recordList: [],
currentPage: 1,
isLastPage: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getRecordList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
// 获取列表
getRecordList: function (page = 1) {
const url = `/mobile/list_delivery`
app.AppService.appRequest(url, 'POST', {
page: page,
page_len: app.globalData.pageLen,
}, (res) => {
const lastRecordList = this.data.recordList || []
let recordList = res.data.result || []
const len = recordList.length
// 不是第一页
if (page > 1) {
// 有下一页
if (len > 0) {
recordList = lastRecordList.concat(recordList)
this.setData({
isLastPage: false
})
} else {
recordList = lastRecordList
this.setData({
isLastPage: true
})
}
}
this.setData({
recordList,
currentPage: page,
})
})
},
// 滚动到底部获取更多
getMoreList: function () {
if (!this.data.isLastPage) {
this.getRecordList(this.data.currentPage + 1)
}
},
// 跳转页面
navigateTo: function (e) {
const url = e.currentTarget.dataset.url
wx.navigateTo({
url: url,
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: '南泰',
path: '/pages/login/login'
}
}
})