const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); const { wxml, style } = require('./demo.js') var QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js'); var qqmapsdk; Page({ data: { citys: "", storeJobId: "", currIndex: '1', //职位ID searchForm: { storeJobId: "", lng: "", lat: "" }, fullScreen:false, labelColor: ["#c41d7f", "#096dd9", "#531dab", "#d46b08", "#389e0d", "#08979c", "#cf1322"], bgColor: ["#fff0f6", "#e6f7ff", "#f9f0ff", "#fff7e6", "#f6ffed", "#e6fffb", "#fff1f0"], jobDetail: {}, //详情 wxCode: '', pbtm:0, shareTitle:'', isCollect:false, src: '', word:'woca', phoneDialog:false, isImg: true, wxml: { text: "啊啊按", }, }, onShow() { var that = this; this.setData({ isLogin: app.globalData.isLogin }); if (!app.globalData.isLogin) { this.wxLogin(); } }, showphone:function(){ this.setData({ phoneDialog: true }); }, close: function () { this.setData({ phoneDialog:false, }) }, wxLogin() { var that = this; wx.login({ success(res) { if (res.code) { that.setData({ wxCode: res.code }); } else { console.log('获取code失败!' + res.errMsg) } } }) }, showImage(e){ let resImg = e.currentTarget.dataset.src; console.log(this.data.jobDetail.storeImage); var imgArr = []; this.data.jobDetail.storeImage.forEach((item) => { // let regs = /\.(jpg|jpeg|png)(\?.*)?$/; // item.isImg = regs.test(item.url.toLowerCase()); if (item.isImg) { imgArr.push(item.url); } }); wx.previewImage({ current: e.currentTarget.dataset.src, // 当前显示图片的http链接 urls: imgArr, }); }, renderToCanvas() { const p1 = this.widget.renderToCanvas({ wxml:wxml(that.data.wxml), style }) p1.then((res) => { console.log('container', res.layoutBox) this.container = res console.log(res); }) }, extraImage() { var that = this; // return new Promise(function (resolve, reject) { that.widget.renderToCanvas({ wxml:wxml(that.data.wxml), style }).then(res1 => { const p2 = that.widget.canvasToTempFilePath() p2.then(res => { console.log(res); that.setData({ src: res.tempFilePath, }) }) }); // }); }, onLoad(query) { var that = this; that.widget = that.selectComponent('.widget') wx.getSystemInfo({ success: res => { console.log('手机信息res' + res.model) let modelmes = res.model; console.log(modelmes.search('iPhone X')); if (modelmes.search('iPhone 12 Pro') != -1 || modelmes.search('iPhone X') != -1 || modelmes.search('iPhone XR') != -1 || modelmes.search('iPhone XS max') != -1 || modelmes.search('iPhone 11') != -1) { that.setData({ pbtm: 40 }) } else { } } }) qqmapsdk = new QQMapWX({ key: '5PTBZ-YI7C6-MZGS3-ES7QN-4T5O2-EJFVR' }); console.log('HHHHHHHHHHHHH' + query.storeJobId); this.data.searchForm.storeJobId = query.storeJobId; // this.data.wxCode = query.wxCode; // this.getLocation(); this.getStoreJobDetailById(); // that.setData({ // wxCode: that.data.wxCode // }) wx.setStorageSync({ key: "storeJobId", data: query.storeJobId }); let agencyUserId = query.agencyUserId; if(agencyUserId) { wx.setStorageSync('storageSyncAgencyUserId', agencyUserId); console.log('agencyUserId', agencyUserId) app.globalData.isCommission = 1; } }, openMap(e){ wx.showLoading({ title: '加载中', }) console.log(e); let address = e.currentTarget.dataset.address; let lat = e.currentTarget.dataset.lat; var formatted_addresses = "" qqmapsdk.reverseGeocoder({ location:`${e.currentTarget.dataset.lat},${e.currentTarget.dataset.lng}`, success: function(res) { console.log(res); formatted_addresses = res.result.formatted_addresses.recommend; } }) console.log(address); console.log(formatted_addresses); wx.getLocation({ type: 'gcj02', //返回可以用于wx.openLocation的经纬度 success (res) { wx.openLocation({ latitude: e.currentTarget.dataset.lat - 0, longitude :e.currentTarget.dataset.lng - 0, name:formatted_addresses, address:address, scale: 8 }) }, complete(res){ wx.hideLoading(); console.log(1123213); } }) }, changeMenu(e) { let currentIndex = parseInt(e.currentTarget.dataset.id); this.setData({ currIndex: e.currentTarget.dataset.id }) }, getLocation() { var that = this; wx.getSetting({ success: res => { console.log(res); // res.authSetting.location if (res.authSetting.location) { wx.getLocation({ success(res1) { console.log("获取位置"); console.log(res1); if ( app.isNotEmptyCheck(res1.latitude) && app.isNotEmptyCheck(res1.longitude) ) { that.data.searchForm.lat = res1.latitude; that.data.searchForm.lng = res1.longitude; } that.getStoreJobDetailById(); }, fail() { that.getStoreJobDetailById(); } }); } else { that.getStoreJobDetailById(); } } }); // my.getLocation({ // success(res) { // my.hideLoading(); // console.log(res) // that.data.searchForm.lng = res.longitude; // that.data.searchForm.lat = res.latitude; // that.getStoreJobDetailById(); // }, // fail() { // my.hideLoading(); // that.getStoreJobDetailById(); // }, // }) }, onShareAppMessage: function () { var path = commonUtil.getCurrentPageUrlWithArgs(); if(app.globalData.isLogin && app.globalData.agencyStatus - 0 != 0) {//当前用户是代理人 path += '&agencyUserId=' + app.globalData.loginUserInfo.id; } var that = this; // const promise = new Promise(resolve => { // that.widget.renderToCanvas({ wxml:wxml(that.data.jobDetail), style }).then(res1 => { // const p2 = that.widget.canvasToTempFilePath() // p2.then(res => { // console.log(res); // resolve({ // title:that.data.shareTitle, // imageUrl: res.tempFilePath, // }) // }) // }); // }); return { "title":that.data.shareTitle, 'imageUrl':that.data.src , 'path': path, // promise } }, showVideo(e) { console.log(e); console.log(wx.getSystemInfo()); var that = this; this.videoContext = wx.createVideoContext(`${e.target.dataset.id}`, this); this.videoContext.requestFullScreen(); this.videoContext.hideStatusBar(); this.videoContext.play(); setTimeout(() => { that.setData({ isShareShow: true, }); }, 500); }, fullScreen(e) { console.log(e); if (!e.detail.fullScreen) { this.setData({ isShareShow: false, }); this.videoContext.stop(); } }, // play(e) { // //执行全屏方法 // var id = e.currentTarget.id; // var videoContext = wx.createVideoContext("a"+id , this); // videoContext.requestFullScreen(); // setTimeout(()=>{ // videoContext.play(); // },100) // this.setData({ // fullScreen:true // }) // }, // screenChange(e){ // console.log(e.currentTarget.id); // var id = e.currentTarget.id; // var videoContext = wx.createVideoContext(id , this); // let fullScreen = e.detail.fullScreen //值true为进入全屏,false为退出全屏 // if (!fullScreen ){ //退出全屏 // videoContext.pause() // this.setData({ // controls: false // }) // }else{ //进入全屏 // this.setData({ // controls: true // }) // } // }, // closeVideo(e) { // var id = e.currentTarget.id; // //执行退出全屏方法 // var videoContext = wx.createVideoContext('a'+id, this); // videoContext.exitFullScreen(); // }, // /**视屏进入、退出全屏 */ // fullScreen(e){ // var isFull = e.detail.fullScreen; // //视屏全屏时显示加载video,非全屏时,不显示加载video // this.setData({ // fullScreen:isFull // }) // }, onShareTimeline:function(){ return { title:this.data.shareTitle, query:"?storeJobId="+ this.data.storeJobId } }, getStoreJobDetailById() { var that = this; wx.request({ // url: app.globalData.ip + "/store/job/getStoreJobDetailById?storeJobId=" + that.data.searchForm.storeJobId, url: app.globalData.ip + "/overall/store/job/getStoreJobDetailById?storeJobId=" + that.data.searchForm.storeJobId, method: "POST", header: app.globalData.headers, data: that.data.searchForm, success: function (res) { console.log(res); var result = res.data.data; var title = result.storeJob.jobName; // var title1 = result.store.aliasName; // that.data.logo2 console.log(title); that.setData({ shareTitle: title, }) let regs = /\.(jpg|jpeg|png)(\?.*)?$/ res.data.data.storeImage.forEach((item)=>{ item.isImg = regs.test(item.url.toLowerCase()) }) console.log(res); console.log(that.data.jobDetail); if (app.isNotEmptyCheck(title)) { title = result.storeJob.jobName; } else { title = result.store.aliasName; } wx.setNavigationBarTitle({ title }); result.storeJob.workType = commonUtil.getWorkTypeById( result.storeJob.workTypeMulti ); if ( app.isNotEmptyCheck(result.storeJob.calculationSalaryType) ) { result.storeJob.calculationSalaryType = result.storeJob.calculationSalaryType.split( "#" )[0]; } if (app.isNotEmptyCheck(result.storeJob.paymentSalaryType)) { result.storeJob.paymentSalaryType = result.storeJob.paymentSalaryType.split( "," ); } if (app.isNotEmptyCheck(result.storeJob.salaryDesp)) { result.storeJob.salaryDesp = result.storeJob.salaryDesp.split( ";" ); } if (app.isNotEmptyCheck(result.storeJob.workDurationDesp)) { result.storeJob.workDurationDesp = result.storeJob.workDurationDesp.split( ";" ); } if (app.isNotEmptyCheck(result.storeJob.probationDesp)) { result.storeJob.probationDesp = result.storeJob.probationDesp.split( ";" ); } if (app.isNotEmptyCheck(result.storeJob.workingLunchDesp)) { result.storeJob.workingLunchDesp = result.storeJob.workingLunchDesp.split( ";" ); } if (app.isNotEmptyCheck(result.storeJob.dormitoryDesp)) { result.storeJob.dormitoryDesp = result.storeJob.dormitoryDesp.split( ";" ); } if (app.isNotEmptyCheck(result.storeJob.foregift)) { result.storeJob.foregift = result.storeJob.foregift.split( ";" ); var arrTemp = []; result.storeJob.foregift.forEach(item => { var arr = item.split(","); if (app.length > 0) { arrTemp.push({ item0: arr[0].split("#")[0], item1: arr[1].split("#")[0] }); } }); result.storeJob.foregift = arrTemp; } else { result.storeJob.foregift = "无押金"; } result.store.distance = commonUtil.getDistanceName( result.store.distance ); if (app.isNotEmptyCheck(result.store.distance)) { result.store.distance = '丨' + result.store.distance; } /*if (app.isNotEmptyCheck(result.store.district)) { var tempArr = result.store.district.split(","); if (tempArr.length == 1) { result.store.district = tempArr[0]; } else if (tempArr.length == 2) { result.store.district = tempArr[0] + "" + tempArr[1]; } else if (tempArr.length > 2) { result.store.district = tempArr[1] + "" + tempArr[2]; } }*/ // getStoreAddress that.disposeJobListData(result); if (app.isNotEmptyCheck(result.store.logo)) { result['logo2'] = result.store.logo.replace("http:","http:"); } else { result['logo2'] = ''; } let citys = commonUtil.setJobInfoPosition(result.store.district) result.storeJob.genderRestrict = commonUtil.getGenderByMinAge(result.storeJob) that.setData({ jobDetail: result, citys: citys || "-", }); console.log(that.data.jobDetail); } }); }, /** * 处理后台返回的职位列表 */ disposeJobListData(jobDetail) { var that = this; // item["workType"] = commonUtil.getWorkTypeById( // item.workTypeMulti // ); // if (app.isNotEmptyCheck(item.distance)) { // item["distanceKm"] = commonUtil.getDistanceName( // item.distance // ); // } //年龄 var ageStr = ''; if (app.isNotEmptyCheck(jobDetail.storeJob.minAge) && app.isNotEmptyCheck(jobDetail.storeJob.maxAge)) { ageStr = jobDetail.storeJob.minAge + '-' + jobDetail.storeJob.maxAge + '岁'; } else if (app.isNotEmptyCheck(jobDetail.storeJob.minAge)) { ageStr = jobDetail.storeJob.minAge + '岁以上'; } else if (app.isNotEmptyCheck(jobDetail.storeJob.maxAge)) { ageStr = jobDetail.storeJob.maxAge + '岁以下'; } jobDetail.storeJob["age"] = ageStr; // //时薪 // var hourlyPayStr = ''; // var hasHourlyPay = false; // if (app.isNotEmptyCheck(jobDetail.storeJob.hourlyPay)) { // hourlyPayStr = jobDetail.storeJob.hourlyPay + '元/小时'; // hasHourlyPay = true; // } else if (app.isNotEmptyCheck(jobDetail.storeJob.dayPay)) { // hourlyPayStr = jobDetail.storeJob.dayPay + '元/日'; // hasHourlyPay = true; // } else { // if (app.isNotEmptyCheck(jobDetail.storeJob.minMonthlyPay) && app.isNotEmptyCheck(jobDetail.storeJob.maxMonthlyPay)) { // if (jobDetail.storeJob.minMonthlyPay == jobDetail.storeJob.maxMonthlyPay) { // hourlyPayStr = jobDetail.storeJob.minMonthlyPay; // } else { // hourlyPayStr = jobDetail.storeJob.minMonthlyPay + '-' + jobDetail.storeJob.maxMonthlyPay; // } // } else if (app.isNotEmptyCheck(jobDetail.storeJob.minMonthlyPay)) { // hourlyPayStr = jobDetail.storeJob.minMonthlyPay; // } else if (app.isNotEmptyCheck(jobDetail.storeJob.maxMonthlyPay)) { // hourlyPayStr = jobDetail.storeJob.maxMonthlyPay; // } // } // jobDetail.storeJob["hourlyPay"] = hourlyPayStr; jobDetail.storeJob["salaryClassifyValue"] = commonUtil.getSalaryClassifyValue(jobDetail.storeJob.salaryClassify, jobDetail.storeJob.salaryClassifyValue); //月薪 var monthlyPayStr = ''; // if (hasHourlyPay) { if (app.isNotEmptyCheck(jobDetail.storeJob.minMonthlyPay) && app.isNotEmptyCheck(jobDetail.storeJob.maxMonthlyPay)) { if (jobDetail.storeJob.minMonthlyPay == jobDetail.storeJob.maxMonthlyPay) { monthlyPayStr = jobDetail.storeJob.minMonthlyPay; } else { monthlyPayStr = jobDetail.storeJob.minMonthlyPay + '-' + jobDetail.storeJob.maxMonthlyPay; } } else if (app.isNotEmptyCheck(jobDetail.storeJob.minMonthlyPay)) { monthlyPayStr = jobDetail.storeJob.minMonthlyPay; } else if (app.isNotEmptyCheck(jobDetail.storeJob.maxMonthlyPay)) { monthlyPayStr = jobDetail.storeJob.maxMonthlyPay; } // } jobDetail.storeJob["monthlyPay"] = monthlyPayStr; //地址深圳丨龙岗区丨 var districtStr = ''; if (app.isNotEmptyCheck(jobDetail.storeJob.district)) { var districtArr = jobDetail.storeJob.district.split(','); if(districtArr.length < 3) { districtStr = districtArr[districtArr.length - 1]; } else { districtStr = districtArr[1] + '丨' + districtArr[2]; } //districtStr = districtArr[1] + '丨' + districtArr[2]; } jobDetail.storeJob["districtStr"] = districtStr; jobDetail.storeJob["districtDetail"] = commonUtil.getStoreAddress(jobDetail.storeJob.district, jobDetail.storeJob.detailPosition); //职位特色 if (app.isNotEmptyCheck(jobDetail.storeJob.jobSpecialLabelNames)) { jobDetail.storeJob['jobSpecialLabelNames'] = that.getJobSpecialLabelNamesArray(jobDetail.storeJob.jobSpecialLabelNames); } }, getJobSpecialLabelNamesArray(jobSpecialLabelNames) { if (app.isNotEmptyCheck(jobSpecialLabelNames)) { return jobSpecialLabelNames.split(', '); } return []; }, goSimilar() { var that = this; console.log(that.data.jobDetail) console.log(that.data.jobDetail.storeJob.jobLabelId) wx.navigateTo({ url: "../similar/index?brandId=" + that.data.jobDetail.store.brandId + "&jobLabelId=" + that.data.jobDetail.storeJob.jobLabelId + "&classify=99" }); }, makePhoneCall() { console.log(1); var that = this; wx.makePhoneCall({ // number: that.data.jobDetail.assistantUserTel + "" phoneNumber:'18039237825' }); // var that = this; // let res = wx.getStorageSync({ // key: "assistantUserTel" // }); // console.log(res); // console.log("缓存获取电话号:" + res.data); // if (app.isNotEmptyCheck(res.data)) { // wx.makePhoneCall({ // number: res.data // }); // } else { // wx.request({ // url: app.globalData.ip + "/store/job/getOneAssistantUser", // method: "POST", // header: app.globalData.headers, // data: {}, // success: function (res) { // console.log(res.data.data.tel); // wx.setStorageSync({ // key: "assistantUserTel", // data: res.data.data.tel // }); // wx.makePhoneCall({ // number: res.data.data.tel + "" // }); // } // }); // } }, textPaste() { var that = this; wx.setClipboardData({ // data: that.data.jobDetail.assistantUserWechat, data:'18039237825', success: function (res) { wx.getClipboardData({ success: function (res) { wx.showToast({ icon: "none", title: '已复制微信号,快去添加好友吧', duration:0, }) wx.showModal({ title: '已复制微信号', content: '快去搜索添加经纪人好友吧', showCancel:false, success (res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } } }) console.log(res.data) // data } }) } }) }, /*collectPaste() { var txt; var that = this; if(!this.data.isCollect){ that.setData({ isCollect: true }) txt = '收藏成功' }else{ that.setData({ isCollect: false }) txt = '取消收藏' } wx.showToast({ icon: "none", title: txt, }) },*/ goEnroll() { var that = this; // wx.setStorageSync({ // key: "jobDetailStorage", // data: that.data.jobDetail // }); wx.setStorageSync('jobDetailStorage', that.data.jobDetail.storeJob); // wx.navigateTo({ // url: "../enroll/index?applyType=1" // }); 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) console.log(that.data.jobDetail.storeJob); /*wx.setStorageSync({ key: "jobDetailStorage", data: that.data.jobDetail.storeJob, });*/ wx.setStorageSync('jobDetailStorage', that.data.jobDetail.storeJob); // 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); }) } else { /*wx.navigateTo({ url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber });*/ promise.then(res => { wx.navigateTo({ //url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber url: "../enroll/index?applyType=1" }); }) } // wx.navigateTo({ // 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&tel=" + res.data.data.phoneNumber url: "../enroll/index?applyType=1" }); }) } }, fail: function (res) { console.log("获取用户手机号错误"); } }) } else { console.log('获取手机号失败!' + res.errMsg) } } }) } }) } else {//拒绝 var collected = e.currentTarget.dataset.collected; if (collected) { try { wx.setStorageSync('comeFromPage', 'detail'); wx.setStorageSync('comeFromPageParam', {storeJobId: that.data.searchForm.storeJobId}); } catch (e) { console.log("detail-页面跳转,设置参数错误:", e); } wx.navigateTo({ url: '/pages/login/index', }) } else { wx.navigateTo({ //url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber url: "../enroll/index?applyType=1" }); } } return false; }, 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) {//取消收藏 that.data.jobDetail.storeJob.collected = 2; txt = '取消收藏'; } else {//收藏 that.data.jobDetail.storeJob.collected = 1; txt = '收藏成功'; } that.setData({ jobDetail: that.data.jobDetail, isLogin: app.globalData.isLogin }); console.log(that.data.jobDetail) wx.showToast({ icon: "none", title: txt, }) }, fail: function (res) { console.log("操作失败"); } }) }, });