<template>
	<div class="p-root-detail-job g_pt_10 g_pl_20 g_pr_20 g_kuaishou">
		<!-- {{ from }} -->
		<!-- {{ selfJob }} -->

		<div v-if="speed == 0">
			<g-loading />
		</div>
		<div v-if="speed == 1">
			<!-- 基本信息 -->
			<div class="r_box g_mb_10 g_pl_10 g_pr_10 servicePrice" @click="showFee">
				<div class="g_flex_row_between flex_center g_fs_16">
					<div class="g_flex_row_start" style="flex: none">
						<div class="g_fw_600 g_mr_4 g_h_67 g_flex_column_center">代理佣金</div>
						<icon :class="showPrice ? 'icon-zhengyan1' : 'icon-biyan1'" class="iconfont g_c_f40 g_fs_22 g_h_67 g_flex_column_center" @click.stop="() => (showPrice = !showPrice)" style="width: 67px"></icon>
					</div>
					<div class="g_flex_row_end flex_center g_h_67" style="flex: 1">
						<span class v-if="showPrice">{{ jobDetail.serverPrice || "详询客服" }}</span>
						<span class v-else>***</span>
						<div class="iconfont icon-gengduo11 g_fs_14 g_c_6 g_ml_4"></div>
					</div>
				</div>
			</div>
			<div class="m-info g_mb_12">
				<div class="g_flex_1">
					<div class="g_mb_10 g_flex_row_between">
						<div class="g_flex_1 g_c_3 g_fs_24 g_fw_bold">{{ jobDetail.jobName }}</div>

						<!-- <div class="g_flex_none g_flex_column_center">
							<g-panel-server :str="attention ? jobDetail.serverPrice : '关注查看'" verson="new" />
						</div> -->
					</div>

					<template v-if="jobDetail.classify == 1">
						<div class="g_fs_14 g_c_6 g_mb_12 g_c_f40 g_lh_1_2 g_flex_column_center g_mr_18">{{ jobDetail.priceStr }}</div>
						<div class="g_flex_row_start g_mb_10">
							<div class="g_flex_row_start g_mr_18" v-if="jobDetail.addressStr">
								<div class="g_flex_column_center">
									<i class="iconfont icon-dingwei2 g_c_6 g_fs_17 g_lh_1_2"></i>
								</div>
								<div class="g_fs_14 g_c_6 g_ml_4 g_lh_1_2 g_flex_column_center">{{ jobDetail.addressStr }}</div>
							</div>
							<div class="g_flex_row_start">
								<div class="g_flex_column_center">
									<i class="iconfont icon-nianling g_c_6 g_fs_16 g_lh_1_2"></i>
								</div>
								<div class="g_fs_14 g_c_6 g_ml_4 g_lh_1_2 g_flex_column_center">{{ jobDetail.genderAge }}</div>
							</div>
						</div>
						<div class="g_flex_row_start">
							<div class="g_flex_column_center">
								<i class="iconfont icon-zhaopinqiye g_c_6 g_lh_1_2"></i>
							</div>
							<div class="g_fs_14 g_c_6 g_ml_4 g_lh_1_2 g_flex_column_center">{{ jobDetail.storeName }}</div>
						</div>
					</template>
				</div>
			</div>
			<template v-if="jobDetail.classify == 2">
				<div class="g_flex_row_between flex_center">
					<div style="background-color: rgba(255, 77, 79, 0.1); color: #ff4d4f; display: inline-block; padding: 0 4px; border-radius: 2px" class="g_mr_16">
						{{ corpUserFlag ? jobDetail.supplier : "-" }}
					</div>
					<div style="float: right; position: relative" @click="makePhone(jobDetail.phone)" v-if="jobDetail.phone">
						<image :src="cdnBaseImg + 'tel.svg'" class="g_w_32 g_h_32"></image>
					</div>
				</div>
				<!-- 	<div class="g_fs_14 g_c_f40 g_mt_8">
							{{jobDetail.priceStr}}
						</div> -->
			</template>
			<div class="g_flex_row_start">
				<div v-for="(item, index) in jobDetail.jobSpecialLabelNames" class="g_mr_8 g_mb_8 g_pl_4 g_pr_4" :style="{ color: labelColor[index % labelColor.length], 'background-color': bgColor[index % bgColor.length] }">{{ item }}</div>
			</div>
			<!-- <div class="g_flex_row_start">
				<div v-for="(item, index) in jobDetail.jobRequestLabelNames" class="g_mr_8 g_mb_4 g_pl_4 g_pr_4 g_c_6 g_bg_f_5"> {{ item }}</div>
			</div>-->
			<!-- 所属公司信息 -->
			<div class="m-boss g_mt_15 g_mb_16" hover-class="thover" @click="goUserMain">
				<div class="box g_flex_row_between g_h_62 g_radius_3 g_pl_16 g_pr_16">
					<div class="g_flex_row_start g_flex_1">
						<div class="g_flex_column_center g_mr_9 g_flex_none">
							<g-panel-image :url="jobDetail.agencyLogo" size="76" />
						</div>
						<div class="g_flex_1 g_flex_column_center">
							<div class="g_ell_1 g_c_3 g_fs_14">{{ jobDetail.agencyName }}</div>
						</div>
					</div>
					<div class="g_flex_column_center g_c_a g_fs_14 g_flex_none g_ml_20">{{ jobDetail.updateTime }}发布</div>
				</div>
			</div>
			<!-- 地址 -->
			<div class="m-address g_mt_16 g_mb_16 g_pt_10 g_pb_10 g_flex_row_start" style="border-top: 1rpx solid #f5f5f5; border-bottom: 1rpx solid #f5f5f5" hover-class="thover" @click="goAddress">
				<div class="g_flex_none g_flex_column_center">
					<image :src="cdnBaseImg + 'jobaddress.svg'" class="g_w_20 g_h_20"></image>
				</div>
				<div class="g_flex_1 g_ml_4 g_mr_4 g_flex_column_center">
					<div class="g_fs_16 g_c_3 g_ell_1">
						{{ jobDetail.storeAddr || "-" }}
					</div>
				</div>
				<div class="g_flex_none g_flex_column_center">
					<image :src="cdnBaseImg + 'jobmore.svg'" class="g_w_14 g_h_14"></image>
				</div>
			</div>
			<!-- <div class="kefuBox">
				<div class="iconBox" v-if="jobDetail.record.customServiceUser && jobDetail.record.customServiceUser.tel">
					<i class="g_fsi_20 iconfont icon-phone g_c_main" @click="takeTel(jobDetail.record)"></i>
				</div>
				<div class="iconBox" v-if="jobDetail.storeJobDetail && jobDetail.storeJobDetail.customServiceUrl">
					<i class="g_fsi_20 iconfont icon-weixin" style="color: #40d559" @click="kefu(jobDetail.record)"></i>
				</div>
			</div> -->
			<!-- 轮播banner -->
			<div class="m-banner g_pb_16 g_border_f5_b" v-if="swiperArray.length > 0">
				<swiper class="swiper" :circular="false" :autoplay="false" :display-multiple-items="swiperArray.length < 5 ? swiperArray.length : 5" style="height: 58px">
					<swiper-item v-for="(item, index) in swiperArray" style="max-width: 58px; padding-right: 12px" :key="index" :class="index == 0 ? 'g_ml_0 g_mr_0' : ''">
						<u-image :radius="4" v-if="item.type == 'image'" :showLoading="true" :src="item.image" width="58px" height="58px" style="border-radius: 4px" @click="handleViewBig(item, index)"></u-image>
						<div class="g_w_58 g_h_58 g_radius_4 videoContainer" style="overflow: hidden" @click="showVideo(item)" v-else>
							<video class="theVideo" :show-fullscreen-btn="false" :show-play-btn="false" :show-center-play-btn="false" :enable-play-gesture="true" :id="item.id" :src="item.image" @fullscreenchange="fullScreen">
								<div class="shareVideo">
									<icon @click="shareVideo(item)" class="iconfont" :class="wxPlat == 'wxwork' ? 'icon-huidaodingbu' : 'icon-zhuanfa1'" hover-class="none" hover-stop-propagation="false"></icon>
								</div>
							</video>
						</div>
					</swiper-item>
				</swiper>
			</div>
			<div class="g_flex_row_center g_border_f5_b g_mb_16" hover-class="none">
				<u-tabs class="g_w_all" bg-color="transparent" from="index" gutter="0" :isScroll="false" :list="tabInfo.list" :current="tabInfo.active" active-color="#00b666" bar-width="64" bar-height="6" @change="handleUpdateTab" font-size="32" duration="0.05" height="92"></u-tabs>
			</div>
			<!-- 职位描述富文本 -->
			<!-- <div class="m-desc g_flex_column_center g_h_28">
				<div class="tip g_flex_row_start">
					<div class="g_flex_column_center">
						<div class="doc g_w_4 g_h_19 g_bg_main g_radius_2 g_mr_10"></div>
					</div>
					<div class="g_fs_18 g_c_3 g_fw_600 g_flex_column_center">职位描述</div>
				</div>
			</div> -->
			<div class="g_position_rela" v-if="attention && tabInfo.list[tabInfo.active].tip == 1">
				<view class="" v-if="!jobDetail.cozeStructureRes">
					<view v-if="jobDetail.notes">
						<view class="detailH3">注意事项</view>
						<view class="pri g_c_f40" style="line-height: 24px; padding: 3px 8px; border-radius: 4px; text-align: justify">{{ jobDetail.notes }}</view>
					</view>
					<view class="detailH3">一、薪资待遇</view>
					<view class="g_radius_4">
						<view class="g_flex_row_between">
							<view class="rb1">1. 薪资明细：</view>
							<view class="textb1">{{ jobDetail.salaryDetail }}</view>
						</view>
					</view>
					<view class="detailH3">二、职位要求</view>
					<view class="g_radius_4">
						<view class="g_flex_row_between">
							<view class="rb1">1. 性别年龄：</view>
							<view class="textb1">{{ (jobDetail.genderRestrict || "-") + " " + (jobDetail.age || "-") }}</view>
						</view>
					</view>
					<view class="detailH3">三、岗位说明</view>
					<view class="g_radius_4">
						<view class="g_flex_row_between">
							<view class="rb1">1. 班次工时：</view>
							<view class="textb1">{{ jobDetail.workClasses }}</view>
						</view>
						<view class="g_flex_row_between">
							<view class="rb1">2. 其他说明：</view>
							<view class="textb1">{{ jobDetail.otherDesp }}</view>
						</view>
					</view>
					<view class="detailH3">四、面试对接</view>
					<view class="g_radius_4">
						<view class="g_flex_row_between">
							<view class="rb1">1. 面试地点：</view>
							<view class="textb1 g_flex_row_end g_flex_1">
								<view class>{{ jobDetail.interviewAddr || "-" }}</view>
								<i v-if="jobDetail.interviewLat" class="iconfont icon-dizhi11 f16 mr4 biggerSize" style="color: #027aff" data-type="interview"></i>
							</view>
						</view>
					</view>
					<view v-if="jobDetail.OtherInfo">
						<view class="detailH3">其它信息</view>
						<view class="pri" style="line-height: 24px; padding: 3px 8px; border-radius: 4px; color: #333">{{ jobDetail.OtherInfo }}</view>
					</view>
				</view>
				<div v-else>
					<template v-for="(item, index) in templateArr">
						<div class="g_flex_row_start flex_center g_fw_600 g_mt_12 g_mb_8 g_fs_16" :key="index" v-if="item.show">
							<div class="" v-if="item.num == 1">一、</div>
							<div class="" v-if="item.num == 2">二、</div>
							<div class="" v-if="item.num == 3">三、</div>
							<div class="" v-if="item.num == 4">四、</div>
							<div class="" v-if="item.num == 5">五、</div>
							<div class="" v-if="item.num == 6">六、</div>
							<div class="">
								{{ item.type }}
							</div>
						</div>
						<template v-for="(inner, index) in item.children">
							<div class="g_flex_row_start g_fs_14" :key="index" style="line-height: 22px; padding-left: 16px" v-if="inner.show">
								<div class="g_flex_row_start flex_start g_fw_600">
									<div class="g_mr_4" hover-class="none" hover-stop-propagation="false">
										{{ `${inner.num}. ` }}
									</div>
									<div class="g_flex_1">
										{{ `${inner.key}: ` }}
										<text class="g_fw_400 g_ml_4" selectable="false" space="false" decode="false">
											{{ inner.value }}
										</text>
									</div>
								</div>
								<!-- @blur="inner.edit = false" -->
							</div>
						</template>
					</template>
				</div>
			</div>

			<div v-if="tabInfo.list[tabInfo.active].tip == 2">
				<div class="g_fs_16 g_pb_32">
					<div class="g_c_3 g_pt_16 pri">
						<div class="">
							<div @click="setCopy('new')" v-if="jobDetail.jobInfoWithoutReturnFee || jobDetail.jobInfo"><span class="desp-copy g_c_main g_border_main">复制</span></div>
							{{ jobDetail.jobInfoWithoutReturnFee || jobDetail.jobInfo || "-" }}
						</div>
					</div>
				</div>
			</div>
			<div class="g_position_rela" v-if="attention && tabInfo.list[tabInfo.active].tip == 3">
				<div class="g_pt_16 g_fs_16 pri" style="">
					<div @click.stop="setCopy('old')">
						<span class="desp-copy g_c_main g_border_main">复制</span>
					</div>
					<rich-text class style="text-align: justify" :nodes="jobDetail.lastNotice"></rich-text>
				</div>
			</div>
			<div v-if="tabInfo.list[tabInfo.active].tip == 4">
				<div class="g_position_rela">
					<div class="g_fs_14 g_c_6 contactInfo g_border_e_r g_border_e_t g_border_e_l" style="white-space: pre-line">
						<div class="g_flex_row_start g_border_e_b">
							<div class="g_w_110 g_border_e_r g_flex_column_center g_text_c" style="padding: 4px 12px">驻场信息</div>
							<div class="g_flex_1 g_c_3" style="padding: 4px 8px">
								{{
									jobDetail.onSiteUsers
										.map((item) => {
											return item.userName + " " + item.tel;
										})
										.join("，") || "-"
								}}
							</div>
						</div>
						<div class="g_flex_row_start g_border_e_b">
							<div class="g_w_110 g_c_6 g_border_e_r g_flex_column_center g_text_c" style="padding: 4px 12px">面试地点</div>
							<div class="g_flex_1 g_c_3" style="padding: 4px 8px">
								{{ jobDetail.interviewAddr || "-" }}
							</div>
						</div>
						<div class="g_flex_row_start g_border_e_b">
							<div class="g_w_110 g_c_6 g_border_e_r g_flex_column_center g_text_c" style="padding: 4px 12px">其他说明</div>
							<div class="g_flex_1 g_c_3" style="padding: 4px 8px">
								{{ jobDetail.otherInfo || "-" }}
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 底部固定操作栏 -->
			<div class="g_h_104"></div>
			<g-panel-fixed>
				<slot>
					<div class="g_pl_20 g_pr_20 g_flex_row_center flex_center flex_nw" style="width: 100%">
						<!-- #ifdef MP-WEIXIN -->
						<div class="g_flex_none g_flex_column_center" v-if="from != 'bill'">
							<button class="g_pl_0 g_pr_0 g_bg_f g_mr_16" hover-class="thover" open-type="share" style="line-height: 1">
								<icon class="iconfont icon-zhuanfa1 g_fsi_16" style="color: #787878; line-height: 1; margin-top: -5px"></icon>
								<div class="g_fs_12 g_c_6 g_w_28" style="margin-top: 8px">分享</div>
							</button>
						</div>
						<!-- #endif -->
						<div class="g_flex_none g_flex_column_center" v-if="false && from == 'bill'">
							<button class="g_pl_0 g_pr_0 g_bg_f g_mr_12" hover-class="thover" @click="goEditJob" style="line-height: 1">
								<icon class="iconfont icon-bianji g_fsi_16" style="color: #787878; line-height: 1; margin-top: -5px"></icon>
								<div class="g_fs_12 g_c_6 g_w_28" style="margin-top: 8px">编辑</div>
							</button>
						</div>
						<div class="g_flex_none g_flex_column_center" v-if="attention && from != 'bill'">
							<button class="g_pl_0 g_pr_0 g_bg_f g_mr_12 g_w_36" hover-class="thover" style="line-height: 1; border-radius: 0" @click="handleCollection">
								<icon v-if="isSc" class="iconfont icon-yishoucang g_fsi_16" style="color: #ff4400; line-height: 1; margin-top: -5px"></icon>
								<icon v-else class="iconfont icon-shoucang g_fsi_16" style="color: #787878; line-height: 1; margin-top: -5px"></icon>
								<div class="g_fs_12 g_c_6" style="margin-top: 8px">{{ isSc ? "已收藏" : "收藏" }}</div>
							</button>
						</div>
						<div class="g_flex_1 g_flex_column_center">
							<g-button btnText="我要报名" class="g_flex_1 g_fw_600" size="small_auto" :type="jobDetail.recruitment == 2 || !attention ? 'infro' : 'primary'" @clickBtn="handleOpenApplyPopup"></g-button>
						</div>
					</div>
				</slot>
			</g-panel-fixed>
		</div>

		<!-- 报名弹窗 -->
		<u-popup v-model="applyPopup.isShow" mode="center" border-radius="8" :mask-close-able="false" width="694rpx">
			<div class="g_pt_24 g_pl_32 g_pr_32 g_pb_24 apply">
				<div class="g_flex_row_center g_fs_18 g_c_3 g_fw_600 g_mb_16">报名确认</div>
				<scroll-view>
					<div class="link">
						<div class="item g_flex_row_start g_mb_10">
							<div class="g_flex_none g_fs_14 g_c_3 g_mr_16 g_w_60 g_text_word_c g_flex_column_center">报名岗位</div>
							<div class="g_flex_1 g_ell_1 g_fs_15 g_c_3 g_fw_600 g_flex_column_center">
								{{ jobDetail.jobName }}
							</div>
						</div>
						<div class="item g_flex_row_start g_mb_12">
							<div class="g_flex_none g_fs_14 g_c_3 g_mr_16 g_w_60 g_text_word_c g_flex_column_center">服务费</div>
							<div class="g_flex_1 g_ell_1 g_c_f0 g_fw_700 g_flex_column_center">
								{{ jobDetail.serverPrice }}
							</div>
						</div>
						<div class="item g_mb_10">
							<div class="g_fs_14 g_c_3 label g_mb_5">姓名</div>
							<div>
								<input type="text" v-model="formInfo.userName" placeholder-class="g_c_c" placeholder="请输入姓名或称呼" class="g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pr_12" />
							</div>
						</div>
						<div class="item g_mb_10">
							<div class="g_fs_14 g_c_3 label g_mb_5">身份证</div>
							<div style="position: relative; line-height: 40px" :maxlength="18" class="g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pr_12">
								<input type="text" maxlength="18" v-model="formInfo.idCard" placeholder-class="g_c_c" class="g_h_40 g_w_200" placeholder="手动输入或拍照自动识别" />
								<div class="t-icon t-icon-paizhao riliIcon" style="width: 16px; height: 14px" @click="getIDCardInfo"></div>
							</div>
						</div>
						<div class="item g_mb_8">
							<div class="g_fs_14 g_c_3 label g_mb_5">联系电话</div>
							<div>
								<input type="text" v-model="formInfo.tel" :maxlength="11" placeholder-class="g_c_c" placeholder="请输入联系电话" class="g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pr_12" />
							</div>
						</div>
						<div class="g_fs_11 g_mb_10" style="color: #b8b8b8">注意：不同的报名人填写同一个手机号报名将会失败。</div>
						<div class="item g_mb_12">
							<div class="g_fs_14 g_c_3 label g_mb_5">预约面试时间</div>
							<div @click="show = true" style="position: relative; line-height: 40px" class="g_flex_1 g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pr_12">
								<div style="position: absolute; left: 0; top: 0; width: 100%; z-index: 2; padding-left: 12px">
									<picker mode="multiSelector" class="g_h_40" :range="dateTimeArray" :value="dateTime" @change="changeDateTime" @columnchange="changeDateTimeColumn($event)" style="color: #333">
										{{ !!currentTime ? currentTime : "----" }}
									</picker>
								</div>
								<i class="iconfont icon-rili g_fs_16 g_ml_4 g_c_9 riliIcon"></i>
							</div>
						</div>
						<div class="item g_mb_16">
							<div class="g_fs_14 g_c_3 g_mb_5">备注</div>
							<div>
								<!-- <input type="text" v-model="formInfo.desp" placeholder="请输入备注" class="g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pr_12"> -->
								<!-- class="g_bg_f_7" -->
								<textarea v-model="formInfo.desp" placeholder-class="g_c_c" type="textarea" placeholder="请输入备注" class="g_bg_f_9 g_radius_4 g_h_40 g_pl_12 g_pt_6" style="min-height: 80px" />
							</div>
						</div>
						<div class="g_flex_row_center g_flex_row_center g_mb_16" style="color: rgba(0, 0, 0, 0.45)">
							<u-checkbox-group @change="radioGroupChange" shape="circle">
								<u-checkbox v-model="agreeRadio" name="agree" active-color="#00b666">
									<div class="g_flex_row_center g_fs_12 g_flex_row_center">
										<div>我已阅读并同意</div>
										<div @click="goPage('/root/person/agreeUser')">《用户协议》</div>
										<div>及</div>
										<div @click="goPage('/root/person/agreeUser')">《隐私政策》</div>
									</div>
								</u-checkbox>
							</u-checkbox-group>
						</div>
						<div class="g_flex_row_between item">
							<div class="g_fs_16 g_c_9 g_flex_c g_mr_16" hover-class="btnHoverBg" @click="applyPopup.isShow = false">取消</div>
							<div class="btn g_fs_16 g_c_f g_bg_main g_flex_1 g_flex_c g_ml_16" hover-class="thover" @click="handleSubmit">确认报名</div>
						</div>
					</div>
				</scroll-view>
			</div>
		</u-popup>
	</div>
