| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- // pages/payment-records/payment-records.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [], //支付明细列表
- pageNo: 1, //页码
- isLast: false, //是否为最后一页
- },
- /**
- * 获取支付明细列表
- * @pageNo {number} 页码
- * @pageSize {number} 页面条数
- */
- getList(pageNo = this.data.pageNo) {
- wx.kx_request({
- url: wx.kx_api.hwPaymentDetail.getHwPaymentDetailsList,
- data: {
- pageNo,
- pageSize: 10
- },
- success: res => {
- if (res.errcode === 0) {
- if (pageNo === 1 && res.data.hwPaymentDetailList && res.data.hwPaymentDetailList.length === 0) {
- this.setData({
- show: true,
- isLast: true
- })
- } else {
- pageNo++;
- this.setData({
- [`list[${pageNo - 2}]`]: res.data.hwPaymentDetailList,
- isLast: res.data.isLast,
- pageNo
- })
- }
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- // 获取支付明细列表
- this.setData({
- list: [],
- pageNo: 1,
- }, _ => {
- this.getList()
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- this.setData({
- list: [],
- pageNo: 1,
- }, _ => {
- this.getList()
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- const isLast = this.data.isLast;
- if (isLast) {
- // wx.showToast({
- // icon: 'none',
- // title: '已经是最后一页了',
- // })
- } else {
- this.getList()
- }
- }
- })
|