// shoppingGuid/page/pages/welfare/welfare.js
const wxService = require('../../../../utils/wxService')
wxService.page({

  /**
   * 页面的初始数据
   */
  data: {
    navBar : [
      { name: '导购学院', type: 1, isActive: true },
      { name: '推荐商品', type: 2, isActive: false },
      { name: '优惠券福利', type: 3, isActive: false},
    ],
    current : 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

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

  },

  //点击事件
  //分类点击
  onTopBarTap(e) {
    let index = e.currentTarget.dataset.index,
      item = e.currentTarget.dataset.item;
    this.data.navBar.forEach(nav => {
      nav.isActive = false;
    });

    this.data.navBar[index].isActive = true;
    this.data.current = this.data.navBar[index].type;

    this.setData({
      navBar: this.data.navBar,
      current: this.data.current
    });
  },
  //跳转导购学院详情
  onTapToGuidCollegeInfo(e){
    let id = 22;
    wx.navigateTo({
      url: '/shoppingGuid/page/pages/guidCollegeInfo/guidCollegeInfo?id=' + id,
    });
  },
  //定向发送优惠券
  onTapToSendConpon(e){
    let id = 22;
    wx.navigateTo({
      url: '/shoppingGuid/page/pages/selectUsers/selectUsers?id=' + id,
    });
  },
  //立即推荐商品给用户
  onTapToRecommandProduct(e){
    let id = 22;
    wx.navigateTo({
      url: '/shoppingGuid/page/pages/selectUsers/selectUsers?id=' + id,
    });
  },


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

  },

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

  },

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

  }
})