</template>

<script>
import dateTimePicker from "../../utils/dateTimePicker.js";
import dateUtil from "../../utils/dateUtil.js";
export default {
	onReady() {
		this.G.setNavStyle();
	},
	onShareAppMessage() {
		this.attention = false;
		return this.G.shareFun("/root/detail/job?id=" + this.jobDetail.id, "", this.jobDetail.jobName + " " + this.jobDetail.priceStr + " " + "好厂好工作 火热招聘中");
	},
	mounted() {
		var obj = dateTimePicker.dateTimePicker(this.startYear, this.endYear, this.currentTime);
		this.currentTime = dateUtil.formatDateYMD(new Date().toLocaleDateString()) + " 06:00";
		this.dateTimeArray = obj.dateTimeArray;
		this.dateTime = obj.dateTime;
	},
	data() {
		return {
			videoContextTemp: {},
			corpUserFlag: false,
			agreeRadio: ["agree"],
			isPerson: false,
			speed: 0,
			uid: 0,
			jobDetail: {},
			isCollection: false,
			swiperArray: [],
			applyPopup: {
				isShow: false,
			},
			formInfo: {
				userName: "",
				idCard: "",
				tel: "",
				interTime: "",
			},
			startYear: new Date().getFullYear(),
			endYear: new Date().getFullYear() + 2,
			currentTime: "",
			dateTimeArray: null,
			dateTime: [],
			from: "", // 来源页面
			isSc: false, // 收藏判断
			attention: false, // 分享时隐藏信息
			selfJob: false, // 是否是自己团队职位的判断
			showPrice: true, // 隐藏服务费
			labelColor: ["#c41d7f", "#096dd9", "#531dab", "#d46b08", "#389e0d", "#08979c", "#cf1322"],
			bgColor: ["#fff0f6", "#e6f7ff", "#f9f0ff", "#fff7e6", "#f6ffed", "#e6fffb", "#fff1f0"],
			loginInfo: {},
			cdnBaseImg: this.G.store().cdnBaseImg,
			IS_CREATOR: false,
			tabInfo: {
				list: [],
				active: 0,
			},
			applyList: [],
			wxPlat: "",
			templateArr: [
				// 职位描述模板
				{
					type: "工作内容",
					show: false,
					childrenType: ["工作内容", "工作方式", "班次工时", "休息", "工衣", "车间", "安检门", "带手机", "流水线"],
					children: [],
				},
				{
					type: "工作要求",
					show: false,
					childrenType: ["性别年龄", "文化学历", "身份证", "资质证件", "纹身烟疤", "案底黑户", "少数民族", "区域要求", "身体状况", "体检要求", "返厂政策"],
					children: [],
				},
				{
					type: "薪资待遇",
					show: false,
					childrenType: ["岗位薪资", "综合月薪", "薪资明细", "发薪日", "银行卡", "预支工资", "岗前培训", "试用期", "员工福利"],
					children: [],
				},
				{
					type: "吃饭住宿",
					show: false,
					childrenType: ["吃饭", "住宿", "保险"],
					children: [],
				},
				{
					type: "押金",
					show: false,
					childrenType: ["餐卡押金", "宿舍押金", "工装押金", "厂牌押金", "工具押金"],
					children: [],
				},
				{
					type: "面试",
					show: false,
					childrenType: ["面试地址", "面试评价", "面试时间", "面试注意事项", "总包驻场"],
					children: [],
				},
			],
		};
	},
	onLoad(options) {
		console.log("详情", options);
		if (options.id) {
			this.uid = options.id;
		}
		if (options.from) {
			this.from = options.from;
		}
		if (!uni.getStorageSync("apply-token")) {
			console.log("apply-token");
			uni.navigateTo({
				url: "/pages/login/index?type=detail&id=" + options.id,
			});
			return;
		}
		this.loginInfo = uni.getStorageSync("apply-userinfo");
		// if (uni.getStorageSync("apply-AGENCY_MAMBER_LIST")) {
		// 	this.applyList = uni.getStorageSync("apply-AGENCY_MAMBER_LIST");
		// 	console.log("this.applyList", this.applyList);
		// } else {
		// 	that.G.Get(that.api.order_peopleList, {}, (res) => {
		// 		console.log("报名人列表：", res.recordList);
		// 		uni.setStorageSync("apply-AGENCY_MAMBER_LIST", res.recordList);
		// 		this.applyList = res.recordList;
		// 		console.log("this.applyList", this.applyList);
		// 	});
		// }

		console.log("this.applyList", this.applyList);
	},
	onShow() {
		let that = this;
		this.IS_CREATOR = uni.getStorageSync("IS_CREATOR") == 1 ? true : false;
		console.log("this.IS_CREATOR", this.IS_CREATOR);
		this.corpUserFlag = uni.getStorageSync("apply-userinfo").corpUserFlag;
		this.getIgnore();
		uni.getSystemInfo({
			success: function (res) {
				console.log(res);
				that.wxPlat = res.hostName;
			},
		});
		this.getDetail().then((res) => {
			console.log("res", res);
			let objMiddle = res.cozeStructureRes ? JSON.parse(res.cozeStructureRes) : {};
			// let objMiddle = JSON.parse(res.cozeStructureRes);
			console.log("objMiddle", objMiddle);
			delete objMiddle["佣金"];
			delete objMiddle["佣金详情"];
			delete objMiddle["企业位置"];
			delete objMiddle["职位标签"];
			delete objMiddle["职位标题"];
			delete objMiddle["职位分类"];
			delete objMiddle["总包驻场"];
			let num1 = 1;
			this.templateArr.forEach((item) => {
				let num = 1;
				item.childrenType.forEach((innerItem) => {
					item.children.push({
						key: innerItem,
						value: objMiddle[innerItem],
						num,
						show: objMiddle[innerItem] ? true : false,
						edit: false,
					});
					if (objMiddle[innerItem]) {
						num++;
					}
				});
				item.num = num1;
				if (item.children[item.children.length - 1].num != 1) {
					item.show = true;
					num1++;
				}
			});
			this.toKnowInfo(res.agencyId);
		});
	},

	methods: {
		goAddress() {
			let that = this;
			uni.navigateTo({
				url: "/root/detail/address?uid=" + that.uid,
			});
		},
		makePhone(tel) {
			uni.makePhoneCall({
				phoneNumber: tel, //仅为示例
			});
		},
		radioGroupChange(e) {
			console.log(e);
		},
		goPage($path) {
			uni.navigateTo({
				url: $path,
			});
		},
		getIgnore() {
			let that = this;
			that.G.Get(that.api.job_watch + "/" + that.uid + "?classify=2", {}, (res) => {
				console.log(res);
			});
		},
		toKnowInfo(id) {
			let that = this;
			console.log(id);
			that.G.Get(that.api.bind_enterpriseDetail + "/" + id, "", (res) => {
				if (that.loginInfo.agencyId == that.jobDetail.agencyId || res.recordStatus == 1 || res.recordStatus == 2) {
					that.attention = true;
				} else {
					that.G.handleConfirm({
						title: "关注发单号",
						content: "你还不是他的粉丝，无法查看职位",
						confirmText: "去关注",
						success: (res) => {
							if (res.confirm) {
								let params = {
									id: that.jobDetail.agencyId,
									isShowMore: false,
									jobDetailShow: false,
								};
								uni.navigateTo({
									url: "/root/detail/user?" + that.G.objToStr(params),
								});
							}
						},
					});
				}
				that.speed = 1;
			});
		},
		handleCollection() {
			let that = this;
			that.G.Get(
				that.api.job_updateStatus + "/" + that.uid,
				{
					classify: 0,
				},
				(res) => {
					that.isSc = !that.isSc;
					uni.showToast({
						title: that.isSc ? "收藏成功" : "取消收藏",
						icon: "success",
					});
				}
			);
		},
		getDetail() {
			let that = this;
			that.speed = 0;
			return new Promise((resolve) => {
				that.G.Get(that.api.job_detail + "/" + that.uid, "", (res) => {
					that.isSc = res.collect == 1 ? true : false;
					console.log("职位详情：", res);
					res = { ...res, ...res.record };
					if (!res.hasOwnProperty("storeJobDetail")) {
						res.storeJobDetail = {
							jobDesp: "",
						};
					}

					console.log("职位详情1：", res);
					that.isPerson = res.agencyId == uni.getStorageSync("apply-agencyId") ? true : false;
					if (that.isPerson) {
						that.tabInfo.list = [
							{
								name: "职位详情",
								active: 1,
								tip: 1,
							},
							{
								name: "通告分享",
								active: 2,
								tip: 2,
							},
							{
								name: "原始通告",
								active: 3,
								tip: 3,
							},
						];
					} else {
						that.tabInfo.list = [
							{
								name: "职位详情",
								active: 1,
								tip: 1,
							},
							{
								name: "通告分享",
								active: 2,
								tip: 2,
							},
						];
					}

					// res.serverPrice = that.G.setReturnFee(res.returnFee, res.returnFeeType);
					res.agencyServerPrice = that.G.setReturnFee(res.agencyReturnFee, res.agencyReturnFeeType);
					res.serverPrice = that.G.setReturnFee(res.returnFee, res.returnFeeType);

					let setData = that.G.disposeJobListData(res);
					res.addressStr = setData.district.slice(0, -1);
					res.sexStr = setData.genderAge;

					// res.ageStr = setData.age;
					// res.priceStr = that.G.getSalaryClassifyValue(res.salaryClassify, res.salaryClassifyValue);
					res.priceStr = res.salaryClassify != 7 ? that.G.getSalaryClassifyValue(res.salaryClassify, res.salaryClassifyValue) : that.G.getSalaryClassifyValue(res.salaryClassify, res.minMonthlyPay, res.maxMonthlyPay);
					res.updateTime = that.G.setDeadLine(res.updateTime, "jiaofu");
					console.log("res.imgs", res.imgs);
					that.swiperArray =
						res.imgs.length == 0
							? []
							: res.imgs.map((item, index) => {
									return {
										id: index + 1,
										image: item.url,
										type: item.url.indexOf(".mp4") > -1 ? "video" : "image",
									};
							  });
					if (res.logo) {
						that.swiperArray.unshift({
							id: 0,
							image: res.logo,
							type: "image",
						});
					}
					that.jobDetail = res;
					that.selfJob = that.jobDetail.agencyId == that.loginInfo.agencyId;
					if (that.jobDetail.jobInfo.indexOf("————————" > -1)) {
						that.jobDetail.jobInfo = that.jobDetail.jobInfo.replace(/\*\*\*\*\*/g, "").split("————————")[0];
					} else {
						that.jobDetail.jobInfo = that.jobDetail.jobInfo.replace(/\*\*\*\*\*/g, "");
					}
					// that.jobDetail.jobRequestLabelNamesList = that.jobDetail.jobRequestLabelNames.split(",");
					// that.jobDetail.jobSpecialLabelNamesList = that.jobDetail.jobSpecialLabelNames.split(",");
					var str = that.jobDetail.supplier;
					var reg = /1[3456789]\d{9}/g;
					var phone = str.match(reg);
					if (phone != null) {
						that.jobDetail["phone"] = phone.toString();
					}
					// console.log(phone.length);

					// that.jobDetail.jobName = '三顿饭卡加斯冯老师独立开发技术的返利看打两发慷慨激昂收代理费'
					resolve(that.jobDetail);
				});
			});
		},
		handleViewBig($item, $index) {
			let that = this;
			uni.previewImage({
				urls: that.swiperArray.map((item) => {
					return item.image;
				}),
				current: $index,
			});
		},
		goUserMain() {
			let that = this;
			let loginId = uni.getStorageSync("apply-userinfo").agencyId;
			if (loginId == this.jobDetail.agencyId) {
				return;
			}
			let params = {
				id: this.jobDetail.agencyId,
				isShowMore: true,
				isShowJob: true,
			};
			uni.navigateTo({
				url: "/root/detail/user?" + that.G.objToStr(params),
			});
		},

		handleOpenApplyPopup() {
			let that = this;
			if (!this.attention) {
				return false;
			}
			uni.navigateTo({
				url: "/root/home/quickApplication?jobId=" + this.jobDetail.id + "&jobName=" + this.jobDetail.jobName + "&title=报名&type=" + that.jobDetail.jobType + "&agencyId=" + that.jobDetail.agencyId,
			});
			// if (this.jobDetail.recruitment == 1) {
			// 	this.formInfo = {
			// 		userName: "",
			// 		idCard: "",
			// 		tel: "",
			// 		interTime: "",
			// 	};
			// 	this.applyPopup = {
			// 		isShow: true,
			// 	};
			// } else {
			// 	uni.showToast({
			// 		title: "停招职位不能报名",
			// 		icon: "none",
			// 	});
			// }
		},
		handleToggleCollection() {
			this.isCollection = !this.isCollection;
			if (this.isCollection) {
				uni.showToast({
					icon: "success",
					title: "收藏成功",
				});
			}
		},

		changeDateTime(e) {
			console.log(e);
			var dateTimeArray = this.dateTimeArray,
				dateTime = e.detail.value;
			this.currentTime = dateTimeArray[0][dateTime[0]].replace("年", "") + "-" + dateTimeArray[1][dateTime[1]].replace("月", "") + "-" + dateTimeArray[2][dateTime[2]].replace("日", "") + " " + dateTimeArray[3][dateTime[3]];
		},

		changeDateTimeColumn(e) {
			console.log(e);
			var arr = this.dateTime;
			var dateArr = this.dateTimeArray;
			arr[e.detail.column] = e.detail.value;
			dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
			for (let index = 0; index < dateArr[2].length; index++) {
				dateArr[2][index] = dateArr[2][index] + "日";
			}
			// .replace("年",'').replace("月",'').replace("日",'')
			dateTimeArray = dateArr;
			dateTime = arr;
		},

		// 复制通告
		setCopy(e) {
			var that = this;
			var contentInfo;
			const query = uni.createSelectorQuery().in(this);
			query
				.select(".contactInfo")
				.boundingClientRect(function (res) {
					console.log(res);
					contentInfo = res.dataset.info;
					if (contentInfo) {
						uni.setClipboardData({
							data: contentInfo,
							success(res) {
								uni.showToast({
									title: "内容已复制",
									icon: "none",
									duration: 1500,
								});
							},
							fail(err) {
								console.log("setClipboardDataerr", err); // data
							},
						});
					} else {
						uni.showToast({
							title: "复制内容为空",
							icon: "none",
							duration: 1500,
						});
					}
				})
				.exec();
		},
		handleSubmit() {
			let that = this;
			console.log("that.formInfo", that.formInfo);
			that.formInfo.jobId = that.uid;
			that.formInfo.interviewTimeStr = that.currentTime;
			console.log("that.formInfo1", that.formInfo, that.agreeRadio);
			if (that.formInfo.userName == "") {
				uni.showToast({
					icon: "none",
					title: "请输入您的真实姓名，只包含中文或英文字符",
				});
				return false;
			}
			if (that.formInfo.idCard == "") {
				uni.showToast({
					icon: "none",
					title: "请输入18位有效身份证号码",
				});
				return false;
			}
			if (!that.G.setReg(that.formInfo.idCard, "idcard")) {
				uni.showToast({
					icon: "none",
					title: "请输入正确的身份证号",
				});
				return false;
			}
			if (that.formInfo.tel == "") {
				uni.showToast({
					icon: "none",
					title: "请输入联系电话",
				});
				return false;
			}
			if (!that.G.setReg(that.formInfo.tel, "tel")) {
				uni.showToast({
					icon: "none",
					title: "请输入正确的联系电话",
				});
				return false;
			}
			if (!that.agreeRadio.length) {
				uni.showToast({
					icon: "none",
					title: "请阅读协议",
				});
				return false;
			}
			that.G.Post(that.api.job_recordJob, that.formInfo, (res) => {
				console.log(res);
				uni.showToast({
					icon: "success",
					title: "报名成功",
				});
				that.applyPopup.isShow = false;
			});
		},
		goEditJob() {
			let that = this;
			uni.navigateTo({
				url: "/root/home/jobForm?id=" + that.uid,
			});
		},
		getIDCardInfo() {
			let that = this;

			that.G.uploadImg((res) => {
				console.log("身份证信息：", res);
				this.formInfo.userName = res.info.name;
				this.formInfo.idCard = res.info.num;
				this.formInfo.nation = res.info.nationality;
				this.formInfo.age = res.info.age;
				this.formInfo.address = res.info.address;
				this.formInfo.idCardImageUrl = res.image;
				this.formInfo.sex = res.info.sex == "男" ? 1 : 2;
			}, "idcard");
		},
		// 显示视频
		showVideo(e) {
			var that = this;
			console.log("showVideo e", e);
			console.log("showVideo that.swiperArray", that.swiperArray);
			this.videoContext = uni.createVideoContext(`${e.id}`, this);
			that.videoContextTemp = that.videoContext;
			this.videoContext.requestFullScreen();
			this.videoContext.hideStatusBar();
			this.videoContext.play();
		},
		takeTel($item) {
			console.log($item);
			// if ($item) {
			uni.makePhoneCall({
				phoneNumber: $item.customServiceUser.tel,
			});
			// }
		},
		kefu(e) {
			console.log(e);
			console.log(this.jobDetail);
			console.log(this.jobDetail.storeJobDetail);
			var that = this;

			let url = this.jobDetail.storeJobDetail.customServiceUrl;
			// console.log('/pages/detail/index?storeJobId' + this.data.searchForm.storeJobId);
			if (url != "") {
				uni.openCustomerServiceChat({
					// extInfo: { url: 'https://work.weixin.qq.com/kfid/kfc84d8465f4c633511' },
					extInfo: { url: url || "https://work.weixin.qq.com/kfid/kfc84d8465f4c633511" },
					showMessageCard: true,
					sendMessagePath: `/root/detail/job.html?id=${that.uid}&classify=${that.jobDetail.classify}`,
					corpId: "wwc227639d3a136c8d",
					success(res) {
						console.log("res", res);
					},
					fail(err) {
						console.log("err", err);
					},
				});
			} else {
				uni.showToast({
					title: "该岗位暂无客服",
					icon: "none",
					duration: 2000,
				});
			}
		},
		fullScreen(e) {
			console.log(e);
			if (!e.detail.fullScreen) {
				this.videoContext.stop();
			}
		},
		shareVideo(e) {
			var that = this;
			console.log(e);
			uni.showLoading({
				title: "下载中...",
				mask: true,
			});
			if (this.wxPlat == "wxwork") {
				uni.downloadFile({
					url: e.image, // 下载url
					success: (downloadRes) => {
						uni.saveVideoToPhotosAlbum({
							filePath: downloadRes.tempFilePath,
							success: () => {
								console.log("视频已保存到相册");
							},
							fail: () => {
								console.error("保存视频到相册失败");
							},
						});
						uni.hideLoading();
					},
					fail: () => {
						uni.hideLoading();
						console.error("下载文件失败");
					},
				});
			} else {
				uni.downloadFile({
					url: e.image, // 下载url
					success(res) {
						// 下载完成后转发
						uni.hideLoading();
						uni.showLoading({
							title: "分享中...",
							mask: true,
						});
						uni.shareVideoMessage({
							videoPath: res.tempFilePath,
							success() {
								uni.hideLoading();
								console.log("=================-----=========");
								console.log(that.videoContextTemp);
								that.videoContextTemp.exitFullScreen();
								// uni.setNavigationBarTitle({
								//   title: '当前页面'
								// })
							},
							fail: (res) => {
								console.log(res);
								console.log("失败原因1111");
								uni.hideLoading();
								uni.showToast({
									title: "分享失败",
								});
							},
						});
					},
					fail: (res) => {
						console.log("失败原因" + res);
						uni.hideLoading();
						uni.showToast({
							title: "下载失败",
						});
					},
				});
			}
		},
		handleUpdateTab(e) {
			console.log("e", e);
			this.G.isLogin();
			if (this.G.isLogin()) {
				this.tabInfo.active = e;
				// this.speed = -1;
				// this.query.page = 1;
				// this.getList();
			}
		},
		showFee() {
			let that = this;
			let content, title;
			if (that.jobDetail.returnFeeDesp) {
				title = "佣金: " + that.jobDetail.serverPrice;
				content = that.jobDetail.returnFeeDesp;
			} else {
				title = "详询客服";
				content = "因三方项目政策变动太快，详情请咨询客服。页面左下角点击“联系客服”直接联系我哟~";
			}

			that.G.handleConfirm({
				title,
				content,
				contentColor: "#ccc",
				confirmColor: "#576b95",
				confirmText: "确定",
				showCancel: false,
				success(res) {},
			});
		},
		// 复制通告
		setCopy(e) {
			var that = this;
			let text;
			console.log(e);
			if (e == "new") {
				text = that.from != "new" ? that.jobDetail.jobInfoWithoutReturnFee || that.jobDetail.jobInfo : that.jobDetail.cozeJobInfoWithoutReturnFee;
			} else if (e == "old") {
				text = that.jobDetail.lastNotice;
			} else if (e == "jobName") {
				text = that.jobDetail.jobName + "@" + (that.jobDetail.supplier.supplierName || "-");
			}
			console.log("text", text);
			uni.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							console.log(res.data); // data
							uni.showToast({
								title: "复制成功",
								icon: "success",
							});
						},
					});
				},
			});
		},
	},
};
</script>

