<template>
	<view class="content">
		<view class="box" v-if="base_info.name == ''">
			<view class="box_title">基本信息</view>
			<view class="hflex acenter jbetween box_info">
				<view class="hflex acenter">
					<image src="/static/images/index/demand/icon1.png" class="box_icon"></image>
					<view class="vflex">
						<view class="box_title">完善个人信息</view>
						<view class="box_subTitle">让更多人更好的了解你</view>
					</view>
				</view>
				<view class="box_btn" @click="perfect(1)">完善</view>
			</view>
		</view>
		<view class="box hflex jbetween" v-else>
			<view class="">
				<view class="hflex acenter">
					<view class="name">{{base_info.name}}</view>
					<view class="edit_btn" @click="perfect(1)">编辑</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}}</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" class="avatar"></image>
		</view>
		<view class="box" v-if="job_inte.job_name == ''">
			<view class="box_title">求职意向</view>
			<view class="hflex acenter jbetween box_info">
				<view class="hflex acenter">
					<image src="/static/images/index/demand/icon1.png" class="box_icon"></image>
					<view class="vflex">
						<view class="box_title">完善求职意向</view>
						<view class="box_subTitle">我们会更精准的为你推荐</view>
					</view>
				</view>
				<view class="box_btn" @click="perfect(2)">完善</view>
			</view>
		</view>
		<view class="box" v-else>
			<view class="hflex acenter jbetween">
				<view class="box_title">求职意向</view>
				<view class="edit_btn" @click="perfect(2)">编辑</view>
			</view>
			<view class="hflex acenter padT-26">
				<view class="box_title">{{job_inte.job_name}}</view>
				<view class="box_title">{{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" v-if="experience.length == 0">
			<view class="box_title">工作经历</view>
			<view class="hflex acenter jbetween box_info">
				<view class="hflex acenter">
					<image src="/static/images/index/demand/icon1.png" class="box_icon"></image>
					<view class="vflex">
						<view class="box_title">完善工作经历</view>
						<view class="box_subTitle">我们会跟精准的为你推荐</view>
					</view>
				</view>
				<view class="box_btn" @click="perfect(3)">完善</view>
			</view>
		</view>
		<view class="box" v-else>
			<view class="hflex acenter jbetween">
				<view class="box_title">工作经历</view>
				<view class="hflex acenter" @click="perfect(3)">
					<u-icon name="plus-circle-fill" color="#555555" size="12"></u-icon>
					<view class="text_style1">添加</view>
				</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.company_name}}</view>
						<u-icon name="arrow-right" color="#555555" size="12"></u-icon>
					</view>
					<view class="hflex acenter padT-26">
						<view class="text_style1 padR-24">{{item.company_date}}</view>
						<view class="text_style1">{{item.company_postion}}</view>
					</view>
					<view class="hflex fwrap padT-26 text_style2">工作内容：{{item.company_content}}</view>
				</view>
			</block>
		</view>
		<view class="box" v-if="skills.length == 0">
			<view class="box_title">专业技能</view>
			<view class="hflex acenter jbetween box_info">
				<view class="hflex acenter">
					<image src="/static/images/index/demand/icon1.png" class="box_icon"></image>
					<view class="vflex">
						<view class="box_title">添加专业技能</view>
						<view class="box_subTitle">把你的强项展示一下吧</view>
					</view>
				</view>
				<view class="box_btn" @click="perfect(4)">添加</view>
			</view>
		</view>
		<view class="box" v-else>
			<view class="hflex acenter jbetween">
				<view class="box_title">专业技能</view>
				<view class="hflex acenter" @click="perfect(4)">
					<u-icon name="plus-circle-fill" color="#555555" size="12"></u-icon>
					<view class="text_style1">添加</view>
				</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.skills_name}}</view>
						<view class="text_style1">{{item.skills_degree}}</view>
						<image src="/static/images/index/demand/detele.png" class="detele" @click="delSkill(item.id)"></image>
					</view>
				</block>
			</view>
		</view>
		<view class="box" v-if="certificate.length == 0">
			<view class="box_title">资质证书</view>
			<view class="hflex acenter jbetween box_info">
				<view class="hflex acenter">
					<image src="/static/images/index/demand/icon1.png" class="box_icon"></image>
					<view class="vflex">
						<view class="box_title">添加资质证书</view>
						<view class="box_subTitle">把你的强项展示一下吧</view>
					</view>
				</view>
				<view class="box_btn" @click="perfect(5)">添加</view>
			</view>
		</view>
		<view class="box" v-else>
			<view class="hflex acenter jbetween">
				<view class="box_title">资质证书</view>
				<view class="hflex acenter" @click="perfect(5)">
					<u-icon name="plus-circle-fill" color="#555555" size="12"></u-icon>
					<view class="text_style1">添加</view>
				</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.certificate_name}}</view>
						<view class="text_style1">{{item.certificate_date}}</view>
						<image src="/static/images/index/demand/detele.png" class="detele" @click="delSkill(item.id)"></image>
					</view>
				</block>
			</view>
		</view>
		<view class="box" style="margin-bottom: 186rpx;">
			<view class="box_title" style="padding-bottom: 16rpx;">福利待遇</view>
			<u-input v-model="salary" placeholder="请填写你期望的薪资待遇" border="none"></u-input>
			<view class="line"></view>
			<view class="box_title" style="padding-bottom: 16rpx;">备注</view>
			<u-input v-model="remarks" placeholder="请填写你想要备注的内容" border="none"></u-input>
		</view>
		<view class="bottom">
			<view class="bottom_btn" :class="is_publish?'publish_btn':''" @click="open">发布</view>
		</view>
		<u-popup :show="show" mode="bottom" :round="20" @close="close">
			<view class="popup">
				<view class="popup_title vflex acenter jcenter">本人承诺</br>以上所填写的内容真实有效</view>
				<view class="popu_label" style="font-size: 28rpx;font-weight: 500;">请填写以下信息</view>
				<view class="popu_label">身份证号</view>
				<u-input v-model="IDNumber" placeholder="请输入身份证号" border="bottom"></u-input>
				<view class="popu_label">手机号码</view>
				<u-input v-model="phone" placeholder="请输入手机号码" border="bottom"></u-input>
				<view class="popu_label">验证码</view>
				<view class="hflex acenter jbetween">
					<u-input v-model="code" placeholder="请输入验证码" border="none"></u-input>
					<view class="popu_label code" @click="getCode">{{tips}}</view>
					<u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-code>
				</view>
				<view class="btn1" @click="publish">立即发布</view>
				<view class="cancel" @click="close">取消</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				is_publish: false,
				salary: '',
				remarks: '',
				base_info: {
					name: '张三',
					avatar: '/static/images/mine/avatar1.jpg',
					sex: '男',
					edu: '本科',
					age: '27',
					year: '5年',
					phone: '18923465789',
					email: '18923465789@qq.com',
				},
				job_inte: {
					job_name: '船舶工程设计师',
					salary: '11-19k',
					job_area: '江苏省南京市浦口区江北街道东方万汇城22号楼一单元2021',
					job_time: '两个月',
					job_type: '全职'
				},
				experience: [
					{
						company_name: '上海船舶技术工程有限公司',
						company_date: '2019.07-2022.02',
						company_postion: '船舶工程设计师',
						company_content: '1，负责线上平台app/小程序页面更新设计，2，负责活动H5页面，banner设计3，负责外包项目设计；4，制定工作计划'
					},
					{
						company_name: '上海船舶技术工程有限公司',
						company_date: '2019.07-2022.02',
						company_postion: '船舶工程设计师',
						company_content: '1，负责线上平台app/小程序页面更新设计，2，负责活动H5页面，banner设计3，负责外包项目设计；4，制定工作计划'
					}
				],
				skills: [
					{
						skills_name: 'Access',
						skills_degree: '熟练'
					},
					{
						skills_name: 'Access',
						skills_degree: '精通'
					}
				],
				certificate: [
					{
						certificate_name: '普通话等级证书',
						certificate_date: '2012-06-12'
					},
					{
						certificate_name: '大学英语四级证书',
						certificate_date: '2012-06-12'
					}
				],
				show: false,
				IDNumber: '',
				phone: '',
				code: '',
				tips: '',
				seconds: 60,
				del_show: false,
				id: '',
				
			}
		},
		onLoad() {
			that = this
		},
		onShow() {
			that.isPubilsh()
		},
		methods: {
			// 判断是否可以发布
			isPubilsh() {
				if (that.base_info.name != '' && that.job_inte.job_name != '') {
					that.is_publish = true
				}
			},
			// 发布
			publish() {
				if($api.formCheck(that.IDNumber, 'identity') && $api.formCheck(that.phone, 'mobile') && $api.formCheck(that.code, 'code6')) {
					$api.info('发布成功')
					that.close()
				}
			},
			// 打开弹窗
			open() {
				if (that.is_publish) {
					that.show = true
				}
			},
			// 关闭弹窗
			close() {
				that.show = false
			},
			// 添加或完善
			perfect(index) {
				$api.jump('/page_index/pages/demand/perfect?index='+index)
			},
			// 修改工作经历
			editInfo(id) {
				$api.jump('/page_index/pages/demand/perfect?index=3&id='+ id)
			},
			// 复制
			copy(value) {
				uni.setClipboardData({
					data: value,
					success: function () {
						$api.info('复制成功')
					}
				});
			},
			// 删除
			delete(id) {
				that.del_show = true
				that.id = id
			},
			// 确定删除
			deleSkill() {
				
			},
			// 验证码文字改变
			codeChange(text) {
				this.tips = text;
			},
			getCode() {
				if(this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码'
					})
					setTimeout(() => {
						uni.hideLoading();
						// 这里此提示会被this.start()方法中的提示覆盖
						uni.$u.toast('验证码已发送');
						// 通知验证码组件内部开始倒计时
						this.$refs.uCode.start();
					}, 2000);
				} else {
					uni.$u.toast('倒计时结束后再发送');
				}
			},
			end() {
				uni.$u.toast('倒计时结束');
			},
			start() {
				uni.$u.toast('倒计时开始');
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content::v-deep {
		background: #F4F4F4;
		.box {
			margin: 20rpx 30rpx 0;
			width: 690rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			box-sizing: border-box;
			padding: 28rpx 20rpx;
			.box_title {
				font-size: 32rpx;
				font-weight: 500;
				color: #222222;
			}
			.name {
				font-size: 40rpx;
				font-weight: 500;
				color: #222222;
			}
			.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: #888888;
			}
			.icon {
				width: 28rpx;
				height: 28rpx;
			}
			.text_style1 {
				font-size: 24rpx;
				padding-left: 5rpx;
				font-weight: 400;
				color: #666666;
			}
			.text_style2 {
				font-size: 22rpx;
				font-weight: 400;
				color: #777777;
				line-height: 32rpx;
			}
			.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: 8rpx 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 40rpx 74rpx;
			.bottom_btn {
				width: 100%;
				height: 84rpx;
				background: #506DFF;
				border-radius: 42rpx;
				opacity: 0.4;
				font-size: 36rpx;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
				line-height: 84rpx;
			}
			.publish_btn {
				opacity: 1;
			}
			
		}
		.popup {
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 0px 0px;
			width: 100%;
			box-sizing: border-box;
			padding: 30rpx;
			.popup_title {
				width: 100%;
				padding-bottom: 32rpx;
				border-bottom: 1rpx solid #F4F4F4;
				font-size: 36rpx;
				font-weight: 500;
				color: #222222;
				line-height: 50rpx;
			}
			.popu_label {
				font-size: 30rpx;
				font-weight: 400;
				color: #222222;
				padding: 24rpx 0;
			}
			.code {
				color: #506DFF;
			}
			.btn1 {
				margin: 90rpx 0 40rpx;
				width: 100%;
				height: 84rpx;
				background: #506DFF;
				border-radius: 21px;
				text-align: center;
				line-height: 84rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #FFFFFF;
			}
			.cancel {
				width: 100%;
				text-align: center;
				font-size: 32rpx;
				font-weight: 400;
				color: #777777;
			}
			.u-input {
				padding: 12rpx 0 !important;
			}
		}
	}
</style>