var app = getApp();
var $ = require('../../../../js/util.js');
Page({
  data: {
    param: {
      id: 0
    },
    id: 0,
    is_show:true,
    data: {}
  },
  onLoad: function (options) {//接收上个页面传的参数
    if(options.id){
      this.setData({
        param: {
          id: options.id
        },
        id: options.id
      });
    }
    if (options.invite_key) {
      app.globalData.invite_key = options.invite_key;
    } 
  },
  onReady: function () {
    var self = this;
    app.getUserInfo(function (ret) {
      //console.log(ret);
        self.getData();
    });
  },
  onShareAppMessage: function () {
    return {
      title: '优惠券',
      desc: '快来领取优惠券吧!',
      path: '/' + $.getCurrentPageUrl() + '?invite_key=' + app.globalData.init_invite_key + '&id=' + this.param.id
    }
  },
  //加载数据
  getData: function (callback) {
    var self = this;
    app.showLoading('加载中...');
    var action = 'c=Member&a=mycoupon_cont';
    app.ajaxRequest(action, 'GET', $.ObjectToStr(self.data.param), function (ret) {
      if (ret.status == 1) {
        self.setData({
          data: ret.data
        });
      } else {
        app.HCerror('提示', ret.msg); return;
      }
    },true);
  },
   //取消二维码弹窗
  lookconfirm: function (event) {
    this.setData({
      is_show: true
    })
  },
  //立即使用
  goToUse: function (event) {
    app.HCswitchTab('../../../index/index'); 
  },
});