<template>
	<view class="container">
		<view class="back-btn" @click="backToBefore()">
			<u-icon name="arrow-left" color="#fff" size="20" customStyle="margin:0 auto"></u-icon>

			<text class="back-text">业务负责人信息</text>
		</view>

		<view class="base-info">
			<view class="info-item" v-for="item in businessPersonInfo">
				<view class="info-item-description">{{item.description}}</view>
				<view class="info-item-name" :class="item.type?item.type:''">{{item.value}}
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'

	import {
		onLoad
	} from "@dcloudio/uni-app"

	import {
		getEnterpriseInfoDetail,
	} from "@/api/work/enterpriseInfo.js"

	function backToBefore() {
		uni.navigateBack({})
	};

	let businessPersonInfo = ref([{
		description: '姓名',
		key: "nameJur2",
		value: ''
	}, {
		description: '性别',
		key: "sex2",
		value: ""
	}, {
		description: '电话',
		key: "tel2",
		value: '',
		type: 'number'
	}, {
		description: '移动电话',
		key: "simCode2",
		value: '',
		type: 'number'
	}, {
		description: '传真',
		key: "faxCode2",
		value: '',
		type: 'number'
	}, {
		description: '电子邮箱',
		key: "email2",
		value: '',
		type: 'email'
	}, {
		description: '护照号码',
		key: "passport2",
		value: '',
		type: 'passport'
	}])

	function filterData(obj) {
		for (let i in businessPersonInfo.value) {
			businessPersonInfo.value[i].value =
				(obj[businessPersonInfo.value[i].key] != null) ? obj[businessPersonInfo.value[i].key] : "--"
		}
	}

	onLoad((option) => {
		getEnterpriseInfoDetail({
			id: option.id
		}).then(res => {
			filterData(res.data.junitInfo)
		})
	})
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
		background-color: #EAF0FA;
	}

	.container {
		position: relative;
		width: 100%;
		height: 100%;
		background: linear-gradient(180deg, #1869F6 0%, #EAF0FA 64%, #EAF0FA 100%);

		.back-btn {
			position: absolute;
			top: 8%;
			left: 4%;
			display: flex;
			font-size: 40rpx;
			font-weight: 500;
			color: #FFF;

			.back-text {
				margin-left: 28rpx;
			}
		}
	}

	.base-info {
		position: absolute;
		left: 4%;
		top: 14%;
		width: 92%;
		height: 584rpx;
		padding: 10rpx 40rpx;
		border-radius: 40rpx;
		box-sizing: border-box;
		background-color: #fff;

		.info-item {
			display: flex;
			justify-content: space-between;
			width: 100%;
			height: 80rpx;

			.info-item-description {
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 32rpx;
				color: #9E9E9E;
			}

			.info-item-name {
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 32rpx;
				color: #343437;
			}

			.number {
				color: #1869F6;
			}

			.email {
				color: #FF530F;
			}

			.passport {
				color: #09B200;
			}
		}
	}
</style>