// pages/member/course/CourseMemberUpdate/CourseMemberUpdate.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language: '',
    updateGoods: [],
    level_data: '',
    level_type: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      goods_id: options.goods_id
    });
    this._getData();
  },
  _getData() {
    var that = this;
    var urlstr = app.getNetAddresss("plugin.video-demand.api.watch-level.condition");
    urlstr += "&goods_id=" + that.data.goods_id;
    app._getNetWork({
      url: urlstr,
      success: function (res) {
        if (res.data.result == 1) {
          console.log(res.data.data);
          if (!app._isTextEmpty(res.data.data)) {
            that.setData({
              course_goods: res.data.data.course_goods,
              level_data: res.data.data.level_data,
              level_type: res.data.data.level_type
            });
          }
        } else {
          // console.error(res);
        }
      },
      fail: function (res) {
        // console.error(res);
      }
    });
  },
  gotoBuy(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/packageA/detail_v2/detail_v2?id=" + id
    });
    // this.$router.push(this.fun.getUrl("goods", {
    //   id: id
    // }));
  },
  goto() {
    wx.reLaunch({
      url: '/packageG/index/index'
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en });
    wx.setNavigationBarTitle({
      title: '会员升级'
    });
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  // 跳转充值页, 携带充值数量
  toRecharge(e){
    let money = e.currentTarget.dataset.money;
    wx.navigateTo({
      url: '/packageA/member/balance/balance_recharge/balance_recharge?balance=' + money
    });
  }
});
