const util = require('../../../utils/utils.js');
var app = getApp()
Page({
  data: {
    code:'',
    rent:0,
    img:app.globalData.imgUrl
  },
  onLoad: function (options) {
    console.log(options)
    wx.setNavigationBarTitle({
      title: app.globalData.title 
    })
    if(options.order){
      this.setData({ code: options.order,rent:options.rent })
      wx.setNavigationBarTitle({
        title: '订单支付',
      })
    }else{
      wx.setNavigationBarTitle({
        title: '余额充值',
      })
    }
  },
  scancode: util.throttle(function (e) {
    wx.scanCode({
      onlyFromCamera: true,
      success: function (res) {
        console.log(res)
        var index = res.result.lastIndexOf("\=");
        var code = res.result.substring(index + 1, res.path.length);
        wx.navigateTo({
          url: '/pages/sweep_code/sweep_code?code=' + code,
        })
      }, fail: function (err) {
        wx.showToast({
          title: '扫码失败',
          icon: 'none'
        })
      }
    })
  },1000),
  money: util.throttle(function (e) {
    wx.navigateTo({
      url: '/pages/personal/wallet/wallet',
    })
  },1000),
  home: util.throttle(function (e) {
    if(app.globalData.compatible){
      wx.reLaunch({
        url: '/pages/compatible/index/index',
      })
    }else{
      wx.reLaunch({
        url: '/pages/index/index',
      })
    }
  },1000),
  detail: util.throttle(function (e) {
    wx.navigateTo({
      url: '/pages/my_riding/my_riding?order='+this.data.code+'&index='+this.data.rent,
    })
  },1000),
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  onShareAppMessage: function () {
    
  }
})