<!-- 招聘详情 -->

<template>
	<view class="loading_text" v-if="loading">加载中...</view>
	<view v-else>
		<view class="order_status_box">
			<image :src="process_line_arrow"></image>
		</view>

		<!-- 招聘信息 -->
		<view class="top_bg" style="padding-bottom: 20upx;position: relative;">
			<view class="main_width">
				<view class="green_title">{{data.title}}</view>
				<view class="green_sara">
					<view style="line-height: 44upx;">{{sys_role==0?data.salary:data.feetotal}}</view>
					<view style="font-size: 30upx;margin-left: 6upx;">元 /{{data.settleType?'完工结':'天'}}</view>
				</view>
				<view class="work_time">
					<view>
						<text
							v-if="data.settle_catalog==0">{{((data.begin_datetime==data.finish_datetime)||!data.finish_datetime)?data.begin_datetime:(data.begin_datetime+'~'+data.finish_datetime)}}</text>
						<text v-else>{{data.begin_datetime+'开始报名'}}</text>
					</view>
					<view style="margin-left: 20upx;display: flex;align-items: center;">
						<image class="mini_icon" src="../../static/clock_grey.png"></image>
						<text style="margin-left: 4upx;">{{data.begin_hour}}~{{data.finish_hour}}</text>
					</view>
				</view>
				<view class="guanfan">
					<view style="display: flex;align-items: center;">
						<image style="width: 30upx;height: 30upx;margin-right: 4upx;"
							:src="data.meals_providing==0?'../../static/guanfan_grey.png':'../../static/guanfan_green.png'">
						</image>
						<text
							:style="data.meals_providing==0?'color: #9B9B9B;':'color: #00C7B2;'">{{data.meals_providing==0?'不管饭':'管饭'}}</text>
					</view>
					<view style="display: flex;align-items: center;">
						<view class="has_signed">
							<!--<image :key="index"
								v-for="(item,index) in formate_enrolled_heads(data.enrolled_heads, (Number(data.now_worker_total000)))"
								:src="serverUrl+'touxiang/'+item+'.png'"></image>-->
							<image :key="index" v-for="(item,index) in data.todo_list" :src="item.profile_photo" mode=""></image>
						</view>
						<text>{{data.now_worker_total000==0?'':(data.now_worker_total000+'人已报名')}}</text>
					</view>
				</view>
			</view>
		</view>

		<view style="padding: 0upx 0 20upx;position: relative;" class="main_width">
			<view @click="check_ins(8)" class="ins_nav">
				<image style="margin-right: 2upx;width: 32upx;height: 30upx;" src="../../static/ins_blue.png"></image>
				小优保障
			</view>
			<view class="page_title">招聘要求</view>
			<view class="tags_top">
				<view>{{data.gender_mode==0?'性别不限':data.gender_mode==1?'限男':'限女'}}</view>
				<view>{{data.age_mode==0?'年龄不限':(data.age_min+'岁-'+data.age_max+'岁')}}</view>
				<view v-if="data.need_total">
					总需求{{data.need_total}}人{{data.need_perday>0&&data.settle_catalog==1?(' 每天'+data.need_perday+'人'):''}}
				</view>
			</view>
			<view style="clear: both;height: 15upx;"></view>
			<view style="padding-bottom: 40upx;clear: both;">
				<view class="page_title2">岗位详情</view>
				<view style="margin-top: 10upx;font-size: 30upx;" class="main_text">工作内容</view>
				<view style="margin-top: 10upx;">
					<text class="main_text">{{data.work_desc}}</text>
				</view>
				<view style="margin-top: 30upx;font-size: 30upx;" class="main_text">工作要求</view>
				<view style="margin-top: 10upx;">
					<text class="main_text">{{data.requirements}}</text>
				</view>
				<image mode="widthFix" style="width: 100%;margin-top: 30upx;" v-if="data.profile_photo"
					:src="data.profile_photo"></image>
			</view>
		</view>

		<view v-if="!loading" style="margin-top: 0upx;padding-bottom: 20upx;">
			<mapBox :dataSource="positionData"></mapBox>
		</view>

		<!-- 公告声明，信息举报 -->
		<view v-if="sys_role==0&&IS_TOURIST!=1" class="ggsm_xxjb">
			<image @click="check_ins(13)" :src="ggsmImg"></image>
			<image @click="open_complaint_modal" :src="xxjbImg"></image>
		</view>

		<view class="main_width">
			<view style="margin-top: 30upx;padding-bottom: 30upx;">
				<view class="page_title2">机构信息</view>
				<view style="margin-top: 0upx;display: flex;flex-direction: row;justify-content: space-between;">
					<navigator :url="'../personal/resumeCheckMerchant?id='+id"
						style="display: flex;align-items: center;" class="main_text">
						<image
							style="width: 32upx;height:32upx;margin-right: 6upx;border-radius: 50%;margin-left: 7upx;"
							:src="data.bt_profile_photo"></image>
						{{data.bt_linker_name||data.bt_nickname||'--'}}
						<image style="width: 32upx;height:32upx;margin-left: 6upx;"
							:src="data.bt_linker_gender=='0'?'../../static/male.png': '../../static/female.png'">
						</image>
					</navigator>
					<navigator :url="'/pages/personal/appraisal?type=0&id='+data.biz_traderid"
						style="display: flex;align-items: center;">
						<trailerStars v-if="!loading" allowTap="0" v-on:changeScore="changeScore"
							:innerScore="data.trader_appraisal_avg">
						</trailerStars>
						<view style="color: #8E97AE;margin-left: 10upx;">{{data.trader_appraisal_avg.toFixed(1)}}</view>
					</navigator>
				</view>

				<navigator :url="'../personal/resumeCheckMerchant?id='+id"
					style="margin-top: 10upx;align-items: center;display: flex;margin-right: 10upx;" class="main_text">
					{{data.bt_companyname}}
					<image v-if="data.bt_certif_confirmed!=0" style="width: 50upx;height: 50upx;margin-right: 0upx;"
						:src="data.bt_certif_confirmed==1?serverUrlImg8:serverUrlImg9"></image>
					<text
						:style="'font-size: 22upx;color:'+(data.bt_certif_confirmed==0?'#909090':data.bt_certif_confirmed==1?'#f7942d':'#00c3b8')">{{data.bt_certif_confirmed==0?'商家认证中':data.bt_certif_confirmed==1?'个人认证':'企业认证'}}</text>
				</navigator>

				<!-- 小优保险 -->
				<view @click="check_ins(9)" style="background-color: #fff4f1;margin-top: 16upx;" class="insurance">
					<view style="display: flex;align-items: center;margin-left: 4%;">
						<image style="width: 36upx;height: 40upx;" :src="serverUrlImg7"></image>
						<view style="color: #fd5529;font-size: 34upx;margin-left: 20upx;">
							<view style="color: #F7942D;font-size: 32upx;">小优保险</view>
							<view style="color: #F7942D;font-size: 26upx;">为您保驾护航</view>
						</view>
					</view>
					<view style="margin-right: 4%; color: #F7942D;display: flex;align-items: center;">
						了解详情
						<image style="width: 13upx;height: 22upx;margin-left: 10upx;"
							src="../../static/arrow_right_orange.png">
						</image>
					</view>
				</view>
			</view>
		</view>
		<view class="line_grey"></view>

		<view style="height: 150upx;"></view>

		<!-- 底部tab，只有会员端 才显示 -->
		<view :class="isIphoneX? 'det_btn_box det_btn_box2':'det_btn_box'" v-if="sys_role==0">
			<block>
				<!-- 分享按钮 -->
				<view @click="open_share_modal" style="background-color: #ffffff;height: 110upx;" class="bot_each2">
					<image style="width: 70upx;height: 48upx;" :src="share_botImg"></image>
					<view style="font-size: 24upx;text-align: center;margin-top: 8upx;">
						成单得{{((Number(data.feetotal)-Number(data.salary))*(Number(data.sharer_fetchrate))).toFixed(2)}}元
					</view>
				</view>
				<!-- 报名和取消报名 -->
				<view v-if="data.todoinfo.canToEnroll" @click="open_sign_modal()" style="background-color: #00C7B2;"
					class="bot_each">
					<image style="width: 50upx;height: 48upx;" :src="sign2Img"></image>
					<view style="margin-left: 8upx;">报名</view>
				</view>
				<view v-else-if="data.todoinfo.canCancelEnroll==1" @click="open_cancel_sign_modal()"
					style="background-color: #de0003;" class="bot_each">取消报名</view>
				<view v-else style="background-color: #de0003;" class="bot_each">不可取消</view>

				<view @click="communicate" style="background-color: #f7942d;" class="bot_each">
					<image style="width: 50upx;height: 50upx;" :src="chatImg"></image>
					<view style="margin-left: 8upx;">沟通</view>
				</view>
			</block>
		</view>

		<!-- 投诉遮罩 -->
		<uni-popup ref="popup" :mask-click="false">
			<view class="modal_box">
				<view style="padding: 30upx;">
					<view style="font-weight: bold;margin-bottom: 20upx;">
						{{complain_type == 'order'?'投诉本次工单':'投诉此招聘信息'}}
					</view>
					<view
						style="display: inline-block;margin-right: 12upx;margin-bottom: 12upx;color: #f7942d;border: 2upx solid #f7942d; padding: 4upx 12upx;"
						:key="index" v-for="(item,index) in complain_ipt_arr" @click="add_ipt_value(index)">
						{{item.text}}
					</view>
				</view>
				<textarea style="height: 350upx;font-size: 30upx;" v-model="ipt_value" @input="ipt_change"
					placeholder="请输入投诉内容"></textarea>
				<view class="modal_btn">
					<view @click="close_complaint_modal" class="modal_btn_cancel">取消</view>
					<view @click="submitNewComplaint" class="modal_btn_confirm">提交</view>
				</view>
			</view>
		</uni-popup>

		<!-- 分享遮罩 -->
		<uni-popup :animation="false" ref="popup_share" :mask-click="false">
			<view class="modal_box">
				<image style="width: 100%;" mode="widthFix" :src="serverUrlImg4"></image>
				<view class="modal_btn">
					<view style="width: 25%;" @click="close_share_modal" class="modal_btn_cancel">取消</view>
					<button style="width: 35%;" open-type="share" class="modal_btn_confirm">
						发送好友
					</button>
					<view @click="save_img" style="width: 35%;" class="modal_btn_confirm">分享到朋友圈</view>
				</view>
			</view>
		</uni-popup>

		<!-- 报名遮罩 -->
		<uni-popup ref="popup_sign" :mask-click="false">
			<view class="modal_box">
				<view style="color: #313131;text-align: center;font-size: 38upx;line-height: 90upx;">注意事项</view>
				<view class="mention">
					<view>1、确认好工作再报名，录取后无法随意更换或取消。</view>
					<view>2、乱报名将被平台记录会降低信用分对个人信用和报名造成影响。</view>
					<view>3、工作中敷衍、偷懒、弄虚作假等行为导致商家不支付薪资后果自行承担。</view>
					<view>4、商家已预付工资到平台，整体流程将在平台内进行，平台会保障您的合法权益。</view>
					<view>
						<navigator v-if="!user_info.true_name" url="/pages/personal/authentication">
							5、实名认证后免费赠送最高10万元的人身意外险，点击去认证。
						</navigator>
					</view>
					<view style="color: #01bcc3;font-weight: bold;align-items: center;">
						本次报名需支付{{data['base_config']['value']}}元押金
						<image src="../../static/ques.png" @click="show_yajin_info()"
							style="margin-left: 10upx;width: 35upx;height: 35upx;"></image>
					</view>
				</view>
				<view class="modal_btn">
					<view @click="close_sign_modal" class="modal_btn_cancel">取消</view>
					<view v-if="data.settle_catalog==1" @click="sign" class="modal_btn_confirm">
						选择报名日期</view>
					<view @click="sign" class="modal_btn_confirm" v-else>确认报名</view>
				</view>
			</view>
		</uni-popup>
		<!--<uni-popup ref="popup_sign" :mask-click="false">
			<view class="modal_box">
				<view style="color: #313131;text-align: center;font-size: 38upx;line-height: 90upx;">注意事项</view>
				<view class="mention">
					<view>1、每个工作报名都会收取押金，若同一时间段报名多个工作，若一商家录取则其他同一时间段报名被动取消，押金一并返还。</view>
					<view>2、未录取前取消工作或未录取工作，押金自然返还。</view>
					<view>3、录取之后完成工作，押金会和工资同时返还。</view>
					<view>4、取之后，若商家违约取消工作，补偿金会和押金自然返还。</view>
					<view>5、仅限因个人原因未到协定岗位者，押金扣除补偿给商家。</view>
					<view>
						<navigator v-if="!user_info.true_name" url="/pages/personal/authentication">
							6、实名认证后免费赠送最高10万元的人身意外险，点击去认证。
						</navigator>
					</view>
					<view style="color: #01bcc3;font-weight: bold;align-items: center;">
						本次报名需支付{{data['base_config']['value']}}元押金
						<image src="../../static/ques.png" @click="show_yajin_info()"
							style="margin-left: 10upx;width: 35upx;height: 35upx;"></image>
					</view>
				</view>
				<view class="modal_btn">
					<view @click="close_sign_modal" class="modal_btn_cancel">取消</view>
					<view v-if="data.settle_catalog==1" @click="sign" class="modal_btn_confirm">
						选择报名日期</view>
					<view @click="sign" class="modal_btn_confirm" v-else>确认报名</view>
				</view>
			</view>
		</uni-popup>-->

		<!-- 取消报名遮罩 -->
		<uni-popup ref="popup_cancel_sign" :mask-click="false">
			<view style="padding-top: 30upx;" class="modal_box">
				<textarea style="height: 350upx;font-size: 30upx;" v-model="ipt_value" @input="textarea_ipt"
					placeholder="请填写取消报名的原因"></textarea>
				<view class="modal_btn">
					<view @click="close_cancel_sign_modal" class="modal_btn_cancel">返回</view>
					<view @click="cancel_sign" class="modal_btn_confirm">确认取消</view>
				</view>
			</view>
		</uni-popup>

		<!-- 押金说明遮罩 -->
		<!--<uni-popup ref="popup_yajin" :mask-click="false">
			<view class="modal_box">
				<view style="color: #313131;text-align: center;font-size: 38upx;line-height: 90upx;">押金支付说明</view>
				<view class="mention">
					<view>1、每个工作报名都会收取押金，若同一时间段报名多个工作，若一商家录取则其他同一时间段报名被动取消，押金一并返还。</view>
					<view>2、未录取前取消工作或未录取工作，押金自然返还。</view>
					<view>3、录取之后完成工作，押金会和工资同时返还。</view>
					<view>4、取之后，若商家违约取消工作，补偿金会和押金自然返还。</view>
					<view>5、仅限因个人原因未到协定岗位者，押金扣除补偿给商家。</view>
				</view>
				<view class="modal_btn">
					<view style="margin: 0 auto;" @click="close_yajin_info" class="modal_btn_confirm">我知道了</view>
				</view>
			</view>
		</uni-popup>-->
		<uni-popup ref="popup_yajin" :mask-click="false" v-if="1==data.urgent_level">
			<view class="modal_box">
				<view style="color: #313131;text-align: center;font-size: 38upx;line-height: 90upx;">押金支付说明</view>
				<view class="mention">
					<view>1、每个工作报名都会收取押金，可以接多个工作。</view>
					<view>2、未录取前取消工作或未录取工作，押金自然返还。</view>
					<view>3、录取之后完成工作，押金会和工资同时返还。</view>
					<view>4、录取之后，若商家违约取消工作，补偿金会和押金自然返还。</view>
					<view>5、仅限因个人原因未到协定岗位者，或未完成工作押金扣除补偿给商家。</view>
				</view>
				<view class="modal_btn">
					<view style="margin: 0 auto;" @click="close_yajin_info" class="modal_btn_confirm">我知道了</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popup_yajin" :mask-click="false" v-else>
			<view class="modal_box">
				<view style="color: #313131;text-align: center;font-size: 38upx;line-height: 90upx;">押金支付说明</view>
				<view class="mention">
					<view>1、每个工作报名都会收取押金，若同一时间段报名多个工作，若一商家录取则其他同一时间段报名被动取消，押金一并返还。</view>
					<view>2、未录取前取消工作或未录取工作，押金自然返还。</view>
					<view>3、录取之后完成工作，押金会和工资同时返还。</view>
					<view>4、录取之后，若商家违约取消工作，补偿金会和押金自然返还。</view>
					<view>5、仅限因个人原因未到协定岗位者，或未完成工作押金扣除补偿给商家。</view>
				</view>
				<view class="modal_btn">
					<view style="margin: 0 auto;" @click="close_yajin_info" class="modal_btn_confirm">我知道了</view>
				</view>
			</view>
		</uni-popup>

		<!-- 日期选择遮罩 -->
		<uni-popup ref="popup_date" :mask-click="false">
			<view class="modal_box">
				<view style="padding-top: 30upx;">
					<view style="width: 50%;float: left;color: #1dd7a8;line-height: 70upx;text-align: center;"
						:key="index" @click="picker_data(item)" v-for="(item,index) in itemList">{{item}}</view>
				</view>
				<view class="modal_btn">
					<view style="width: 50%;clear: both;top: ;" @click="close_date_modal" class="modal_btn_cancel">取消
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import commonData from '../../commonData.js'
	import commonFun from '../../commonFun.js'

	import trailerStars from '../../components/starts/index.vue'
	import share from '../../components/share/index.vue'
	import mapBox from '../../components/mapBox/index.vue'

	export default {
		data() {
			return {
				// 在线图片
				formate_enrolled_heads: commonFun.formate_enrolled_heads,
				serverUrl: this.serverUrl,
				ggsmImg: this.serverUrl + 'ggsm.jpg',
				xxjbImg: this.serverUrl + 'xxjb.jpg',
				chatImg: this.serverUrl + 'chat.png',
				sign2Img: this.serverUrl + 'sign2.png',
				share_botImg: this.serverUrl + 'share_bot.png',
				process_line_arrow: this.serverUrl + 'process_line_arrow.png',
				serverUrlImg4: this.serverUrl + 'show/complaint_modal.png',
				serverUrlImg6: this.serverUrl + 'new/cancel.png',
				serverUrlImg7: this.serverUrl + 'new/insurance2.png',
				serverUrlImg8: this.serverUrl + 'cer_1.png',
				serverUrlImg9: this.serverUrl + 'cer_2.png',

				IS_TOURIST: uni.getStorageSync('IS_TOURIST'), // 获取游客模式
				sys_role: commonData.sys_role, //角色，0是会员，1是商家
				id: '', //招聘详情id
				detailType: 0, //进入招聘详情的类型，1是用户工单进入，0是非用户工单进入
				data: { //招聘详情
					todoinfo: {}
				},
				positionData: {}, //位置信息
				loading: true, //加载中
				shareId: '', //分享者id//可以没有
				user_info: {
					true_name: '',
				}, //个人信息
				ipt_value: '', //投诉内容
				picurls: '',
				picurls2: '',

				todo_title: '',
				todo_remarks: '',
				todo: '',
				reason: '',
				breakdate: '',
				pickDateList: [],
				is_agree: [],
				isIphoneX: uni.getStorageSync('isIphoneX'),
				open_date_modal_type: 'sign',
				itemList: [],
				complain_ipt_arr: [{
					text: '散播违法/敏感言论'
				}, {
					text: '涉黄'
				}, {
					text: '职位虚假'
				}, {
					text: '薪资虚假'
				}, {
					text: '违法/欺诈行为'
				}, {
					text: '变相收费'
				}, {
					text: '与实际工作不符'
				}, {
					text: '商家要求线下结账'
				}, {
					text: '其他'
				}, ],
				complain_type: 'recruit',
			}
		},
		onShareAppMessage(e) {
			this.close_share_modal()
			console.log(e.target.dataset.key)
			return {
				title: this.data.title,
				path: '/pages/order/detail?id=' + this.id + '&share=' + this.user_info.id
			}
		},
		methods: {
			// 取消报名
			cancel_sign() {
				let reason = this.reason
				if (!reason) {
					uni.showModal({
						title: '请填写取消报名的原因!',
						showCancel: false
					})
					return
				}
				uni.showModal({
					title: '确认取消报名？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '加载中...',
								mask: true
							})
							let params = {
								bizCatalog: 'TodoWorkEntity',
								handleMode: 'enrollCancel',
								reason,
							}
							this.data.todoinfo.canCancelEnroll == 1 ? params.workId = this.data.todoinfo
								.tdwkid : params
								.teamid = this.data.todoinfo.workteamid

							console.log('取消报名请求参数')
							console.log(params)

							commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', params,
								res => {
									if (res.status) {
										uni.showModal({
											content: '取消报名成功',
											showCancel: false,
											success: () => {
												this.close_cancel_sign_modal()
												this.get_data()
											}
										})
										uni.hideLoading()
									}
								})
						}
					}
				})
			},
			// 保存图片
			save_img() {
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
					bizCatalog: 'WorkerEntity',
					handleMode: 'fetchRecuritPoster',
					recuritid: this.id
				}, res => {
					if (res.status) {
						console.log(res.data.Result)
						uni.downloadFile({
							url: res.data.Result,
							success: (res) => {
								if (res.statusCode === 200) {
									uni.saveImageToPhotosAlbum({
										filePath: res.tempFilePath,
										success: function() {
											uni.showToast({
												title: "保存成功",
												icon: "none"
											});
										},
										fail: function(e) {
											uni.showModal({
												title: '保存图片失败',
												content: JSON.stringify(e),
												showCancel: false,
												success: function(res) {}
											});
										}
									});
								}
							},
							fail(e) {
								uni.showModal({
									title: '保存图片失败',
									content: JSON.stringify(e),
									showCancel: false,
									success: function(res) {}
								});
							}
						})

					}
					uni.hideLoading()
				})
			},
			// 选中同意违约协议
			checkboxChange(e) {
				this.is_agree = e.detail.value
			},
			// 选择日期
			picker_data(date) {
				this.close_date_modal()
				if (this.open_date_modal_type == 'break') {
					this.breakdate = date
				} else {
					this.sign_fun(date)
				}
			},
			// 输入操作备注
			textarea_ipt(e) {
				this.reason = e.target.value
			},
			// 获取工单详情数据
			get_detail_data(bizId) {
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
					bizCatalog: 'RecruitEntity',
					handleMode: 'fetch',
					bizId
				}, res => {
					if (res.status) {
						this.pickDateList = res.data.Result.pickDateList
					}
				})
			},
			// 查看小优保险
			check_ins(index) {
				uni.navigateTo({
					url: '/pages/login/web?index=' + index
				})
			},
			// 输入框输入
			ipt_change(e) {
				this.ipt_value = e.target.value
			},
			// 追加输入框内容
			add_ipt_value(index) {
				this.ipt_value = this.ipt_value + '#' + this.complain_ipt_arr[index]['text']
			},
			// 提交新的投诉
			submitNewComplaint() {
				if (this.ipt_value == '') {
					uni.showModal({
						content: '请输入投诉内容！',
						showCancel: false
					})
					return
				}
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				let params = {
					bizCatalog: 'InteractionEntity',
					handleMode: 'submitNewComplaint',
					content: this.ipt_value
				}
				if (this.complain_type == 'order') {
					params.workid = this.data.todoinfo.tdwkid
				} else {
					params.recuritid = this.id
				}
				// console.log(params)
				// return
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', params,
					res => {
						if (res.status) {
							uni.showModal({
								content: '投诉成功！',
								showCancel: false
							})
							uni.hideLoading()
							this.close_complaint_modal()
						}
					})
			},
			// 获取个人信息
			get_info() {
				commonFun.get_user_info(res => {
					if (res.status) {
						this.user_info = res.data.Result
						console.log('招聘详情页获取个人信息')
						console.log(this.user_info)
						console.log(JSON.stringify(this.user_info))
					}
				})
			},
			// 报名执行函数
			sign_fun(planDotime) {
				uni.showModal({
					title: '确认报名？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '加载中...',
								mask: true
							})
							uni.login({
								success: res => {
									let params = {
										bizCatalog: 'TodoWorkEntity',
										handleMode: 'singleEnroll',
										recruitId: this.id,
										planDotime,
										sharerWorkerId: this.shareId,
										minaCode: res.code,
									}
									console.log('报名请求参数')
									console.log(params)
									commonFun.requestUrl(
										'&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle',
										params,
										res => {
											if (res.status) {
												console.log('报名返回结果')
												console.log(res)

												// 无需支付
												if (res.data.Result.payResult) {
													uni.showModal({
														content: '报名成功',
														showCancel: false,
														success: () => {
															this.get_data()
														}
													})
													uni.hideLoading()
													this.close_sign_modal()
													return
												}
												// 需要支付
												let prePayInfo = res.data.Result
													.prePayInfo
												console.log('prePayInfo')
												console.log(prePayInfo)
												uni.hideLoading()
												uni.requestPayment({
													...prePayInfo,
													success: (res2) => {
														uni.showModal({
															content: '报名成功',
															showCancel: false,
															success: () => {
																this.get_data()
															}
														})
														uni.hideLoading()
														this.close_sign_modal()
													},
													fail: function(res2) {
														if (res2.errMsg.indexOf(
																'cancel') == -1) {
															uni.showModal({
																title: '支付失败',
																content: JSON
																	.stringify(
																		res2
																	),
																showCancel: false,
															})
														}
													}
												});
											}
										})
								}
							})
						}
					}
				})

			},
			// 报名
			sign() {
				let itemList = []
				for (let i in this.data.pickDateList) {
					itemList.push(this.data.pickDateList[i])
				}
				this.itemList = itemList

				if (this.data.settle_catalog == 1) {
					console.log(itemList)
					this.open_date_modal()
					this.open_date_modal_type = 'sign'
				} else {
					this.sign_fun('')
				}

			},
			// 点击评分
			changeScore(e) {
				console.log(e)
			},
			// 沟通
			communicate() {
				uni.showActionSheet({
					itemList: ['拨号', '在线联系'],
					success: (res) => {
						if (res.tapIndex == 0) {
							uni.makePhoneCall({
								phoneNumber: this.data.linker_phone
							})
						} else {
							let data = this.data
							uni.setStorageSync('targetUser', {
								name: data.bt_companyname,
								avatar: data.bt_profile_photo
							})
							uni.navigateTo({
								url: '/pages/message/chat?to=mer_' + this.data.biz_traderid + '&id=' +
									this.data.id +
									'&title=' + this.data.title + '【' + data.salary + '元/' + (data
										.settleType ? '完工结' : '天') +
									'】'
							})
						}
					},
					fail: function(res) {}
				});
			},
			// 打开日期选择遮罩
			open_date_modal() {
				this.$refs.popup_date.open('top')
			},
			// 关闭日期选择遮罩
			close_date_modal() {
				this.$refs.popup_date.close('top')
			},
			// 打开取消报名窗口
			open_cancel_sign_modal() {
				this.$refs.popup_cancel_sign.open('top')
			},
			// 关闭消报名窗口
			close_cancel_sign_modal() {
				this.$refs.popup_cancel_sign.close('top')
			},
			// 打开分享窗口
			open_share_modal() {
				this.$refs.popup_share.open('top')
			},
			// 关闭分享窗口
			close_share_modal() {
				this.$refs.popup_share.close('top')
			},
			// 打开投诉窗口
			open_complaint_modal() {
				this.$refs.popup.open('top')
			},
			// 关闭投诉窗口
			close_complaint_modal() {
				this.$refs.popup.close('top')
			},
			// 打开报名窗口
			open_sign_modal() {
				if (this.IS_TOURIST == 1) {
					uni.showModal({
						title: '请登录后报名！',
						confirmText: '去登录',
						success: (res) => {
							if (res.confirm) {
								uni.navigateTo({
									url: '../login/index?need_back=1'
								})
							}
						}
					})
					return
				}
				this.$refs.popup_sign.open('top')
			},
			// 关闭报名窗口
			close_sign_modal() {
				this.$refs.popup_sign.close('top')
			},
			// 获取数据
			get_data(bizId = this.id) {
				uni.showLoading({
					title: '加载中...',
					mask: true
				})

				commonFun.requestUrl('&WsAjaxBiz=' + ((this.IS_TOURIST == 1 || this.IS_TOURIST == '') ? 'Public' :
						'Worker') +
					'&WsAjaxAction=entityDataHandle', {
						bizCatalog: 'RecruitEntity',
						handleMode: 'fetch',
						bizId
					}, res => {
						if (res.status) {
							this.data = res.data.Result
							this.positionData = {
								work_addr: this.data.work_addr,
								work_addr1: this.data.work_addr1,
								work_addr_lng: this.data.work_addr_lng,
								work_addr_lat: this.data.work_addr_lat,
							}
							console.log('招聘详情页获取')
							this.complain_type = this.data['todoinfo']['canCancelEnroll'] == 0 && !this.data[
								'todoinfo']['canToEnroll'] ? 'order' : 'recruit'
							console.log(this.data)
						}
						this.loading = false
						uni.hideLoading()
						uni.stopPullDownRefresh()
					})
			},
			// 绑定分享关系
			bind_share() {
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
					bizCatalog: 'RecruitEntity',
					handleMode: 'markshare',
					recruitId: this.id,
					sharerWorkerId: this.shareId,
				}, res => {
					console.log('点击被分享招聘返回')
					console.log(res)
				})
				uni.setStorageSync('shareBindId', '')
			},
			show_yajin_info() {
				this.$refs.popup_yajin.open('top')
			},
			close_yajin_info() {
				this.$refs.popup_yajin.close('top')
			},
		},
		onShow() {
			this.IS_TOURIST = uni.getStorageSync('IS_TOURIST') == '' ? 1 : uni.getStorageSync('IS_TOURIST')
			this.get_info()
			this.get_data()

			let shareBindId = uni.getStorageSync('shareBindId')
			if (shareBindId && this.IS_TOURIST != 1) { //非游客模式绑定
				this.bind_share()
			}
		},
		onLoad(e) {
			// console.log('招聘详情页面e')
			// console.log(e)
			this.id = e.id //测试id：369，正式的时候把 || 369去掉
			// this.id = 578
			if (e.detailType) { //进入招聘详情的类型，1是用户工单进入，0是非用户工单进入
				this.detailType = e.detailType
			}

			// 通过点击被分享进入的招聘
			if (e.share) {
				this.shareId = e.share
				if (this.IS_TOURIST != 1 && this.IS_TOURIST != '') { // 非游客模式绑定
					this.bind_share()
				} else { //游客模式执行
					uni.setStorageSync('shareBindId', this.shareId)
				}
			}
		},
		onPullDownRefresh() {
			this.get_info()
			this.get_data(this.id);
		},
		components: {
			trailerStars,
			share,
			mapBox,
		},
	}
</script>

<style>
	@import url("./detail.css");
</style>
