<template>
	<view class="resume">
		<loadlogo v-if="!loadlogo" />
		<far-bottom></far-bottom>
		<view class="resume-content" v-if="loadlogo">
			<view class="resume-content-title">
				<view class="dis-flex">
					<view class="content-title-data flex-box">
						<view class="title-name">{{resumeData.name}}</view>
						<view class="title-time">{{resumeData.work_status_text}}
						<text style="padding-left: 90upx;font-size: 26upx;">
						<text class="iconfont icon-phone" style="font-size: 26upx;color: #333333;padding-right: 10upx;"></text>
						{{resumeData.phone}}</text>
						</view>
						<view class="title-tag">
							<image :src="imgfixUrls + 'gongzuo.png'" mode=""></image>
							<text>{{resumeData.experience}}</text>
							<image :src="imgfixUrls + 'xueli.png'" mode=""></image>
							<text>{{resumeData.education}}</text>
							<image :src="imgfixUrls + 'shengri.png'" mode=""></image>
							<text>{{resumeData.age}}岁</text>
						</view>
					</view>
					<view class="title-img">
						<view style="width: 120upx;height: 120upx;position: relative;">
							<view class="gender" v-if="resumeData.gender_text == '女'"><image :src="imgfixUrls + 'inviteImg/nvxing.png'" mode=""></image></view>
							<view class="gender" style="background-color: #008CFF;" v-else><image :src="imgfixUrls + 'inviteImg/nanxing.png'" mode=""></image></view>
							<image
								style="width: 120upx;height: 120upx;border-radius: 50%;"
								:src="resumeData.avatar"
							></image>
						</view>
					</view>
				</view>
			</view>
			<view class="Self-introduction">
				<view class="dis-flex Self-text">
					<view class="left-name">个人介绍</view>
					<view class="rigth-text">发布于{{resumeData.create_time_text}}</view>
				</view>
				<view class="Self-content">
					{{resumeData.self_evaluation}}
				</view>
			</view>
			<view class="job-intention">
				<view class="job-title">
					求职意向
				</view>
				<view class="job-tag">
					<view class="tag-item" v-for="(item,index) in resumeData.expect_position_list">
						{{item}}
					</view>
				</view>
				<view class="intention">
					<view class="dis-il-block" style="padding-right: 45upx;">
						<text class="iconfont icon-recharge c-ff4444" style="font-size: 32upx;"></text>
						<text class="salary">{{resumeData.salary}}</text>
					</view>
					<view class="dis-il-block">
						<text class="iconfont icon-location" style="font-size: 28upx;"></text>
						<text class="job-location">{{resumeData.region}}</text>
					</view>
				</view>
			</view>
			<view class="work-experience" >
				<view class="work-title">
					工作经历
				</view>
				<view class="experience-item" v-for="(item,index) in resumeData.work_experience">
					<!-- 小球 -->
					<view class="item-ball"></view>
					<view class="item-title dis-flex">
						<view class="item-post">
							{{item.title}}
						</view>
						<view class="item-date">
							{{item.start_time}}至{{item.end_time}}
						</view>
					</view>
					<view class="company-name">
						{{item.corporate_name}}
					</view>
					<view class="working">
						{{item.content}}
					</view>
<!-- 					<view class="working">
						2、有较强的文字驾驭能力,有两年的事业单位文书经验,擅长各类公文写作;
					</view> -->
				</view>
			</view>
			<view class="education">
				<view class="education-title">
					教育经历
				</view>
				<view class="experience-item" v-for="(item,index) in resumeData.educational_experience">
					<!-- 小球 -->
					<view class="item-ball"></view>
					<view class="item-title dis-flex">
						<view class="item-post">
							{{item.school}}
						</view>
					</view>
					<view class="company-name" style="padding: 10upx 0 30upx;">
						{{item.start_time}} - {{item.end_time}}
					</view>
					<view class="working education-working">
						{{item.major}}
					</view>
				</view>
			</view>
			<view class="btns-box dis-flex">
				<view class="invite" @click="invitation">
					邀请面试
				</view>
				<view class="online-chat" @click="goChat">
					在线聊天
				</view>
			</view>
		</view>
		<PopManager :show="isShow" type="center" @clickmask="close">
			<view class="b-f invitePop">
				<view class="invitePop-title f-w">
					邀请面试
					<text class="iconfont icon-close" style="float: right;vertical-align: top;font-size: 30upx;" @click="close"></text>
				</view>
				<view class="f-26 dis-flex" style="padding: 30upx 0;" @click="visiblec = true">
					<view class="flex-box">
						面试时间
					</view>
					<view :class="time?'f-26':'f-26 col-9'">
						{{time || '请选择面试时间	'}}
					</view>
				</view>
				<view class="f-26 dis-flex" style="padding: 0upx 0 30upx;">
					<view style="flex: 0.3;">
						面试地点
					</view>
					<view style="flex: 0.7;">
						<input v-if="isShow" type="text" class="t-r f-26" placeholder-style="color: #999999;" placeholder="请输入面试地址" v-model="site" />
					</view>
				</view>
				<view class="f-26 dis-flex" style="padding: 0upx 0 30upx;">
					<view style="flex: 0.3;">
						面试职位
					</view>
					<view style="flex: 0.7;" @click="visible = true">
						<view :class="selectorItem?'f-26 t-r':'f-26 col-9 t-r'">
							{{selectorItem || '请选择面试职位'}}
						</view>
					</view>
				</view>
				<view class="abBox" @click="invitationLetter">
					确定
				</view>
			</view>
		</PopManager>
		<w-picker
			:visible.sync="visiblec"
			mode="date"
			startYear="1970"
			endYear="2100"
			:value="time"
			fields="minute"
			@confirm="onConfirmdete($event, 'region')"
			ref="date"
		></w-picker>
		<w-picker
		:visible.sync="visible"
		mode="selector"
		:value="selectorItem"
		default-type="title"
		:default-props="defaultProps"
		:options="selectorList"
		@confirm="onConfirm($event,'selector')"
		ref="selector"></w-picker>
		
	</view>
