// packageC/o2o/card/new_card/new_card.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language: '',
    dainfo:'',
    spec:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.level_id
    });
    if(options.spec == 'goods_spec'){
      this.setData({
        spec:true
      });
    }
    this.getData();
  },
  openSubmit(){
    
    if(this.data.spec){
      wx.navigateTo({
        url: '/packageC/o2o/card/CardChooseMembership/CardChooseMembership?goods_id=' + this.data.dainfo + '&level_id=' + this.data.member_level.has_one_universal_level.member_level_id
      });
    }else{
      wx.navigateTo({
        url: '/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&optionsId=&total=1&goodsId=' + this.data.dainfo,
      });
      
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en});
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  radiong(e){
    console.log(e);
    this.setData({
      dainfo: Number(e.detail)
    });
  },
  getData(){
    let that = this;
    let urlStr = app.getNetAddresss('plugin.universal-card.api.home.getLevel');
    let json = {
      level_id: this.data.id
    };
    app._getNetWork({
      url: urlStr,
      data:json,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            member_goods: res.data.member_goods,
            member_level: res.data.member_level,
            dainfo: (res.data.member_goods.length > 0) ? res.data.member_goods[0].id : ''
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  }
});