// pages/trip/trip.js var app = getApp() const util = require('../../utils/utils.js') Page({ /** * 页面的初始数据 */ data: { orderList: [], pages: 1,//页码 links:'',//下一页地址 }, onLoad: function (options) { this.initial() }, initial: util.throttle(function (e) { var that = this; my.showLoading({ content: '加载中...', mask: true }) that.getOrder() }, 1000), //获取订单列表 getOrder: function () { let that = this let data = { page: that.data.pages } app.request('/orders', data, 'GET').then(res => { console.log(res) if (res.status == 200) { let arr=res.data.data var orderList =that.data.orderList.concat(arr); if(arr.length==0){ my.showToast({ content: '暂无更多~', icon:'none' }) }else{ that.setData({ orderList, links:res.data.meta.pagination.links }) } my.hideLoading({ complete: (res) => { }, }) } }).catch(err => { console.log(err) }) }, //跳转订单详情页面 tripDetail: function (e) { console.log(e, 'ppppppp') let status = e.currentTarget.dataset.index.status let order_no = e.currentTarget.dataset.index.no if (status == 2) { my.navigateTo({ url: '/pages/pay/pay?order=' + order_no, }) } else { my.navigateTo({ url: '/pages/trip_detail/trip_detail?order_no=' + order_no, }) } }, //下拉刷新 onReachBottom: function () { if(this.data.links==null){ my.showToast({ content: '暂无更多', icon:'none' }) return }else{ let page=this.data.pages++ page++ this.setData({ pages: page }) this.getOrder() } }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onShareAppMessage: function () { }, })