var app = getApp();
Component({
  properties: {
    data: {
      type: []
    },
    params: {
      type: null
    }
  },
  data: {
    language: '',
    datas: []
  }, // 私有数据，可用于模板渲染

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {
      let language = wx.getStorageSync('langIndex');
      this.setData({ 'language': language.en});
      let arr = this.properties.data;
      arr.map(item => {
        if (!app._isTextEmpty(item.end_time)) {
          item.nowTime = new Date().getTime() / 1000;
          if (!app._isTextEmpty(item.start_time)) {
            let start_time = new Date(item.start_time).getTime() / 1000;
            if (start_time > item.nowTime) {
              item.ishow = false;
              item.getTime = new Date(item.start_time).getTime() / 1000;
            } else {
              item.ishow = true;
            }
          }
          item.overTime = new Date(item.end_time).getTime() / 1000;
        }
      });
      let dataArr = this.properties.data;
      dataArr.map(item => {
        if (app._isTextEmpty(item.min_price)) {
          item.min_price = '';
        }
        if (app._isTextEmpty(item.max_price)) {
          item.max_price = '';
        }
      });

      this.setData({
        datas: dataArr
      });
    },
    moved() {},
    detached() {}
  },

  methods: {
    // 去开团
    buy(e) {
      let item = e.target.dataset.item || e.currentTarget.dataset.item;
      wx.navigateTo({
        url: '/packageA/detail_v2/detail_v2?id=' + item.id + '&name=group'
      });
    }
  }

});
