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: {
    recordShow: false,
    images:[],
    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',
    swiperHeight:0,
    bottomLift:0,
    showfixToast:false,
    current:0,
  },
  showVideo (e) {
    console.log(e.target.dataset.id);
    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(){
    this.videoContext.stop();
  },
  doNothing(){},
  closeFix(){
    this.setData({
      showfixToast:false
    })
  },
  bindchange(e){
    console.log(e.detail.current)
    this.setData({
      current:e.detail.current,
    })
  },
  showFix(e){
    var that = this;
    console.log(e.currentTarget.dataset.id);
    var id = e.currentTarget.dataset.id;
    var profiles = that.data.jobDetail.storeImage
    var currentProfileIndex = (profiles|| []).findIndex((profile) => profile.id === id);
 
    console.log(currentProfileIndex );

    this.setData({
      current:currentProfileIndex,
      showfixToast:true
    })
  },
	showdialog() {
		this.setData({
			iosDialog: true,
		});
	},
	closeDialog() {
		this.setData({
			iosDialog: false,
		});
	},
	onShow() {
    var that = this;

    wx.getSystemInfo({
      success: res => {
        that.data.bottomLift = res.screenHeight - res.safeArea.bottom + 60;
      },
      fail(err) {
        console.log(err);
      }
    })


    console.log(that.data.bottomLift);

		this.setData({
      bottomLift:that.data.bottomLift,
      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();
    }

   
	},
	showphone: function () {
		var that = this;
    // console.log( that.data.serviceInfo.workPhone);
		wx.makePhoneCall({
			// number: that.data.jobDetail.assistantUserTel + ""
			phoneNumber: that.data.jobDetail.customServiceUser.tel || "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.images.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;
		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);
		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);
		        this.data.searchForm.storeJobId = sceneJson.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;
    }
  },
  
	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: that.data.swiperHeight - 34,
						}
          );
          this.animate(
						".noBack",
						[
							{
                opacity: 1
							},
							{
                opacity: 0
							},
						],
						800,
						{
							scrollSource: "#listBox",
							timeRange: 1000,
							startScrollOffset: 0,
							endScrollOffset: 1,
						}
					);
			
				}
			)
			.exec();
	},

  // onReady() {
	// 	let that = this;
	// 	var query = wx.createSelectorQuery();
	// 	query.select(".page-section").boundingClientRect();
	// 	query.exec(function (res) {
	// 		//res就是 所有标签为v1的元素的信息 的数组
	// 		console.log(res);
	// 		//取高度
	// 		console.log(res[0].height);
	// 		that.setData({
	// 			swiperHeight: res[0].height,
	// 		});
	// 	});
	// },

	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.currentTarget.dataset.address);
    var address = e.currentTarget.dataset.address
    wx.openLocation({
      latitude: Number(address.storeLat),
      longitude:  Number(address.storeLng),
      name: address.storeName,
      address: address.storeAddr,
      scale: 15,
      success (res) {
        console.log(res)
      },
      fail (res) {
        console.log(res)
      }
    });
    // wx.getLocation({
    //   type: 'gcj02', //返回可以用于wx.openLocation的经纬度
    //   success (res) {
    //     console.log(res)
    //     wx.openLocation({
    //       latitude: Number(address.storeLat),
    //       longitude:  Number(address.storeLng),
    //       name: address.storeName,
    //       address: address.storeAddr,
    //       scale: 15,
    //       success (res) {
    //         console.log(res)
    //       },
    //       fail (res) {
    //         console.log(res)
    //       }
    //     });
    //   },
    //   fail(res){
    //     console.log(res);
    //   }
    // })  
		// 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();
		//     },
		// })
  },
  onShareAppMessage(){},
	// 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.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.hourlyPay, salaryClassifyValueLeft, baseTop + salaryClassifyValueTop, 400 * 2, 20, "#ff4400", titleSize, "600"); // 时薪
							fillTextLineBreak(ctx, that.data.jobDetail.monthlyPay, salaryClassifyValueLeft + ctx.measureText(that.data.jobDetail.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.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(){
    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 + "/yishoudan/custom/job/detailApp/" + that.data.searchForm.storeJobId,
			method: "get",
			header: app.globalData.headers,
			success: function (res) {
				console.log(res);
				if (res.data.status == 200) {
          var result = {};
          result = res.data.data.record;
					var title = result.jobName;
					// var title1 = result.store.aliasName;
					// that.data.logo2
					// wx.setStorageSync({
					//   key: "onSiteRemark",
					//   data: result.onSiteRemark,
					// })
          let regs = /\.(jpg|jpeg|png)(\?.*)?$/;
					res.data.data.images.forEach((item) => {
						item.isImg = regs.test(item.url.toLowerCase());
					});
					result.genderRestrict = commonUtil.getGenderByMinAge(result);
					that.setData({
            shareTitle: title,
            images:res.data.data.images,
						onSiteRemark: result.onSiteRemark,
					});

        
					if (app.isNotEmptyCheck(title)) {
						title = result.jobName;
					} else {
						title = result.store.aliasName;
					}

					wx.setNavigationBarTitle({
						title,
					});

					result.workType = commonUtil.getWorkTypeById(result.workTypeMulti);

					if (app.isNotEmptyCheck(result.calculationSalaryType)) {
						result.calculationSalaryType = result.calculationSalaryType.split("#")[0];
					}
					if (app.isNotEmptyCheck(result.jobDesp)) {
						result.jobDesp = result.jobDesp.replaceAll("*****", "").split("————————")[0];
						result["jobDesp1"] = result.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["jobDesp1"] = result.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.paymentSalaryType)) {
						result.paymentSalaryType = result.paymentSalaryType.split("，");
					}

					if (app.isNotEmptyCheck(result.salaryDesp)) {
						result.salaryDesp = result.salaryDesp.split("；");
					}

					if (app.isNotEmptyCheck(result.workDurationDesp)) {
						result.workDurationDesp = result.workDurationDesp.split("；");
					}

					if (app.isNotEmptyCheck(result.probationDesp)) {
						result.probationDesp = result.probationDesp.split("；");
					}

					if (app.isNotEmptyCheck(result.workingLunchDesp)) {
						result.workingLunchDesp = result.workingLunchDesp.split("；");
					}

					if (app.isNotEmptyCheck(result.dormitoryDesp)) {
						result.dormitoryDesp = result.dormitoryDesp.split("；");
					}

					if (app.isNotEmptyCheck(result.foregift)) {
						result.foregift = result.foregift.split("；");
						var arrTemp = [];
						result.foregift.forEach((item) => {
							var arr = item.split("，");

							if (app.length > 0) {
								arrTemp.push({
									item0: arr[0].split("#")[0],
									item1: arr[1].split("#")[0],
								});
							}
						});
						result.foregift = arrTemp;
					} else {
						result.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.returnFeeType, result.returnFee));
					console.log("isout");
					if (app.isNotEmptyCheck(result.returnFeeType) || result.returnFeeType == "0" || result.returnFee == "0") {
						that.setData({
							fuWuFei: commonUtil.getReturnFeeTypeName1ById(result.returnFeeType, result.returnFee),
						});
					}
					//  else if (result.returnFeeType == 7) {
					//   that.setData({
					//     fuWuFei: commonUtil.getReturnFeeTypeNameById(result.returnFeeType),
					//   });
					// }
					else {
						that.setData({
							fuWuFei: "-",
						});
					}

					console.log(result);
					console.log(commonUtil);
					let citys = commonUtil.setJobInfoPosition(result.storeDistrict);
          // result.storeImage.splice(0,1)

          that.data.jobDetail["storeName"] = result.storeName;
					that.data.jobDetail["notes"] = result.jobInfo;

					that.setData({
						jobDetail: result,
						isMaskShow: !(result.recruitment == "1"),
						citys: citys || "-",
						// addressNew: result.store.district.replace(/,/g, "") + result.store.detailPosition,
					});
			

					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.minAgeMan) || app.isNotEmptyCheck(that.data.jobDetail.maxAgeMan)) {
			manStr = "男 ";
		}

		if (app.isNotEmptyCheck(that.data.jobDetail.minAgeMan)) {
			manStr = manStr + that.data.jobDetail.minAgeMan;
		}
		if (app.isNotEmptyCheck(that.data.jobDetail.maxAgeMan)) {
			manStr = manStr + "-" + that.data.jobDetail.maxAgeMan;
		}

		if (app.isNotEmptyCheck(that.data.jobDetail.minAgeWoman) || app.isNotEmptyCheck(that.data.jobDetail.maxAgeWoman)) {
			womanStr = "女 ";
		}
		if (app.isNotEmptyCheck(that.data.jobDetail.minAgeWoman)) {
			womanStr = womanStr + that.data.jobDetail.minAgeWoman;
		}
		if (app.isNotEmptyCheck(that.data.jobDetail.maxAgeWoman)) {
			womanStr = womanStr + "-" + that.data.jobDetail.maxAgeWoman;
		}

		if (womanStr != "") {
			manStr = manStr + `${manStr == "" ? "" : "；"}` + womanStr;
		}

		that.setData({
			showSexAgeText: manStr,
		});
	},
	/**
	 * 处理后台返回的职位列表
	 */
	disposeJobListData(jobDetail) {
		var that = this;
    console.log(jobDetail);
		// item["workType"] = commonUtil.getWorkTypeById(
		//     item.workTypeMulti
		// );

		// if (app.isNotEmptyCheck(item.distance)) {
		//     item["distanceKm"] = commonUtil.getDistanceName(
		//         item.distance
		//     );
		// }
		//年龄
		var ageStr = "";
		if (app.isNotEmptyCheck(jobDetail.minAge) && app.isNotEmptyCheck(jobDetail.maxAge)) {
			ageStr = jobDetail.minAge + "-" + jobDetail.maxAge + "岁";
		} else if (app.isNotEmptyCheck(jobDetail.minAge)) {
			ageStr = jobDetail.minAge + "岁以上";
		} else if (app.isNotEmptyCheck(jobDetail.maxAge)) {
			ageStr = jobDetail.maxAge + "岁以下";
		}
		jobDetail["age"] = ageStr;
		//时薪
		// var hourlyPayStr = "";
		var hasHourlyPay = true;
		console.log(jobDetail);
		// if (app.isNotEmptyCheck(jobDetail.hourlyPay)) {
		// 	hourlyPayStr = jobDetail.hourlyPay + "元/小时";
		// 	hasHourlyPay = true;
		// } else if (app.isNotEmptyCheck(jobDetail.dayPay)) {
		// 	hourlyPayStr = jobDetail.dayPay + "元/日";
		// 	hasHourlyPay = true;
		// } else {
		// 	if (app.isNotEmptyCheck(jobDetail.minMonthlyPay) && app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
		// 		if (jobDetail.minMonthlyPay == jobDetail.maxMonthlyPay) {
		// 			hourlyPayStr = jobDetail.minMonthlyPay;
		// 		} else {
		// 			hourlyPayStr = jobDetail.minMonthlyPay + "-" + jobDetail.maxMonthlyPay;
		// 		}
		// 	} else if (app.isNotEmptyCheck(jobDetail.minMonthlyPay)) {
		// 		hourlyPayStr = jobDetail.minMonthlyPay;
		// 	} else if (app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
		// 		hourlyPayStr = jobDetail.maxMonthlyPay;
		// 	}
		// }
		// if (app.isNotEmptyCheck(jobDetail.dayPay)){

		// }
		// if (app.isNotEmptyCheck(jobDetail.salaryClassify) && app.isNotEmptyCheck(jobDetail.salaryClassifyValue)) {

		// }
		//月薪
		var monthlyPayStr = "";
		if (hasHourlyPay) {
			if (app.isNotEmptyCheck(jobDetail.minMonthlyPay) && app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
				if (jobDetail.minMonthlyPay == jobDetail.maxMonthlyPay) {
					monthlyPayStr = jobDetail.minMonthlyPay/100;
				} else {
					monthlyPayStr = jobDetail.minMonthlyPay/100 + "-" + jobDetail.maxMonthlyPay/100;
				}
			} else if (app.isNotEmptyCheck(jobDetail.minMonthlyPay)) {
				monthlyPayStr = jobDetail.minMonthlyPay/100;
			} else if (app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
				monthlyPayStr = jobDetail.maxMonthlyPay/100;
			}
		}
    jobDetail["monthlyPay"] = monthlyPayStr;
		jobDetail["hourlyPay"] = commonUtil.getSalaryClassifyValue(jobDetail.salaryClassify, jobDetail.salaryClassifyValue,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];
		// 	}
		// }
		// jobDetail.store["districtStr"] = districtStr;
		// jobDetail["districtDetail"] = commonUtil.getStoreAddress(jobDetail.district, jobDetail.detailPosition);
		//职位特色
		if (app.isNotEmptyCheck(jobDetail.jobSpecialLabelNames)) {
			jobDetail["jobSpecialLabelNames"] = that.getJobSpecialLabelNamesArray(jobDetail.jobSpecialLabelNames);
    }
    if (app.isNotEmptyCheck(jobDetail.jobRequestLabelNames)) {
			jobDetail["jobRequestLabelNames"] = that.getJobRequestLabelNamesArray(jobDetail.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.jobLabelId);

		wx.navigateTo({
			url: "../similar/index?brandId=" + that.data.jobDetail.store.brandId + "&jobLabelId=" + that.data.jobDetail.jobLabelId + "&classify=99",
		});
	},

	makePhoneCall() {
		console.log(1);
		var that = this;
		wx.makePhoneCall({
			// number: that.data.jobDetail.assistantUserTel + ""
			phoneNumber: that.data.jobDetail.customServiceUser.tel || "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;
    console.log('jobDetail',that.data.jobDetail);
		wx.setClipboardData({
			// data: that.data.jobDetail.assistantUserWechat,
			data: that.data.jobDetail.customServiceUser.weChat ,
			success: function (res) {
        console.log(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
					},
				});
			},
      fail: function(err) {
          console.log(err);
      }
		});
	},
	/*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;
    console.log(e.currentTarget.dataset.job);
    this.setData({
      recordShow: true,
      currentInfo: e.currentTarget.dataset.job,
    })
    console.log(this.data.recordShow);
    wx.hideTabBar({
      animation: false,
      success: (result) => {

      },
      fail: () => { },
      complete: () => { }
    });
    return
   
		let argument;
    argument = JSON.stringify(that.data.jobDetail).replace(/\=|\&/g, "3D");
    
    if (!this.data.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);
		/*wx.setStorageSync({
            key: "jobDetailStorage",
            data: that.data.jobDetail,
        });*/
		wx.setStorageSync("jobDetailStorage", that.data.jobDetail);
		// 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).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).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.collected = 2;
					txt = "取消收藏";
				} else {
					//收藏
					that.data.jobDetail.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,
		});
  },
  hidedrawershow (e) {
    console.log(e);
    this.setData({
      [e.detail.type]: false
    })
    wx.showTabBar({
      animation: false,
      success: (result) => {

      },
      fail: () => { },
      complete: () => { }
    });
  },
});
