// shoppingGuid/page/pages/userInfo/userInfo.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 },
      { name: '退单信息', type: 4, isActive: false },
      { name: '优惠券', type: 5, isActive: false },
      { name: '积分', type: 6, isActive: false },
    ],
    current: 1,
    onlineOrderStatus: [{ name: '线上订单', type: 1, isActive: true }, { name: '线下订单', type: 2, isActive: false }],
    returnOrderStatus: [{ name: '线上订单', type: 1, isActive: true },{ name: '线下订单', type: 2, isActive: false }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  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
    });
  },
  //线上订单状态切换
  onTapChangeOnlineOrderStatus(e){
    let index = e.currentTarget.dataset.index,
      item = e.currentTarget.dataset.item;
    this.data.onlineOrderStatus.forEach(nav => {
      nav.isActive = false;
    });

    this.data.onlineOrderStatus[index].isActive = true;

    this.setData({
      onlineOrderStatus: this.data.onlineOrderStatus,
    });
  }, 
  //退单
  onTapChangeReturnOrderStatus(e){
    let index = e.currentTarget.dataset.index,
      item = e.currentTarget.dataset.item;
    this.data.returnOrderStatus.forEach(nav => {
      nav.isActive = false;
    });

    this.data.returnOrderStatus[index].isActive = true;

    this.setData({
      returnOrderStatus: this.data.returnOrderStatus,
    });
  },

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

  },

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

  },

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

  }
})