<template>
	<view class="content">
		<view class="card">
			<u-cell-group>
				<u-cell title="照片">
					<template #value>
						<u--image :src="info.PHOTO" shape="circle" width="100upx" height="100upx"
							@click="fnPreview(info.PHOTO)"></u--image>
					</template>
				</u-cell>
				<u-cell title="姓名" :value="info.NAME"></u-cell>
				<u-cell title="性别" :value="info.SEX === '1' ? '女' : '男'">
				</u-cell>
				<u-cell title="出生年月" :value="info.DATE_OF_BIRTH"></u-cell>
				<u-cell title="年龄" :value="info.AGE"></u-cell>
				<u-cell title="身份证" :value="info.CARD_ID"></u-cell>
				<u-cell title="就职单位相关方单位" :value="info.RELEVANT_UNIT_NAME"></u-cell>
				<u-cell title="岗位名称" :value="info.POST_ID"></u-cell>
				<u-cell title="联系电话" :value="info.PHONE"></u-cell>
				<u-cell title="人员类型" :value="info.ISFLOW === '1' ? '流动人员' : '固定人员'">
				</u-cell>
				<u-cell title="二维码" v-if="!CODE_TYPE && info.CORPINFO_ID && info.code != '' && (info.DEPART_STATE == '0' || info.DEPART_STATE == '-1')">
					<template #value>
						<u--image :src="info.code" width="100upx" height="100upx" @click="fnPreview(info.code)">
						</u--image>
					</template>
				</u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import {
		getElectronicWorkCard,
		getElectronicWorkCardQRCode
	} from "../../api";

	export default {
		data() {
			return {
				info: {},
				USER_ID: '',
				CODE_TYPE: ''
			}
		},
		created() {
			this.fnGetData()
		},
		onLoad(query) {
			this.USER_ID = query.USER_ID
			this.CODE_TYPE = query.CODE_TYPE
		},
		methods: {
			async fnGetData() {
				var params = {}
				if (this.CODE_TYPE) {
					params.USER_ID = this.USER_ID
				}
				let resData = await getElectronicWorkCard(params)
				let {
					code
				} = await getElectronicWorkCardQRCode(params)
				this.info = resData.pd
				console.log(this.$filePath + resData.pd.PHOTO)
				this.info.PHOTO = this.$filePath + resData.pd.PHOTO
				this.info.code = 'data:image/jpg;base64,' + code
			},
			fnPreview(urls) {
				uni.previewImage({
					urls: [urls]
				})
			}
		},
	}
</script>

<style scoped>

</style>