</template>

<script>
	import App from '@/common/js/app.js';
	import Loadlogo from '@/components/template/loadlogo.vue';
	import PopManager from '@/components/template/PopManager';
	import wPicker from '@/components/w-picker/w-picker.vue';
	export default{
		data(){
			return{
				resumeData:{},
				loadlogo:false,
				isShow:false,
				visiblec:false,
				visible:false,
				time:'',
				site:'',
				recruitment_type:1,
				pageId:0,
				userInfoId:'',
				defaultProps:{"label":"title","value":"id"},
				selectorList:[],
				selectorItem:'',
				selectorItemId:'',
				release_sid:'',
				workId:'',
			}
		},
		components:{
			Loadlogo,
			PopManager,
			wPicker
		},
		onLoad(e) {
			this.recruitment_type = e.flag;
			this.pageId = e.id;
			this.workId = e.pageId;
			this.release_sid = e.sid;
			this.userInfoId = uni.getStorageSync('userinfo');
			this.getResumeData(e.id);
		},
		methods:{
			
			goChat(){ //联系对方，instantMessenger为websocket链接，chat页面为循环调用最新消息并渲染
				// App.navigationTo({
				// 	url: `pages/subPages/homepage/chat/chat?id=${this.release_sid || this.userInfoId.mid}&other_party_id=${this.resumeData.mid}&other_party_type=1&type=${this.release_sid?2:1}`
				// })
				let getSetInfo = uni.getStorageSync('getSetInfo');
				if(getSetInfo.type == 1){
					App.navigationTo({
						url: 'pagesA/instantMessenger/instantMessenger?other_party_id=' + this.resumeData.mid + '&other_party_type=' + 1+ '&type=' + (this.release_sid?2:1) + '&id=' + (this.release_sid || this.userInfoId.mid)
					})
				}else{
					App.navigationTo({
						url: 'pages/subPages/homepage/chat/chat?other_party_id=' + this.resumeData.mid + '&other_party_type=' + 1+ '&type=' + (this.release_sid?2:1) + '&id=' +(this.release_sid || this.userInfoId.mid)
					})
				}
			},
			invitationLetter(){
				if(!this.time){
					uni.showToast({
						icon:'none',
						title:'请选择面试时间'
					});
					return
				}else if(!this.site){
					uni.showToast({
						icon:'none',
						title:'请填写面试地址'
					});
					return
				}else if(!this.selectorItemId){
					uni.showToast({
						icon:'none',
						title:'请选择面试职位'
					});
					return
				}
				let data = {
					resume_id:this.pageId,
					recruit_id:this.selectorItemId,
					interview_time:this.getDataTime(this.time),
					interview_area:this.site
				}
				App._post_form(
					`&p=recruit&do=inviteAnInterview`,
					data,
					res => {
						console.log(res)
						this.isShow = false;
						uni.showToast({
							title:res.message
						})
					},
					false,
					() => {
						this.loadlogo = true;
					}
				);
			},
			// 时间转时间戳
			getDataTime(timeValue) {
				let ontime;
				ontime = timeValue.replace(/-/g, '/');
				let date = new Date(ontime);
				let time = date.getTime();
				return time;
			},
			close(){
				this.isShow = false
				this.time = '';
				this.site = '';
			},
			invitation(){
				let data = {
					status:4,
					recruitment_type:this.recruitment_type,
					release_mid:this.recruitment_type==1?this.userInfoId:'',
					release_sid:this.recruitment_type==2?this.release_sid:'',
					}
				App._post_form(
					`&p=recruit&do=homeList`,
					data,
					res => {
						console.log(res)
						this.selectorList = res.data;
						this.selectorList.map(item=>{
							if(item.id == this.workId){
								this.selectorItem = item.title;
								this.selectorItemId = item.id;
							}
						})
						if(this.selectorList.length == 0){
							App.showError(
								`您尚无招聘中的岗位,是否前往添加?`,
								data => {
									if (data.confirm) {
										App.navigationTo({
											url: `pages/subPages2/hirePlatform/postRecruitment/postRecruitment`
										});
										return
									}
								},
								true
							);
						}else{
							this.isShow = true;
						}
						// this.selectorItem = res.data[0].title;
						
					},
					false,
					() => {
						this.loadlogo = true;
						
					}
				);
			},
			onConfirm(e){
				console.log(e);
				this.selectorItem = e.result;
				this.selectorItemId = e.value;
			},
			onConfirmdete(e) {
				console.log(e);
				this.time = e.result;
				// let date = new Date(e.value).getTime();
				// console.log(e, date);
			},
			getResumeData(id){
				App._post_form(
					`&p=recruit&do=resumeDesc&id=${id}&recruit_id=${this.workId || ''}`,
					{},
					res => {
						console.log(res)
						this.resumeData = res.data;
					},
					false,
					() => {
						this.loadlogo = true;
					}
				);
			}
		}
	}
