// pages/groupPage//discount-group/discount-group.js
import httpRequestApi from '../../../utils/APIClient';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    recommendList: []
  },

  //点击跳转到团购详情
  groupDetail:function ({currentTarget}) {
    const productId = currentTarget.dataset.productid;
    const id = currentTarget.dataset.id;
    const groupId = currentTarget.dataset.groupid;
    const ind = currentTarget.dataset.ind;
    //const groupType = this.data.groupData.recommendList[ind].groupType;
      wx.navigateTo({
        url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
      })
    // if(groupType === "PROMOTION") {
    //   wx.navigateTo({
    //     url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${id}&groupId=${groupId}`
    //   })
    // }else  {
    //   wx.navigateTo({
    //     url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
    //   })
    // }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '优惠团购'
    })
      //优惠内容
      httpRequestApi.getGroupList().success( (res) => {
        console.log('推荐团购',res.data.data)
        this.setData({
          recommendList: res.data.data
        })
      }).fail((error) => {
        console.log('错误',error)
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})