<template>
	<div class="p-root-detail-apply g_w_all g_bg_f_5 g_kuaishou g_pb_10">
		<div v-if="speed == 0">
			<rh-loading />
		</div>
		<div class="g_mr_10 g_ml_10" v-if="speed > 0">
			<!-- {{orderDetail.upAgencyName}} -->
			<div class="g_pt_10" hover-class="none" hover-stop-propagation="false">
				<div class="g_bg_f g_radius_8 g_pt_16 g_pb_12 g_pl_16 g_pr_16" hover-class="none" hover-stop-propagation="false">
					<div class="g_flex_1 g_flex_row_between">
						<div class="g_flex_none g_flex_column_start">
							<div class="g_ell_1 g_fs_18 g_fw_600" style="color: rgba(0, 0, 0, 0.85); max-width: 420rpx">{{orderDetail.aliasJobName ||  orderDetail.storeJobName || orderDetail.jobName || "我是职位名" }}</div>
						</div>
						<!-- {{fromListInfo.cus_price}} -->
						<div class="g_flex_column_start g_fs_20 g_c_f40 g_fw_600">
							<!-- <rich-text :nodes="fromListInfo.cus_price" v-if="fromListInfo.cus_price != '月薪'"></rich-text>
									<div v-else>{{ fromListInfo.monthlyPay }}</div> -->
							<div class="g_fs_18" v-html="fromListInfo.no_style_price"></div>
						</div>
					</div>
					<div class="g_flex_none g_flex_row_start g_fs_14 g_mt_8" style="color: rgba(0, 0, 0, 0.45)">
						<div class="g_ell_1" style="max-width: 264px" hover-class="none" hover-stop-propagation="false">
							{{ (fromListInfo.addss || "") + (fromListInfo.addss ? "丨" + fromListInfo.ageStr : fromListInfo.ageStr || "") }}
							<!-- {{ fromListInfo.addresa + (fromListInfo.ageStr ? " | " + fromListInfo.ageStr : "") }} -->
						</div>
					</div>
					<div class="g_flex_1 g_flex_row_center g_mt_8">
						<div class="g_flex_row_start_none g_flex_1">
							<!-- <div class="label_btn" v-for="(itm, inx) in fromListInfo.jobSpecialLabelNameArray" :key="inx">{{ itm }}</div> -->
							<div class="label_btn" v-for="(itm, inx) in fromListInfo.jobSpecialLabelNames" :key="inx">{{ itm }}</div>
						</div>
						<!-- <div class="g_fs_14" style="color: rgba(0, 0, 0, 0.45)">{{ dateUtil.timeShowXXX(fromListInfo.updateTime) }}</div> -->
					</div>
					<div class="g_flex_1 g_flex_row_between g_mt_8">
						<div class="g_g_fs_14 g_c_6" hover-class="none" hover-stop-propagation="false"> {{ fromListInfo.createTime }} </div>
						<div class="g_fs_14 g_c_6">{{ fromListInfo.status_text }}</div>
					</div>
				</div>
			</div>

			<!-- 用户信息 -->
			<div class="m-user g_pt_10">
				<div class="g_bg_f g_pl_15 g_pr_15 g_pt_10 g_radius_8">
					<div class="g_flex_row_between g_pb_4">
						<div class="g_flex_1 g_flex_column_center g_mr_10">
							<div class="g_ell_1 g_fs_16 g_fw_bold"> {{ orderDetail.userName }}{{ orderDetail.setTitle }} </div>
						</div>
						<div class="g_flex_none g_flex_row_end">
							<div class="g_flex_row_end flex_center g_flex_1" :style="{color: themeColor}" v-if="from == 'toc'"> {{ orderDetail.status_text }}</div>
							<!-- <div class="g_flex_row_end g_pr_16 g_pl_16 g_pt_9 g_pb_9" style="background-color: #f5f5f5; border-radius: 17px">
								<div class="g_flex_row_end" @click="goFellow">
									<div class="g_flex_column_center">
										<i class="iconfont icon-bianji g_c_3 g_fsi_14"></i>
									</div>
									<div class="g_fs_12 g_c_3 g_ml_8">编辑</div>
								</div>
							</div> -->
						</div>
					</div>
					<!-- <div class="g_pb_10 g_c_9">{{ orderDetail.address ? orderDetail.address : "-" }}</div> -->
					<div class="g_flex_row_start g_pb_10">
						<div class="g_flex_none g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
							<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/bocaigongyinglian/id_card.svg" class="g_w_24 g_h_24"></image>
						</div>
						<div class="g_flex_column_center g_fs_15 g_c_6">{{ orderDetail.idCard ? orderDetail.idCard : "-" }}</div>
					</div>
					<div class="g_flex_row_start g_pb_15">
						<div class="g_flex_row_end">
							<div class="g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
								<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/bocaigongyinglian/call.svg" class="g_w_24 g_h_24"></image>
							</div>
							<div class="g_flex_column_center g_text_r g_fs_15 g_c_6">{{ orderDetail.tel ? orderDetail.tel : "-" }}</div>
						</div>
						<div class="g_flex_row_start g_ml_24">
							<div class="g_flex_none g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
								<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/wechat1.svg" class="g_w_24 g_h_24"></image>
							</div>
							<div class="g_flex_column_center g_fs_15 g_c_6">{{ orderDetail.weChat ? orderDetail.weChat : "-" }}</div>
						</div>
					</div>
					<div class="g_pb_17" v-if="orderDetail.idCardImageUrl">
						<g-panel-image :url="orderDetail.idCardImageUrl" radius="8" size="152" @clickItem="handleClickIDcard" />
					</div>
				</div>
			</div>
			<!-- 费用 -->
			<!-- <div class="m-price">
				<div class="g_h_12"></div>
				<div class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="政策模式" v-if="isCreator" :value="orderDetail.zhengceTextShow" afterIcon="icon-gengduo11" @clickItem="handleOpenZhengceModal" from="zhengce-info" />
					<g-panel-detail-item label="报名备注" :value="orderDetail.desp" />
					<div class="g_h_15"></div>
				</div>
			</div> -->
			<!-- 职位信息 -->
			<div class="m-job">
				<div class="link g_bg_f g_pt_10 g_radius_8 g_mt_12" style="overflow: hidden">
					<!-- <g-panel-detail-item label="报名企业" :value="orderDetail.storeName" /> -->
					<g-panel-detail-item label="报名职位" :value="orderDetail.storeJobName || orderDetail.jobName" />
					<g-panel-detail-item label="报名企业" :value="orderDetail.storeName" />
					<!-- <div v-if="(!orderDetail.nextRecordId && !orderDetail.prevRecordId) || orderDetail.prevRecordId || agencyId == orderDetail.agencyId">
						<g-panel-detail-item :label="isCreator ? '代理费' : '服务费'" :value="setReturnFee(orderDetail.agencyReturnFee, orderDetail.agencyReturnFeeType)" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.agencyReturnFee / 100, '代理费', 'form', orderDetail.agencyReturnFeeType)" />
						<g-panel-detail-item :label="isCreator ? '代理费详情' : '服务费详情'" :value="orderDetail.agencyReturnFeeDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.agencyReturnFeeDesp, '代理费详情', 'edit')" />
					</div> -->

					<div class=" " v-if="false">
						<div v-if="orderDetail.status == 10 || orderDetail.status == 20 || orderDetail.status == 25">
							<g-panel-detail-item from="times" label="面试时间" :value="orderDetail.interview_time" />
						</div>
						<div v-if="orderDetail.status == 30">
							<g-panel-detail-item from="times" label="约入职时间" :value="orderDetail.willEntry_time" />
						</div>
						<div v-if="orderDetail.status == 40">
							<g-panel-detail-item from="times" label="入职时间" :value="orderDetail.entry_time" />
						</div>
						<div v-if="orderDetail.status == 48">
							<g-panel-detail-item from="times" label="约离职时间" :value="orderDetail.willLeave_time" />
						</div>
						<div v-if="orderDetail.status == 50">
							<g-panel-detail-item from="times" label="离职时间" :value="orderDetail.leave_time" />
						</div>
						<div v-if="orderDetail.status == 21 || orderDetail.status == 26 || orderDetail.status == 35 || orderDetail.status == 45">
							<g-panel-detail-item from="times" label="完成时间" :value="orderDetail.update_time" />
						</div>
					</div>

					<g-panel-detail-item label="面试地址" v-if="false" :value="orderDetail.interviewAddress" maxWidth="230px" :afterIcon="'icon-dizhi1'" :afterIconColor="themeColor" @clickItem="handleChooseAddressModal" />
					<!-- 服务费 最上游或者不是管理人员不显示 orderDetail.nextRecordId为空 是最上游 -->
					<!-- 代理费/服务费 最下游不显示 orderDetail.prevRecordId为空 是最下游 -->
					<!-- <g-panel-detail-item label="驻场信息" v-if="resumeFlag == 2" :value="orderDetail.totalZC || '-'" maxWidth="230px" from="resident-info" :afterIcon="orderDetail.upOnSiteInfo || orderDetail.onSiteInfo ? 'icon-fuzhi' : ''" iconColor="g_c_main" afterType="multi" @clickItem="handleClickLabelBtn(orderDetail.totalZC || '-')" /> -->
					<g-panel-detail-item label="其他说明" v-if="false" :value="orderDetail.interviewDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.interviewDesp, '其他说明', 'div')" />
					<!-- <g-panel-detail-item label="职位说明" :value="orderDetail.employeeSalary" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.employeeSalary, '职位说明', 'edit')" /> -->
					<!-- <div class="g_h_15"></div> -->
				</div>
			</div>
			<!-- 企业信息 -->
			<!-- <div class="m-boss">
				<div class="g_h_10"></div>
				<div class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="企业地址" :value="orderDetail.storeAddr" afterIcon="icon-gengduo11" @clickItem="handleChooseAddressModal" />
					<g-panel-detail-item label="驻场信息" :value="orderDetail.onSiteUsers" :beforeIcon="type == 2 ? 'icon-bianji' : ''" afterType="list" @clickItem="handleOpenModal" from="resident-info" />
				</div>
			</div> -->
			<div class="g_h_10 g_bg_f_5"></div>
		</div>

		<u-popup v-model="recordModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true">
			<div>
				<div class="g_flex_row_between g_border_e_b">
					<div class="g_pl_12 g_c_3 g_fs_15 g_pt_18 g_pb_18" @click="recordModal.isShow = false">取消</div>
					<div class="g_pr_12 g_fs_15 g_pt_18 g_pb_18" :style="{color: themeColor}" @click="handleSubmitRemark">确定</div>
				</div>
				<div class="g_p_16">
					<div class="g_fs_15 g_c_6 g_pb_16">备注</div>
					<div class="">
						<u-input v-model="recordModal.remark" type="textarea" :height="600" :clearable="false" />
					</div>
				</div>
			</div>
		</u-popup>

		<u-popup v-model="peopleModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true" :closeable="true">
			<div class="g_fs_18 g_c_3 g_flex_row_center g_pt_16"> 报名人选择 </div>
			<scroll-view scroll-y="true" style="height: 700rpx">
				<div class="g_pl_12 g_pr_12">
					<div class="g_flex_row_between g_pt_16 g_pb_16 g_border_d_b" v-for="(item, index) in peopleData.recordList" :key="index" @click="handleChoosePeople(item, index)">
						<div class="g_fs_17 g_c_3">{{ item.aliasName || item.userName || item.tel }}</div>
						<div class="g_flex_column_center">
							<i
								class="iconfont icon-a-duigoubeifen2"
								v-if="applyInfo.applyUserId == item.id"
								style="font-size: 24px"
								:style="{
									color: applyInfo.applyUserId == item.id ? '#6A81FF' : '#fff',
								}"
							></i>
						</div>
					</div>
				</div>
			</scroll-view>
		</u-popup>

		<u-popup v-model="infoModal.isShow" mode="center" border-radius="16" width="630" :mask-close-able="true">
			<div class="g_flex_column_center">
				<div class="g_flex_row_center g_pt_32 g_fs_18 g_fw_600 g_mb_20">报名信息</div>
				<scroll-view scroll-y class="g_pb_32 g_pr_16 g_pl_16 g_flex_row_center g_flex_1" style="max-height: 600px; box-sizing: border-box">
					<div class="g_pb_48">
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">姓名：</div>
							<div class="label g_fs_16 g_fw_600 g_c_3 g_flex_1 g_ell_1"> {{ orderDetail.userName }}{{ orderDetail.setTitle }} </div>
						</div>
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">电话：</div>
							<div class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.tel ? orderDetail.tel : "-" }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">身份证号：</div>
							<div class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.idCard ? orderDetail.idCard : "-" }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">家庭住址：</div>
							<div class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.address ? orderDetail.address : "-" }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">报名职位：</div>
							<div class="label g_fs_16 g_c_3 g_fw_600 g_flex_1 g_ell_1">
								{{ orderDetail.storeJobName ? orderDetail.storeJobName : "-" }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_8">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">员工薪资：</div>
							<div class="label g_fs_16 g_c_3 g_flex_1 g_white_p">
								{{ orderDetail.employeeSalary ? orderDetail.employeeSalary : "-" }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_8" v-if="isCreator">
							<div class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">代理政策：</div>
							<div class="label g_fs_16 g_c_3 g_flex_1 g_white_p">
								{{ orderDetail.policy ? orderDetail.policy : "-" }}
							</div>
						</div>
					</div>
				</scroll-view>
				<div class="g_flex_row_between g_border_e_t g_bg_f" style="position: absolute; bottom: 0; width: 100%">
					<div class="g_c_3 g_fs_18 g_pt_18 g_pb_18 g_flex_c g_fw_700" style="width: 50%; height: 49px" @click="handleCopy">复制文本</div>
					<div class="g_fs_18 g_pt_18 g_pb_18 g_flex_c" :style="{color: themeColor}" style="width: 50%; height: 49px; border-left: 1rpx solid #eee" @click="infoModal.isShow = false">知道了</div>
				</div>
			</div>
		</u-popup>
	</div>
</template>

<script>
export default {
	onReady() {
		this.G.setNavStyle();
	},
	onShareAppMessage() {
		return this.G.shareFun();
	},
	data() {
		return {
			themeColor: getApp().globalData.themeColor,
			from: "", // 判断来源
			cdnBaseImg: this.G.store().cdnBaseImg,
			agencyId: uni.getStorageSync("apply-agencyId"),
			isAdmin: uni.getStorageSync("apply-userinfo").admin,
			fromListInfo: {},
			isCreator: false, //管理人员判断
			speed: 0,
			applyInfo: {}, // 提交更改的对象
			oid: 0,
			type: 0,
			orderDetail: {},
			peopleData: {
				recordList: [],
			},

			peopleModal: {
				isShow: false,
				uid: 0,
			},
			infoModal: {
				isShow: false,
			},
			recordModal: {
				isShow: false,
				remark: "",
			},
			zhengceList: [
				{
					name: "政策一",
					id: 1,
					isSelected: false,
				},
				{
					name: "政策二",
					id: 2,
					isSelected: false,
				},
				{
					name: "政策三",
					id: 3,
					isSelected: false,
				},
				{
					name: "政策四",
					id: 4,
					isSelected: false,
				},
				{
					name: "政策五",
					id: 5,
					isSelected: false,
				},
				{
					name: "政策六",
					id: 6,
					isSelected: false,
				},
				{
					name: "政策七",
					id: 7,
					isSelected: false,
				},
				{
					name: "政策八",
					id: 8,
					isSelected: false,
				},
				{
					name: "政策九",
					id: 9,
					isSelected: false,
				},
			],
			resumeFlag: 0,
			statusList: {
				unadd: [
					{
						name: "空号",
						icon: "icon-konghao",
						id: 1,
					},
					{
						name: "停机",
						icon: "icon-tingji",
						id: 2,
					},
					{
						name: "无法添加",
						icon: "icon-wufatianjia",
						id: 8,
					},
				],
				adding: [
					{
						name: "无人接听",
						icon: "icon-wurenjieting",
						id: 3,
					},
					{
						name: "拒接",
						icon: "icon-jujie",
						id: 4,
					},
					{
						name: "通话中",
						icon: "icon-tonghuazhong",
						id: 5,
					},
					{
						name: "无法接通",
						icon: "icon-wufajietong",
						id: 6,
					},
					{
						name: "关机",
						icon: "icon-guanji",
						id: 7,
					},
					{
						name: "已申请",
						icon: "icon-yishenqing",
						id: 10,
					},
				],
				added: [
					{
						name: "已接通",
						icon: "icon-yijietong",
						id: 100,
					},
					{
						name: "已添加",
						icon: "icon-yitianjia",
						id: 9,
					},
				],
			},
		};
	},
	onLoad(options) {
		// console.log("options", options);
		this.oid = options.id;
		this.type = options.type;
		this.resumeFlag = options.resumeFlag; // 1简历 2工单
		this.from = options.from; // 1简历 2工单
		this.fromListInfo = JSON.parse(options.item);
		uni.setNavigationBarTitle({
			title: "详情",
		});
	},
	onShow() {
		this.themeColor = getApp().globalData.themeColor;
		this.isCreator = uni.getStorageSync("IS_CREATOR") == 1 ? true : false;
		this.getPeople();
		this.getDetail();
	},
	methods: {
		handleClickLabelBtn($data) {
			var that = this;
			var text = "";
			let copy = "";
			// console.log("$data", $data);
			if (!this.orderDetail.totalZC) {
				return false;
			}

			if (that.orderDetail.upOnSiteInfo || !that.orderDetail.prevRecordId) {
				copy = that.orderDetail.upOnSiteInfo.slice(-11);
			}
			if (that.orderDetail.prevRecordId || (!that.orderDetail.prevRecordId && !that.orderDetail.nextRecordId)) {
				copy = that.orderDetail.onSiteInfo.slice(-11);
			}

			if (that.orderDetail.upAgencyName == "江西人海") {
				text = that.orderDetail.storeJobName + "\n\n⚠驻场接人：" + copy + "(接待面试，优先联系）\n\n服务投诉：19036980065";
			} else {
				text = that.orderDetail.storeJobName + "\n\n⚠驻场接人：" + copy;
			}
			wx.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							// console.log(res.data); // data
							wx.showToast({
								title: "内容已复制",
								icon: "none",
								duration: 1500,
							});
						},
					});
				},
			});
		},

		getPeople() {
			let that = this;
			that.G.Get(that.api.order_peopleList, {}, (res) => {
				// console.log("报名人列表：", res);
				that.peopleData = res;
			});
		},
		getDetail() {
			let that = this;
			that.speed = 0;
			if (this.resumeFlag == 1) {
				that.G.Post(that.api.resume_detail_new + "/" + that.oid, {}, (res) => {
					// console.log("简历详情", res);
					res = { ...res.resume, ...res };
					// // console.log("that.G.getOrderStatus()", that.G.getOrderStatus());
					res.status_text = that.G.getOrderStatusNew().filter((itm, inx) => {
						return itm.id == res.status;
					})[0].name;

					res.serveRecords.forEach((item) => {
						item.create_time = that.G.getPointTime(item.createTime, "YY--MM--DD HH:MM");
					});
					res.setTitle = that.G.titleToStr(res);
					res.records = res.serveRecords;
					that.orderDetail = res;
					that.speed = 1;
					// console.log("res", res);
				});
			} else {
				that.G.Get(
					that.api.order_detail_new,
					{
						orderId: that.oid,
					},
					(res) => {
						// console.log("工单详情：", res);
						// return;
						// console.log("res", res);
						res = { ...res.applyOrder, ...res };
						if (res.policyNum === "" || res.policyNum === 0) {
							res.policyNum = 1;
						}
						if (res.policyIdx === "" || res.policyIdx === 0) {
							res.policyIdx = 1;
						}
						if (res.policyIdx) {
							let list = [];
							for (let i = 0; i < res.policyNum; i++) {
								let pickerStr = that.G.policyNumToHanZi(i + 1);
								list[i] = { value: i + 1, name: pickerStr, isSelected: false };
							}
							// console.log("list", list);
							// console.log("res.policyIdx - 1 ", res.policyIdx);
							list[res.policyIdx - 1 >= 0 ? res.policyIdx - 1 : 0].isSelected = true;
							that.zhengceList = list;
						} else {
							that.zhengceList = [{ name: "政策一", value: 1, isSelected: true }];
						}
						res.zhengceTextShow = that.G.policyNumToHanZi(res.policyIdx);
						// 驻场信息样式统一
						// res.newZhuchang = res.onSiteInfo.replaceAll("；", "\n");
						// // console.log("res.newZhuchang", res.newZhuchang);
						// // console.log("res.onSiteInfo", res.onSiteInfo);
						// res.totalZC = "";
						// if (res.prevRecordId || (!res.prevRecordId && !res.nextRecordId)) {
						// 	res.totalZC = "我的驻场:" + (res.onSiteInfo.slice(-11) || " -");
						// }
						// if (res.upOnSiteInfo || !res.prevRecordId) {
						// 	res.totalZC = res.totalZC ? res.totalZC + "\n项目方:" + (res.upOnSiteInfo.slice(-11) || " -") : "项目方:" + (res.upOnSiteInfo.slice(-11) || " -");
						// }

						// if (res.upOnSiteInfo) {
						// 	res.totalZC = res.upOnSiteInfo || !res.prevRecordId ? res.upOnSiteInfo.replaceAll("；", "\n") + "\n" + res.totalZC : res.totalZC;
						// 	// // console.log("newZhuchang upZhuchang", res.upZhuchang + "123" + res.newZhuchang);
						// }
						// // console.log("res.totalZC", res.totalZC);
						// // console.log(res.totalZC.match(/\d+/g));
						// // console.log(/\d+/g.test(res.totalZC));
						// console.log("res.upAgencyName ", res.upAgencyName);
						// if (res.upAgencyName == "江西人海" && /\d+/g.test(res.totalZC)) {
						// 	if (res.totalZC.indexOf(" ") > -1) {
						// 		res.totalZC = res.totalZC.split(" ")[1];
						// 		res.zhuchangTel = res.totalZC.replace(/\s+/g, "");
						// 	} else {
						// 		res.totalZC = res.zhuchangTel = res.totalZC.match(/\d+/g)[0];
						// 	}
						// }
						res.status_text = that.G.getOrderStatusNew().filter((itm, inx) => {
							return itm.id == res.status;
						})[0].name;

						if (res.createTime) {
							res.create_time = that.G.getPointTime(res.createTime, "YY--MM--DD HH:MM");
						}
						if (res.interviewTime) {
							res.interview_time = that.G.getPointTime(res.interviewTime, "YY--MM--DD HH:MM");
						}
						if (res.willEntryTime) {
							res.willEntry_time = that.G.getPointTime(res.willEntryTime, "YY--MM--DD HH:MM");
						}
						if (res.entryTime) {
							res.entry_time = that.G.getPointTime(res.entryTime, "YY--MM--DD HH:MM");
						}
						if (res.willLeaveTime) {
							res.willLeave_time = that.G.getPointTime(res.willLeaveTime, "YY--MM--DD HH:MM");
						}
						if (res.leaveTime) {
							res.leave_time = that.G.getPointTime(res.leaveTime, "YY--MM--DD HH:MM");
						}
						if (res.updateTime) {
							res.update_time = that.G.getPointTime(res.updateTime, "YY--MM--DD HH:MM");
						}
						that.orderDetail.serveRecords = {};
						for (var key in res.records) {
							res.records[key].forEach((item, index) => {
								if (item.desp.substr(item.desp.length - 3, 3) == "备注：") {
									item.desp = item.desp.replace(/备注：/g, "");
								}
								if (item.type == 1) {
									item["statusText"] = "报名审核中";
								} else if (item.type == 2) {
									item["statusText"] = "待接待";
								} else if (item.type == 3) {
									item["statusText"] = "待入职";
								} else if (item.type == 4) {
									item["statusText"] = "在职中";
								} else if (item.type == 5) {
									item["statusText"] = "已离职";
								} else if (item.type == 9) {
									item["statusText"] = "约离职";
								} else if (item.type == 6) {
									item["statusText"] = "已完成";
								} else if (item.type == 11) {
									item["statusText"] = "审核未通过";
								} else if (item.type == 12) {
									item["statusText"] = "已接到";
								} else if (item.type == 13) {
									item["statusText"] = "未接到";
								} else if (item.type == 14) {
									item["statusText"] = "面试未通过";
								} else if (item.type == 15) {
									item["statusText"] = "未入职";
								}

								if (item.createTime) {
									item.create_time = that.G.getPointTime(item.createTime, "YY--MM--DD HH:MM");
								}
							});
						}

						res.setTitle = that.G.titleToStr(res);
						that.orderDetail = res;
						// console.log("that.orderDetail", that.orderDetail.onSiteInfo);
						that.applyInfo = {
							orderId: res.id,
							applyUserId: res.applyUserId,
							agencyReturnFee: res.agencyReturnFee,
							agencyReturnFeeType: res.agencyReturnFeeType,
							agencyReturnFeeDesp: res.agencyReturnFeeDesp,
							policyIdx: res.policyIdx,
							interviewDesp: res.interviewDesp,
							employeeSalary: res.employeeSalary,
							version: res.version,
						};
						// console.log("that.orderDetail", that.orderDetail);
						that.$forceUpdate();
						that.speed = 1;
					}
				);
			}
		},

		handleClickIDcard() {
			this.G.viewBigImage(this.orderDetail.idCardImageUrl);
		},
		goTel($item) {
			if ($item) {
				uni.makePhoneCall({
					phoneNumber: $item,
				});
			}
		},

		goBossDetail() {
			let that = this;
			let agencyId = uni.getStorageSync("apply-agencyId");
			if (agencyId == that.orderDetail.agencyId) {
				return false;
			}
			let params = {
				id: that.orderDetail.agencyId,
				// type: 2,
				isShowMore: true,
				isShowJob: false,
			};
			uni.navigateTo({
				url: "/root/detail/user?" + that.G.objToStr(params),
			});
		},

		handleOpenPeopleModal() {
			this.peopleModal.uid = this.orderDetail.applyUserId;
			this.peopleModal.isShow = true;
		},
		handleChoosePeople($item, $index) {
			let that = this;
			// console.log("$item", $item);
			// return;
			// that.peopleModal.uid = $item.id;
			that.applyInfo.applyUserId = $item.id;
			that.G.Post(
				that.api.order_update_detail,
				{
					...that.applyInfo,
				},
				(res) => {
					// console.log("res", res);
					that.peopleModal.isShow = false;
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
			// that.G.Post(
			// 	that.api.order_submitPeople,
			// 	{
			// 		userApplyOrderId: that.oid,
			// 		userId: that.peopleModal.uid,
			// 		statistic: 1,
			// 		agree: 1,
			// 	},
			// 	() => {
			// 		that.peopleModal.isShow = false;
			// 		uni.showToast({
			// 			title: "修改成功",
			// 			icon: "success",
			// 		});
			// 		that.getDetail();
			// 	}
			// );
		},

		handleCopy() {
			let that = this;
			var text = "姓名：" + that.orderDetail.userName + "/" + (that.orderDetail.sex == 1 ? "男" : "女") + "/" + that.orderDetail.age + "岁" + (that.orderDetail.nation == "族" ? "" : "/" + that.orderDetail.nation) + "\n电话：" + (that.orderDetail.tel == "" || that.orderDetail.tel == undefined || that.orderDetail.tel == null ? "-" : that.orderDetail.tel) + "\n身份证号：" + (that.orderDetail.idCard == "" ? "-" : that.orderDetail.idCard) + "\n家庭地址：" + (that.orderDetail.address == "" || that.orderDetail.address == undefined || that.orderDetail.address == null ? "-" : that.orderDetail.address) + "\n报名岗位：" + that.orderDetail.storeJobName + "\n员工薪资：" + (that.orderDetail.employeeSalary || "-") + (that.isCreator ? "\n代理政策：" + that.orderDetail.policy : "");
			uni.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							// console.log(res.data); // data
							uni.showToast({
								title: "复制成功",
								icon: "success",
							});
						},
					});
				},
			});
		},
		goFellow() {
			let that = this,
				params = {};
			// console.log("that.orderDetail", that.orderDetail);
			params = {
				name: this.orderDetail.userName,
				sex: this.orderDetail.sex,
				age: this.orderDetail.age,
				nation: this.orderDetail.nation,
				tel: this.orderDetail.tel ? this.orderDetail.tel : "",
				idCard: this.orderDetail.idCard ? this.orderDetail.idCard : "",
				idCardImageUrl: this.orderDetail.idCardImageUrl ? this.orderDetail.idCardImageUrl : "",
				address: this.orderDetail.address ? this.orderDetail.address : "",
				imgs: "",
				userName: this.orderDetail.userName,
				userId: that.orderDetail.userId,
				resumeFlag: this.resumeFlag,
				weChat: that.orderDetail.weChat,
			};
			// if (this.resumeFlag == 1) {
			// } else {
			// 	params.weChat = "";
			// }
			uni.navigateTo({
				url: "/root/detail/fellow?" + that.G.objToStr(params),
			});
		},
		goRecordInfo(e) {
			let that = this,
				params = {};
			params = {
				info: e.info ? JSON.parse(e.info).policy : "-",
				time: e.time,
				title: e.title,
				type: e.type,
			};
			that.orderDetail.policy = params.info;
			that.infoModal.isShow = true;

			// uni.navigateTo({
			// 	url: "/root/detail/jobDesp?" + that.G.objToStr(params),
			// });
		},
		goInfo($info, $title, $type, $dis) {
			uni.setStorageSync("APPLY_OBJ", this.orderDetail);
			uni.navigateTo({
				url: "/root/detail/jobDesp?info=" + $info + "&time=" + this.orderDetail.create_time + "&title=" + $title + "&type=" + $type + "&dis=" + $dis,
			});
		},
		handleOpenRemarkModal() {
			// console.log("备注点击事件");
			this.recordModal.remark = "";
			this.recordModal.isShow = true;
		},
		handleChooseAddressModal() {
			let that = this;
			// console.log("经纬度：", that.orderDetail);
			if (that.orderDetail.interviewLat && that.orderDetail.interviewLng) {
				uni.openLocation({
					name: that.orderDetail.interviewAddress,
					latitude: Number(that.orderDetail.interviewLat),
					longitude: Number(that.orderDetail.interviewLng),
					success: function () {},
				});
			} else {
				uni.showToast({
					icon: "none",
					title: "请检查地址",
				});
			}
		},
		handleSubmitRemark() {
			let that = this;
			if (that.recordModal.remark == "") {
				uni.showToast({
					title: "请输入备注",
					icon: "none",
				});
				return false;
			}
			let params = {
				type: that.resumeFlag,
				desp: that.recordModal.remark,
			};
			if (that.resumeFlag == 1) {
				params.resumeId = that.oid;
			} else {
				params.orderId = that.oid;
			}
			that.G.Post(that.api.resume_follow, params, () => {
				that.recordModal.isShow = false;
				uni.showToast({
					title: "修改成功",
					icon: "success",
				});
				that.getDetail();
			});
		},

		handleMianshi(e) {
			this.submitTime(1, e);
		},
		handleYueruzhi(e) {
			this.submitTime(2, e);
		},
		handleRuzhi(e) {
			this.submitTime(3, e);
		},
		handleYuelizhi(e) {
			this.submitTime(4, e);
		},
		handleLizhi(e) {
			this.submitTime(5, e);
		},
		submitTime($type, $time) {
			let that = this;
			that.G.Post(
				that.api.order_submitTime,
				{
					orderId: that.oid,
					timeStr: $time,
					type: $type,
				},
				() => {
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
		},

		handleChooseZhengce($item, $index) {
			let that = this;
			that.zhengceList.forEach((item, index) => {
				if (index == $index) {
					if (item.isSelected) {
						item.isSelected = false;
					} else {
						item.isSelected = true;
					}
				} else {
					item.isSelected = false;
				}
			});
		},
		setReturnFee(returnFee, returnFeeType) {
			return this.G.setReturnFee(returnFee, returnFeeType);
		},
		record($item) {
			// console.log("$item", $item);
			uni.navigateTo({
				url: "/root/home/quickApplication",
				// 小程序页面间通信, 确保页面渲染完再获取简历信息
				events: {
					ceshi: function (data) {
						setTimeout(() => {
							uni.$emit("getTownsman", { info: $item });
						}, 0);
						// console.log(data);
					},
				},
			});
		},
	},
};
</script>

<style lang="scss">
.p-root-detail-apply {
	min-height: 100%;
	.g-components-panel-fixed {
		border-top: 1rpx solid #fff;
	}
	.label_btn {
		display: inline-block;
		height: 20px;
		box-sizing: border-box;
		font-size: 12px;
		font-weight: 400;
		color: #666;
		background: #f1f1f1;
		border-radius: 2px;
		padding: 0 4px 0px;
		line-height: 20px;
		margin-right: 6px;
		margin-bottom: 0px;
		position: relative;
		top: 1px;
	}
}
</style>
