
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
      order_id:0,
      id:'',
      show: false,
      statusType: ["拼团"],
      status:[ "0"],
      currentType: 0,
      nav_type:0,
      height:''
    },
    statusTap: function (e) {
      var curType = e.currentTarget.dataset.index;
      this.setData({
          currentType: curType,
          nav_type:curType
      });
      
      app.console("================="+curType)
  },
    onClickShow() {
      this.setData({ show: true });
    },
  
    onClickHide() {
      this.setData({ show: false });
    },
    onClickLeft() {
        wx.navigateBack()
      },
    noop() {},
    //返回首页
    index(){
        wx.switchTab({
          url: '/pages/index/index',
        })
    },
    //订单详情
       godetail(){
        wx.navigateTo({
          url: '/pages/orderdetail/orderdetail?'+"type="+'3'+ '&id=' +this.data.order_id,
        })
    },
      //条目点击跳转
      itemgodetail(e){
        wx.navigateTo({
          url: "/shopping/pages/goddess/goddess?id=" + e.currentTarget.dataset.id,
      });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
        app.console(statusBarHeight+"=================xxxxxxxxxxxxxxxxxxxxxxxx")
        this.setData({
            statusBarHeight: statusBarHeight,
            height: 46 + statusBarHeight,
        });
        app.console(this.data.height+"=================xxxxxxxxxxxxxxxxxxxxxxxx")
      this.setData({
        order_id:options.order_id
      })
      this.paySuccess()
    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    },
    //支付成功
    paySuccess: function () {
    var that = this;
    wx.request({
        url: app.buildUrl("/app/Goddesswechat/paySuccess"),
        header: app.getRequestHeader(),
        method:'POST',
        data: {
          version_number: this.data.version_number,
          uid:wx.getStorageSync('uid'),
          token:wx.getStorageSync('token'),
          order_id:this.data.order_id
        },
        success: function (res) {
            var resp = res.data;
            console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
            if(resp.erro==0){
              that.setData({
                tg_kj_status:resp.goods_infor.tg_kj_status,
                id:resp.goods_infor.id,
                goods_infor:resp.goods_infor,
                goods:resp.goods
             });
             app.console(that.data.tg_kj_status+"=================状态值")
             if(that.data.tg_kj_status==1){
               wx.showToast({ title: '弹出拼团弹框', icon: 'none' });
              this.setData({ show: true });
             }
            }
        }
    });
  },
  /**
   * 跳过
   */
  tiaoguo(){
    this.setData({ show: false });
  },
  /**
   * 同意发起
   */
  tongyifaqi(){
  this.confirmCollage()
  },
   //确认发起团购/砍价
   confirmCollage: function () {
    var that = this;
    wx.request({
        url: app.buildUrl("/app/Goddesswechat/confirmCollage"),
        header: app.getRequestHeader(),
        method:'POST',
        data: {
          version_number: this.data.version_number,
          uid:wx.getStorageSync('uid'),
          token:wx.getStorageSync('token'),
          order_id:this.data.order_id
        },
        success: function (res) {
            var resp = res.data;
            console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
            if(resp.erro==0){
              wx.showToast({ title: resp.msg, icon: 'none' });
              that.setData({ show: false });
            }
        }
    });
  },
})