// pages/callPhone/callPhone.js let app = getApp(); import { timeShowXXX, getUserApplyOrderStatusById, getDateYMDHM, getDateYMD, formatDateYMDHM, formatDateYMD, timeAfterOrder } from "../../utils/dateUtil"; Page({ /** * 页面的初始数据 */ data: { hasChange:false, allYqShow: false, chaShowed: false, sactive: 1, shactive : -1, activeTab: 0, fromId: "", roleOf41: false, roleOf132: false, managerRoleClassify:false, tabs: [{ title: '全部' }, { title: '待审核' }, { title: '待接待' }, { title: '待面试' }, { title: '待入职' }, { title: '在职中' }, { title: '已完成' }], isTrigger: false, navlist: -1, statusmark: 1, inputVal: "搜索姓名", hasMoreData: false, // 获取更多数据是否显示 // 状态栏高度 statusBarHeight: wx.getStorageSync("statusBarHeight"), // 导航栏高度 navigationBarHeight: wx.getStorageSync("navigationBarHeight"), // 胶囊按钮高度 menuButtonHeight: wx.getStorageSync("menuButtonHeight"), // 胶囊信息 menuButton: wx.getStorageSync("menuButtonInfo"), navigatorHeight: wx.getStorageSync("statusBarHeight") + wx.getStorageSync("navigationBarHeight"), searchParam: { pageNum: 1, pageSize: 20, roleTag: 1, statusTag: 0, status: -1, auditStep:"" }, searchParam2: { pageNum: 1, pageSize: 20, roleTag: 1, statusTag: 0, status: -1, auditStep:"" }, billList: [], yqBillList:[], underReviewList: [], underReviewNum: "0", timer: null, // 防抖 from: '', numbers: {}, yqActive: -1, }, onTabClick(e) { var that = this; const index = e.detail.index console.log(index); let status = -1; if (index == 1) { status = 10 this.data.searchParam.expired = 0 this.data.searchParam2.expired = 0 } else if (index == 2) { status = 20 } else if (index == 3) { status = 25 } else if (index == 4) { status = 30 } else if (index == 5) { status = 40 that.data.searchParam.sortField = "status40" that.data.searchParam.sortType = "desc" that.data.searchParam2.sortField = "status40" that.data.searchParam2.sortType = "desc" } else if (index == 6) { status = 999 } else { status = -1 } this.data.searchParam.pageNum = 1; this.data.searchParam.status = status; this.data.searchParam2.pageNum = 1; this.data.searchParam2.status = status; this.data.searchParam.expired = 0; this.data.searchParam2.expired = 0; this.data.searchParam.auditStep = ""; this.data.searchParam2.auditStep = ""; if(that.data.searchParam.sortField){ delete that.data.searchParam.sortField } if(that.data.searchParam.sortType){ delete that.data.searchParam.sortType } this.setData({ // expired:0, allYqShow:false, yqActive: -1, sactive: 1, shactive: -1, navlist: e.mark.ind, activeTab: index, searchParam: this.data.searchParam, searchParam2: this.data.searchParam2, billList: [], yqBillList:[], }); // this.getYqList(); this.getList(); }, changeShenhe(e){ var that = this; let id = e.currentTarget.dataset.id; wx.showLoading({ title: '加载中...', }) this.setData({ shactive: id, }) that.data.searchParam.auditStep = id; this.data.searchParam.pageNum = 1; if(that.data.searchParam.sortField){ delete that.data.searchParam.sortField } if(that.data.searchParam.sortType){ delete that.data.searchParam.sortType } this.setData({ searchParam: that.data.searchParam, billList: [], }); // this.getYqList(); this.getList(); }, changeMenu(e) { var that = this; let id = e.currentTarget.dataset.id; wx.showLoading({ title: '加载中...', }) this.setData({ sactive: id, }) if (id == 1) { that.data.searchParam.sortField = "status40" that.data.searchParam.sortType = "desc" } else if (id == 2) { that.data.searchParam.sortField = "entryTime" that.data.searchParam.sortType = "desc" } else if (id == 3) { that.data.searchParam.sortField = "entryTime" that.data.searchParam.sortType = "asc" } else if (id == 4) { that.data.searchParam.sortField = "status48" that.data.searchParam.sortType = "desc" } else if (id == 5) { that.data.searchParam.sortField = "willLeaveTime" that.data.searchParam.sortType = "desc" } else if (id == 6) { that.data.searchParam.sortField = "willLeaveTime" that.data.searchParam.sortType = "asc" } this.data.searchParam.pageNum = 1; this.setData({ searchParam: that.data.searchParam, billList: [], }); // this.getYqList(); this.getList(); }, changeMenuYq(e) { var that = this; let id = e.currentTarget.dataset.id; wx.showLoading({ title: '加载中...', }) if (that.data.yqActive != id) { this.data.searchParam.expired = 1; this.setData({ yqActive: id, }) } else { this.data.searchParam.expired = 0; this.setData({ yqActive: -1, }) } this.data.searchParam.pageNum = 1; this.setData({ searchParam: that.data.searchParam, billList: [], }); // this.getYqList(); this.getList(); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; this.data.searchParam.status = 10; let data = { mark: { ind: -1, }, }; // console.log(app.globalData.roleOf41) // if(!app.globalData.roleOf41){ // this.setData({ // tabs: [{title: '全部'},{title: '待接待'},{title: '待面试'},{title: '待入职'},{title: '在职中'},{title: '已完成'}], // }) // } this.setData({ from: options.from, fromId: options.id, roleOf41: app.globalData.roleOf41, roleOf132: app.globalData.roleOf132, managerRoleClassify: app.globalData.managerRoleClassify // tabs: [{title: '全部'}], }); console.log(options.id); let index = options.id; let status = 0; if (index == 1) { status = 10 } else if (index == 2) { status = 20 } else if (index == 3) { status = 25 } else if (index == 4) { status = 30 } else if (index == 5) { status = 40 that.data.searchParam.sortField = "status40" that.data.searchParam.sortType = "desc" } else if (index == 6) { status = 999 } this.data.searchParam.status = status; this.data.searchParam.pageNum = 1; this.data.searchParam2.status = status; this.data.searchParam2.pageNum = 1; console.log() this.setData({ activeTab: index, // ["searchParam.status"]: status, underReviewList: [], billList: [], yqBillList:[], searchParam: { pageSize: 20, }, searchParam: this.data.searchParam, searchParam2: this.data.searchParam2, }); console.log(this.data.searchParam); // this.changeactive(data); // this.getList(); // this.getBillNum(); that.getRead(); that.getBillNum(); that.changeactive(); }, onScrollRefresh() { this.data.billList = []; this.data.searchParam.pageNum = 1; // this.getYqList(); this.getList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; // debugger if(that.data.inputVal != '搜索姓名' || that.data.hasChange){ that.getRead(); that.getBillNum(); that.changeactive(); } }, getRead() { var that = this; // let currData = {}; // currData["roleTag"] = 1; // currData["keys"] = that.data.inputVal == '搜索姓名' ? '' : that.data.inputVal; // console.log(that.data.inputVal) // wx.request({ // url: app.globalData.ip + "/user/apply/order/listStatisticsNumNotRead", // header: app.globalData.header, // method: "GET", // data: currData, // success: function(res) { // console.log(res); // that.setData({ // numbers: res.data.data // }) // }, // }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, getBillNum() { let that = this; wx.request({ url: app.globalData.ip + "/user/apply/order/listStatisticsNum", header: app.globalData.headers, data: that.data.searchParam, method: "GET", success(res) { console.log(res); if (res.data.status == 200) { that.setData({ underReviewNum: res.data.data.num10, }); } }, }); }, changeactive: function (e) { this.data.searchParam.pageNum = 1; this.data.searchParam2.pageNum = 1; this.setData({ // navlist: e.mark.ind, searchParam: this.data.searchParam, searchParam2: this.data.searchParam2, // ["searchParam.status"]: e.mark.ind, billList: [], yqBillList:[], }); // this.getYqList(); this.getList(); }, getList: function (under) { var that = this; console.log(app.globalData); that.data.isLoading = true; let nowTime = new Date().getTime(); let time1 = new Date().getTime() + 30 * 60 * 1000 //超过30分钟 let time5 = new Date().getTime() + 5 * 60 * 1000 //超过5分钟 let time800 = new Date(getDateYMD(new Date()) + ' 20:00').getTime() //超过5分钟 let inTime = ""; let timeA = "" let timeB = "" let timeC = "" let timeD = "" var currArr = []; wx.showLoading({ title: "加载中", }); that.data.searchParam.keys = that.data.inputVal == '搜索姓名' ? '' : that.data.inputVal; wx.request({ url: app.globalData.ip + '/user/apply/order/list', data: that.data.searchParam, header: app.globalData.headers, method: "GET", success: function (res) { console.log(res.data); let data = res.data; if (res.data.status == 200) { if (res.data.data != null && res.data.data.length > 0) { res.data.data.forEach((item) => { if (item.nation.substr(item.nation.length - 1, 1) != '族' && item.nation.substr(item.nation.length - 1, 1) != '') { item.nation = item.nation + '族' } if (item.status == 10 || item.status == 20 || item.status == 21 || item.status == 26) { item["updateTimeStr"] = formatDateYMDHM(item.receptionTime) } else if (item.status == 25 || item.status == 35 || item.status == 45) { item["updateTimeStr"] = formatDateYMDHM(item.interviewTime) } else if (item.status == 30) { item["updateTimeStr"] = formatDateYMDHM(item.willEntryTime) } else if (item.status == 40 || item.status == 48) { item["updateTimeStr"] = formatDateYMDHM(item.updateTime) } else if (item.status == 50) { item["updateTimeStr"] = formatDateYMDHM(item.leaveTime) } else { item["updateTimeStr"] = formatDateYMDHM(item.updateTime); } let timeSrc = item["updateTimeStr"] // console.log(timeSrc.slice(0, 4)); // console.log(timeSrc); // console.log(new Date().getFullYear()); if (item["updateTimeStr"].slice(0, 4) == new Date().getFullYear()) { item["updateTimeStr"] = item["updateTimeStr"].slice(5) } item['statusText'] = getUserApplyOrderStatusById(item.status) // debugger; if (item.status == 10) { timeA = item.createTime + 30 * 60 * 1000 item['showTime'] = timeAfterOrder(nowTime, timeA) if (nowTime > timeA) { item['isYq'] = true } else { item['isYq'] = false } } else if (item.status == 20) { timeB = item.receptionTime + 5 * 60 * 1000 item['showTime'] = timeAfterOrder(nowTime, timeB) if (nowTime > timeB) { item['isYq'] = true } else { item['isYq'] = false } } else if (item.status == 25) { inTime = new Date(formatDateYMD(item.interviewTime) + ' 20:00').getTime() console.log(formatDateYMD(item.interviewTime)); console.log(new Date(formatDateYMD(item.interviewTime) + ' 20:00')); item['showTime'] = timeAfterOrder(nowTime, inTime) if (nowTime > inTime) { item['isYq'] = true } else { item['isYq'] = false } } else if (item.status == 30) { timeC = item.willEntryTime + 5 * 60 * 1000 item['showTime'] = timeAfterOrder(nowTime, timeC) if (nowTime > timeC) { item['isYq'] = true } else { item['isYq'] = false } } else if (item.status == 48) { timeD = item.willLeaveTime + 5 * 60 * 1000 item['showTime'] = timeAfterOrder(nowTime, timeD) if (nowTime > timeD) { item['isYq'] = true } else { item['isYq'] = false } } currArr.push(item); if (app.isNotEmptyCheck(item.userServeRecordDespLatest)) { item.userServeRecordDespLatest = item.userServeRecordDespLatest.replace(/「/g, "").replace(/」/g, ""); } // } }); } if (res.data.data != null && res.data.data.length < 20) { var recordListTemp = res.data.data; that.data.billList = that.data.billList.concat(recordListTemp); // that.data.billList.forEach((item,index)=>{ // if(item.isYq){ // that.data.billList.splice(index, 1) // } // }) that.setData({ hasMoreData: false }); } else { var recordListTemp = res.data.data; that.data.billList = that.data.billList.concat(recordListTemp); // that.data.billList.forEach((item,index)=>{ // if(item.isYq){ // that.data.billList.splice(index, 1) // } // }) that.setData({ hasMoreData: true }); } // that.data.billList.forEach((item,index)=>{ // if(item.isYq){ // that.data.billList.splice(index, 1) // } // }) that.setData({ billList: that.data.billList, isTrigger: false }); console.log(currArr); if (currArr.length == 0) { that.setData({ allYqShow: false }) } else { var tmps = []; currArr.forEach(item => { if (item.isYq) { tmps.push(item) that.setData({ allYqShow: true }) return } }) that.setData({ // allYqShow: tmps.length == that.data.billList.length, yqBillList: tmps }) } wx.hideLoading(); } else if (res.data.status == 9999) { app.showTips(that, res.data.msg); } else { app.showTips(that, res.data.msg); } wx.hideLoading(); that.data.isLoading = false; }, fail: function (res) { console.log(res); wx.hideLoading(); that.data.isLoading = false; }, }); }, inputTyping: function (e) { this.setData({ inputVal: e.detail.value, }); console.log(this.data.inputVal == ''); if (this.data.inputVal == '') { this.data.billList = []; this.data.searchParam.pageNum = 1; this.data.searchParam.keys = ""; this.data.yqBillList = []; this.data.searchParam2.pageNum = 1; this.data.searchParam2.keys = ""; // this.getYqList(); this.getList(); this.getRead(); } }, searchKey: function (e) { console.log(e); this.data.billList = []; this.data.yqBillList = []; this.data.searchParam.pageNum = 1; this.data.searchParam.keys = this.data.inputVal; this.data.searchParam2.pageNum = 1; this.data.searchParam2.keys = this.data.inputVal; // this.getYqList(); this.getList(); this.getRead(); }, // searchinput: function (e) { // let that = this; // this.setData({ // inputVal: e.detail.value, // }); // this.data.searchParam.keys = e.detail.value; // this.data.searchParam.pageNum = 1; // that.setData({ // billList: [], // searchParam: this.data.searchParam, // }); // if (that.data.timer) { // clearTimeout(that.data.timer); // } // that.data.timer = setTimeout(() => { // this.getList(); // }, 500); // }, goSearch() { wx.navigateTo({ url: '../search/index?from=process', }) }, clearInput() { let that = this; this.data.billList = []; this.setData({ inputVal: "搜索姓名", chaShowed: false, }); this.data.searchParam.keys = ""; this.data.searchParam.pageNum = 1; this.setData({ searchParam: this.data.searchParam, }); // this.getYqList(); this.getList(); this.getRead(); }, toDetail(e) { var that = this; console.log(e.mark.id); console.log(e.mark.index); that.data.billList[e.mark.index].hasRead = 1; that.setData({ billList: that.data.billList }); // console.log(this.data.statusmark); wx.navigateTo({ url: `/pages/channelOrder/index?workOrderId=${e.mark.id}&from=${that.data.from}`, }); // url:'/pages/workOrderId/index?workOrderId=' + e.mark.id }, goBack() { wx.navigateBack({ delta: 1, }); }, tounderReview() { wx.navigateTo({ url: "/pages/underReview/index?from=" + this.data.from, }); // let that = this; // this.setData({ // ["searchParam.status"]: 10, // ["searchParam.pageSize"]: 100, // }); // that.data.searchParam.status = 10 // that.getList(true); // setTimeout(() => { // that.tounderReview(); // }, 200); }, onScrollToLower() { console.log(this.data.searchParam); this.data.searchParam.pageNum = this.data.searchParam.pageNum + 1; // this.getYqList(); this.getList(); }, makePhoneCall(e) { console.log(e); wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.tel, }); } });