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

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 1,
    Status:'',
    KeyWord:'',
    list:''
  },
  //点击切换
  tabCharge(e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
     that.getdata();
    }
   
  },

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

  //获取客户管理页面信息
  getdata() {
    let that = this;
    let url = 'counselor/familylist';
    let param = {
      UserId: app.globalData.UserId,
      Status: that.data.currentTab,
      KeyWord: that.data.KeyWord
    }
    app.post(url, param).then((res) => {
      console.log(res)
      if (res.data.code == 200) {
        if (res.data.data.type == '-13') {
          wx.showToast({
            title: '会员到期,请充值',
            icon: 'none'
          }, 2000)
          wx.navigateTo({
            url: '../../my/recharge/recharge',
          })
        } else if (res.data.data.type == '-12') {
          wx.showToast({
            title: '您已经被禁用,请联系管理员',
            icon: 'none'
          }, 2000)
        } else if (res.data.data.type == '-11') {
          wx.showToast({
            title: '您的权限不足',
            icon: 'none'
          }, 2000)
        } else {
          that.setData({
            list: res.data.data.list,
            cid: res.data.data.list[0].users[0].cid,
            KeyWord: ''
          })
        }
      }

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

  //家庭信息
  familyData() {
    wx.navigateTo({
      url: '../remind/remind',
    })
  },

  //个人信息详情
  infoDetail() {
    wx.navigateTo({
      url: '../personInfo/personInfo',
    })
  },

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

  //管理成员
  addPerson(e) {
    let familyid = e.currentTarget.dataset.familyid;
    wx.navigateTo({
      url: '../addNewFamily/addNewFamily?familyid=' + familyid,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getdata()
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})