var app = getApp()
Page({
  data: {
    arr:[],
    arr1:[],
    page:1,
    show:false,
    img:app.globalData.imgUrl,
    setting:{}
  },
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载中...',
      mask:true
    })
    this.setData({
      setting: wx.getStorageSync('setting')
    })
    app.request("/card_riding/user_history_orders", '', "GET").then(res => {
      console.log(res)
      wx.hideLoading({
        complete: (res) => {},
      })
      if (res.data.data == '') {
        return;
      }
      that.setData({ arr: res.data.data })
    }).catch(err => {
      console.log(err)
    })
  },
  show(){
    this.setData({show:true})
  },
  hide() {
    this.setData({ show: false })
  },
  onReady: function () {

  },
  onShow: function () {
    var that = this;
    app.request("/card_riding/user_card", '', "GET").then(res => {
      console.log(res)
      if (res.data.user_card == '') {
        return;
      }
      that.setData({ arr1: res.data.user_card })
    }).catch(err => {
      console.log(err)
    })
  },
  goBuy(){
    wx.navigateTo({
      url: '/pages/recharge/recharge',
    })
  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {
    console.log('1')
    var that = this;
    var page = that.data.page+1;

    app.request("/card_riding/user_history_orders?page="+page, '', "GET").then(res => {
      console.log(res)
      if (res.data.data == '') {
        wx.showToast({
          title: '没有更多了',
          icon:'none'
        })
        return;
      }
      that.setData({ arr: that.data.arr.concat(res.data.data),page })
    }).catch(err => {
      console.log(err)
    })
  },
  onShareAppMessage: function () {
    
  }
})