<template>
	<view class="resume-container">
		<view class="server-info">
			<view class="worker">
				<view class="name">
					{{workerInfo.workerName}}
				</view>
				<view class="info">
					<view class="age">
						{{workerInfo.age}}岁
					</view>
					<view class="worker-years">
						{{workerInfo.workingYears}}年服务经验
					</view>
					<view class="address">
						{{workerInfo.cityName}}
					</view>
				</view>
				<view class="introduce">
					{{workerInfo.introduce}}
				</view>
			</view>

		</view>
		<view class="zz-info">

		</view>
		<view class="huawang-info">

			<view class="img" @tap="previewImage">
				<image :src="workerInfo.certificateFileUrl" mode=""></image>

			</view>

		</view>

	</view>
</template>

<script>
	const api = require('@/config/api.js');
	var util = require('../../../utils/util.js');
	export default {
		data() {
			return {
				servantId: '',
				workerInfo: {
					workerName: '',
					workerYears: '',
					introduce: '',
					age: '',
					certificateFileUrl: '',
					cityName: ''
				},

			}
		},
		onLoad(options) {
			if (options.scene) {
				let scene = decodeURIComponent(options.scene);
				if (scene) {
					var servantId = scene.split(',')[1];
					this.setData({
						servantId: servantId
					})
				}
			}
			if (options.servantId) {
				console.log("options", options);
				this.setData({
					servantId: options.servantId
				})
			}

			this.getData()
		},
		onShow() {
			// this.getData()
		},
		methods: {
			// 预览图片单张
			previewImage() {
				console.log('photoImg', this.workerInfo.certificateFileUrl)
				let imgsArray = [];
				imgsArray[0] = this.workerInfo.certificateFileUrl;
				console.log('imgsArray[0]', imgsArray[0])
				uni.previewImage({
					current: 0,
					urls: imgsArray,
				});
			},

			getData() {
				uni.showLoading({
					title: '加载中'
				});
				let that = this;
				util.request(api.getHwAuthInfo, {
					servantId: this.servantId
				}, 'GET').then(function(res) {
					console.log('11', res.data);
					if (res.errno === 0) {
						that.setData({
							workerInfo: res.data
						});

						uni.hideLoading();
					}
				});
			},
		}
	}
</script>

<style>
	.resume-container {
		width: 100vw;
		height: 100vh;
		background-color: #f6f6f6;
		padding: 13rpx 20rpx 0rpx;
	}

	.server-info {
		width: 100%;
		height: 293rpx;
		background-image: url('https://mall.zhaijieshi.cc/file/wx-huawang/dyg.png');
		background-repeat: no-repeat;
		background-size: cover;
		padding: 96rpx 10rpx 20rpx 150rpx;
	}

	.server-info .worker {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.worker .name {
		font-size: 36rpx;
		font-weight: 400;
		height: 40rpx;
		line-height: 40rpx;
	}

	.worker .info {
		display: flex;
		font-size: 30rpx;
		font-weight: 400;
		height: 40rpx;
		line-height: 40rpx;
	}

	.info .age {
		width: 110rpx;
		text-align: left;
	}

	.info .worker-years {
		text-align: center;
		width: 280rpx;
		border-left: 4rpx solid #000;
		border-right: 4rpx solid #000;
	}

	.info .address {
		flex: 1;
		text-align: center;
	}

	.worker .introduce {
		font-size: 26rpx;
		font-weight: 400;
	}

	.zz-info {
		width: 100%;
		height: 239rpx;
		background-image: url('https://mall.zhaijieshi.cc/file/wx-huawang/zz.png');
		background-size: cover;
		margin: 30rpx auto;
		background-repeat: no-repeat;
	}

	.huawang-info {
		width: 100%;
		height: 531rpx;
		background-image: url('https://mall.zhaijieshi.cc/file/wx-huawang/rz.png');
		background-size: cover;
		background-repeat: no-repeat;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.huawang-info .img {
		width: 520rpx;
		height: 372rpx;
	}

	.huawang-info .img image {
		width: 100%;
		height: 100%;
	}
</style>