// pages/recordChoice/index.js let app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); Page({ /** * 页面的初始数据 */ data: { pageType: "", pageShow: false, hasMoreData: true, inputVal: "", inputAgencyVal: "", storeJobListSearchForm: { pageNum: 1, pageSize: 10, classify: 1, sex: -1, workTypeStr: "", lat: "", lng: "", jobClassify: "", sortTag: 0, jobSpecialLabelIds: "", cityName: "", brandIds: "", }, recordList: [], agencyList: [], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options); this.setData({ pageType: options.type, }); if (this.data.pageType == "job") { wx.setNavigationBarTitle({ title:'岗位选择' }) this.getJobList(); // wx. } else if (this.data.pageType == "agency") { wx.setNavigationBarTitle({ title:'代理选择' }) this.getAgencyList(); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() {}, /** * 生命周期函数--监听页面显示 */ onShow() {}, getJobList() { var that = this; return new Promise(function (resolve, reject) { wx.showLoading({ title: "加载中...", }); wx.request({ url: app.globalData.ip + "/overall/store/job/list", method: "POST", header: app.globalData.headers, data: that.data.storeJobListSearchForm, success: function (res) { console.log("职位列表↓↓↓↓"); console.log(res); that.setData({ loading: true, }); setTimeout(function () { that.setData({ triggered: false, }); }, 1000); if (app.isEmptyCheck(res.data.data)) { that.setData({ hasMoreData: false, }); } else if (res.data.data.recordList == null || res.data.data.recordList.length == 0 || res.data.data.recordList.length < that.data.storeJobListSearchForm.pageSize) { var jobListTemp = that.disposeJobListData(res.data.data.recordList); that.data.recordList = that.data.recordList.concat(jobListTemp); that.setData({ recordList: that.data.recordList, hasMoreData: false, }); } else { var jobListTemp = that.disposeJobListData(res.data.data.recordList); that.data.recordList = that.data.recordList.concat(jobListTemp); that.setData({ recordList: that.data.recordList, }); } wx.hideLoading({ success: (res) => {}, }); that.setData({ pageShow: true, storeJobListSearchForm: that.data.storeJobListSearchForm, }); resolve(); that.setData({ recordList: that.data.recordList, }); }, }); }); }, getAgencyList() { let that = this; wx.showLoading({ title: "加载中...", }); wx.request({ url: app.globalData.ip + "/agency/getByPmdUserId", method: "POST", header: app.globalData.headers, data: that.data.storeJobListSearchForm, success: function (res) { console.log(res); if (res.data.status == 200) { console.log(res); that.setData({ agencyList: res.data.data, hasMoreData: false, }); } wx.hideLoading(); }, }); }, /** * 处理后台返回的职位列表 */ disposeJobListData(recordList) { var that = this; recordList.forEach((item) => { item["workType"] = commonUtil.getWorkTypeById(item.workTypeMulti); if (app.isNotEmptyCheck(item.distance)) { item["distanceKm"] = commonUtil.getDistanceName(item.distance); } //年龄 var ageStr = ""; if (app.isNotEmptyCheck(item.minAge) && app.isNotEmptyCheck(item.maxAge)) { ageStr = item.minAge + "-" + item.maxAge + "岁"; } else if (app.isNotEmptyCheck(item.minAge)) { ageStr = item.minAge + "岁以上"; } else if (app.isNotEmptyCheck(item.maxAge)) { ageStr = item.maxAge + "岁以下"; } item["age"] = ageStr; // console.log(item.salaryClassify,'=============', item.salaryClassifyValue); item["salaryClassifyValue"] = commonUtil.getSalaryClassifyValue(item.salaryClassify, item.salaryClassifyValue); //月薪 var monthlyPayStr = ""; // if (hasHourlyPay) { if (app.isNotEmptyCheck(item.minMonthlyPay) && app.isNotEmptyCheck(item.maxMonthlyPay)) { if (item.minMonthlyPay == item.maxMonthlyPay) { monthlyPayStr = item.minMonthlyPay; } else { monthlyPayStr = item.minMonthlyPay + "-" + item.maxMonthlyPay; } } else if (app.isNotEmptyCheck(item.minMonthlyPay)) { monthlyPayStr = item.minMonthlyPay; } else if (app.isNotEmptyCheck(item.maxMonthlyPay)) { monthlyPayStr = item.maxMonthlyPay; } // } item["monthlyPay"] = monthlyPayStr; //地址深圳丨龙岗区丨 let citys = commonUtil.setJobListInfoPosition(item.district) item["district"] = citys; //职位特色 item.jobSpecialLabelNameArray = []; that.getJobSpecialLabelNamesArray(item.jobSpecialLabelNames).forEach((i, index) => { if (index <= 2) { item["jobSpecialLabelNameArray"].push(i); } }); // item["jobSpecialLabelNames"] = ; }); return recordList; }, getJobSpecialLabelNamesArray(jobSpecialLabelNames) { if (app.isNotEmptyCheck(jobSpecialLabelNames)) { return jobSpecialLabelNames.split(", "); } return []; }, onScrollToLower() { console.log("===================================================="); var that = this; that.data.storeJobListSearchForm.pageNum = that.data.storeJobListSearchForm.pageNum + 1; that.getJobList(); // 根据实际数据加载情况设定 loadMore 的值即可,分别为 load 和 over // this.setData({ // loadMore: "load", // loading:true // }); }, onScrollAgencyToLower() { var that = this; that.data.storeJobListSearchForm.pageNum = that.data.storeJobListSearchForm.pageNum + 1; that.getAgencyList(); }, inputTyping: function (e) { this.setData({ inputVal: e.detail.value, }); console.log(this.data.inputVal == ""); if (this.data.inputVal == "") { this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = ""; this.getJobList(); } }, inputAgency(e) { this.setData({ inputAgencyVal: e.detail.value, }); if (this.data.inputAgencyVal == "") { this.data.agencyList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.agencyName = ""; this.getAgencyList(); } }, searchKey: function (e) { console.log(e); console.log(this.data.inputVal); this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = this.data.inputVal; this.getJobList(); }, searchAgencyKey(e) { this.data.agencyList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.agencyName = this.data.inputAgencyVal; this.getAgencyList(); }, clearInput: function () { this.setData({ inputVal: "", hasMoreData: true, }); this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = ""; this.getJobList(); }, clearAgencyInput() { this.setData({ inputAgencyVal: "", hasMoreData: true, }); this.data.agencyList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.agencyName = ""; this.getAgencyList(); }, getDetail(e) { console.log(); let argument = JSON.stringify(e.currentTarget.dataset.info).replace(/\=|\&/g, "3D"); wx.redirectTo({ url: `../newEnroll/index?info=${argument}`, }); }, getAgencyDetail(e) { console.log(e); wx.redirectTo({ url: `../newEnroll/index?agencyInfo=${JSON.stringify(e.currentTarget.dataset.info)}`, }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() { console.log('==============','isUnload'); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {}, });