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.

1581 lines
51 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: {
isLogin: false,
statusBarHeight: wx.getStorageSync("statusBarHeight"), // 状态栏高度
navigationBarHeight: wx.getStorageSync("navigationBarHeight"), // 导航栏高度
menuButtonHeight: wx.getStorageSync("menuButtonHeight"), // 胶囊按钮高度
menuButton: wx.getStorageSync("menuButtonInfo"), // 胶囊信息
backHeight: wx.getMenuButtonBoundingClientRect().top + (wx.getMenuButtonBoundingClientRect().height / 2) + 'px',
storeJobId: "",
iosDialog: false,
//职位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, // 管理员权限
serviceInfo: app.globalData.serviceInfo,
isMaskShow: false,
onSiteRemark: "",
img: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/bg.png",
canvasImg: "",
isLoading: true,
iosDialogTobe: false, // 成为代理弹窗显示
userInfo: {},
shareListImg: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/detail830-1.png",
shareDetailImg: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/posterbg1.1.png",
posterImg: "",
safeBottom: wx.getWindowInfo().screenHeight - wx.getWindowInfo().safeArea.height + 'px',
fromScene: false,
fromShoucangOrBaoming: '',
recordBillShow: false
},
showdialog () {
this.setData({
iosDialog: true,
});
},
closeDialog () {
this.setData({
iosDialog: false,
});
},
onShow () {
var that = this;
console.log(that.data.safeBottom);
this.setData({
isLogin: app.globalData.isLogin,
// backHeight:wx.getMenuButtonBoundingClientRect().top,
isLoading: true,
// userInfo:{...app.globalData.loginUserInfo, agencyStatus:0},
});
if (app.globalData.isLogin) {
that.setData({
// agencyStatus: app.globalData.agencyStatus,
userInfo: app.globalData.loginUserInfo,
});
} else {
this.wxLogin();
}
that.searchAnimate();
console.log(that.data.userInfo);
},
showphone: function () {
var that = this;
wx.makePhoneCall({
// number: that.data.jobDetail.assistantUserTel + ""
phoneNumber: that.data.serviceInfo.workPhone || "0371-6611 3723",
});
},
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;
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;
// let systemInfo = wx.getSystemInfoSync();
// let rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null; //胶囊按钮位置信息
// wx.getMenuButtonBoundingClientRect();
// let navBarHeight = (function() { //导航栏高度
// let gap = rect.top - systemInfo.statusBarHeight; //动态计算每台手机状态栏到胶囊按钮间距
// return 2 * gap + rect.height;
// })();
console.log((wx.getMenuButtonBoundingClientRect().top - wx.getWindowInfo().statusBarHeight) * 2 + wx.getMenuButtonBoundingClientRect().height + wx.getWindowInfo().statusBarHeight);
console.log(wx.getWindowInfo().screenTop)
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,
corpUserFlag: app.globalData.loginUserInfo.corpUserFlag,
managerRoleClassify: app.globalData.loginUserInfo.managerRoleClassify,
userInfo: app.globalData.loginUserInfo,
});
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(query);
if (app.isNotEmptyCheck(query.fromShoucangOrBaoming)) {
that.setData({
fromShoucangOrBaoming: query.fromShoucangOrBaoming
})
}
console.log("HHHHHHHHHHHHH" + query.storeJobId);
if (app.isNotEmptyCheck(query.storeJobId)) {
console.log("HHHHHHHHHHHHH");
this.data.searchForm.storeJobId = query.storeJobId;
} else if (app.isNotEmptyCheck(query.scene)) {
console.log("XXXXXXXXXXXX")
//扫小程序码携带参数
var sceneStr = decodeURIComponent(query.scene);
var sceneJson = commonUtil.sceneToJson(sceneStr);
console.log("sceneJson===", sceneJson);
let arr = sceneJson.i.split('_')
if (arr[0] > 0) {
wx.setStorageSync("applyUserId", arr[0]);
}
if (arr[1] > 0) {
wx.setStorageSync("agencyId", arr[1]);
app.globalData.agencyId = arr[1]
}
if (arr[2] > 0) {
this.data.searchForm.storeJobId = arr[2];
}
// wx.setStorageSync("agencyId", sceneJson.agencyId);
that.setData({
fromScene: true
})
}
if (app.isNotEmptyCheck(query.from)) {
that.setData({
fromScene: true
})
}
// 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;
}
},
backIndex () {
wx.switchTab({
url: '../index/index',
})
},
searchAnimate () {
let that = this;
wx.createSelectorQuery()
.select("#listBox")
.fields(
{
scrollOffset: true,
size: true,
},
(res) => {
this.animate(
".navigatorBar",
[
{
opacity: 0
},
{
opacity: 1
},
],
800,
{
scrollSource: "#listBox",
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 120,
}
);
this.animate(
".noBack",
[
{
opacity: 1
},
{
opacity: 0
},
],
800,
{
scrollSource: "#listBox",
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 1,
}
);
}
)
.exec();
},
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) {
var that = this;
console.log(e);
try {
wx.setStorageSync("onSiteRemark", that.data.onSiteRemark);
wx.setStorageSync("addressList", e.currentTarget.dataset.address);
} catch (error) {
console.log(error);
}
wx.navigateTo({
url: "../mine/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();
// },
// })
},
// onShareAppMessage1: 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 this.getCanvas().then(()=>{
// return {
// title: that.data.shareTitle,
// imageUrl: that.data.canvasImg,
// path: path,
// // promise
// };
// })
// },
getCanvas () {
const that = this;
return new Promise((resolve) => {
var mycenter = 0; //文字左右居中显示
var myheight = 0; //文字高度
const query = wx.createSelectorQuery();
query
.select("#canvasId")
.fields({ node: true, size: true })
.exec((res) => {
console.log(res);
const canvas = res[0].node;
const ctx = canvas.getContext("2d");
new Promise(function (resolve) {
// 绘制背景图片
wx.getImageInfo({
src: that.data.img, //网络图片,如果不行请换一个
success (res) {
console.log(res);
var width = res.width;
var height = res.height;
mycenter = width / 2;
myheight = height;
canvas.width = width;
canvas.height = height;
const img = canvas.createImage();
console.log(ctx);
img.src = res.path;
img.onload = () => {
ctx.drawImage(img, 0, 0, width, height);
resolve(true);
};
},
});
})
.then(() => {
ctx.font = "500 70px Arial";
ctx.textAlign = "left";
// ctx.fillStyle = "#333";
ctx.fillStyle = "#fff";
// console.log(that.data.factoryBill.totalSalary.toString().length);
// let steNumber = that.data.factoryBill.totalSalary.toString().length
// ctx.fillRect(40, 168, steNumber * 30, 72);
ctx.fillText("职位详情", 40, 210);
})
.then(function () {
wx.canvasToTempFilePath({
canvas: canvas,
success (res) {
console.log(res);
that.setData({
canvasImg: res.tempFilePath,
// base64: canvas.toDataURL(),
});
resolve();
// console.log(that.data.canvasImg);
},
});
})
.catch((err) => { });
});
});
},
// onShareTimeline: function () {
// return {
// title: this.data.shareTitle,
// query: "?storeJobId=" + this.data.storeJobId,
// };
// },
getCanvas () {
const that = this;
return new Promise((resolve) => {
var mycenter = 0; //文字左右居中显示
var myheight = 0; //文字高度
const query = wx.createSelectorQuery();
query
.select("#canvasId")
.fields({ node: true, size: true })
.exec((res) => {
console.log(res);
const canvas = res[0].node;
const ctx = canvas.getContext("2d");
new Promise(function (resolve) {
// 绘制背景图片
wx.getImageInfo({
src: that.data.shareDetailImg, //网络图片,如果不行请换一个
success (res) {
console.log(res);
var width = res.width;
var height = res.height;
mycenter = width / 2;
myheight = height;
canvas.width = width;
canvas.height = height;
const img = canvas.createImage();
console.log(ctx);
img.src = res.path;
img.onload = () => {
ctx.drawImage(img, 0, 0, width, height);
resolve(true);
};
},
});
}).then(() => {
console.log(530);
const fillTextLineBreak = (ctx, text, x, y, lw, lh, color = "#333", font = "32", weight = "500") => {
var i = 0;
var n = 0;
var r = -1;
var initHeight = 0;
ctx.font = weight + " " + font + "px Arial"; //字体大小
ctx.fillStyle = color; //字体颜色
while (i < text.length) {
while (ctx.measureText(text.substring(n, i)).width < lw && i < text.length) {
i++;
}
r++;
ctx.fillText(text.substring(n, i), x, y + lh * r);
n = i;
}
initHeight = lh * r;
// wx.setStorageSync("initHeight", initHeight);
};
const roundRect = (ctx, img, bg_x, bg_y, bg_w, bg_h, bg_r) => {
// 开始绘制
ctx.save();
ctx.beginPath();
ctx.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5);
ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2);
ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_h - bg_r, bg_r, 0, Math.PI * 0.5);
ctx.arc(bg_x + bg_r, bg_y + bg_h - bg_r, bg_r, Math.PI * 0.5, Math.PI);
ctx.clip();
ctx.drawImage(img, bg_x, bg_y, bg_w, bg_h);
// 恢复之前保存的绘图上下文
ctx.restore();
};
const roundRect_yuan = (ctx, x, y, size) => {
// 开始绘制
ctx.save(); // 保存
ctx.beginPath(); // 开始绘制
// ctx.arc(100, 75, 50, 0, 2 * Math.PI)
ctx.arc(size / 2 + x, size / 2 + y, size / 2, 0, Math.PI * 2, false);
ctx.clip();
// 恢复之前保存的绘图上下文
ctx.restore();
};
function roundRect1 (ctx, x, y, w, h, r, color) {
//绘制圆角矩形(无填充色))
ctx.save();
ctx.fillStyle = color;
ctx.strokeStyle = color;
ctx.lineJoin = "round"; //交点设置成圆角
ctx.lineWidth = r;
ctx.strokeRect(x + r / 2, y + r / 2, w - r, h - r);
ctx.fillRect(x + r, y + r, w - r * 2, h - r * 2);
ctx.stroke();
ctx.closePath();
}
//使用:
new Promise((imgres) => {
// that.data.checkedList.forEach((item, index) => {
console.log(587);
let labelLeft = 0;
// ctx.arcTo()
let baseTop, logoLeft, logoSize, titleSize, ageTop, salaryClassifyValueLeft, salaryClassifyValueTop, monthlyPaySize, position, markTop, roundRectHeight;
logoLeft = 56 * 2;
let baseMiddle = 248 * 2;
// if (that.data.checkedList.length == 1) {
baseTop = 2 * 370;
logoSize = 2 * 96;
titleSize = 2 * 36;
roundRectHeight = 2 * 260;
ageTop = 2 * 110;
salaryClassifyValueLeft = 2 * 176;
salaryClassifyValueTop = 2 * 54;
monthlyPaySize = 2 * 28;
markTop = 2 * 145;
console.log(603);
// }
// else {
// baseTop = 2 * 294;
// logoSize = 2 * 80;
// titleSize = 2 * 32;
// roundRectHeight = 2 * 226;
// ageTop = 2 * 88;
// salaryClassifyValueLeft = 2 * 156;
// salaryClassifyValueTop = 2 * 48;
// monthlyPaySize = 2 * 24;
// markTop = 2 * 115;
// }
roundRect1(ctx, 24 * 2, baseTop - 100, 1104, roundRectHeight, 32, "#fff");
console.log(that.data.jobDetail.store);
that.data.jobDetail.storeJob.jobSpecialLabelNames.forEach((item1, index) => {
// console.log(item1);
// console.log(ctx.measureText(item1).width);
if (index <= 2) {
fillTextLineBreak(ctx, item1, 60 * 2 + labelLeft, baseTop + markTop + 30 * 2, 400 * 2, 20, "#333", monthlyPaySize); // 标签字符
roundRect1(ctx, 52 * 2 + labelLeft, baseTop + markTop, ctx.measureText(item1).width + 16 * 2, 40 * 2, 32 * 2, "#00000008");
labelLeft += ctx.measureText(item1).width + 32 * 2;
}
});
console.log(that.data.jobDetail.store);
console.log(that.data.jobDetail);
fillTextLineBreak(ctx, that.data.jobDetail.store.aliasName, logoLeft, baseTop, 500 * 2, 20, "#333", titleSize, "600"); // 岗位标题
console.log(630);
fillTextLineBreak(ctx, that.data.jobDetail.storeJob.hourlyPay, salaryClassifyValueLeft, baseTop + salaryClassifyValueTop, 400 * 2, 20, "#ff4400", titleSize, "600"); // 时薪
fillTextLineBreak(ctx, that.data.jobDetail.storeJob.monthlyPay, salaryClassifyValueLeft + ctx.measureText(that.data.jobDetail.storeJob.monthlyPay).width, baseTop + salaryClassifyValueTop, 400 * 2, 20, "#ff4400", monthlyPaySize, "400"); // 月工资
fillTextLineBreak(ctx, that.data.jobDetail.store.districtStr + "丨", salaryClassifyValueLeft, baseTop + ageTop, 300 * 2, 20, "#333", monthlyPaySize); // 省市年龄
fillTextLineBreak(ctx, that.data.jobDetail.storeJob.age, salaryClassifyValueLeft + ctx.measureText(that.data.jobDetail.store.districtStr + "丨").width, baseTop + ageTop, 300 * 2, 20, "#333", monthlyPaySize); // 省市年龄
// let src
// src = that.data.jobDetail.store.logo.indexOf("https") > -1 ? that.data.jobDetail.store.logo : that.data.jobDetail.store.logo.replace("http", "https")
console.log(that.data.jobDetail.store.logo);
wx.downloadFile({
url: that.data.jobDetail.store.logo, //网络图片,如果不行请换一个
success (res) {
console.log(res);
const img = canvas.createImage();
img.src = res.tempFilePath;
img.onload = () => {
roundRect(ctx, img, logoLeft, baseTop + 40, logoSize, logoSize, 8);
// if (index == that.data.checkedList.length - 1) {
setTimeout(() => {
imgres();
}, 200);
// }
};
},
fail (err) {
console.log(err);
}
});
// });
// setTimeout(() => {
// },500);
})
.then(function () {
wx.canvasToTempFilePath({
canvas: canvas,
success (res) {
console.log(res);
that.setData({
canvasImg: res.tempFilePath,
});
resolve(res);
},
fail (res) {
wx.hideLoading();
wx.showToast({
title: res.errMsg,
icon: "error",
});
},
});
})
.catch((err) => {
console.log(err);
});
});
});
});
},
/**
* 分享海报生成海报图并转发
*
*
*/
sharePoster () {
wx.showLoading({
title: "生成中...",
});
this.getCanvas().then((res) => {
console.log(res);
wx.hideLoading();
this.setData({
posterImg: res.tempFilePath,
posterShow: true,
});
});
// this.setData({
// });
},
hidePoster () {
this.setData({
posterShow: false,
});
},
saveToalbum () {
let that = this;
wx.saveImageToPhotosAlbum({
filePath: that.data.posterImg,
success (res) {
console.log(res);
if (res.errMsg == "saveImageToPhotosAlbum:ok") {
wx.showToast({
title: "图片已保存",
icon: "none",
duration: 1500,
});
}
},
fail (res) {
console.log(res);
wx.showToast({
title: "图片保存失败",
icon: "none",
duration: 1500,
});
},
});
},
goBack () {
if (this.data.fromScene) {
wx.switchTab({
url: '../index/index',
})
} else {
wx.navigateBack({
delta: -1,
})
}
},
getStoreJobDetailById () {
var that = this;
wx.showLoading({
title: "加载中...",
});
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);
if (res.data.status == 200) {
var result = res.data.data;
var title = result.storeJob.jobName;
// var title1 = result.store.aliasName;
// that.data.logo2
// wx.setStorageSync({
// key: "onSiteRemark",
// data: result.storeJob.onSiteRemark,
// })
that.setData({
shareTitle: title,
onSiteRemark: result.storeJob.onSiteRemark,
});
let regs = /\.(jpg|jpeg|png)(\?.*)?$/;
res.data.data.storeImage.forEach((item) => {
item.isImg = regs.test(item.url.toLowerCase());
});
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.jobDesp)) {
result.storeJob.jobDesp = result.storeJob.jobDesp.replaceAll("*****", "").split("————————")[0];
result.storeJob["jobDesp1"] = result.storeJob.jobDesp.replace("⚠", "<i class='t-icon t-icon-zhuyi' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>");
result.storeJob["jobDesp1"] = result.storeJob.jobDesp1.replace("[红包]", "<i class='t-icon t-icon-hongbao' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>");
}
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:", "https:");
result.store.logo.indexOf("https") > -1 ? result.store.logo : result.store.logo.replace("http", "https")
} else {
result["logo2"] = "";
}
// console.log(commonUtil.getReturnFeeTypeName1ById(result.storeJob.returnFeeType, result.storeJob.returnFee));
console.log("isout");
if (app.isNotEmptyCheck(result.storeJob.returnFeeType) || result.storeJob.returnFeeType == "0" || result.storeJob.returnFee == "0") {
that.setData({
fuWuFei: commonUtil.getReturnFeeTypeName1ById(result.storeJob.returnFeeType, result.storeJob.returnFee),
});
}
// else if (result.storeJob.returnFeeType == 7) {
// that.setData({
// fuWuFei: commonUtil.getReturnFeeTypeNameById(result.storeJob.returnFeeType),
// });
// }
else {
that.setData({
fuWuFei: "-",
});
}
console.log(result);
console.log(commonUtil);
let citys = commonUtil.setJobInfoPosition(result.store.district);
// city = city.replace(/,/g, " | ")
result.storeImage.splice(0, 1)
that.setData({
jobDetail: result,
isMaskShow: !(result.storeJob.recruitment == "1"),
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);
}
wx.hideLoading();
},
});
},
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.store.district)) {
var districtArr = jobDetail.store.district.split(",");
if (districtArr.length < 3) {
districtStr = districtArr[districtArr.length - 1];
} else {
districtStr = districtArr[1] + "丨" + districtArr[2];
}
//districtStr = districtArr[1] + '丨' + districtArr[2];
}
jobDetail.store["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.serviceInfo.workPhone || "0371-6611 3723",
});
// 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,
})
},*/
hideModal () {
this.setData({
recordBillShow: false
})
},
goNewEnroll (e) {
let that = this;
// this.data.recordBillShow = true
this.setData({
recordBillShow: true
})
return
let argument;
argument = JSON.stringify(that.data.jobDetail.storeJob).replace(/\=|\&/g, "3D");
if (!app.globalData.isLogin) {
wx.setStorageSync("comeFromPage", "detailBaoming");
wx.setStorageSync("baomingDetail", argument);
wx.navigateTo({
url: "/pages/login/index",
});
return;
}
// wx.navigateTo({
// url: `../newEnroll/enroll/index?applyType=1&info=${argument}`,
// });
// wx.navigateTo({
// url: `../newEnroll/enroll/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",
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;
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/enroll/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",
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) => {
let argument;
argument = JSON.stringify(that.data.jobDetail.storeJob).replace(/\=|\&/g, "3D");
wx.navigateTo({
url: `../newEnroll/enroll/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;
},
setCopy (e) {
var that = this;
var contentInfo;
const query = wx.createSelectorQuery().in(this);
query
.select(".contactInfo")
.boundingClientRect(function (res) {
contentInfo = res.dataset.info;
wx.setClipboardData({
data: e.currentTarget.dataset.content + contentInfo,
success (res) {
wx.getClipboardData({
success (res) {
console.log(res.data); // data
wx.showToast({
title: "内容已复制",
icon: "none",
duration: 1500,
});
},
});
},
});
})
.exec();
},
changeContact () {
console.log(2123);
wx.navigateTo({
url: `/pages/configAnnunciate/index`,
});
},
collectPaste (e) {
var txt;
var that = this;
if (!this.data.isLogin) {
wx.setStorageSync("comeFromPage", "detail");
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) {
//取消收藏
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,
});
}
},
imageLoad () {
this.setData({
isLoading: false,
});
},
/**
* 阻止滑动穿透
*
*
*/
modalMove () {
return false;
},
showTobe () {
this.setData({
iosDialogTobe: true,
});
},
closeTobe () {
this.setData({
iosDialogTobe: false,
});
},
});