// shoppingGuid/page/pages/userList/userList.js
const app = getApp()
const wxService = require('../../../../utils/wxService')
import { Integer } from '../../../../utils/integerDigitalConvertion'
wxService.page({
  /**
   * 页面的初始数据
   */
  data: {
    list : [],
    name : '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let tagId = Integer.digit(options.id,64,10),
      groupId = Integer.digit(options.groupId, 64, 10),
      type = options.type,
      name = options.name;
    
    this.setData({
      name : name
    });
    this.getMemberList(tagId, groupId, type);

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },
  // 获取标签下会员
  getMemberList(tagId, groupId, type){
    wx.showLoading({
      title: '加载中'
    });
    let query = {
      tagId,
      groupId,
      type
    }
    wxService.post(`/marketing/shoppingguide/tag/member`, query).then(res => {
      if (res) {
        const { result, data } = res.data
        if (result == 0) {
          wx.hideLoading()
          this.data.list = data;
          this.setData({
            list: this.data.list,
          });
        }
      }
    })
  },
  //跳转到会员详情
  onTapToMemberInfo(e){
    let item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: '/shoppingGuid/page/pages/userInfo/userInfo?id=' + item.id,
    });
  },
  //回访
  onTapRecall(e){
    let item = e.currentTarget.dataset.item;
  },

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

  },

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

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

  }
})