<template>
	<view class="content">
		<view class="box hflex jbetween">
			<view class="">
				<view class="hflex acenter">
					<view class="name">{{base_info.name}}</view>
				</view>
				<view class="hflex acenter">
					<view class="hflex acenter padR-24">
						<image src="/static/images/index/demand/sex.png" class="icon"></image>
						<view class="text_style1">{{base_info.sex}}</view>
					</view>
					<view class="hflex acenter padR-24">
						<image src="/static/images/index/demand/edution.png" class="icon"></image>
						<view class="text_style1">{{base_info.edu}}</view>
					</view>
					<view class="hflex acenter padR-24">
						<image src="/static/images/index/demand/birthday.png" class="icon"></image>
						<view class="text_style1">{{base_info.age}}</view>
					</view>
					<view class="hflex acenter padR-24">
						<image src="/static/images/index/demand/work.png" class="icon"></image>
						<view class="text_style1">{{base_info.year}}</view>
					</view>
				</view>
				<view class="hflex acenter padT-26">
					<u-icon name="phone-fill" color="#666666" size="14" class="padR-24"></u-icon>
					<view class="text_style1">{{base_info.phone}}<span style="color: #506dff;" @click="take(base_info.phone)"><span style="padding: 0 5rpx;">|</span>拨打</span></view>
				</view>
				<view class="hflex acenter padT-26">
					<image src="/static/images/index/demand/email.png" class="icon"></image>
					<view class="text_style1">{{base_info.email}}<span style="color: #506dff;" @click="copy(base_info.email)"><span style="padding: 0 5rpx;">|</span>复制</span></view>
				</view>
			</view>
			<image :src="base_info.avatar" mode="aspectFill" class="avatar"></image>
		</view>
		<view class="box">
			<view class="hflex acenter jbetween">
				<view class="box_title">求职意向</view>
			</view>
			<view class="hflex acenter padT-26">
				<view class="box_title">{{job_inte.job_name}}</view>
				<view class="box_title" style="padding-left: 24rpx;">{{job_inte.salary}}</view>
			</view>
			<view class="hflex fwrap padT-26">
				<view class="label">可工作区域</view>
				<view class="text_style1" style="flex: 1;">{{job_inte.job_area}}</view>
			</view>
			<view class="hflex acenter padT-26">
				<view class="label">可工作时间</view>
				<view class="text_style1">{{job_inte.job_time}}</view>
			</view>
			<view class="hflex acenter padT-26">
				<view class="label">工作性质</view>
				<view class="text_style1">{{job_inte.job_type}}</view>
			</view>
		</view>
		<view class="box" >
			<view class="hflex acenter jbetween">
				<view class="box_title">工作经历</view>
			</view>
			<block v-for="(item,index) in experience" :key="index">
				<view class="padT-26" @click="editInfo(item.id)">
					<view class="hflex acenter jbetween">
						<view class="box_title">{{item.content.company_name}}</view>
						<!-- <u-icon name="arrow-right" color="#555555" size="12"></u-icon> -->
					</view>
					<view class="hflex acenter jbetween padT-26">
						<view class="text_style1">{{item.content.position_name}}</view>
						<view class="text_style3 padR-24">{{item.content.on_job_start}}-{{item.content.on_job_end}}</view>
					</view>
					<view class="hflex fwrap padT-26 text_style2">工作内容：{{item.content.job_description}}</view>
				</view>
			</block>
		</view>
		<view class="box" >
			<view class="hflex acenter jbetween">
				<view class="box_title">专业技能</view>
			</view>
			<view class="hflex acenter fwrap">
				<block v-for="(item,index) in skills" :key="index">
					<view class="hflex acenter jbetween item_box2">
						<view class="text_style1">{{item.content.skill_name}}</view>
						<view class="text_style1">{{item.content.degree}}</view>
					</view>
				</block>
			</view>
		</view>
		<view class="box" >
			<view class="hflex acenter jbetween">
				<view class="box_title">资质证书</view>
			</view>
			<view class="">
				<block v-for="(item,index) in certificate" :key="index">
					<view class="hflex aend item_box3">
						<view class="box_title padR-24">{{item.content.certificate_name}}</view>
						<view class="text_style1">{{item.content.gain_time}}</view>
					</view>
				</block>
			</view>
		</view>
		<view class="box">
			<view class="box_title">福利待遇</view>
			<view class="text_style1">{{salary}}</view>
		</view>
		<view class="box" style="margin-bottom: 186rpx;">
			<view class="box_title">备注</view>
			<view class="text_style1">{{remarks}}</view>
		</view>
		<view class="bottom hflex acenter jbetween">
			<view class="hflex acenter">
				<view class="vflex acenter" style="margin-right: 20px;" @click="collect">
					<u-icon name="star" color="#444444" size="20" v-if="is_collect == 0"></u-icon>
					<u-icon name="star-fill" color="#506DFF" size="20" v-else></u-icon>
					<view class="text_style1">收藏</view>	
				</view>	
				<view class="vflex acenter" @click="share('Poster1')">
					<image src="https://ship.shipcc.cn/common/share.png" mode="" class="bottom_img"></image>	
					<view class="text_style1">分享</view>	
				</view>	
			</view>
			<view class="left_btn hflex acenter jcenter" @click="like">
				<u-icon name="heart" color="#506DFF" size="20" v-if="is_like == 0"></u-icon>
				<u-icon name="heart-fill" color="#506DFF" size="20" v-else></u-icon>
				<view class="btn_text">感兴趣</view>
			</view> 
			<view class="right_btn hflex acenter jcenter" @click="into_chatroom" v-if="pageData.huanxinID">
				<image src="https://ship.shipcc.cn/common/chat.png" class="btn_icon"></image>
				<view class="btn_text2">立即沟通</view>
			</view>
		</view>
		<view class="share_content" :class="share_show?'':'share_content1'">
			<!-- <view style="width: 100%;height: 168rpx;"></view> -->
			<view class="share_box vflex">
				<view class="hflex acenter">
					<image class="Poster1 head_img" :data-enode="base_info.avatar" data-etype="image" :src="base_info.avatar"></image>
					<view class="Poster1 title" :data-enode="base_info.name">{{base_info.name}}</view>
					<view class="Poster1 subtitle" :data-enode="'/' + base_info.sex + '士'">/{{base_info.sex}}士</view>
				</view>
				<view class="Poster1 pos_title2" data-enode="求职意向">求职意向</view>
				<view class="hflex acenter">
					<view class="label Poster1" data-enode="可工作区域">可工作区域</view>
					<view class="Poster1 text" :data-enode="job_inte.job_area">{{job_inte.job_area}}</view>
				</view>
				<view class="hflex acenter">
					<view class="label Poster1" data-enode="可工作时间">可工作时间</view>
					<view class="Poster1 text" :data-enode="job_inte.job_time">{{job_inte.job_time}}</view>
				</view>
				<view class="hflex acenter">
					<view class="label Poster1" data-enode="工作性质">工作性质</view>
					<view class="Poster1 text" :data-enode="job_inte.job_type">{{job_inte.job_type}}</view>
				</view>
				<view class="hflex acenter share_text jcenter Poster1" style=" margin: 0 190rpx 12rpx;" data-enode="长按或扫码查看">扫码查看职位详情</view>
				<view style="width: 100%;" class="vflex acenter jcenter">
					<image class="Poster1" style="width: 25rpx;height: 20rpx;" :data-enode="style.img1" data-etype="image" :src="style.img1"></image>
					<image class="Poster1" style="width: 100%;height: 2rpx;margin: 30rpx 0;" :data-enode="style.img2" data-etype="image" :src="style.img2"></image>
				</view>
				<view class="hflex acenter jbetween">
					<view class="vflex">
						<view class="share_name Poster1" style="margin: 54rpx 0 20rpx;" data-enode="船百知">船百知</view>
						<view class="share_text Poster1" style="margin: 0 0 36rpx;" data-enode="船百知伴你一起杨帆启航,驶向成功彼岸">船百知伴你一起杨帆启航,驶向成功彼岸</view>
					</view>
					<image class="Poster1" data-etype="image" :data-enode="style.code" :src="style.code" style="width: 136rpx;height: 136rpx;"></image>
					<!-- <image class="Poster1" data-etype="image" :data-enode="base_info.avatar" :src="base_info.avatar" style="width: 136rpx;height: 136rpx;"></image> -->
				</view>
			</view>
			<evils-el-poster width="325" height="467" @on-error="onError" :list="list" backgroundColor="rgb(255, 255, 255)" @on-success="onSuccess" ref="Eposter"></evils-el-poster>
			<view class="share_bottom">
				<view class="hflex acenter jcenter">
					<button class="vflex acenter jcenter bottom_item" open-type="share">
						<image src="https://ship.shipcc.cn/common/wx.png" class="item_icon"></image>
						<view class="item_text">微信好友</view>
					</button>
					<!-- <button class="vflex acenter jcenter bottom_item" open-type="share">
						<image src="https://ship.shipcc.cn/common/moments.png" class="item_icon"></image>
						<view class="item_text">朋友圈</view>
					</button> -->
					<view class="vflex acenter jcenter bottom_item" @click="saveImg">
						<image src="https://ship.shipcc.cn/common/download.png" class="item_icon"></image>
						<view class="item_text">保存图片</view>
					</view>
				</view>
				<view class="share_cancel" @click="close">取消</view>
			</view>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				salary: '',
				remarks: '',
				base_info: {
					
				},
				job_inte: {
					
				},
				experience: [
					
				],
				skills: [
					
				],
				certificate: [
					
				],
				is_collect: 0,
				is_like: 0,
				id: '',
				share_show: false,
				list: {},
				style: {
					img1: 'https://ship.shipcc.cn/common/down2.png',
					img2: 'https://ship.shipcc.cn/common/line.png',
					code: 'https://ship.shipcc.cn/common/code.jpg'
				},
				pageData: {}
			}
		},
		onLoad(options) {
			that = this
			that.id = options.id
			that.getData()
		},
		methods: {
			getData() {
				$api.req({
					url: '/data/api.auth.DemandLabor/demanddetail',
					method: 'POST',
					data: {
						type: 2,
						id: that.id
					}
				}, function(res) {
					if(res.code == 1) {
						console.log(res);
						that.pageData = res.data
						that.id = res.data.id
						that.salary = res.data.welfare_benefits
						that.remarks = res.data.remark
						that.base_info.name = '*' + res.data.real_name.slice(1)
						that.base_info.sex = res.data.sex
						that.base_info.edu = res.data.schooling
						that.base_info.age = res.data.age
						that.base_info.year = res.data.work_year
						that.base_info.phone = res.data.phone
						that.base_info.email = res.data.email
						that.base_info.avatar = res.data.head_img
						that.job_inte.job_name = res.data.job_application
						that.job_inte.salary = res.data.monthly_salary
						that.job_inte.job_area = res.data.job_application
						that.job_inte.job_time = res.data.working_time
						that.job_inte.job_type = res.data.work_nature
						that.experience = res.data.workexperience
						that.skills = res.data.professionalskills
						that.certificate = res.data.certificate
						that.is_collect = res.data.is_collection
						that.is_like = res.data.is_like
					}
				})
			},
			collect() {
				$api.req({
					url: '/data/api.auth.DemandLabor/cocanclecollection',
					method: 'POST',
					data: {
						type: 2,
						id: that.id,
						category: that.is_collect + 1
					}
				}, function(res) {
					if(res.code == 1) {
						$api.info(res.info)
						if(that.is_collect) {
							that.is_collect = 0
						}  else {
							that.is_collect = 1
						}
					}
				})
			},
			like() {
				$api.req({
					url: '/data/api.auth.DemandLabor/cocanclelike',
					method: 'POST',
					data: {
						type: 2,
						id: that.id,
						category: that.is_like + 1
					}
				}, function(res) {
					if(res.code == 1) {
						$api.info(res.info)
						if(that.is_like) {
							that.is_like = 0
						}  else {
							that.is_like = 1
						}
					}
				})
			},
			into_chatroom() {
				var my = uni.getStorageSync("myUsername");
				var nameList = {
				  myName: my,
				  your: that.pageData.huanxinID,
				};
				uni.navigateTo({
				  url: "/pages/chatroom/chatroom?username=" + JSON.stringify(nameList),
				});
			},
			take(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			copy(email) {
				uni.setClipboardData({
					data: email,
					success: function () {
						console.log('复制成功');
						$api.info('复制成功')
					}
				});
			},
			share(elClass) {
				let view = uni.createSelectorQuery().in(this).select(".Poster1");
				
				view.fields({
				  size: true,
				  rect: true,
				  scrollOffset: true
				}, data => {
				}).exec();
				that.share_show = true
				that.$refs.Eposter.createForElRect(elClass,false)
			},
			close() {
				that.share_show = false
			},
			onSuccess(e) {
				console.log(e);
				that.tempImage = e
			},
			onError(err) {
				console.log('发生错误');
				console.log(err);
			},
			saveImg() {
				console.log(that.tempImage);
				uni.authorize({
				    scope: 'scope.writePhotosAlbum',
				    success() {
				        uni.saveImageToPhotosAlbum({
				        	filePath: that.tempImage,
				        	success: function () {
				        		console.log('save success');
								$api.info('保存成功')
								that.close()
				        	}
				        });
				    }
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		
		.box {
			width: 690rpx;
			margin: 0 30rpx;
			box-sizing: border-box;
			padding: 20rpx 0;
			border-bottom: 1rpx solid #F4F4F4;
			.box_title {
				font-size: 32rpx;
				font-weight: 500;
				color: #222222;
			}
			.name {
				font-size: 40rpx;
				font-weight: 500;
				color: #222222;
				padding-bottom: 16rpx;
			}
			.edit_btn {
				width: 84rpx;
				height: 36rpx;
				background: #F0F2F6;
				border-radius: 20rpx;
				font-size: 20rpx;
				text-align: center;
				font-weight: 400;
				color: #506DFF;
				line-height: 36rpx;
				margin-left: 16rpx;
			}
			.padT-26 {
				padding-top: 26rpx;
			}
			.padR-24 {
				padding-right: 24rpx;
			}
			.label {
				width: 148rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #444444;
			}
			.icon {
				width: 28rpx;
				height: 28rpx;
			}
			.text_style1 {
				font-size: 28rpx;
				padding-left: 5rpx;
				font-weight: 400;
				color: #333;
			}
			.text_style2 {
				font-size: 22rpx;
				font-weight: 400;
				color: #444;
				line-height: 32rpx;
			}
			.text_style3 {
				font-size: 24rpx;
				font-weight: 400;
				color: #B1B1B1;
				line-height: 34rpx;
			}
			.item_box2 {
				background: #F4F4F4;
				border-radius: 26rpx;
				box-sizing: border-box;
				padding: 8rpx 34rpx;
				margin: 20rpx 32rpx 0 0;
				position: relative;
				.detele {
					position: absolute !important;
					right: 1rpx;
					top: 1rpx;
					width: 21rpx;
					height: 21rpx;
				}
			}
			.item_box3 {
				width: 100%;
				background: #F4F4F4;
				border-radius: 26rpx;
				box-sizing: border-box;
				padding: 16rpx 20rpx;
				margin: 20rpx 0 0;
				position: relative;
				.detele {
					position: absolute !important;
					right: 1rpx;
					top: 1rpx;
					width: 21rpx;
					height: 21rpx;
				}
			}
			.avatar {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
			}
			.box_info {
				margin: 42rpx 0 0;
				
				.box_icon {
					width: 56rpx;
					height: 56rpx;
					margin-right: 28rpx;
				}
				.box_subTitle {
					margin-top: 4rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #777777;
				}
				.box_btn {
					box-sizing: border-box;
					padding: 6rpx 24rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 34rpx;
					background: #506DFF;
					border-radius: 14px;
				}
			}
			.line {
				margin: 20rpx 0;
				width: 100%;
				height: 1rpx;
				background: #F3F3F5;
			}
		}
		.bottom {
			width: 100%;
			z-index: 9;
			position: fixed;
			bottom: 0;
			height: 166rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 8rpx 30rpx 74rpx;
			box-shadow: 0px -1px 0px 0px #F4F4F4;
			.text_style1 {
				font-size: 20rpx;
				font-weight: 400;
				color: #444444;
			}
			.left_btn {
				width: 230rpx;
				height: 80rpx;
				background: #F1F6FF;
				border-radius: 42rpx;
				margin-left: 20rpx;
			}
			.btn_text {
				font-size: 32rpx;
				font-weight: 500;
				color: #506DFF;
				line-height: 44rpx;
				padding-left: 10rpx;
			}
			.right_btn {
				width: 270rpx;
				height: 80rpx;
				background: #506DFF;
				border-radius: 42rpx;
				margin-left: 20rpx;
				.btn_icon {
					width: 40rpx;
					height: 40rpx;
				}
				.btn_text2 {
					font-size: 32rpx;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 44rpx;
					padding-left: 10rpx;
				}
			}
			.bottom_img {
				width: 40rpx;
				height: 40rpx;
			}
			
		}
		.share_content {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			width: 100vw;
			height: 100vh;
			background: rgba(0,0,0,0.5);
			backdrop-filter: blur(5px);
			padding: 0 0 0;
			.pos_img {
				width: 112rpx;
				height: 112rpx;
				margin: 0 12rpx 0 0;
			}
			.pos_title {
				font-size: 32rpx;
				font-weight: 500;
				color: #222222;
				line-height: 44rpx;
				margin: 0 0 0 0;
			}
			.pos_subtitle {
				font-size: 32rpx;
				font-weight: 400;
				color: #506DFF;
				line-height: 40rpx;
				margin: 24rpx 0 0;
			}
			.pos_title2 {
				font-size: 28rpx;
				font-weight: 500;
				color: #222222;
				line-height: 40rpx;
				margin: 36rpx 0 28rpx;
			}
			.label {
				width: 148rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #444444;
				line-height: 34rpx;
				margin: 0 0 20rpx;
			}
			.text {
				font-size: 24rpx;
				font-weight: 400;
				color: #222;
				line-height: 34rpx;
				margin: 0 0 20rpx;
			}
			.share_box {
				margin: 130rpx auto 0;
				width: 650rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				box-sizing: border-box;
				padding: 48rpx 40rpx 0;
				.head_img {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}
				.title {
					font-size: 36rpx;
					font-weight: 500;
					color: #222222;
					line-height: 50rpx;
				}
				.subtitle{
					font-size: 24rpx;
					font-weight: 400;
					color: #888888;
					line-height: 34rpx;
				}
				.share_name {
					width: 100%;
					font-size: 32rpx;
					font-weight: 500;
					color: #222222;
					line-height: 44rpx;
				}
				.share_label {
					width: 100%;
					font-size: 28rpx;
					font-weight: 400;
					color: #222222;
					line-height: 40rpx;
				}
				.share_text {
					width: 100%;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;
					line-height: 34rpx;
					text-overflow: ellipsis;
					overflow: hidden;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					box-orient: vertical;
					line-clamp: 5;
					-webkit-line-clamp: 5;
				}
				.box_bottom {
					width: 100%;
					padding: 34rpx 0 16rpx;
					border-top: 1rpx dashed #C3C3C3;
					
					.bottom_left1 {
						font-size: 32rpx;
						font-weight: 500;
						color: #222222;
						line-height: 44rpx;
						padding-bottom: 20rpx;
						
					}
					.bottom_left2 {
						font-size: 22rpx;
						font-weight: 400;
						color: #999999;
						line-height: 32rpx;
					}
					.bottom_right {
						width: 136rpx;
						height: 136rpx;
					}
				}
			}
			.canvas {
				position: absolute;
				top: 188rpx;
				left: 50rpx;
				width: 650rpx;
				min-height: 494rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
			}
			.share_bottom {
				position: fixed;
				bottom: 0;
				width: 100%;
				height: 388rpx;
				background: #F5F7FF;
				border-radius: 40rpx 40rpx 0px 0px;
				.bottom_item {
					width: 33%;
					margin: 50rpx 0 90rpx;
					border: none !important;
					background-color: #F5F7FF !important;
					
					
					.item_icon {
						width: 76rpx;
						height: 76rpx;
					}
					.item_text {
						font-size: 26rpx;
						font-weight: 400;
						color: #333333;
						line-height: 36rpx;
						margin-top: 12rpx;
					}
				}
				button::after {
					border: none !important;
				}
				.share_cancel {
					width: 100%;
					text-align: center;
					font-size: 32rpx;
					font-weight: 400;
					color: #333333;
					line-height: 44rpx;
				}
			}
		}
		.share_content1 {
			z-index: -99 !important;
		}
	}
</style>