<template>
	<view class="page">
		<!-- 头部 -->
		<view class="head">
			<view class="head_img">
				<image :src="baseUrl + detailData.headImg[0].url" mode="widthFix"></image>
			</view>
			<view class="info">
				<view class="top">
					<view class="item name" style="margin-top: 15rpx;">
						<span class="left">姓名：</span>
						<span class="right">{{detailData.name}}</span>
					</view>
					<view class="item name" style="margin-top: 15rpx;">
						<span class="left">姓别：</span>
						<span class="right">{{detailData.gender}}</span>
					</view>
					<view class="item name" style="margin-top: 15rpx;">
						<span class="left">年龄：</span>
						<span class="right">{{detailData.age}}</span>
					</view>
					<view class="item nation" style="margin-top: 15rpx;">
						<span class="left">民族：</span>
						<span class="right">{{detailData.nation}}</span>
						
					</view>
					<view class="item policy" style="margin-top: 15rpx;">
						<span class="left">政治面貌：</span>
						<span class="right">{{detailData.politicalOutlook}}</span>
					</view>
					<view class="item education" style="margin-top: 15rpx;">
						<span class="left">学历：</span>
						<span class="right">{{detailData.education}}</span>
					</view>
				</view>
			</view>
		</view>
		<view class="phone">
			<view class="p_lef">
				毕业院校
			</view>
			<view class="p_right">
				{{detailData.graduationInstitution}}
			</view>
		</view>
		<view class="phone">
			<view class="p_lef">
				电话号码
			</view>
			<view class="p_right">
				{{detailData.phoneNumber}}
			</view>
		</view>
		<view class="content">
			<p class="title">工作经历</p>
			<view class="detail" v-html="detailData.workExperience">

			</view>
		</view>
		<!-- <view class="buttons" v-show="isAdmin">
			<button type="primary" size="mini" @click="toUpdate(id)">修改</button>
			<button type="warn" size="mini" @click="del(id)">删除</button>
		</view> -->
	</view>
</template>

<script>
	import request from '@/utils/request.js'
	export default {
		data() {
			return {
				gender:'男',
				isAdmin:false,
				id:'',
				detailData:{},
				baseUrl: "https://www.dygxq-es.cn",
			}
		},
		onLoad(options) {
			this.getUser()
			console.log(JSON.parse(options.data))
			this.id = JSON.parse(options.data)
			this.getDetail()
		},
		methods: {
			// 获取用户信息
			getUser() {
				if (uni.getStorageSync('user')) {
					let userCode = uni.getStorageSync("user")
					console.log(userCode)
					if(userCode.userInfo.userId === 'admin'){
						this.isAdmin = true
					}
					console.log('用户已登录！')
				} 
				// else {
				// 	uni.showToast({
				// 		title: '请登录',
				// 		icon: 'none'
				// 	})
				// 	setTimeout(() => {
				// 		uni.reLaunch({
				// 			url: '/pages/login/index'
				// 		})
				// 	})
				// }
			},
			
			
			//获取详细信息
			 getDetail(){
				 let that = this
				 this.API.getRecommendInfo(this.id).then(res=>{
					 console.log(res)
					 if(res.code === 200){
						 this.detailData = res.data
					 }
				 })
			 },
			 // 跳转修改传递id
			 toUpdate(item){
				 uni.navigateTo({
				 	url:`/pages/recommend/postRecommend/postRecommend?data=${JSON.stringify(item)}`
				 })
			 },
			 // 删除
			 del(id){
				 uni.showModal({
				 	title: "提示",
				 	content: "确定删除吗？",
				 	success: (res) => {
				 		request({
				 			url: this.baseUrl + `/api/SubDev/basetalentrecommendation/${id}`,
				 			method: 'delete',
				 			data: {}
				 		}).then(res => {
				 			console.log(res)
				 			if (res.code === 200) {
				 				uni.showToast({
				 					icon: "success",
				 					title: '删除成功！'
				 				}).then(()=>{
									uni.navigateTo({
										url:'/pages/recommend/recommend'
									})
								})
				 			}
				 		})
				 	}
				 })
			 }
		}
	}
</script>

<style lang="scss" scoped>
	@import 'info.scss'
</style>
