You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1030 lines
29 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const app = getApp();
const commonUtil = require("../../utils/commonUtil");
const { wxml, style } = require("./demo.js");
var QQMapWX = require("../../utils/qqmap-wx-jssdk.min.js");
var qqmapsdk;
Page({
data: {
storeJobId: "",
currIndex: "1",
//职位ID
searchForm: {
storeJobId: "",
lng: "",
lat: "",
},
fullScreen: false,
bclr: "",
djxx: "",
currIndex: "1",
jobDetail: {}, //详情
wxCode: "",
pbtm: 0,
shareTitle: "",
isCollect: false,
src: "",
word: "woca",
phoneDialog: false,
isImg: true,
labelColor: ["#c41d7f", "#096dd9", "#531dab", "#d46b08", "#389e0d", "#08979c", "#cf1322"],
bgColor: ["#fff0f6", "#e6f7ff", "#f9f0ff", "#fff7e6", "#f6ffed", "#e6fffb", "#fff1f0"],
wxml: {
text: "啊啊按",
},
addressNew: "",
citys: "",
showSexAgeText: "",
fuWuFei: "",
isServicePriceShow: true,
isAgency: true,
isShareShow: false,
managerRoleClassify: false, // 管理员权限
serviceTel:app.globalData.serviceTel,
},
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,
});
},
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();
}
},
shareVideo(e) {
console.log(e);
wx.showLoading({
title: "下载中...",
mask: true,
});
wx.downloadFile({
url: e.currentTarget.dataset.src, // 下载url
success(res) {
// 下载完成后转发
wx.hideLoading();
wx.showLoading({
title: "分享中...",
mask: true,
});
wx.shareVideoMessage({
videoPath: res.tempFilePath,
success() {
wx.hideLoading();
},
fail: () => {
wx.hideLoading();
wx.showToast({
title: "分享失败",
});
},
});
},
fail: () => {
wx.hideLoading();
wx.showToast({
title: "下载失败",
});
},
});
},
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;
console.log(app.globalData.loginUserInfo);
qqmapsdk = new QQMapWX({
key: "5PTBZ-YI7C6-MZGS3-ES7QN-4T5O2-EJFVR",
});
that.setData({
isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false,
managerRoleClassify: app.globalData.loginUserInfo.managerRoleClassify,
});
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 {
}
},
});
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;
}
},
getAgencyInfo(job) {
var that = this;
console.log(job);
console.log("打印基本信息");
let objAgency = {
returnFeeDesp: job.returnFeeDesp,
returnFeeType: job.returnFeeType,
transferFee: job.transferFee,
returnFee: job.returnFee != null ? new Number(job.returnFee).toFixed(2) : null,
};
let agencyStr = "";
if (app.isNotEmptyCheck(job.transferFee)) {
agencyStr = "伯才利润:" + job.transferFee + ";";
}
if (job.returnFeeType == 0) {
agencyStr += `\n服务费xxx元/时`;
} else if (job.returnFeeType == 1) {
agencyStr += `\n服务费xxx元/天`;
} else if (job.returnFeeType == 2) {
agencyStr += `\n服务费xxx元/月`;
} else if (job.returnFeeType == 3) {
agencyStr += `\n服务费xxx元/次`;
}
if (objAgency.returnFee > 0) {
agencyStr = agencyStr.replace("xxx", objAgency.returnFee);
} else if (app.isNotEmptyCheck(job.transferFee)) {
agencyStr = "伯才利润:" + job.transferFee + ";";
} else {
agencyStr = "-";
}
if (app.isEmptyCheck(objAgency.returnFeeDesp)) {
// return agencyStr
that.setData({
bclr: agencyStr,
});
} else {
that.setData({
bclr: agencyStr + "\n" + objAgency.returnFeeDesp,
});
// return agencyStr + '\n' + objAgency.returnFeeDesp;
}
},
toMapChoice(e){
console.log(e);
try {
wx.setStorageSync('addressList', e.currentTarget.dataset.address)
} catch (error) {
console.log(error);
}
wx.navigateTo({
url:'../addressPage/index'
})
},
// 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(formatted_addresses);
// console.log(lat);
// 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
};
},
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.aliasName;
// 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);
result.storeJob.genderRestrict = commonUtil.getGenderByMinAge(result.storeJob)
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"] = "";
}
// console.log(commonUtil.getReturnFeeTypeName1ById(result.storeJob.returnFeeType, result.storeJob.returnFee));
console.log("isout");
that.setData({
fuWuFei: commonUtil.getReturnFeeTypeName1ById(result.storeJob.returnFeeType, result.storeJob.returnFee),
});
console.log(result.store);
console.log(commonUtil);
let citys = commonUtil.setJobInfoPosition(result.store.district)
// city = city.replace(/,/g, " | ")
that.setData({
jobDetail: result,
citys: citys || "-",
addressNew: result.store.district.replace(/,/g, "") + result.store.detailPosition,
});
that.data.jobDetail.storeJob["storeName"] = that.data.jobDetail.store.storeName;
that.showSexAge();
// that.getAgencyInfo(res.data.data.storeJob);
if (app.isEmptyCheck(res.data.data.storeJob.handoverInfo)) {
that.setData({
djxx: "暂无对接信息",
});
} else {
that.setData({
djxx: res.data.data.storeJob.handoverInfo,
});
}
console.log(that.data.jobDetail);
},
});
},
showSexAge() {
var that = this;
var manStr = "";
var womanStr = "";
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.minAgeMan) || app.isNotEmptyCheck(that.data.jobDetail.storeJob.maxAgeMan)) {
manStr = "男 ";
}
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.minAgeMan)) {
manStr = manStr + that.data.jobDetail.storeJob.minAgeMan;
}
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.maxAgeMan)) {
manStr = manStr + "-" + that.data.jobDetail.storeJob.maxAgeMan;
}
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.minAgeWoman) || app.isNotEmptyCheck(that.data.jobDetail.storeJob.maxAgeWoman)) {
womanStr = "女 ";
}
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.minAgeWoman)) {
womanStr = womanStr + that.data.jobDetail.storeJob.minAgeWoman;
}
if (app.isNotEmptyCheck(that.data.jobDetail.storeJob.maxAgeWoman)) {
womanStr = womanStr + "-" + that.data.jobDetail.storeJob.maxAgeWoman;
}
if (womanStr != "") {
manStr = manStr + `${manStr == "" ? "" : ""}` + womanStr;
}
that.setData({
showSexAgeText: manStr,
});
},
/**
* 处理后台返回的职位列表
*/
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 = true;
console.log(jobDetail.storeJob);
// 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;
// }
// }
// if (app.isNotEmptyCheck(jobDetail.storeJob.dayPay)){
// }
// if (app.isNotEmptyCheck(jobDetail.storeJob.salaryClassify) && app.isNotEmptyCheck(jobDetail.storeJob.salaryClassifyValue)) {
jobDetail.storeJob["hourlyPay"] = 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);
}
// if (app.isNotEmptyCheck(jobDetail.storeJob.jobRequestLabelNames)) {
// jobDetail.storeJob['jobRequestLabelNames'] = that.getJobRequestLabelNamesArray(jobDetail.storeJob.jobRequestLabelNames);
// }
},
getJobSpecialLabelNamesArray(jobSpecialLabelNames) {
if (app.isNotEmptyCheck(jobSpecialLabelNames)) {
return jobSpecialLabelNames.split(", ");
}
return [];
},
getJobRequestLabelNamesArray(jobRequestLabelNames) {
console.log(jobRequestLabelNames);
if (app.isNotEmptyCheck(jobRequestLabelNames)) {
return jobRequestLabelNames.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: that.data.serviceTel,
});
// 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: '16619732648',
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,
})
},*/
goNewEnroll(e) {
let that = this;
let argument;
argument = JSON.stringify(that.data.jobDetail.storeJob).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/index?applyType=1&info=${argument}`,
});
},
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,
type: "yishoudan",
},
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;
console.log(that.data.isAgency);
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) => {
let argument;
argument = JSON.stringify(that.data.jobDetail.storeJob).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/index?applyType=1&info=${argument}`,
});
});
}
promise.then(() => {
console.log(app.globalData.loginUserInfo.agencyStatus);
that.setData({
isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false,
});
});
// 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,
type: "yishoudan",
},
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) => {
let argument;
argument = JSON.stringify(that.data.jobDetail.storeJob).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/index?applyType=1&info=${argument}`,
});
});
}
promise.then(() => {
console.log(app.globalData.loginUserInfo.agencyStatus);
that.setData({
isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false,
});
});
},
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("操作失败");
},
});
},
toggleprice(type) {
console.log(type);
if (type.target.dataset.index == 1) {
this.setData({
isServicePriceShow: false,
});
} else {
this.setData({
isServicePriceShow: true,
});
}
},
});