<template>
	<view class="fullHeight">
		<headers class="" style="position: fixed; top: 0; left: 0; width: 100%; z-index: 10;" :showBack="true" :themeType="'white'">
			<view class="headerName">
				车辆档案
			</view>
		</headers>
		<view class="personDetail_content" :style="{paddingTop: (mobileTopHeight + 50) * 1.5 + 'rpx'}">
			<view class="title_wrap">
				<view class="flex" style="position: relative;">
					<view class="carModule" :style="`border-color:${pdgroundColor};color:${pdgroundColor}`">
						{{workerInfo.carModuleType == 1 ? '固定车' : workerInfo.carModuleType == 2 ? '长期车' :'临时车'}}
					</view>
					<view class="flex">
					
						<!-- <image class="photograph" @click="previewImage(workerInfo.fieldAcquisitionUrl,1)"
							:src="url_config+'image/'+workerInfo.fieldAcquisitionUrl"></image>
						<image class="photograph" @click="previewImage(workerInfo.idCardBigPhotoUrl,2)"
							:src="url_config+'image/'+workerInfo.idCardBigPhotoUrl"></image> -->
							<image class="photograph" v-for="item in (workerInfo.carPhotosUrl && JSON.parse(workerInfo.carPhotosUrl)) || []" @click="previewImage(item.url,1)"
								:src="url_config+'image/'+item.url"></image>
					</view>
					<view class="user_info">
						<view class="name">{{workerInfo.carNumber}}</view>
						<!-- <view class="code">{{workerInfo.idCard}}</view> -->
						<view class="nation">车种类型：{{workerInfo.carTypeName}}</view>
						<view class="nation">车身颜色：{{workerInfo.carColor}}</view>
						<view class="nation">预约开始时间：{{workerInfo.reserveStartTime}}</view>
						<view class="nation">预约结束时间：{{workerInfo.reserveEndTime}}</view>
					</view>
					<!-- 操作按钮 -->
					<view style="width: 60rpx;height: 120rpx; text-align: center;" v-if="false">
						<image class="more" src="../../../../static/personManage/more.png" @click="operateBtn"></image>
					</view>
				</view>
				<view class="projectName">{{workerInfo.projectName}}</view>
				<view class="details-content" v-if="codeShow">
					<view class="left-content">
						<view class="project_info">
							<text class="name">企业名称：</text>
							<text>{{workerInfo.enterpriseName}}</text>
						</view>
						<view class="project_info">
							<text class="name">司机：</text>
							<text>{{workerInfo.driverWorkerName}}</text>
						</view>
						<view class="project_info">
							<text class="name">司机电话：</text>
							<text>{{workerInfo.driverTelephone}}</text>
						</view>
						<view class="project_info">
							<text class="name">司机身份证号：</text>
							<text>{{workerInfo.outsideDriverIdCard}}</text>
						</view>
						<view class="project_info" v-if="workerInfo.carModuleType != 1">
							<text class="name">允许进出次数：</text>
							<text>{{workerInfo.entryAndExitPermit == 0 ? '单次':'多次'}}</text>
						</view>
					</view>
					<tki-qrcode ref="qrcode" :size="120" cid="1001" :val="qrUrl" :background="backgroundColor"
						:foreground="foregroundColor" :pdground="pdgroundColor" :onval="true" :loadMake="true" />
				</view>
			</view>
			<view class="item_wraps">
				<view class="item_title">
					驾驶证
				</view>
				<view class="item_wrap flex">
					<image class="item" v-for="item in (workerInfo.jsz && JSON.parse(workerInfo.jsz)) || []" @click="previewImage(item.url,1)"
						:src="url_config+'image/'+item.url"></image>
				</view>
			</view>
			<view class="item_wraps">
				<view class="item_title">
					行驶证
				</view>
				<view class="item_wrap flex">
					<image class="item" v-for="item in (workerInfo.xsz && JSON.parse(workerInfo.xsz)) || []" @click="previewImage(item.url,1)"
						:src="url_config+'image/'+item.url"></image>
				</view>
			</view>
			<view class="item_wraps">
				<view class="item_title">
					交强险
				</view>
				<view class="item_wrap flex">
					<image class="item" v-for="item in (workerInfo.jqx && JSON.parse(workerInfo.jqx)) || []" @click="previewImage(item.url,1)"
						:src="url_config+'image/'+item.url"></image>
				</view>
			</view>
			<view class="item_wraps">
				<view class="item_title">
					其它证明
				</view>
				<view class="item_wrap flex">
					<image class="item" v-for="item in (workerInfo.otherProve && JSON.parse(workerInfo.otherProve)) || []" @click="previewImage(item.url,1)"
						:src="url_config+'image/'+item.url"></image>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	export default {
		components: {
			tkiQrcode,
		},
		data() {
			return {
				mobileTopHeight: 0,
				codeShow: false,
				backgroundColor: '#fff',
				foregroundColor: '#000',
				pdgroundColor: '#000',
				qrUrl: '此二维码仅供展示',
				workerId: 0,
				operateType: false,
				workerInfo: {}, //基本信息
				certificateList: [], //资格证书
				workExperienceList: [], //从业信息
				reduceScoreList: [], // 扣分记录
				badList: [], //不良记录
				rewardList: [], //--奖励记录
				contractList: [], //合同列表
				physicalsList: [], //体检列表
				safeEducationList: [], //安全教育信息
				monthAttendance: [],
				insuranceList: [],

				showReduceScoreList: false,
				showBadList: false,
				showRewardList: false,
				showWorkExperienceList: false,
				showCertificateList: false,

			}
		},
		onLoad(options) {
			console.log('22222222222', options.id)
			this.workerId = options.id;
			// this.getDetailsData();
		},
		onShow() {
			this.getDetailsData();
		},
		mounted() {
			var that = this
			uni.getSystemInfo({
				success(res) {
					that.mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : 0;
					uni.setStorageSync('systemInfo',res)
					console.log(res)
				}
			})
			console.log('this.mobileTopHeight',this.mobileTopHeight)
		},
		methods: {
			setCodeColor(fenshu) {
				console.log(fenshu)
				if (fenshu == 0) {
					this.foregroundColor = "green";
					this.pdgroundColor = "green";
				} else if (fenshu == 1) {
					// this.fontColor = "red";
					this.foregroundColor = "#F0212A";
					this.pdgroundColor = "#F0212A";
				}
				this.codeShow = true;
			},
			
			//获取详情数据
			getDetailsData() {
				this.sendRequest({
					url: 'xmgl/carInfo/queryById',
					method: 'post',
					data: {
						projectSn:JSON.parse(uni.getStorageSync('userInfo')).sn,
						id: this.workerId,
					},
					success: res => {
						if (res.code == 200) {
							console.log("333333333333333",res)
							this.workerInfo = res.result;
							this.setCodeColor(this.workerInfo.isBlack)
						}
					}
				})
			},
			//预览图片
			previewImage(url, type) {
				let fileList = [];
				if (type == 1 || type == 2) {
					fileList = [this.url_config + 'image/' + url]
				}
				uni.previewImage({
					current: 0,
					urls: fileList
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.fullHeight{
		// height: 100%;
		// background-color: #f6f6f6;
		// min-height: 100%;
		.fixedheader{
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 2;
			.headerName{
				z-index: 1;
			}
		}
	}
	
	.carModule {
		font-size: 28rpx;
		padding: 0 12rpx;
		border: 2rpx solid;
		position: absolute;
		top: 0;
		right: 0;
		border-radius: 8rpx;
	}
	
	.flex {
		display: flex;
		align-items: center;
	}

	.flex2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.flex3 {
		display: flex;
	}

	.personDetail_content {
		padding: 30rpx 30rpx;
		box-sizing: border-box;
		width: 100%;
	}

	.personDetail_content .title_wrap {
		width: 100%;
		box-shadow: 0 4px 26rpx 0 rgba(212, 220, 236, 0.67);
		box-sizing: border-box;
		padding: 40rpx 28rpx 20rpx;
		border-radius: 16rpx;
		position: relative;
	}

	.header_bg {
		position: absolute;
		top: 0;
		right: 0;
		z-index: 1;
		width: 568rpx;
		height: 90rpx;
	}

	.photograph {
		width: 116rpx;
		height: 150rpx;
		z-index: 5;
		margin-right: 16rpx;
	}

	.more {
		width: 47rpx;
		height: 37rpx;
		z-index: 2222;
	}

	.more:active {
		background-color: #999;
	}

	.user_info {
		margin-left: 4rpx;
		width: 70%;
	}

	.user_info .name {
		font-size: 34rpx;
		line-height: 48rpx;
		font-weight: 500;
		color: #488DEC;

	}

	.user_info .code {
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #2A2B5B;
		line-height: 37rpx;
		margin: 10rpx 0;
		opacity: 0.8;
	}

	.user_info .nation {
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #2A2B5B;
		line-height: 37rpx;
		opacity: 0.8;
		margin-bottom: 4px;
	}

	.projectName {
		font-size: 30rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 700;
		color: #2A2B5B;
		line-height: 42rpx;
		margin-top: 30rpx;
	}

	.details-content {
		display: flex;
		align-items: center;
		justify-content: space-between;
		.left-content {
			flex: 1;
		}
	}

	.project_info {
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #2A2B5B;
		line-height: 52rpx;
	}

	.project_info .name {
		color: #372D66;
		opacity: 0.6;
	}

	.item_wraps {
		width: 100%;
		margin: 20rpx 0;
		box-shadow: 0 8rpx 26rpx 0 rgba(212, 220, 236, 0.67);
		padding: 20rpx 20rpx 20rpx 20rpx;
		box-sizing: border-box;
		border-radius: 16rpx;
	}
	
	.item_wraps .item_title {
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 700;
		color: #2A2B5B;
	}

	.item_wrap {
		width: 100%;
		flex-wrap: wrap;
		/* justify-content: space-between; */
	}

	.item_wrap .item {
		width: 32%;
		font-size: 30rpx;
		height: 121rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #372D66;
		line-height: 84rpx;
		position: relative;
		margin-top: 14rpx;
		margin-left: 8rpx;
	}

	.item_wrap .item .state1 {
		position: absolute;
		top: 0;
		left: 58px;
		padding: 3px 6px;
		font-size: 20rpx;
		background: #4181FE;
		color: #fff;
		line-height: 28rpx;
		border-radius: 6rpx;
	}

	.item_wrap .item .state2 {
		position: absolute;
		top: 0;
		left: 58px;
		padding: 3px 6px;
		font-size: 20rpx;
		background: red;
		color: #fff;
		line-height: 28rpx;
		border-radius: 6rpx;
	}



	.margin_r_5 {
		margin-right: 10rpx;
	}

	.log_wrap {
		width: 100%;
		margin: 20rpx 0;
		box-shadow: 0 4px 26rpx 0 rgba(212, 220, 236, 0.67);
		padding: 24rpx 28rpx;
		box-sizing: border-box;
		border-radius: 16rpx;
	}

	.log_wrap .title {
		font-size: 30rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 700;
		color: #2A2B5B;
		line-height: 42rpx;
	}

	.log_wrap .log_content {
		margin-top: 16rpx;
		border-top: 1px solid #C8C7CC;
		box-sizing: border-box;
		padding-top: 16rpx;
	}

	.log_wrap .log_content_item {
		background-color: #f1f7fe;
		border-radius: 4rpx;
		border: 1px dashed #888888;
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #2A2B5B;
		line-height: 40rpx;
		box-sizing: border-box;
		padding: 20rpx 28rpx;
		margin-bottom: 16rpx;
	}

	.title_dialog {
		position: absolute;
		top: 40rpx;
		right: 46px;
		font-size: 24rpx;
		line-height: 48rpx;
		background-color: #fff;
		width: 65px;
		text-align: center;
		z-index: 999;
		border: 1px solid #999;
		padding: 3px 16rpx;
		border-radius: 4rpx;
	}
</style>