const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); Page({ data: { isScrollTop:false, background: ['http://matripe.oss-cn-beijing.aliyuncs.com/banner/banner1.jpg'], pullNum: 0,//下拉次数 tabs: [], activeTab: 0, innerAudioContext:{}, systemInfo: {}, getMenuButtonBoundingClientRect: {}, // 手机基础信息 tabs2: [], loadMore: "", loadContent: [ "马不停蹄加载更多数据中...", "-- 已经到底了,加不了咯 --" ], activeTab2: 0, contentIndex: 0, latestClass: 0, zoneClass: 0, jobList: [], jobSpecialLabelNames: [], storeJobListSearchForm: { pageNum: 1, pageSize: 20, classify: 1, sex: -1, workTypeStr: "", lat: "", lng: "", jobClassify: '', sortTag: 0, jobSpecialLabelIds: '', cityName: '', brandIds: '', }, loading: true, topJobList: [], hasLocation: false, chooseActive: false, //筛选是否高亮 labelItems: [], checkedlabelItems: [], hasMoreData: true, //下拉是否还有更多数据 inputShowed: false, inputVal: "", wxCode: '', isCollect: false, collectTxt: '收藏', isLogin: false, hasUserInfo: 0, searchCityParamStorage: {name: '', shortName: ''}, iosDialog1: false, iosDialog2: false, phoneDialog:false, triggered: false, pageShow:false, getTop:false, getTopn:false, siv:'', activez:'', activen:'', dialog1: false, dialog2: false, jobSpecialLabelList: [], brandList: [], firstMenu:'工价', tagArray0:[], tagArray1:[], tagArray2:[], tagArray3:[], }, PageScroll(e) { let that = this; const query = wx.createSelectorQuery().in(this); query .select(".xgxg") .boundingClientRect(function (res) { // console.log(res.top); if (res.top > 24) { that.setData({ isScrollTop: false, }); } else{ that.setData({ isScrollTop: true, }); } }) .exec(); }, // onPullDownRefresh:function(){ // this.getJobList(); // console.log(123); // wx.stopPullDownRefresh({ // success() { // app.refreshSuccess(); // } // }); // }, closeFix:function(){ var that = this; setTimeout(() => { that.setData({ getTop:false, getTopn:false, }) }, 1); }, chooseGj:function(){ var that = this; that.setData({ }) // setTimeout(() => { that.setData({ getTop:true, getTopn:false, // siv:'menu', }) // }, 301); // wx.pageScrollTo({ // scrollTop: 290, // duration: 300, // complete: function(res) { // console.log(res) // } // }) }, toSpecialArea: function(e) { var id = e.currentTarget.dataset.id; wx.navigateTo({ url: "../specialArea/index?id=" + id }) }, chooseM:function(e){ var str = e.currentTarget.dataset.id; console.log(str); var that = this; that.setData({ activez:str }) if(str == 'zuijin') {//距离最近 wx.getLocation({ type: 'gcj02', success(res1) { console.log("获取位置1"); console.log(res1); app.globalData.lng = res1.longitude; app.globalData.lat = res1.latitude; that.data.storeJobListSearchForm.sortTag = 2; that.data.storeJobListSearchForm.lng = res1.longitude; that.data.storeJobListSearchForm.lat = res1.latitude; that.setData({ firstMenu:'最近', storeJobListSearchForm: that.data.storeJobListSearchForm }); that.data.storeJobListSearchForm.pageNum = 1; that.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm, jobList: [], }); // var promise = new Promise(function(resolve,reject){ // that.getJobList(); // }); that.getJobList().then(()=>{ that.setData({ siv:'menu', }) }) }, fail() { console.log('获取位置失败,打开位置设置界面'); wx.openSetting({ success (res) { console.log(res.authSetting); if (res.authSetting['scope.userLocation']) { wx.getLocation({ type: 'gcj02', success(res1) { console.log("获取位置2"); console.log(res1); app.globalData.lng = res1.longitude; app.globalData.lat = res1.latitude; that.data.storeJobListSearchForm.sortTag = 2; that.data.storeJobListSearchForm.lng = res1.longitude; that.data.storeJobListSearchForm.lat = res1.latitude; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm, jobList: [], }); that.getJobList().then(()=>{ that.setData({ siv:'menu', }) }) }, fail() { } }); } } }) } }); } else if(str == 'zuigao') {//工价最高 that.data.storeJobListSearchForm.sortTag = 0; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm, firstMenu:'工价', jobList: [], }); that.getJobList().then(()=>{ that.setData({ siv:'menu', }) }) } }, chooseNl:function(){ var that = this; that.setData({ }) // setTimeout(() => { that.setData({ getTopn:true, getTop:false // siv:'menu' }) // }, 301); // wx.pageScrollTo({ // scrollTop: 290, // duration: 300, // complete: function(res) { // console.log(res) // } // }) }, choosen:function(e){ var str = e.currentTarget.dataset.id; var ageStr = e.currentTarget.dataset.str; console.log(str); var that = this; if(that.data.activen == str) { str = ''; ageStr = ''; } that.setData({ activen:str }) that.data.storeJobListSearchForm.pageNum = 1; that.data.storeJobListSearchForm.ageStr = ageStr; that.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm, jobList: [], }); that.getJobList(); // that.getJobList().then(()=>{ // that.setData({ // siv:'menu', // }) // }) }, onScrollRefresh: function () { var that=this; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ jobList: [], }) that.getJobList(); // setTimeout(function(){ // that.setData({ // jobList: [],: false, // }) // },2000); }, open1() { // wx.pageScrollTo({ // scrollTop: 290, // duration: 300, // complete: function(res) { // console.log(res) // } // }) this.setData({ dialog1: true, getTopn:false, getTop:false }); }, open2() { // wx.pageScrollTo({ // scrollTop: 290, // duration: 300, // complete: function(res) { // console.log(res) // } // }) this.setData({ dialog2: true, getTopn:false, getTop:false }); }, cc:function(){}, close: function () { this.setData({ dialog1: false, dialog2: false, iosDialog1: false, iosDialog2: false, phoneDialog:false, }) }, openIOS1: function() { this.setData({ iosDialog1: true }); }, openIOS2: function() { this.setData({ iosDialog2: true }); }, showphone:function(){ this.setData({ phoneDialog: true }); }, searchKey: function(e) { console.log(e); this.data.jobList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = e.detail.value; this.getJobList(); }, showInput: function() { this.setData({ inputShowed: true }); }, hideInput: function() { this.setData({ inputVal: "", inputShowed: false }); }, onShareAppMessage: function () { var path = commonUtil.getCurrentPageUrlWithArgs(); if(app.globalData.isLogin && app.globalData.agencyStatus - 0 != 0) {//当前用户是代理人 path += (path.indexOf('?') >= 0 ? '&' : '?') + 'agencyUserId=' + app.globalData.loginUserInfo.id; } console.log(path) return { "title":'一才', 'path': path, } }, clearInput: function() { this.setData({ inputVal: "", inputShowed: false, hasMoreData: true, }); this.data.jobList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = ''; this.getJobList(); }, inputTyping: function(e) { this.setData({ inputVal: e.detail.value }); }, clear() { wx.clearStorage(); console.log("清除成功"); }, getListByTypeAndIndustry: function () { var that = this; wx.request({ url: app.globalData.ip + '/labels/getListByTypeAndIndustry', data: { type: 90, industry: 2 }, header: app.globalData.header, method: "GET", success: function (res) { console.log(res.data.data); res.data.data.forEach(item=>{ if(item.typeClassify=='0'){ that.data.tagArray0.push(item); }else if(item.typeClassify=='1'){ that.data.tagArray1.push(item); }else if(item.typeClassify=='2'){ that.data.tagArray2.push(item); }else if(item.typeClassify=='3'){ that.data.tagArray3.push(item); } }) that.setData({ tagArray0:that.data.tagArray0, tagArray1:that.data.tagArray1, tagArray2:that.data.tagArray2, tagArray3:that.data.tagArray3, }) var jobSpecialLabelIdArray = that.data.storeJobListSearchForm.jobSpecialLabelIds.split(','); res.data.data.forEach(item => { item['checked'] = false; jobSpecialLabelIdArray.forEach(item1 => { if (item.id == item1) { item['checked'] = true; } }); }); that.setData({ jobSpecialLabelList:res.data.data }) } }) }, getBrandNameAllList: function () { var that = this; wx.request({ url: app.globalData.ip + '/brand/getBrandNameAllList', data: { }, header: app.globalData.header, method: "GET", success: function (res) { console.log(res); var brandIdArray = that.data.storeJobListSearchForm.brandIds.split(','); res.data.data.forEach(item => { item['checked'] = false; brandIdArray.forEach(item1 => { if (item.id == item1) { item['checked'] = true; } }); }); that.setData({ brandList:res.data.data }) } }) }, selectJobSpecialLabel: function(e) { var that = this; var index = e.currentTarget.dataset.index; var indexTag = e.currentTarget.dataset.indextag; // debugger; if(indexTag=='0'){ if(that.data.tagArray0[index].checked) { that.data.tagArray0[index].checked = false; } else { that.data.tagArray0[index].checked = true; } this.setData({ tagArray0: that.data.tagArray0 }); }else if(indexTag=='1'){ if(that.data.tagArray1[index].checked) { that.data.tagArray1[index].checked = false; } else { that.data.tagArray1[index].checked = true; } this.setData({ tagArray1: that.data.tagArray1 }); }else if(indexTag=='2'){ if(that.data.tagArray2[index].checked) { that.data.tagArray2[index].checked = false; } else { that.data.tagArray2[index].checked = true; } this.setData({ tagArray2: that.data.tagArray2 }); }else if(indexTag=='3'){ if(that.data.tagArray3[index].checked) { that.data.tagArray3[index].checked = false; } else { that.data.tagArray3[index].checked = true; } this.setData({ tagArray3: that.data.tagArray3 }); } // jobSpecialLabelList // if(that.data.jobSpecialLabelList[index].checked) { // that.data.jobSpecialLabelList[index].checked = false; // } else { // that.data.jobSpecialLabelList[index].checked = true; // } // this.setData({ // jobSpecialLabelList: that.data.jobSpecialLabelList // }); }, selectBrand: function(e) { var that = this; var index = e.currentTarget.dataset.index; if(that.data.brandList[index].checked) { that.data.brandList[index].checked = false; } else { that.data.brandList[index].checked = true; } this.setData({ brandList: that.data.brandList }); }, reset:function(e){ var that = this; if(e.target.dataset.type == 1) {//特色 that.data.jobSpecialLabelList.forEach(item => { if (item.checked) { item.checked = false; } }) that.setData({ jobSpecialLabelList: that.data.jobSpecialLabelList, }); } else if(e.target.dataset.type == 2) {//品牌 that.data.brandList.forEach(item => { if (item.checked) { item.checked = false; } }) that.setData({ brandList:that.data.brandList }); } }, loginOut: function () { var that = this; var jobSpecialLabelIdArray = []; that.data.jobSpecialLabelList.forEach(item => { if (item.checked) { jobSpecialLabelIdArray.push(item.id); } }); if (jobSpecialLabelIdArray.length > 0) { that.data.storeJobListSearchForm.jobSpecialLabelIds = jobSpecialLabelIdArray.join(','); } else { that.data.storeJobListSearchForm.jobSpecialLabelIds = ''; } var brandIdArray = []; that.data.brandList.forEach(item => { if (item.checked) { brandIdArray.push(item.id); } }); if (brandIdArray.length > 0) { that.data.storeJobListSearchForm.brandIds = brandIdArray.join(','); } else { that.data.storeJobListSearchForm.brandIds = ''; } that.data.storeJobListSearchForm.pageNum = 1; that.setData({ jobList: [], dialog2: false, dialog1: false, }) that.getJobList(); }, onLoad(options) { var that = this; wx.showLoading({ title: '加载中...', }) this.getListByTypeAndIndustry(); this.getBrandNameAllList(); // 查看是否授权 wx.getSetting({ success (res){ if (res.authSetting['scope.userInfo']) { // 已经授权,可以直接调用 getUserInfo 获取头像昵称 wx.getUserInfo({ success: function(res) { console.log(res.userInfo) } }) } } }) if (app.isNotEmptyCheck(options.fromSearchPage) && options.fromSearchPage ==1) { try { var searchJobListParamStorage = wx.getStorageSync('searchJobListParamStorage') if (searchJobListParamStorage) { console.log("searchJobListParamStorage:======", searchJobListParamStorage); that.data.storeJobListSearchForm.jobSpecialLabelIds = searchJobListParamStorage.jobSpecialLabelIds; that.data.storeJobListSearchForm.brandIds = searchJobListParamStorage.brandIds; that.data.storeJobListSearchForm.sortTag = searchJobListParamStorage.sortTag; if (searchJobListParamStorage.sortTag == 2) { that.findLocation(); } that.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm }); } } catch (e) { console.log("获取缓存设置的查询职位列表参数错误:", e); } try { var searchCityParamStorage = wx.getStorageSync('searchCityParamStorage') if (searchCityParamStorage) { console.log("searchCityParamStorage======", searchCityParamStorage); that.data.storeJobListSearchForm.cityName = searchCityParamStorage.name; if (app.isEmptyCheck(searchCityParamStorage.name)) { that.data.storeJobListSearchForm.cityName = '全国'; } that.setData({ searchCityParamStorage: searchCityParamStorage }); } } catch (e) { console.log("获取缓存设置的查询职位列表参数错误:", e); } } else { try { wx.removeStorageSync('searchJobListParamStorage'); } catch (e) { console.log("删除缓存设置的查询职位列表参数错误:", e); } try { wx.removeStorageSync('searchCityParamStorage'); } catch (e) { console.log("删除缓存设置的查询职位列表参数错误:", e); } } try { if(app.globalData.isScanQRCodes - 1 == 0) { wx.showToast({ title: '欢迎查看好工作', icon: 'success', duration: 2000 }) if(!getApp().globalData.isLogin) { setTimeout(function() { if(!getApp().globalData.isLogin) { that.openIOS2(); } }, 5000) } } } catch (e) { console.log("获取缓存设置的查询职位列表参数错误:", e); } console.log('options==============================1'); console.log(options); console.log('options==============================2'); if (app.isNotEmptyCheck(options.scene)) {//扫小程序码携带参数 var sceneStr = decodeURIComponent(options.scene); var sceneJson = commonUtil.sceneToJson(sceneStr); console.log("sceneJson===", sceneJson); if (sceneJson.fromType == 1) { app.globalData.isCommission = 1; wx.setStorageSync('storageSyncAgencyUserId', sceneJson.userId); } //先设置代理人缓存人再登录 app.getLoginUserTokenInfo(); } else if (app.isNotEmptyCheck(options.fromType)) {//扫小程序普通二维码携带参数-来源ID console.log("options.fromType========" + options.fromType); if (options.fromType == 0) { console.log("options.id========" + options.id); console.log("options.userId========" + options.userId); try { app.globalData.isCommission = 1; wx.setStorageSync('fromQrCodeChannelContactId', options.id); that.getAgencyUserId(options.id); } catch (e) { console.log("0-扫描微信二维码,设置参数错误:", e); } } else if (options.fromType.indexOf('0&id=') >= 0) {//兼容2021-9-9之前的二维码 var paramsTempId = options.fromType.replace('0&id=', ''); console.log("¶msTempId========" + paramsTempId); try { app.globalData.isCommission = 1; wx.setStorageSync('fromQrCodeChannelContactId', paramsTempId); that.getAgencyUserId(paramsTempId); } catch (e) { console.log("0-扫描微信二维码,设置参数错误:", e); } } else {//兼容2021-9-9之前的二维码 var paramsTempId = options.fromType.replace('0,id=', ''); console.log("=paramsTempId========" + paramsTempId); try { app.globalData.isCommission = 1; wx.setStorageSync('fromQrCodeChannelContactId', paramsTempId); that.getAgencyUserId(paramsTempId); } catch (e) { console.log("0-扫描微信二维码,设置参数错误:", e); } } } else { console.log("options.fromType===else=====" + options); } //this.wxLogin(); let res = wx.getStorageSync('storeJobId'); //详情页返回 console.log(res); if (app.isEmptyCheck(res.data)) { this.setData({ jobList: [] }); } else { wx.removeStorageSync({ key: "storeJobId" }); } console.log("on show"); //登录=================================start if (app.globalData.isLogin) { this.setData({ isLogin: app.globalData.isLogin, hasUserInfo: app.globalData.hasUserInfo, }); } else { // 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 app.userLoginCallback = res => { this.setData({ isLogin: app.globalData.isLogin, hasUserInfo: app.globalData.hasUserInfo, }); } } //登录=================================end this.getHopeJobLabels(); var reset = true; let agencyUserId = options.agencyUserId; if(agencyUserId) { wx.setStorageSync('storageSyncAgencyUserId', agencyUserId); console.log('agencyUserId', agencyUserId) app.globalData.isCommission = 1; } }, onTabClick(e) { const index = e.detail.index this.setData({ activeTab: index }) }, onChange(e) { const index = e.detail.index this.setData({ activeTab: index }) }, findLocation() { var that = this; wx.getLocation({ type: 'gcj02', success(res1) { console.log("获取位置2"); console.log(res1); app.globalData.lng = res1.longitude; app.globalData.lat = res1.latitude; }, fail() { } }); }, emptyMethod() { }, play(){ this.data.innerAudioContext.play() }, onShow() { let that = this; this.setData({ isLogin: app.globalData.isLogin, iosDialog2: app.globalData.isLogin ? false : that.data.iosDialog2, }); if(app.globalData.isLogin) { this.collectedStoreJobList(); } else { this.wxLogin(); } console.log(app.globalData.headers) that.data.innerAudioContext = wx.createInnerAudioContext({ useWebAudioImplement: false // 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项 }) that.data.innerAudioContext.src = 'http://bocaiyishoudan.oss-cn-beijing.aliyuncs.com/success.wav' that.play(); // innerAudioContext.play() // 播放 // innerAudioContext.pause() // 暂停 // innerAudioContext.stop() // 停止 /*this.wxLogin(); let res = wx.getStorageSync({ key: "storeJobId" }); //详情页返回 if (app.isEmptyCheck(res.data)) { this.setData({ jobList: [] }); } else { wx.removeStorageSync({ key: "storeJobId" }); } console.log("on show"); this.getHopeJobLabels(); var reset = true;*/ }, collectedStoreJobList() { var that = this; wx.request({ url: app.globalData.ip + "/store/job/collected/list?ucj=1", method: "GET", data: {}, header: app.globalData.headers, success: function(res) { console.log(res) let collectList = res.data.data.jobList; let jobs = that.data.jobList; if(collectList != null && collectList != '' && collectList != undefined && collectList.length != 0 && jobs != null && jobs != '' && jobs != undefined && jobs.length != 0) { for(var j = 0; j != jobs.length; ++j) { jobs[j].collected = 2; } for(var i = 0; i != collectList.length; ++i) { for(var j = 0; j != jobs.length; ++j) { if(collectList[i].storeJobId - jobs[j].id == 0) { jobs[j].collected = 1; break; } } } that.setData({ jobList: jobs, }); } }, fail: function(res) { } }); }, getHopeJobLabels() { var that = this; wx.request({ url: app.globalData.ip + "/labels/findAllHopeJobLabels", // ?category=4 method: "GET", data: {}, success: function(res0) { console.log("感兴趣职位 ↓↓↓"); console.log(res0); if (res0.data.data != null) { res0.data.data.forEach((item, index) => { item["title"] = item.name; item["checked"] = false; if (index == 0 || index == 1) { item["checked"] = true; } }); } that.setData({ labelItems: res0.data.data == null ? [] : res0.data.data }); that.initData(); console.log("感兴趣职位 赋值title↓↓↓"); console.log(res0); }, fail: function(res) { wx.showToast({ title: '获取失败', icon: 'none', duration: 2000 }) } }); }, makePhoneCall() { var that = this; wx.makePhoneCall({ phoneNumber: '18039237825' }); }, goScreen(){ wx.navigateTo({ url: '../screen/index', }) }, goCity(){ wx.navigateTo({ url: '../city/index', }) }, initData() { var that = this; try { // 获取手机基础信息(头状态栏和标题栏高度) let systemInfo = wx.getSystemInfoSync(); let getMenuButtonBoundingClientRect = wx.getMenuButtonBoundingClientRect(); console.log(wx.getMenuButtonBoundingClientRect()); this.setData({ systemInfo, getMenuButtonBoundingClientRect }); } catch (e) { console.log(e); wx.alert({ title: "温馨提示", content: "onLoad 执行异常" }); } let res0 = wx.getStorageSync("checkedlabelItems"); console.log(app.isNotEmptyCheck(res0.data)); that.data.tabs2 = [{ name: "打勾推荐", category: -1, id: 406, checked: true, title: "打勾推荐" }]; if (app.isNotEmptyCheck(res0.data)) { for (var i = 0; i < res0.data.length; i++) { res0.data[i]["title"] = res0.data[i].name; // that.data.tabs2.push(res0.data[i]); } console.log("获取缓存"); // res0.data.unshift(); // console.log(res.data.unshift({name: "打勾推荐", category: 3, id: 406, checked: true, title: "打勾推荐"})); } else { console.log("无感兴趣职位 push两个职位 ↓↓↓"); console.log(that.data.labelItems); that.data.labelItems.forEach(item => { if (item.name == "理货员" || item.name == "餐饮服务员") { // that.data.tabs2.push(item); } }); // that.data.tabs2.push(that.data.labelItems[0], that.data.labelItems[1]) } that.setData({ tabs2: that.data.tabs2 }); let res = wx.getStorageSync("sex"); //性别 if (app.isNotEmptyCheck(res.data)) { that.data.storeJobListSearchForm.sex = res.data; that.data.storeJobListSearchForm.pageNum = 1; } else { // res.data = []; } let res2 = wx.getStorageSync("checkedJobItems"); //筛选职位 let workTypeStrCurr = ""; if (app.isNotEmptyCheck(res2.data)) { res2.data.forEach((item, index) => { workTypeStrCurr += item.value + ","; }); if (workTypeStrCurr.length > 0) { workTypeStrCurr = workTypeStrCurr.substr( 0, workTypeStrCurr.length - 1 ); } that.data.storeJobListSearchForm.workTypeStr = workTypeStrCurr; that.data.storeJobListSearchForm.pageNum = 1; } else { that.data.storeJobListSearchForm.workTypeStr = ""; that.data.storeJobListSearchForm.pageNum = 1; } console.log(res.data + "===" + res2.data); if (res.data == -1 && (res2.data == null || res2.data == "")) { that.setData({ chooseActive: false }); } else { that.setData({ chooseActive: true }); } this.getJobList(); }, getJobList() { var that = this; return new Promise(function(resolve,reject){ if (that.data.storeJobListSearchForm.sortTag == 2) {//如果按照距离排序,拼接上坐标 that.data.storeJobListSearchForm.lng = app.globalData.lng; that.data.storeJobListSearchForm.lat = app.globalData.lat; } wx.request({ url: app.globalData.ip + "/store/job/list", method: "POST", header: app.globalData.headers, data: that.data.storeJobListSearchForm, success: function(res) { console.log("职位列表↓↓↓↓"); console.log(res); // that.setData({ // hasMoreData: false // }); that.setData({ loading: true, hasMoreData: true }); setTimeout(function(){ that.setData({ triggered: false, }) },1000); if (app.isEmptyCheck(res.data.data)) { that.setData({ hasMoreData: false }); } else if ( res.data.data.jobList == null || res.data.data.jobList.length == 0 || res.data.data.jobList.length < that.data.storeJobListSearchForm.pageSize ) { var jobListTemp = that.disposeJobListData(res.data.data.jobList); that.data.jobList = that.data.jobList.concat(jobListTemp); that.setData({ jobList: that.data.jobList, hasMoreData: false }); } else { var jobListTemp = that.disposeJobListData(res.data.data.jobList); that.data.jobList = that.data.jobList.concat(jobListTemp); that.setData({ jobList: that.data.jobList, }); } wx.hideLoading({ success: (res) => {}, }) that.setData({ loading: false, pageShow:true, storeJobListSearchForm: that.data.storeJobListSearchForm }); resolve(); } }); }) }, /** * 处理后台返回的职位列表 */ disposeJobListData(jobList) { var that = this; jobList.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; item["salaryClassifyValue"] = commonUtil.getSalaryClassifyValue(item.salaryClassify, item.salaryClassifyValue); // //时薪 // var hourlyPayStr = ''; // var hasHourlyPay = false; // if (app.isNotEmptyCheck(item.hourlyPay)) { // hourlyPayStr = item.hourlyPay + '元/小时'; // hasHourlyPay = true; // } else if (app.isNotEmptyCheck(item.dayPay)) { // hourlyPayStr = item.dayPay + '元/日'; // hasHourlyPay = true; // } else { // if (app.isNotEmptyCheck(item.minMonthlyPay) && app.isNotEmptyCheck(item.maxMonthlyPay)) { // if (item.minMonthlyPay == item.maxMonthlyPay) { // hourlyPayStr = item.minMonthlyPay; // } else { // hourlyPayStr = item.minMonthlyPay + '-' + item.maxMonthlyPay; // } // } else if (app.isNotEmptyCheck(item.minMonthlyPay)) { // hourlyPayStr = item.minMonthlyPay; // } else if (app.isNotEmptyCheck(item.maxMonthlyPay)) { // hourlyPayStr = item.maxMonthlyPay; // } // } // item["hourlyPay"] = hourlyPayStr; //月薪 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; //地址深圳丨龙岗区丨 var districtStr = ''; if (app.isNotEmptyCheck(item.district)) { var districtArr = item.district.split(','); if(districtArr.length < 3) { districtStr = districtArr[districtArr.length - 1]; } else { districtStr = districtArr[1] + '丨' + districtArr[2]; } //districtStr = districtArr[1] + '丨' + districtArr[2]; } item["district"] = districtStr; //职位特色 item['jobSpecialLabelNames'] = that.getJobSpecialLabelNamesArray(item.jobSpecialLabelNames); }); return jobList; }, // 下拉加载更多 onScrollToLower() { var that = this; if (app.globalData.isLogin) { that.data.storeJobListSearchForm.pageNum = that.data.storeJobListSearchForm.pageNum + 1; that.getJobList(); // 根据实际数据加载情况设定 loadMore 的值即可,分别为 load 和 over this.setData({ loadMore: "load", // loading:true }); } else { if (that.data.pullNum == 0) { // 通过审核后打开 // that.openIOS1(); } } that.data.pullNum = that.data.pullNum + 1; }, getJobSpecialLabelNamesArray(jobSpecialLabelNames) { if (app.isNotEmptyCheck(jobSpecialLabelNames)) { return jobSpecialLabelNames.split(', '); } return []; }, handleTabClick(e) { var that = this; var index = e.detail.index; console.log( e.detail.index ); let categoryCurr = that.data.tabs2[index].category; // that.data.tabs2.forEach((item,index2) => { // if (index == index2) { // categoryCurr = item.category // } // if( index == 0){ // categoryCurr = -1 // } // }) this.setData({ // [tabsName]: index, contentIndex: index }); console.log(categoryCurr); that.data.storeJobListSearchForm.jobClassify = categoryCurr; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ jobList: [] }); that.getJobList(); }, goDetail(e) { console.log(e); var that = this; wx.navigateTo({ url: "../detail/index?storeJobId=" + e.currentTarget.dataset.id + "&wxCode=" + that.data.wxCode }); }, goEnroll(e) { // wx.navigateTo({ // url: "../enroll/index?applyType=0" // }); var that = this; console.log(that.data.jobList[e.currentTarget.dataset.idx]); wx.setStorageSync('jobDetailStorage', that.data.jobList[e.currentTarget.dataset.idx]); wx.navigateTo({ url: "../enroll/index?applyType=1&tel=" + app.globalData.loginUserInfo.tel }); }, emptyMethod() { }, wxLogin() { var that = this; wx.login({ success(res) { if (res.code) { that.setData({ wxCode: res.code }); } else { console.log('获取code失败!' + res.errMsg) } } }) }, getPhoneNumber(e) { var that = this; console.log(e) console.log(e.detail.errMsg) /*wx.setStorageSync({ key: "jobDetailStorage", data: that.data.jobList[e.currentTarget.dataset.idx] });*/ wx.setStorageSync('jobDetailStorage', that.data.jobList[e.currentTarget.dataset.idx]); // console.log(e); // console.log(e.detail.errMsg) // console.log(e.detail.iv) // console.log(e.detail.encryptedData) if ("getPhoneNumber:ok" == e.detail.errMsg) { //同意 var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; wx.checkSession({ success() { //session_key 未过期,并且在本生命周期一直有效 wx.request({ url: app.globalData.ip + '/getWechatTel', data: { code: that.data.wxCode, iv: iv, encryptedData: encryptedData, }, success: function(res) { console.log(res); app.globalData.openId = res.data.data.openId; let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null); var collected = e.currentTarget.dataset.collected; if (collected) { promise.then(res => { that.setData({ isLogin: app.globalData.isLogin }); that.doCollected(collected, e.currentTarget.dataset.jobid); that.collectedStoreJobList(); }) } else { promise.then(res => { wx.navigateTo({ url: "../enroll/index?applyType=1" //url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber }); }) } }, fail: function(res) { console.log("获取用户手机号错误"); } }) }, fail() { // session_key 已经失效,需要重新执行登录流程 wx.login({ success(res) { if (res.code) { console.log(res.code); //发起网络请求 wx.request({ url: app.globalData.ip + '/getWechatTel', data: { code: res.code, iv: iv, encryptedData: encryptedData, }, success: function(res) { console.log(res); let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null); var collected = e.currentTarget.dataset.collected; if (collected) { promise.then(res => { that.setData({ isLogin: app.globalData.isLogin }); that.doCollected(collected, e.currentTarget.dataset.jobid); }) } else { promise.then(res => { wx.navigateTo({ url: "../enroll/index?applyType=1" //url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber }); }) } }, fail: function(res) { console.log("获取用户手机号错误"); } }) } else { console.log('获取手机号失败!' + res.errMsg) } } }) } }) } else { //拒绝 var collected = e.currentTarget.dataset.collected; if (collected) { try { wx.setStorageSync('comeFromPage', 'index'); } catch (e) { console.log("index-页面跳转,设置参数错误:", e); } wx.navigateTo({ url: '/pages/login/index', }) } else { wx.navigateTo({ url: "../enroll/index?applyType=1" }); } } return false; }, getPhoneNumber1(e) { var that = this; console.log(e) console.log(e.detail.errMsg) that.close(); // console.log(e); // console.log(e.detail.errMsg) // console.log(e.detail.iv) // console.log(e.detail.encryptedData) if ("getPhoneNumber:ok" == e.detail.errMsg) { //同意 var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; wx.checkSession({ success() { //session_key 未过期,并且在本生命周期一直有效 wx.request({ url: app.globalData.ip + '/getWechatTel', data: { code: that.data.wxCode, iv: iv, encryptedData: encryptedData, }, success: function(res) { console.log(res); let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null); promise.then(res => { that.setData({ isLogin: app.globalData.isLogin }); that.onScrollToLower(); }) }, fail: function(res) { console.log("获取用户手机号错误"); } }) }, fail() { // session_key 已经失效,需要重新执行登录流程 wx.login({ success(res) { if (res.code) { console.log(res.code); //发起网络请求 wx.request({ url: app.globalData.ip + '/getWechatTel', data: { code: res.code, iv: iv, encryptedData: encryptedData, }, success: function(res) { console.log(res); let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null); promise.then(res => { that.setData({ isLogin: app.globalData.isLogin }); }) }, fail: function(res) { console.log("获取用户手机号错误"); } }) } else { console.log('获取手机号失败!' + res.errMsg) } } }) } }) } else { //拒绝 if(e.currentTarget.dataset.type != 'close') { try { wx.setStorageSync('comeFromPage', 'index'); } catch (e) { console.log("index-页面跳转,设置参数错误:", e); } wx.navigateTo({ url: '/pages/login/index', }) } else { that.close(); } } return false; }, getAgencyUserId(id) { var that = this; wx.request({ url: app.globalData.ip + "/channel/contact/getAgencyUserId", method: "GET", header: app.globalData.header, data: { channelContactId: id }, success: function(res) { console.log("获取来源对应的代理人,来源ID:", id); console.log(res); try { if (app.isNotEmptyCheck(res.data.data)) { wx.setStorageSync('storageSyncAgencyUserId', res.data.data); } //先设置代理人缓存人再登录 app.getLoginUserTokenInfo(); } catch (e) { console.log("0-扫描微信二维码,设置参数错误:", e); //先设置代理人缓存人再登录 app.getLoginUserTokenInfo(); } }, fail: function(res0) { console.log("获取来源对应的代理人错误", id); } }); }, collectPaste(e) { var txt; var that = this; var collected = e.currentTarget.dataset.collected; var storeJobId = e.currentTarget.dataset.jobid; that.doCollected(collected, storeJobId); // console.log(collected); // if(!this.data.isCollect){ // that.setData({ // isCollect: true, // collectTxt:'已收藏' // }) // txt = '收藏成功' // }else{ // that.setData({ // isCollect: false, // collectTxt:'收藏' // }) // } }, doCollected(collected, storeJobId) { var that = this; var url = '/user/collect/job/add'; if (collected - 1 == 0) { url = '/user/collect/job/remove'; } console.log(app.globalData.headers) //发起网络请求 wx.request({ url: app.globalData.ip + url, data: { storeJobId: storeJobId, }, header: app.globalData.headers, method: "GET", success: function(res) { var txt; if (collected - 1 == 0) { //取消收藏 for (var i = 0; i != that.data.jobList.length; ++i) { if (that.data.jobList[i].id - storeJobId == 0) { that.data.jobList[i].collected = 2; break; } } txt = '取消收藏'; } else { //收藏 for (var i = 0; i != that.data.jobList.length; ++i) { if (that.data.jobList[i].id - storeJobId == 0) { that.data.jobList[i].collected = 1; break; } } txt = '收藏成功'; } that.setData({ jobList: that.data.jobList, isLogin: app.globalData.isLogin }); wx.showToast({ icon: "none", title: txt, }) }, fail: function(res) { console.log("操作失败"); } }) }, getUserInfoBtn: function(e) { console.log(e) let that = this; let type = e.currentTarget.dataset.type; var collected = e.currentTarget.dataset.collected; var storeJobId = e.currentTarget.dataset.jobid; let idx = e.currentTarget.dataset.idx; console.log(type) wx.getUserProfile({ desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { console.log(res) //发起网络请求 wx.request({ url: app.globalData.ip + '/updateUserWechatInfo', data: { nickName: res.userInfo.nickName, avatarUrl: res.userInfo.avatarUrl, gender: res.userInfo.gender, country: res.userInfo.country, province: res.userInfo.province, city: res.userInfo.city, }, method: "POST", header: app.globalData.headers, success: function(res) { console.log(res); app.globalData.hasUserInfo = 1; that.setData({ hasUserInfo: 1 }) that.doMenuClick(type, collected, storeJobId, idx); }, fail: function(res) { that.doMenuClick(type, collected, storeJobId, idx); } }) }, fail: (res) => { console.log(res) that.doMenuClick(type, collected, storeJobId, idx); } }) }, doMenuClick: function(_type, _collected, _storeJobId, _idx) { let that = this; if(_type - 1 == 0) {//点击全国 that.goCity(); } else if(_type - 2 == 0) {//搜索 that.showInput(); } else if(_type - 3 == 0) {//筛选 that.goScreen(); } else if(_type - 4 == 0) {//收藏 that.doCollected(_collected, _storeJobId); } else if(_type - 5 == 0) {//报名 wx.setStorageSync('jobDetailStorage', that.data.jobList[_idx]); wx.navigateTo({ url: "../enroll/index?applyType=1&tel=" + app.globalData.loginUserInfo.tel }); } } });