<style lang="scss">
.shareVideo {
	position: absolute;
	bottom: 80px;
	right: 30px;
	width: 36px;
	height: 36px;
	text-align: center;
	z-index: 1111;
	background-color: #ffffff66;
	border-radius: 50%;

	.iconfont {
		color: #fff;
		font-size: 20px;
		line-height: 36px;
		&.icon-huidaodingbu {
			transform: rotate(180deg);
		}
	}
}

.p-root-detail-job {
	.m-boss {
		.box {
			background-color: rgba(0, 182, 102, 0.05);
		}
	}

	.m-banner {
		.u-swiper__wrapper__item {
			margin-right: 10px;
		}

		image {
			border-radius: 4px !important;
		}
	}

	.m-state {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 1;
		box-shadow: 0px -4rpx 8rpx 0px rgba(218, 218, 218, 0.5);
	}

	.apply {
		.link {
			.item {
				.btn {
					width: 240rpx;
					height: 76rpx;
					border-radius: 42rpx;

					&:first-child {
						border: 2rpx solid #00b666;
					}
				}

				.label {
					position: relative;

					&::before {
						content: "*";
						color: #ff0000;
					}
				}
			}
		}
	}

	.riliIcon {
		position: absolute;
		right: 15px;
		top: 50%;
		transform: translateY(-50%);
		z-index: 1;
	}
	.servicePrice {
		height: 64px;
		border: 1rpx solid #eee;
		// background-color: #ffeee7;
		// border-right-color: transparent;
		// border-left-color: transparent;
		// width: 100vw;
		// margin-left: -20px;
	}
	.kefuBox {
		position: fixed;
		right: 25px;
		bottom: 182px;
		z-index: 9999;
		.iconBox {
			width: 48px;
			height: 48px;
			margin-bottom: 12px;
			border-radius: 50%;
			text-align: center;
			line-height: 48px;
			box-shadow: 2px 0 12px 2px rgba(108, 108, 108, 0.2);
			background: #fff;
			z-index: 9999;
		}
	}
	.desp-copy {
		font-size: 12px;
		float: right;
		/* top: 11px;
  right: 8px;
  position: relative; */
		border-radius: 25rpx;
		padding: 0px 8px;
		height: 16px;
		line-height: 16px;

		margin-right: 16px;
	}
	.detailH3 {
		font-size: 16px;
		font-weight: 400;
		color: #000;
		line-height: 22px;
		margin-top: 16px;
		margin-bottom: 8px;
	}
	.pri {
		white-space: pre-line;
	}
	.pri:empty:before,
	.textb1:empty:before {
		content: "-" !important;
		color: #333;
	}
}
</style>
