// pages/mobile/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { chaShowed:false, inputShowed: false, inputVal: "搜索姓名、手机号", searchParam: { pageNum: 1, pageSize:100, del: 0, keys: '' }, recordList:[], topTips:false }, goSearch(){ wx.navigateTo({ url: '../search/index?from=mobile', }) }, inputTyping: function (e) { this.setData({ inputVal: e.detail.value, }); console.log(this.data.inputVal == ""); if (this.data.inputVal == "") { this.data.recordList = []; this.data.searchParam.pageNum = 1; this.data.searchParam.keys = ""; this.getJobList(); } }, searchKey: function (e) { console.log(e); this.data.recordList = []; this.data.searchParam.pageNum = 1; this.data.searchParam.keys = this.data.inputVal; this.getJobList(); }, showInput: function () { this.setData({ inputShowed: true, }); }, hideInput: function () { this.setData({ inputVal: "", inputShowed: false, }); }, clearInput: function () { this.setData({ inputVal: "搜索姓名、手机号", chaShowed: false, inputShowed: false, hasMoreData: true, }); this.data.recordList = []; this.data.searchParam.pageNum = 1; this.data.searchParam.keys = ""; this.getJobList(); }, getJobList(){ var that = this; console.log(that.data.inputVal); that.data.searchParam.keys = that.data.inputVal == '搜索姓名、手机号' ? '' : that.data.inputVal; wx.request({ url: app.globalData.ip + '/corp/user/list', data: that.data.searchParam, header: app.globalData.header, method: "GET", success: function (res) { console.log(res.data); if (res.data.status == 200) { // let currMobile = ''; res.data.data.list.forEach((item,index)=>{ var arr = []; if(item.workPhone != "" && item.workPhone != "/"){ arr.push(item.workPhone); } if(item.workPhoneBak != "" && item.workPhoneBak != "/"){ arr.push(item.workPhoneBak); } if(item.userPhone != "" && item.userPhone != "/"){ arr.push(item.userPhone); } if(item.mobile != "" && item.mobile != "/"){ arr.push(item.mobile); } // console.log(item, arr) item.currMobile = arr.length == 0 ? '' : arr[0]; // if(item.workPhone != "" && item.workPhone != "/"){ // item.currMobile = item.workPhone // }else if(item.workPhone == '' && (item.workPhoneBak != '' && item.workPhoneBak != "/")){ // item.currMobile = item.workPhoneBak // }else if(item.workPhone == '' && item.workPhoneBak == '' && (item.userPhone != '' && item.userPhone != '/')){ // item.currMobile = item.userPhone // }else{ // item.currMobile = item.mobile // } }) that.setData({ recordList: res.data.data.list, }); wx.hideLoading(); } else { wx.showToast({ title: "请先登录", icon: 'error', duration: 2000 }) // wx.hideLoading(); } }, fail: function (res) { console.log(res); wx.hideLoading(); } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, toDetail(e){ wx.navigateTo({ url: '../mobileInfo/index?id='+e.mark.id, }) }, makePhoneCall(e){ wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.tel, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { wx.showLoading({ title: '加载中...', }) setTimeout(function(){ wx.hideLoading({ success: (res) => {}, }) },500) }, /** * 生命周期函数--监听页面显示 */ onShow() { // wx.showToast({ // title: '您拒绝了定位权限,将无法使用XX功能', // icon: 'none' // }); if(app.globalData.hasAva){ this.setData({ topTips:false }) }else{ this.setData({ topTips:true }) } if (!app.globalData.isLogin) { wx.redirectTo({ url: "/pages/login/index?path=" + 'mobile', }); } else { this.getJobList(); } // this.getJobList(); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, getUserInfoBtn(){ app.getUserInfoBtn(this); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })