const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); const dateUtil = require("../../utils/dateUtil.js"); Page({ data: { jobDetail:{}, toped: "1", chaShowed: false, 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, keys: 1, agencyUserId: "", }, 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: "", }, iosDialog1: false, phoneDialog: false, triggered: false, pageShow: false, whichOneShow: "", siv: "", activez: "zuigao", sexid: "-1", // 性别筛选的id dialog1: false, dialog2: false, recordCount: 0, totalPage: 0, currPage: 0, }, // onPullDownRefresh:function(){ // this.getJobList(); // console.log(123); // wx.stopPullDownRefresh({ // success() { // app.refreshSuccess(); // } // }); // }, goLogin() { wx.setStorageSync("comeFromPage", "index"); wx.navigateTo({ url: "/pages/login/index", }); }, watch() {}, onScrollRefresh: function () { var that = this; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ recordList: [], }); that.getJobList(); // setTimeout(function(){ // that.setData({ // recordList: [],: false, // }) // },2000); }, cc: function () {}, close: function () { this.setData({ dialog1: false, dialog2: false, phoneDialog: false, }); }, searchKey: function (e) { if (!this.data.isLogin) { wx.navigateTo({ url: "../login/index", }); return; } console.log(e); this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = this.data.inputVal; this.getJobList(); }, goSearch() { if (!this.data.isLogin) { wx.navigateTo({ url: "../login/index", }); return; } wx.navigateTo({ url: `../jobListSearch/index?from=project`, }); }, clearInput: function () { this.setData({ inputVal: "搜索工作", chaShowed: false, inputShowed: false, hasMoreData: true, }); this.inputBlur(); this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.data.storeJobListSearchForm.keys = ""; this.getJobList(); }, 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(); } }, /** * 清除本地缓存 * * */ clear() { wx.clearStorage(); console.log("清除成功"); }, inputBlur() {}, loginOut: function () { var that = this; var jobSpecialLabelIdArray = []; // var brandIdArray = []; that.data.selectBrandList = []; that.data.filterData.classifyList.forEach((item) => { if (item.active) { if (that.data.selectBrandList.indexOf(item) == -1) { that.data.selectBrandList.push(item); } // brandIdArray.push(item.id); } }); that.data.selectJobList = []; let subArr = that.data.filterData.jobFilter; let jobList = subArr.tagArray0.concat(subArr.tagArray1, subArr.tagArray2, subArr.tagArray3, subArr.tagArray4); jobList.forEach((item) => { if (item.active) { if (that.data.selectJobList.indexOf(item) == -1) { that.data.selectJobList.push(item); } } }); // if (brandIdArray.length > 0) { // // that.data.storeJobListSearchForm.brandIds = brandIdArray.join(","); // that.data.storeJobListSearchForm.jobCategoryLabelIds = brandIdArray.join(","); // } else { // // that.data.storeJobListSearchForm.brandIds = ""; // that.data.storeJobListSearchForm.jobCategoryLabelIds = ""; // } // that.data.storeJobListSearchForm.pageNum = 1; that.setData({ // recordList: [], // siv: "", // whichOneShow: "", selectBrandList: that.data.selectBrandList, selectJobList: that.data.selectJobList, // innerFilter:true }); // that.getJobList(); }, onLoad(options) { var that = this; console.log(options); console.log(wx.getSystemInfoSync()); wx.getSetting({ success(res) { if (res.authSetting["scope.userInfo"]) { // 已经授权,可以直接调用 getUserInfo 获取头像昵称 wx.getUserInfo({ success: function (res) { console.log(res.userInfo); }, }); } }, }); 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(); this.getJobList(); }, onReady() { let that = this; }, /** * 智能匹配结束 * * * */ goChannel(e) { console.log(e); }, emptyMethod(e) { console.log(e); }, PageScroll(e) { let that = this; const query = wx.createSelectorQuery().in(this); query .select(".sticky") .boundingClientRect(function (res) { // console.log(res); if (res.top <= 5) { that.setData({ isScrollTop: true, }); } else if (res.top > 0 && res.top < 90) { that.setData({ isScrollTop: false, }); } else if (res.top >= 90) { that.setData({ isScrollTop: false, }); } }) .exec(); }, onShow() { let that = this; 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: [], }); this.getJobList(); } } catch (e) { console.log("获取缓存设置的查询职位列表参数错误:", e); } wx.removeStorageSync("FROMCITY"); }else{ that.setData({ recordList: [], }); that.getJobList(); } 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"); this.getHopeJobLabels(); var reset = true;*/ that.searchAnimate(); }, 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.pageBean.recordList; let jobs = that.data.recordList; 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({ recordList: jobs, }); } }, fail: function (res) {}, }); }, 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; // debugger that.setData({ pageShow: false, }); return new Promise(function (resolve, reject) { that.data.storeJobListSearchForm.keys = that.data.inputVal == "搜索工作" ? "" : that.data.inputVal; // debugger; wx.showLoading({ title: "加载中...", }); console.log(that.data.storeJobListSearchForm); wx.request({ url: app.globalData.ip + "/assistant/job/list", method: "POST", header: app.globalData.headers, data: that.data.storeJobListSearchForm, success: function (res) { console.log("职位列表↓↓↓↓"); console.log(res); if(res.data.status == '9999'){ wx.navigateTo({ url: '../login/index', }) } 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.pageBean.recordCount) { // that.setData({ // hasMoreData: true, // }); // } else { // that.setData({ // hasMoreData: false, // }); // } }, }); }); }, onScrollRefresh() { this.data.recordList = []; this.data.storeJobListSearchForm.pageNum = 1; this.getJobList(); }, // 下拉加载更多 onScrollToLower() { console.log("===================================================="); var that = this; // if (app.globalData.isLogin) { that.data.storeJobListSearchForm.pageNum = that.data.storeJobListSearchForm.pageNum + 1; if (that.data.hasMoreData) { that.getJobList(); } this.setData({ loadMore: "load", }); // } else { // } that.data.pullNum = that.data.pullNum + 1; }, 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({ recordList: [], }); that.getJobList(); }, /** * 标准详情 * * */ goDetail(e) { console.log(e); var that = this; // if (this.data.isLogin) { wx.navigateTo({ url: "../detail/index?storeJobId=" + e.currentTarget.dataset.id + "&wxCode=" + that.data.wxCode, }); // } else { // wx.navigateTo({ // url: "../login/index", // }); // } }, hideDrawer() { let that = this; this.getTabBar().setData({ isShow: true, }); that.setData({ drawerShow: false, }); // this.getJobList(); // setTimeout(() => { // wx.showTabBar({ // success(e) {}, // }); // }, 300); }, 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.pageBean.openId; let promise = app.setLoginUserTokenInfo(res.data.data.pageBean.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.pageBean.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.pageBean.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.pageBean.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.pageBean.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.pageBean)) { wx.setStorageSync("storageSyncAgencyUserId", res.data.data.pageBean); } //先设置代理人缓存人再登录 app.getLoginUserTokenInfo(); } catch (e) { console.log("0-扫描微信二维码,设置参数错误:", e); //先设置代理人缓存人再登录 app.getLoginUserTokenInfo(); } }, fail: function (res0) { console.log("获取来源对应的代理人错误", id); }, }); }, collectPaste(e) { var txt; var that = this; if (!this.data.isLogin) { wx.navigateTo({ url: "/pages/login/index", }); return; } 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.recordList.length; ++i) { if (that.data.recordList[i].id - storeJobId == 0) { that.data.recordList[i].collected = 2; break; } } txt = "取消收藏"; that.data.currentJobDrawer.collected = 2; if (that.data.choiceCollect == 1) { if (that.data.drawerShow) { that.data.drawerShow = false; } that.data.storeJobListSearchForm.pageNum = 1; that.setData({ recordList: [], drawerShow: that.data.drawerShow, storeJobListSearchForm: that.data.storeJobListSearchForm, }); that.getJobList(); } } else { //收藏 for (var i = 0; i != that.data.recordList.length; ++i) { if (that.data.recordList[i].id - storeJobId == 0) { that.data.recordList[i].collected = 1; break; } } that.data.currentJobDrawer.collected = 1; txt = "收藏成功"; } console.log(that.data.currentJobDrawer); that.setData({ recordList: that.data.recordList, currentJobDrawer: that.data.currentJobDrawer, isLogin: app.globalData.isLogin, }); wx.showToast({ icon: "none", title: txt, }); }, fail: function (res) { console.log("操作失败"); }, }); }, /** * 收藏的切换 * * */ collectChange(e) { let that = this; if (that.data.isLogin || (!that.data.isLogin && e.currentTarget.dataset.id == 0)) { if (e.currentTarget.dataset.id) { that.data.choiceCollect = e.currentTarget.dataset.id; that.data.storeJobListSearchForm.ucj = e.currentTarget.dataset.id; that.data.storeJobListSearchForm.pageNum = 1; that.setData({ choiceCollect: that.data.choiceCollect, storeJobListSearchForm: that.data.storeJobListSearchForm, recordList: [], hasMoreData: false, }); that.getJobList(); } } else { that.setData({ recordList: [], hasMoreData:false, choiceCollect: 1, }); // } } }, scroll(e) { return false; }, stoptap(e) { return false; }, closeDialog() { this.setData({ iosDialog: false, }); }, showLeft() { this.setData({ leftShow: true, }); }, /** * 阻止滑动穿透 * * */ modalMove() { return false; }, onPageScroll(e) {}, searchAnimate() { let that = this; wx.createSelectorQuery() .select("#listBox") .fields( { scrollOffset: true, size: true, }, (res) => { this.animate( "#searchInputBox", [ { // paddingTop: "10px", // paddingBottom: "10px", top: "10px", width: "100%", // height: "40px", // backgroundColor: "#f5f5f5", }, { // paddingTop: that.data.statusBarHeight + (that.data.navigationBarHeight - that.data.menuButtonHeight) / 2 + "px", // paddingBottom: "30px", top: "-40px", width: "70%", // height: "84px", // backgroundColor: "#ff4400", // paddingTop:'100px', }, ], 800, { scrollSource: "#listBox", timeRange: 1000, startScrollOffset: 0, endScrollOffset: 60, } ); this.animate( "#searchInput", [ { backgroundColor: '#fff' }, { backgroundColor: '#f5f5f5' }, ], 500, { scrollSource: "#listBox", timeRange: 1000, startScrollOffset: 0, endScrollOffset: 90, } ); this.animate( "#sticky", [ { marginTop: "56px", // top: "0px", }, { marginTop: "0px", // top: "-272px", }, ], 2000, { scrollSource: "#listBox", timeRange: 2000, startScrollOffset: 50, endScrollOffset: 362, } ); this.animate( ".daotian", [ { opacity: "1", }, { opacity: "0", }, ], 1000, { scrollSource: "#listBox", timeRange: 1000, startScrollOffset: 0, endScrollOffset: 90, } ); } ) .exec(); }, // tabbar点击监听 onTabItemTap(e) { console.log(e); let that = this; that.setData({ topNum: 1, }); }, onHide() { this.setData({ whichOneShow: "", // topNum: 1, }); }, onUnload() { console.log("destory"); }, goList() { wx.navigateTo({ url: "/pages/filterPage/index", }); }, goNewEnroll (e) { let that = this; console.log(e.currentTarget.dataset.job); // this.data.recordBillShow = true this.setData({ jobDetail:e.currentTarget.dataset.job, recordBillShow: true }) // setTimeout(()=>{ // that.setData({ // recordBillShow: true // }) // },10) } });