const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); Page({ data: { toped: "1", chaShowed: false, backHeight:wx.getMenuButtonBoundingClientRect().top + (wx.getMenuButtonBoundingClientRect().height/2) +'px', isTrigger: false, // background: ["../../assets/images/banner1.jpg", "../../assets/images/banner2.jpg", "../../assets/images/banner3.jpg", "../../assets/images/banner4.jpg"], pullNum: 0, //下拉次数 tabs: [], activeTab: 0, systemInfo: {}, getMenuButtonBoundingClientRect: {}, // 手机基础信息 tabs2: [], loadMore: "", loadContent: ["马不停蹄加载更多数据中...", "-- 已经到底了,加不了咯 --"], statusBarHeight: wx.getStorageSync("statusBarHeight"), // 状态栏高度 navigationBarHeight: wx.getStorageSync("navigationBarHeight"), // 导航栏高度 menuButtonHeight: wx.getStorageSync("menuButtonHeight"), // 胶囊按钮高度 menuButton: wx.getStorageSync("menuButtonInfo"), // 胶囊信息 navigatorHeight: 60, activeTab2: 0, contentIndex: 0, latestClass: 0, zoneClass: 0, recordList: [], jobSpecialLabelNames: [], storeJobListSearchForm: { pageNum: 1, pageSize: 20, }, loading: true, topJobList: [], hasLocation: false, chooseActive: false, //筛选是否高亮 labelItems: [], checkedlabelItems: [], hasMoreData: false, //下拉是否还有更多数据 inputShowed: false, inputVal: "搜索工作", wxCode: "", isCollect: false, collectTxt: "收藏", isLogin: app.globalData.isLogin, hasUserInfo: 0, searchCityParamStorage: { name: "", shortName: "", }, recordCount: 0, totalPage: 0, currPage: 0, serviceInfo: {}, // 代理信息 placeholderText: "", // 当前关键词 from:'', topNum: 0, }, goBack(){ wx.navigateBack({ delta: -1, }) }, // onPullDownRefresh:function(){ // this.getJobList(); // console.log(123); // wx.stopPullDownRefresh({ // success() { // app.refreshSuccess(); // } // }); // }, goLogin() { wx.setStorageSync("comeFromPage", "index"); wx.navigateTo({ url: "/pages/login/index", }); }, onScrollRefresh: function () { var that = this; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ recordList: [], }); that.getJobList(); }, cc: function () {}, /** * 清除本地缓存 * * */ clear() { wx.clearStorage(); console.log("清除成功"); }, onLoad(options) { var that = this; console.log(options.from == 'shoucang'); console.log(wx.getSystemInfoSync()); // Array.prototype.logResult = function(){ // console.log('Array'); // } if(options.from == 'shoucang'){ wx.setNavigationBarTitle({ title: '我的收藏', }) this.setData({ from: 'shoucang', }); }else if(options.from == 'baoming'){ wx.setNavigationBarTitle({ title: '我的报名', }) this.setData({ from: 'baoming', }); } let arr = []; arr.logResult(); // 查看是否授权 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 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({ recordList: [], }); } else { wx.removeStorageSync({ key: "storeJobId", }); } console.log("on show"); //登录=================================start if (app.globalData.isLogin) { this.setData({ isLogin: app.globalData.isLogin, hasUserInfo: app.globalData.hasUserInfo, agencyStatus: app.globalData.loginUserInfo.agencyStatus, corpUserFlag: app.globalData.loginUserInfo.corpUserFlag, userInfo: app.globalData.loginUserInfo, serviceInfo: app.globalData.serviceInfo, isLoading: true, }); } else { // 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 app.userLoginCallback = (res) => { this.setData({ isLogin: app.globalData.isLogin, hasUserInfo: app.globalData.hasUserInfo, agencyStatus: app.globalData.loginUserInfo.agencyStatus, corpUserFlag: app.globalData.loginUserInfo.corpUserFlag, userInfo: app.globalData.loginUserInfo, serviceInfo: app.globalData.serviceInfo, }); console.log(that.data.serviceInfo); }; console.log(that.data.serviceInfo); } //登录=================================end var reset = true; let agencyUserId = options.agencyUserId; if (agencyUserId) { wx.setStorageSync("storageSyncAgencyUserId", agencyUserId); console.log("agencyUserId", agencyUserId); app.globalData.isCommission = 1; } app.getLoginUserTokenInfo(); // that.getJobList(); }, /** * 智能匹配结束 * * * */ /** * 获取banner信息 * * */ onChange(e) { const index = e.detail.index; this.setData({ activeTab: index, }); }, emptyMethod(e) { console.log(e); }, onShow() { let that = this; that.setData({ recordList: [], }); that.data.storeJobListSearchForm.pageNum = 1; wx.setStorageSync("BILLFROM", "firstBill"); // wx.showTabBar({ // success(e) {}, // }); // let index = 1; // that.setData({ // placeholderText: that.data.swiperTextList[0], // }); // setInterval(() => { // that.data.placeholderText = that.data.swiperTextList[index % that.data.swiperTextList.length]; // that.setData({ // placeholderText: that.data.placeholderText, // }); // index++; // }, 5000); if (wx.getStorageSync("FROMCITY")) { 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, storeJobListSearchForm: that.data.storeJobListSearchForm, }); that.setData({ recordList: [], }); } } catch (e) { console.log("获取缓存设置的查询职位列表参数错误:", e); } wx.removeStorageSync("FROMCITY"); }else{ that.setData({ recordList: [], }); } if (typeof this.getTabBar === "function" && this.getTabBar()) { this.getTabBar().setData({ selected: 0, isShow: true, }); } wx.setStorageSync("comeFromPage", "index"); this.setData({ storeJobListSearchForm: that.data.storeJobListSearchForm, isLogin: app.globalData.isLogin, recordBillType: "", }); console.log(app.globalData); setTimeout(() => { if (app.globalData.isLogin) { that.setData({ agencyStatus: app.globalData.loginUserInfo.agencyStatus, corpUserFlag: app.globalData.loginUserInfo.corpUserFlag, userInfo: app.globalData.loginUserInfo, serviceInfo: app.globalData.serviceInfo, }); console.log(app.globalData.loginUserInfo); } else { that.setData({ serviceInfo: app.globalData.serviceInfo, }); this.wxLogin(); } }, 100); console.log(app.globalData.headers); // if (that.data.inputVal != "搜索工作") { // console.log(that.data.inputVal); // that.setData({ // recordList: [], // }); // that.getJobList(); // } wx.removeStorage({ key: "townsManInfo", }); wx.removeStorage({ key: "townsManInfoJob", }); /*this.wxLogin(); let res = wx.getStorageSync({ key: "storeJobId" }); //详情页返回 if (app.isEmptyCheck(res.data)) { this.setData({ recordList: [] }); } else { wx.removeStorageSync({ key: "storeJobId" }); } console.log("on show"); var reset = true;*/ this.getJobList(); }, getJobList() { var that = this; // debugger that.setData({ pageShow: false, }); return new Promise(function (resolve, reject) { wx.showLoading({ title: "加载中...", }); console.log(that.data.storeJobListSearchForm); let url = ''; if(that.data.from == 'shoucang'){ url = '/assistant/job/collect/list' }else if(that.data.from == 'baoming'){ url = '/assistant/mine/info' } wx.request({ url: app.globalData.ip + url, method: "POST", header: app.globalData.headers, data: that.data.storeJobListSearchForm, success: function (res) { console.log("职位列表↓↓↓↓"); console.log(res); if(that.data.from == 'baoming'){ res.data.data.recordList = res.data.data.pageBean.recordList } that.setData({ totalPage: res.data.data.pageBean.pageCount, currPage: res.data.data.pageBean.currentPage, }); setTimeout(function () { that.setData({ triggered: false, }); }, 1000); if (res.data.data.pageBean.recordList == null || res.data.data.pageBean.recordList.length == 0 || res.data.data.pageBean.recordList.length < that.data.storeJobListSearchForm.pageSize) { var jobListTemp = commonUtil.disposeJobListData(res.data.data.pageBean.recordList); that.data.recordList = that.data.recordList.concat(jobListTemp); that.setData({ recordList: that.data.recordList, hasMoreData: false, isTrigger: false, }); } else { var jobListTemp = commonUtil.disposeJobListData(res.data.data.pageBean.recordList); that.data.recordList = that.data.recordList.concat(jobListTemp); that.setData({ recordList: that.data.recordList, hasMoreData: true, isTrigger: false, }); } wx.hideLoading({ success: (res) => {}, }); that.setData({ loading: false, pageShow: true, storeJobListSearchForm: that.data.storeJobListSearchForm, }); resolve(); that.setData({ recordList: that.data.recordList, currentJobDrawer: that.data.currentJobDrawer, }); // if (that.data.recordList.length < res.data.data.recordCount) { // that.setData({ // hasMoreData: true, // }); // } else { // that.setData({ // hasMoreData: false, // }); // } }, }); }); }, /** * 标准详情 * * */ goDetail(e) { console.log(e); var that = this; if (this.data.isLogin) { wx.navigateTo({ url: "../detail/index?storeJobId=" + e.currentTarget.dataset.id, }); } else { wx.navigateTo({ url: "../login/index", }); } }, 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.recordList[e.currentTarget.dataset.idx] });*/ wx.setStorageSync("jobDetailStorage", that.data.recordList[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; console.log(iv, "=-=========", encryptedData); wx.checkSession({ success() { //session_key 未过期,并且在本生命周期一直有效 wx.request({ url: app.globalData.ip + "/getWechatTel", data: { code: that.data.wxCode, iv: iv, encryptedData: encryptedData, type: "yishoudan", appId:app.globalData.appId }, 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 { if (that.data.recordBillType == "photo" || that.data.recordBillType == "record") { promise.then((res) => { if (that.data.recordBillType == "photo") { that.chooseIdCard(); } else { that.navigatorToRecord(); } }); } else { promise.then((res) => { let argument; argument = JSON.stringify(e.currentTarget.dataset.info).replace(/\=|\&/g, "3D"); wx.navigateTo({ url: `../newEnroll/enroll/index?applyType=1&info=${argument}`, }); }); } } }, 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, type: "yishoudan", appId:app.globalData.appId }, 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, type: "yishoudan", appId:app.globalData.appId }, 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, type: "yishoudan", appId:app.globalData.appId }, 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; }, modalMove() { return false; }, });