<template>
	<view>
		<view class="remarks flex justify-center" v-if="info.status==3">
			<view class="remarks-box flex justify-between align-center">
				<text>拒绝原因:</text>
				<text>{{info.auditContent}}</text>
			</view>
		</view>
		<view class="remarks flex justify-center">
			<view class="remarks-box flex justify-between align-center">
				<text style="color: #00B88F;font-weight: bold;">{{info.status==1?'待审核':(info.status==2?'进行中':(info.status==3?'已拒绝':(info.status==4?'已取消':'已关闭')))}}</text>
				<text style="color: #cccccc;font-size: 24rpx;">{{info.createTime}}</text>
			</view>
		</view>
		<view class="remarks flex justify-center" v-if="info.isOverdue==1">
			<view class="remarks-box flex justify-between align-center">
				<text style="color: #000000;font-weight: bold;">已到期</text>
				<text style="color: #000000;font-size: 24rpx;">{{info.overdueTime}}</text>
			</view>
		</view>
		<!-- 岗位要求 -->
		<view class="job flex justify-center">
			<view class="job-info flex justify-center">
				<view class="job-info-c">
					<view class="job-info-c-title">
						{{info.stationName}}
					</view>
					<view class="job-info-c-label flex align-center flex-wrap">
						<view class="job-info-c-label-item">
							{{info.county}}
						</view>
						<view class="job-info-c-label-item">
							{{info.experience}}
						</view>
						<view class="job-info-c-label-item">
							{{info.education}}
						</view>
					</view>
					<view class="job-info-c-price">
						{{info.salaryRange}}
					</view>
				</view>
			</view>
		</view>
		<!-- 岗位介绍 -->
		<view class="jobRemarks flex justify-center">
			<view class="jobRemarks-box flex justify-center">
				<view class="jobRemarks-box-c">
					<view class="jobRemarks-box-c-title">
						岗位介绍
					</view>
					<view class="jobRemarks-box-c-label flex align-center flex-wrap" v-if="info.tag">
						<view class="jobRemarks-box-c-label-item" v-for="(item,index) in info.tag.split(',')" :key="index">
							{{item}}
						</view>
					</view>
					<view class="jobRemarks-box-c-con" v-if="info.positionDetails">
						<view class="jobRemarks-box-c-con-item" v-html="info.positionDetails">
						</view>
					</view>
					<view class="jobRemarks-box-c-line"></view>
					<view class="jobRemarks-box-c-title" style="margin-top: 25rpx;">
						岗位福利
					</view>
					<view class="jobRemarks-box-c-label flex align-center flex-wrap" v-if="info.positionWelfare">
						<view class="jobRemarks-box-c-label-item" v-for="(item,index) in info.positionWelfare?info.positionWelfare.split(','):[]" :key="index">
							{{item}}
						</view>
					</view>
					<view class="jobRemarks-box-c-label flex align-center flex-wrap" v-else>
						<view class="jobRemarks-box-c-label-item">
							暂无
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 企业简介 -->
		<view class="enterprise flex justify-center">
			<view class="enterprise-box flex justify-center">
				<view class="enterprise-box-c">
					<view class="enterprise-box-c-info flex align-center">
						<image :src="info.company?info.company.companyLogo:'../../../static/logo.png'" style="width: 95rpx;height: 95rpx;border-radius: 50%;" mode=""></image>
						<view class="enterprise-box-c-info-n">
							<view class="">
								{{info.company.companyName}}
							</view>
							<view class="">
								{{info.company.companyScope}}
							</view>
						</view>
					</view>
					<view class="enterprise-box-c-bto flex align-center justify-between" @click.stop="gotoMap()">
						<view class="enterprise-box-c-bto-l flex align-center">
							<u-icon name="map" color="#00B88F" style="margin-left: 20rpx;margin-right: 10rpx;" size="28"></u-icon>
							{{info.province}}{{info.city}}{{info.county}}{{info.address}}
						</view>
						<view class="enterprise-box-c-bto-r">
							<u-icon name="arrow-right" color="#00B88F" style="margin-right: 20rpx;" size="28"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部操作 -->
		<view class="btn flex justify-center" v-if="info.status==1">
			<view class="btn-box bgBox flex justify-center align-center" @click="cancelProject">
				取消招聘
			</view>
		</view>
		<view class="btn flex justify-center" v-if="info.status==4 || info.isOverdue==1" @click="updataServeType(info.postPushId,'save')">
			<view class="btn-box bgBox flex justify-center align-center">
				重新发布
			</view>
		</view>
		<view class="btn flex justify-center" v-if="info.status==3 && info.isOverdue==0">
			<view class="btn-box bgBox flex justify-center align-center" @click="updataServeType(info.postPushId,'updata')">
				修改内容
			</view>
		</view>
		<view class="btn flex justify-center" v-if="info.status==2 && info.isOverdue == 0">
			<view class="btn-box flex justify-between">
				<view class="btn-box bgBox btn-boxs flex justify-center align-center" @click="closeOpenJob('close')">
					关闭岗位
				</view>
				<view class="btn-box bgBox btn-boxs flex justify-center align-center" @click="updataServeType(info.postPushId,'updata')">
					修改内容
				</view>
			</view>
		</view>
		<view class="btn flex justify-center" v-if="info.status==5 && info.isOverdue == 0">
			<view class="btn-box flex justify-between">
				<view class="btn-box bgBox btn-boxs flex justify-center align-center" @click="closeOpenJob('open')">
					开启岗位
				</view>
				<view class="btn-box bgBox btn-boxs flex justify-center align-center" @click="updataServeType(info.postPushId,'updata')">
					修改内容
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				postPushId:'',
				info:{},//岗位详情
			};
		},
		onLoad(option) {
			this.postPushId = option.postPushId
			this.getInfo()
		},
		methods:{
			//修改岗位
			updataServeType(postPushId,type) {
				let companyStatus = uni.getStorageSync('companyStatus')
				if(companyStatus==1){
					uni.showToast({
						title:'企业认证审核中，请审核通过后操作!',
						icon:'none'
					})
					return
				}
				if(companyStatus==3){
					uni.showToast({
						title:'企业认证审核未通过，请重新认证!',
						icon:'none'
					})
					return
				}
				uni.navigateTo({
					url: '/package/addJob/addJob?postPushId=' + postPushId+'&type='+type
				})
			},
			//取消招聘
			cancelProject() {
				let that = this
				uni.showModal({
					content: '确认取消该招聘？',
					title: '提示',
					confirmColor:'#00B88F',
					success(iet) {
						if (iet.confirm) {
							let data = {
								postPushId: that.postPushId
							}
							that.$Request.postT('/app/postPush/cancelPostPush', data).then(res => {
								if (res.code == 0) {
									uni.showToast({
										title: '取消成功',
										duration: 1500,
										complete() {
											that.getInfo()
										}
									})
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'none'
									})
								}
								uni.hideLoading()
							})
						}
					}
				})
			},
			//关闭/开启岗位
			closeOpenJob(type){
				let that = this
				uni.showModal({
					title:'提示',
					content:type=='close'?'关闭岗位后，该岗位不会再推荐给用户，是否关闭？':'开启岗位后，该岗位会重新推荐给用户，是否开启？',
					complete(ret) {
						if(ret.confirm){
							that.$Request.getT('/app/postPush/closeOrOpen',{postPushId:that.postPushId}).then(res => {
								if (res.code == 0) {
									uni.showToast({
										title:type=='close'?'已关闭':'已开启',
										duration: 1500,
										complete() {
											that.getInfo()
										}
									})
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					}
				})
			},
			//拉起地图导航
			gotoMap(){
				let that = this
				uni.openLocation({
					latitude:that.info.lat,
					longitude:that.info.lng,
					address:that.info.province+''+that.info.city+''+that.info.county+''+that.info.address,
					name:that.info.address,
					// complete(ret) {
						
					// }
				})
			},
			/**
			 * 获取岗位详情
			 */
			getInfo(){
				this.$Request.getT("/app/postPush/selectPostPushDetails",{
					// userId:uni.getStorageSync('userId'),
					postPushId:this.postPushId
				}).then(res => {
					if(res.code==0){
						this.info = res.data
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F2F2F7;
		padding-bottom: 200rpx;
	}
	.remarks{
		width: 100%;
		margin-top: 30rpx;
		.remarks-box{
			width: 686rpx;
			border-radius: 24rpx;
			background-color: #ffffff;
			padding: 30rpx 20rpx;
			color: red;
		}
	}
	.job{
		width: 100%;
		margin-top: 30rpx;
		
		.job-info{
			width: 686rpx;
			height: 100%;
			border-radius: 24rpx;
			background-color: #ffffff;
			.job-info-c{
				width: 626rpx;
				height: 100%;
				padding-top: 30rpx;
				padding-bottom: 30rpx;
			}
			.job-info-c-title{
				color: #333333;
				font-size: 38rpx;
				font-weight: 800;
			}
			.job-info-c-label{
				margin-top: 30rpx;
				.job-info-c-label-item{
					margin-right: 30rpx;
					color: #999999;
					font-size: 28rpx;
					margin-bottom: 10rpx;
				}
			}
			.job-info-c-price{
				color: #00B88F;
				font-size: 38rpx;
				font-weight: bold;
				margin-top: 30rpx;
			}
		}
	}
	.jobRemarks{
		width: 100%;
		margin-top: 20rpx;
		.jobRemarks-box{
			width: 686rpx;
			height: 100%;
			background-color: #ffffff;
			border-radius: 24rpx;
			.jobRemarks-box-c{
				width: 628rpx;
				height: 100%;
				padding-top: 30rpx;
				padding-bottom: 30rpx;
			}
			.jobRemarks-box-c-title{
				color: #333333;
				font-size: 32rpx;
				font-weight: 800;
			}
			.jobRemarks-box-c-label{
				width: 100%;
				margin-top: 25rpx;
				.jobRemarks-box-c-label-item{
					color: #666666;
					font-size: 24rpx;
					padding: 10rpx 15rpx;
					background-color: #F6F6F6;
					border-radius: 8rpx;
					margin-right: 20rpx;
					margin-bottom: 10rpx;
				}
			}
			.jobRemarks-box-c-con{
				width: 100%;
				margin-top: 25rpx;
				.jobRemarks-box-c-con-item{
					margin-bottom: 10rpx;
					color: #141414;
					font-size: 28rpx;
					font-weight: 500;
				}
			}
			.jobRemarks-box-c-line{
				width: 100%;
				border: 1rpx solid #E6E6E6;
				margin-top: 25rpx;
			}
		}
	}
	.enterprise{
		width: 100%;
		// height: 256rpx;
		margin-top: 25rpx;
		.enterprise-box{
			width: 686rpx;
			background-color: #ffffff;
			height: 100%;
			border-radius: 24rpx;
			padding-bottom: 25rpx;
			.enterprise-box-c{
				width: 626rpx;
				height: 100%;
			}
			.enterprise-box-c-info{
				width: 100%;
				height: 95rpx;
				margin-top: 40rpx;
				.enterprise-box-c-info-n{
					margin-left: 18rpx;
					view:nth-of-type(1){
						color: #333333;
						font-size: 32rpx;
						font-weight: 800;
					}
					view:nth-of-type(2){
						color: #999999;
						font-size: 24rpx;
						font-weight: 500;
						margin-top: 10rpx;
					}
				}
			}
			.enterprise-box-c-bto{
				width: 100%;
				// height: 60rpx;
				padding-top: 15rpx;
				padding-bottom: 15rpx;
				background-color: #EDFFFB;
				border-radius: 30rpx;
				margin-top: 20rpx;
				color: #00B88F;
				font-size: 24rpx;
				font-weight: 500;
			}
		}
	}
	.bgBox{
		color: #ffffff;
		background-color: #00B88F;
		font-weight: bold;
		border-radius: 40rpx;
	}
	.btn{
		width: 100%;
		height: 88rpx;
		margin-top: 30rpx;
		.btn-boxs{
			width: 45% !important;
			
		}
		.btn-box{
			width: 686rpx;
			height: 100%;
			
		}
	}

</style>
