CustomerManagement.js 4.1 KB
// pages/CustomerManagement/CustomerManagement.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 2,
    Status:'',
    KeyWord:'',
    mainid: '',
    vip_state: false
  },

  //点击切换
  tabCharge(e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
      that.getInfo()
    }
  },

  //设置查询的关键词
  setKeyWord(e) {
    let that = this;
    that.setData({
      KeyWord: e.detail.value
    })
  },

  //获取客户管理页面信息
  getInfo() {
    let that = this;
    let url = 'counselor/familylist';
    let param = {
      UserId: app.globalData.UserId,
      Status: this.data.currentTab,
      KeyWord: that.data.KeyWord
    }
    console.log(param)
    app.post(url, param).then((res) => {
      let data = res.data;
      console.log(data.code)
      console.log(res.data.data.list)
      if (data.code == 200) {
        console.log(1)
        console.log(data.data.list)
        that.setData({
            list: data.data.list
        })

      }
    }).catch((errMsg) => {
      // console.log(errMsg)
    })
  },


  //获取客户管理页面信息
  getdata() {
    let that = this;
    let url = 'pubilc/UserType';
    let param = {
      UserId: app.globalData.UserId,
    }
    app.post(url, param).then((res) => {
      if (res.data.code == 200) {
        if (res.data.data.type == 5) {
          wx.showToast({
            title: '会员到期,请充值',
            icon: 'none'
          }, 2000)
          that.setData({
            vip_state: false
          })
        } else if (res.data.data.type == 2) {
          wx.showToast({
            title: '您的权限不足',
            icon: 'none'
          }, 2000)
          that.setData({
            vip_state: false
          })
        } else{
          that.setData({
            vip_state: true
          })
        }
      }
    }).catch((errMsg) => {
      // console.log(errMsg)
    })
  },



  //家庭信息
  familyData(e) {
    var that = this
    let familyid = e.currentTarget.dataset.familyid;
    let list = that.data.list;
    // console.log(list)
    for (let items of list) {
      if (items.family_id == familyid) {
        for (let j in items.users) {
          if (items.users[j].user_family == 1) {
            that.setData({
              mainid: items.users[j].id, //户主ID
              cid: items.users[j].cid //顾问ID
            })
          }
        }
      }
    }
    wx.navigateTo({
      url: '../remind/remind?cid=' + this.data.cid + '&mainid=' + this.data.mainid,
    })
  },

  //个人信息详情
  infoDetail(e) {
    // wx.navigateTo({
    //   url: '../personInfo/personInfo?DefId=' + e.currentTarget.dataset.id,
    // })
    wx.navigateTo({
      url: '/pages/index/EntryInformation2/EntryInformation2?DefId=' + e.currentTarget.dataset.id,
    })
  },

  //创建新家庭
  addFamily() {
    var flag = true
    wx.navigateTo({
      url: '../addNewFamily/addNewFamily?flag=' + flag,
    })
    wx.setStorageSync('familyid', '')
  },

  //管理成员
  addPerson(e) {
    let familyid = e.currentTarget.dataset.familyid;
    wx.navigateTo({
      url: '../addNewFamily/addNewFamily?familyid=' + familyid,
    })
    wx.setStorageSync('familyid', familyid)
  },

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

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getInfo()
    this.getdata()
  },

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

  },

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

  },

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

  },

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

  },

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

  }
})