var app = getApp();
const util = require('../../utils/utils.js')
Page({
  data: {
    detail: [],
    order_no: ''
  },
  onLoad: function (options) {
    console.log(options)
    my.showLoading({
      content: '加载中...',
      mask: true
    })
    app.request('/punishment_order?no=' + options.no, '', 'GET').then(res => {
      if (res.status == 200) {
        console.log(res)
        // this.data.detail = res.data
        this.setData({ detail: res.data, order_no: options.no })
      }
      my.hideLoading({
        complete: (res) => { },
      })
    })
  },
  pay: util.throttle(function () {
    var data = {
      no: this.data.order_no
    }
    app.request('/punishment_order/pay', data, 'POST').then(res => {
      if (res.status == 200) {
        console.log(res)
        my.tradePay({
          tradeNO: res.data.tradeNo,
          success(resp) {
            console.log(resp, 'zhifubao')
            if (resp.resultCode == 9000) {
              my.showToast({
                content: '支付成功',
                success: function () {
                  my.navigateBack()
                }
              })

            } else {
              return
            }
          },
          fail(err) {
            // console.log(err)
            // my.showToast({
            //   title: '支付失败',
            //   icon: 'none'
            // })
          }
        })
      }
    })
  }, 2000),
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  onShareAppMessage: function () {

  }
})