</script>

<style lang="scss" scoped>
.resume {
	// padding: 30upx;
	.resume-content {
		padding: 50upx 30upx 0;
		.resume-content-title {
			padding-bottom: 50upx;
			border-bottom: 1upx solid #eeeeee;
			.content-title-data {
				.title-name {
					font-size: 48upx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}
				.title-time {
					font-size: 32upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					padding: 30upx 0;
				}
				.title-tag {
					font-size: 28upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					image {
						height: 30upx;
						width: 30upx;
						vertical-align: top;
						padding-top: 5upx;
						padding-right: 10upx;
					}
					text {
						padding-right: 80upx;
					}
				}
			}
			.title-img {
				position: relative;
				.gender {
					background-color: #ff838e;
					padding: 8upx;
					border-radius: 50%;
					width: 20upx;
					height: 20upx;
					position: absolute;
					bottom: 0;
					right: 0;
					z-index: 9;
					uni-image {
						width: 20upx;
						height: 20upx;
						vertical-align: top;
					}
				}
			}
		}
		.Self-introduction {
			padding: 50upx 0upx 0;
			.Self-text {
				.left-name {
					flex: 0.5;
					text-align: left;
					font-size: 32upx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}
				.rigth-text {
					flex: 0.5;
					text-align: right;
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			.Self-content{
				padding: 40upx 0;
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				line-height: 48upx;
				border-bottom: 1upx solid #EEEEEE;
			}
		}
		.job-intention{
			padding: 50upx 0;
			border-bottom: 1upx solid #EEEEEE;
			.job-title{
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
			.job-tag{
				padding: 40upx 0;
				.tag-item{
					display: inline-block;
					padding: 12upx 20upx;
					margin-right: 10upx;
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #666666;
					background: #F4F4F4;
					border-radius: 4upx;
				}
			}
			.intention{
				.salary{
					font-size: 32upx;
					font-family: DINPro;
					font-weight: 500;
					color: #FF4444;
				}
				.job-location{
					font-size: 28upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
			}
		}
		.work-experience{
			padding: 50upx 0;
			border-bottom: 1upx solid #EEEEEE;
			.work-title{
				font-size: 32upx;
				padding-bottom: 50upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
			
		}
		.experience-item{
			padding-left: 40upx;
			position: relative;
			border-left: 1upx solid #EEEEEE;
			.item-ball{
				width: 12upx;
				height: 12upx;
				border: 4upx solid #3388FF;
				border-radius: 50%;
				position: absolute;
				left: -10upx;
				top: -10upx;
			}
			.item-title{
				position: relative;
				bottom: 20upx;
				.item-post{
					font-size: 28upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					flex: 0.5;
				}
				.item-date{
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
					flex: 0.5;
					text-align: right;
				}
			}
			.company-name{
				font-size: 24upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				padding-bottom: 40upx;
			}
			.working{
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				padding: 0upx 0 50upx;
				line-height: 48upx;
			}
			.education-working{
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
		}
		.education{
			padding: 55upx 0;
			border-bottom: 1upx solid #EEEEEE;
			.education-title{
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				padding-bottom: 50upx;
			}
		}
		.btns-box{
			padding: 25upx 0upx;
			.invite{
				margin-right: 20upx;
				border: 1upx solid #3388FF;
				border-radius: 4upx;
				padding: 30upx 75upx;
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #3388FF;
				text-align: center;
			}
			.online-chat{
				background: #3388FF;
				border-radius: 4upx;
				font-size: 32upx;
				padding: 30upx 130upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
			}
		}
	}
	.invitePop{
		width: 70vw;
		border-radius: 20upx;
		padding: 30upx;
		position: relative;
		.invitePop-title{
			font-size: 26upx;
		}
		.abBox{
			font-size: 30upx;
			color: #FFFFFF;
			padding: 10upx 50upx;
			background-color: #FF4444;
			border-radius: 60upx;
			display: inline-block;
			position: absolute;
			left: 50%;
			bottom: -40%;
			transform: translate(-50%);
		}
	}
}
</style>
