123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- // 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 () {
- },
- })
|