<template>
	<view>
		<view class="contentListBoxs">
			<uni-swipe-action>
				<uni-swipe-action-item v-for="(item, index) in pageInfo" :key="index">
					<view class="listbIXS" @click="editJL(item.resumeId)">
						<view class="headTitls">{{item.resumeName}}</view>
						<view class="dis_fs">
							<view class="left_imgbox"><image style="width: 100%;height: 100%;" :src="userInfo.oneInchPhotos === null ? '@/static/avatar1.png': $method.splitImgHost(userInfo.oneInchPhotos)" mode="aspectFit"></image></view>
							<view class="rightCon">
								<view class="tithead">{{item.realname}}</view>
								<view class="tyList">年龄：{{item.userBirth === null ? '':item.userBirth + '岁'}}</view>
								<view class="tyList">学历：{{item.eduLevel}}</view>
								<view class="tyList">电话：{{item.telphone}}</view>
								<view class="tyList">应聘岗位：{{item.job}}</view>
							</view>
						</view>
					</view>
					<template v-slot:right>
						<view class="bigboxsRight">
							<view class="boxslist"><image style="width: 100%;height: 100%;" src="@/static/del@3x.png" mode="" @click="delList(item)"></image></view>
						</view>
					</template>
				</uni-swipe-action-item>
			</uni-swipe-action>
		<view class="fotBtns" @click.stop="addJL">新建简历</view>
		</view>
		</view>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
	data() {
		return {
			pageInfo:{}
		};
	},
	onShow() {
		this.init()
	},
	computed: { ...mapGetters(['userInfo']) },
	methods: {
		init(){
			var self = this
			this.$api.recruitresumelist().then(res => {
				if(res.data.code === 200){
					res.data.rows.forEach((item,index) => {
						if(item.userBirth){
						item.userBirth = self.getYears(item.userBirth.slice(0,item.userBirth.indexOf("T")))
						}
					})
					this.pageInfo = res.data.rows
				}
			})
		},
		delList(item){
			var self = this
			uni.showModal({
				title: '提示',
				content:'是否删除该简历',
				success:function(res){
					if(res.confirm){
						var data = {
							resumeId: item.resumeId,
							status: -1
						}
						self.$api.editrecruitresume(data).then(result => {
							if(result.data.code === 200){
								uni.showToast({
									title: '删除成功'
								})
								self.init()
							}else{
								uni.showToast({
									title: '删除失败'
								})
							}
						})
					}
				}
			})
		},
		editJL(v){
			this.$navTo.togo('/pages2/resume/addResume', {
				id: v
			});
		},
		addJL() {
			console.log(this.userInfo,66)
			if (this.userInfo.oneInchPhotos ==null||this.userInfo.oneInchPhotos ==undefined) {
				uni.showModal({
					title: '提示',
					content: '请先上传一寸照片',
					success: function(res) {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages2/wd/info'
							});
						} else if (res.cancel) {
						}
					}
				});
				return;
			}
			this.$navTo.togo('/pages2/resume/addResume', {});
		},
		getYears(strBirthday) {
			if (strBirthday === undefined) {
				return '-';
			}
			var returnAge;
			var strBirthdayArr = strBirthday.split('-');
			var birthYear = strBirthdayArr[0];
			var birthMonth = strBirthdayArr[1];
			var birthDay = strBirthdayArr[2];
			var d = new Date();
			var nowYear = d.getFullYear();
			var nowMonth = d.getMonth() + 1;
			var nowDay = d.getDate();
		
			if (nowYear == birthYear) {
				returnAge = 0; //同年 则为0岁
			} else {
				var ageDiff = nowYear - birthYear; //年之差
				if (ageDiff > 0) {
					if (nowMonth == birthMonth) {
						var dayDiff = nowDay - birthDay; //日之差
						if (dayDiff < 0) {
							returnAge = ageDiff - 1;
						} else {
							returnAge = ageDiff;
						}
					} else {
						var monthDiff = nowMonth - birthMonth; //月之差
						if (monthDiff < 0) {
							returnAge = ageDiff - 1;
						} else {
							returnAge = ageDiff;
						}
					}
				} else {
					returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
				}
			}
			return returnAge; //返回周岁年龄
		}
	}
};
</script>

<style scoped>
.topBoxsz {
	margin: 32rpx auto;
	width: 536rpx;
	height: 56rpx;
}
.listbIXS {
	margin: 12rpx 35rpx 12rpx;
	border-radius: 32rpx;
	background-color: #fff;
	box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
	padding: 25rpx 24rpx 21rpx;
}
.contentListBoxs {
	margin-bottom: 95rpx;
}
.bigboxsRight {
	width: 99rpx;
	display: flex;
	align-items: center;
}
.boxslist {
	width: 64rpx;
	height: 64rpx;
	border-radius: 50%;
	overflow: hidden;
}
.headTitls {
	font-size: 30rpx;
	color: #333;
	font-weight: 800;
	margin-bottom: 24rpx;
}
.dis_fs {
	display: flex;
}
.dis_fy{
	display: flex;
	align-items: center;
}
.left_imgbox {
	width: 170rpx;
	height: 240rpx;
	margin-right: 25rpx;
	overflow: hidden;
	border-radius: 16rpx;
}
.rightCon {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}
.tithead {
	color: #2a4174;
	font-weight: bold;
	font-size: 30rpx;
}
.tyList {
	font-size: 26rpx;
	color: #32467b;
	font-weight: bold;
}
.fotBtns {
	width: 200rpx;
	height: 64rpx;
	line-height: 64rpx;
	border-radius: 32rpx;
	background-color: #32467b;
	box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.15);
	position: fixed;
	bottom: 15rpx;
	color: #fff;
	left: 50%;
	text-align: center;
	transform: translateX(-50%);
}
.imgICon{
	width:70rpx;
	height: 86rpx;
	margin-right: 24rpx;
}
.headerInfos{
	font-size: 30rpx;
	font-weight: bold;
	color: #2a4174;
}
.pris{
	text-align: center;
	margin: 50rpx auto;
	font-size: 24rpx;
	color: #999;
	font-weight: 500;
}
</style>
