let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tagID: 0,
    details: {},
    tagBoxActive: 0,
    tagName: '',
    tagList: [
      {
        id: 1,
        name: '跟团游',
        Class: 'tuan'
      },
      {
        id: 2,
        name: '自由行',
        Class: 'ziyou'
      },
      {
        id: 3,
        name: '当地游',
        Class: 'dangdi'
      },
      {
        id: 4,
        name: '机票',
        Class: 'jipiao'
      },
      {
        id: 5,
        name: '签证',
        Class: 'qianzheng'
      },
      {
        id: 6,
        name: '门票',
        Class: 'menpiao'
      },
      {
        id: 7,
        name: '定制游',
        Class: 'dingzhi'
      },
      {
        id: 8,
        name: '美食',
        Class: 'meishi'
      },
    ],
  },
  getDetailse: function (url, orderId, index) {
    console.log(index)
    let msg = {
      orderType: index,
      orderId: orderId
    }
    app.$apiJavaNew(url, msg).then(res => { 
      this.setData({
        details: res
      })
    }).catch(err => { })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let _this = this;
    let index = Number(options.tagIndex);
    let url = ''; 
    if (index == 4){  // 机票
      url = 'api/b2b/user/getAirTicketOrderDetail'
      _this.getDetailse(url, options.orderId, index)
    } else if (index == 5){ //签证
      url = 'api/b2b/visa/getVisaOrderDetail'
      _this.getDetailse(url, options.orderId, index)
    } else if (index == 6) {  // 门票
      url = 'api/b2b/scenic/getTicketCouponsOrderDetail'
      _this.getDetailse(url, options.orderId, index)
    } else if (index == 8) {  // 美食  读取缓存数据
    console.log('美食1')
      wx.getStorage({
        key: 'DetailsItem',
        success: function (res) {
          _this.setData({
            details: res.data,
          })
        },
      })
    } else {
      // 1：跟团游 2：自由行 3：当地游 7: 定制游
      url = 'api/b2b/user/getrecentOrderDetail'
      _this.getDetailse(url, options.orderId, index)
    }
    console.log(index,"荷藕")
    _this.setData({
      tagBoxActive: index -1,
      tagName: _this.data.tagList[index - 1].name
    })
    wx.setNavigationBarTitle({
      title: '订单详情'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})