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.

549 lines
15 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.

// pages/jobDetail/index.js
const app = getApp();
const commonUtil = require("../../utils/commonUtil");
Page({
/**
* 页面的初始数据
*/
data: {
navlist:1,
jjHeight:0,
jjText:"-",
storeJobId:"",
showSexAgeText:'',
isImg:true,
mapLoad:true,
case:1,
},
case(e){
this.setData({
case:e.currentTarget.dataset.id
})
},
openMap(e){
var that = this;
console.log(e);
let lat = e.currentTarget.dataset.lat;
let lng = e.currentTarget.dataset.lng;
let address = e.currentTarget.dataset.address;
console.log(lat);
wx.openLocation({
latitude:Number(lat),
longitude:Number(lng),
name:address,
scale: 15
})
that.setData({
mapLoad:false
})
},
changeactive: function(e) {
this.setData({
navlist: e.mark.ind,
});
// this.getList();
},
editDetail(e){
var title = e.currentTarget.dataset.title;
var content = e.currentTarget.dataset.content;
var namestr = e.currentTarget.dataset.namestr;
wx.navigateTo({
url: './editDetail/index?title='+title+"&namestr="+namestr,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
storeJobId:options.storeJobId
})
for (let i = 0; i < 50; ++i) {
this.setData({
["isEditA" + i] :false,
["isEditB" + i] :false,
["isEditC" + i] :false
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
var that = this;
this.getStoreJobDetailById();
},
changeEdit(e){
var that = this;
let curr = e.currentTarget.dataset.edit
for (let i = 0; i < 50; ++i) {
if(curr == i){
that.setData({
["isEditA" + i] :true,
["isEditB" + i] :true,
["isEditC" + i] :true
})
}else{
that.setData({
["isEditA" + i] :false,
["isEditB" + i] :false,
["isEditC" + i] :false
})
}
}
},
shrinkAll(e){
var that = this;
// for (let i = 0; i < 100; ++i) {
// this.setData({
// ["isEditA" + i] :false,
// })
// setTimeout(()=>{
// that.setData({
// ["isEditB" + curr] :false
// })
// },250)
// }
},
shrink(e){
var that = this;
let curr = e.currentTarget.dataset.edit
// setTimeout(()=>{
that.setData({
["isEditA" + curr] :false,
["isEditB" + curr] :false
})
setTimeout(()=>{
that.setData({
["isEditC" + curr] :false
})
},200)
},
getStoreJobDetailById(){
var that = this;
console.log(that.data.mapLoad);
if((wx.getStorageSync('isLoad') == "" || wx.getStorageSync('isLoad')) && that.data.mapLoad ){
wx.showLoading({
title: '加载中...',
})
}
wx.removeStorage({
key: 'isLoad',
})
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.storeJobId,
method: "POST",
header: app.globalData.headers,
data: that.data.searchForm,
success: function (res) {
console.log(res);
wx.setStorageSync('jobDetail', res.data.data)
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)
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;
}
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.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(result.storeJob);
wx.hideLoading({
success: (res) => {},
})
for (let key in result.storeJob) {
// console.log(typeof(result.storeJob[key])) // foo, bar
if(result.storeJob[key] == ""){
result.storeJob[key] = "-";
}
// console.log(typeof(result.storeJob[key]) == "string");
// console.log(typeof(result.storeJob[key]) == string);
if(typeof(result.storeJob[key]) == "string"){
result.storeJob[key] = result.storeJob[key].trim();
}
// else{
// // result.storeJob[key] = result.storeJob[key].trim();
// }
}
console.log(result.storeImage);
if(result.storeImage.length > 4){
result.storeImage = result.storeImage.splice(0,4)
}
// result.storeImage = res.data.data.imageList.splice(0,4)
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();
setTimeout(() => { //厂区简介高度判断
let query = wx.createSelectorQuery();
query.select('.dtHeight').boundingClientRect(rect=>{
let height = rect.height;
console.log(height);
that.setData({
jjHeight:height
})
}).exec();
}, 200)
},
});
},
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",
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
xzDetail(){
wx.navigateTo({
url: './xzDetail/index',
})
},
sexAge(){
wx.navigateTo({
url: './sexAge/index',
})
},
xzffDetail(){
wx.navigateTo({
url: './xzffDetail/index',
})
},
editAddress(){
wx.navigateTo({
url: './editAddress/index',
})
},
editImg(){
wx.navigateTo({
url: './editImg/index',
})
},
})