<template>
	<view class="renYuanDetail-container">
		<view class="renYuanDetail-top" :style="{ paddingTop: safeAreaInsets.top + 'px' }">
			<view class="top-icon">
				<u-icon @click="goBack" name="arrow-left" color="#FFF" size="18"></u-icon>
			</view>
			<image class="top-user-pic"
				:src="teamPersonInfo.pic != null ? teamPersonInfo.pic : '../../../../static/mine/kehu.png'"
				mode="scaleToFill" />
			<view class="top-user-name">{{ teamPersonInfo.crewName }}</view>
			<view class="top-user-info">
				<image src="../../../../static/images/polling/sex0.png" mode="scaleToFill" />
				<view>{{ sex }}</view>
			</view>
		</view>
		<view class="user-info-box">
			<text class="info-box-title">人员信息</text>
			<view class="info-box-view">
				<view class="info-box-view-left">组织名称</view>
				<view class="info-box-view-right">{{ teamPersonInfo.teamName }}</view>
			</view>
			<u-line></u-line>
			<view class="info-box-view">
				<view class="info-box-view-left">所在部门</view>
				<view class="info-box-view-right">{{ teamPersonInfo.unitName }}</view>
			</view>
			<u-line></u-line>
			<view class="info-box-view">
				<view class="info-box-view-left">专业名称</view>
				<view class="info-box-view-right">测试</view>
			</view>
			<u-line></u-line>
			<view class="info-box-view">
				<view class="info-box-view-left">职位名称</view>
				<view class="info-box-view-right">{{ setDict(teamPersonInfo.teamRole) }}</view>
			</view>
			<u-line></u-line>
			<view class="info-box-view">
				<view class="info-box-view-left">联系方式</view>
				<view class="info-box-view-right" style="color: #00edd0">{{ teamPersonInfo.phone }}</view>
			</view>
			<u-line></u-line>
		</view>
	</view>
</template>

<script>
	import {
		getEmergencycrew
	} from '@/api/indexpage/emergencycrew/index.js';
	import {
		getDicts
	} from '@/api/indexpage/user.js';
	export default {
		data() {
			return {
				ssid: '',
				teamPersonInfo: {},
				safeAreaInsets: 0,
				specialStatusList: []
			};
		},
		onLoad(options) {
			this.safeAreaInsets = uni.getSystemInfoSync().safeAreaInsets.top;
			this.ssid = options.ssId;
			this.getEmergencycrewInfo();
			this.getDicts();
		},
		computed: {
			sex() {
				if (this.teamPersonInfo.sex == '0') {
					return '男';
				} else {
					return '女';
				}
			}
		},
		methods: {
			// 查找字典值
			setDict(stauts) {
				for (let item of this.specialStatusList) {
					if (item.value === stauts) {
						return item.text;
					}
				}
			},
			// 获取字典数据
			getDicts() {
				getDicts('team_role').then(res => {
					let middleData = res.data;
					let a = [];
					middleData.map(item => {
						a.push({
							value: item.dictValue,
							text: item.dictLabel
						});
					});
					this.specialStatusList = a;
				});
			},
			goBack() {
				//携带设备id
				this.$tab.navigateBack(`/pages/indexpage/expert/expert`);
			},
			async getEmergencycrewInfo() {
				let result = await getEmergencycrew(this.ssid);
				if (result.code == 200) {
					this.teamPersonInfo = result.data;
				}
			}
		}
	};
</script>

<style lang="scss" scoped>
	.renYuanDetail-container {
		height: 100vh;
		display: flex;
		flex-direction: column;
		font-family: Noto Sans S Chinese;

		.renYuanDetail-top {
			box-sizing: border-box;
			width: 100%;
			height: 640rpx;
			background-repeat: no-repeat;
			background-size: cover;
			position: relative;
			background-image: url(../../../../static/images/polling/bgRenYuanDetail.png);
			overflow: hidden;

			.top-icon {
				width: 100%;
				box-sizing: border-box;
				width: calc(100% - 60rpx);
				margin: 0 auto;
				height: 30rpx;
				display: flex;
				margin-top: 92rpx;
				justify-content: space-between;

				.arrow-left-r {
					transform: rotate(90deg);
				}
			}

			.top-user-pic {
				margin-left: 292rpx;
				margin-top: 82rpx;
				width: 160rpx;
				height: 160rpx;
				border-radius: 5px;
				border: 2px solid #ffffff;
				background: #000000;

				.top-user-pic {
					width: 100%;
					height: 100%;
					object-fit: cover;
				}
			}

			.top-user-name {
				width: 100%;
				margin-top: 60rpx;
				text-align: center;
				font-family: PingFang;
				font-weight: bold;
				font-size: 24px;
				color: #ffffff;
			}

			.top-user-info {
				margin: 0 auto;
				margin-top: 48rpx;
				width: 112rpx;
				height: 48rpx;
				border-radius: 12px;
				display: flex;
				align-items: center;
				justify-content: center;
				border: 1px solid #ffffff;
				color: #ffffff;
				font-family: PingFang;
				font-weight: 500;
				font-size: 12px;
				color: #ffffff;

				& image {
					width: 24rpx;
					height: 24rpx;
					margin-right: 16rpx;
				}
			}
		}

		.user-info-box {
			flex: 1;

			box-sizing: border-box;
			padding: 42rpx 28rpx 0 28rpx;

			.info-box-title {
				width: 51px;
				height: 13px;
				font-weight: 400;
				font-size: 13px;
				color: #888888;
				margin-bottom: 26rpx;
			}

			.info-box-view {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 690rpx;
				height: 92rpx;

				.info-box-view-left {
					font-weight: 500;
					font-size: 16px;
					color: #333333;
				}

				.info-box-view-right {
					width: 300rpx;
					font-weight: 400;
					font-size: 14px;
					color: #aaaaaa;
					margin-bottom: 4rpx;
					text-align: end;
					overflow: hidden;
					text-overflow: ellipsis; // 文本溢出添加省略号
					white-space: nowrap; // 碰到有边界不要折行
				}
			}
		}
	}
</style>