var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = getApp();

Page({
  data: {
    couponId: '',
    discId: '',
    storeId: '',
    storeTopicId: '',
    tickDiscount: {}
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    // console.log('discId' + options.discId)
    // console.log('couponId' + options.couponId)
    if (options.couponId) {
      this.setData({
        couponId: options.couponId
      });
    }
    if (options.discId) {
      this.setData({
        discId: options.discId
      });
    }
    this.setData({
      storeId: options.storeId
    });
    this.getTickDiscountDetail();
  },
  onReady: function () { },
  onShow: function () { },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  },
  getTickDiscountDetail() {
    var that = this;
    util.request(api.DiscountDetail, {
      couponId: that.data.couponId,
      storeId: that.data.storeId,
      discId: that.data.discId
    })
      .then(function (res) {
        if (res.errno === 0) {
          console.log(res.data);
          if (res.data) {
            that.setData({
              tickDiscount: res.data
            });
          }
        }
      });
  }
})