<template>
	<view class="electronicImg">
		<text>{{electronicSignatureName}}</text>
		<image v-if="electronicSignatureImage" class="swiperIcon" @click="previewImage(electronicSignatureImage)" :src="electronicSignatureImage">
		</image>
	</view>
</template>

<script>
	export default {
		// name: 'ElectronicSignature',
		props: ['userId'],
		data() {
			return {
				projectChilderUserList: [],
				electronicSignatureName: "",
				electronicSignatureImage: "",
			};
		},
		created() {
			this.getProjectChilderSystemUserList();
		},
		computed: {
			// electronicSignatureName() {
			// 	const find = this.projectChilderUserList.find(item => item.userId == this.userId);
			// 	return find ? find.realName : '';
			// },
			// electronicSignatureImage() {
			// 	const find = this.projectChilderUserList.find(item => item.userId == this.userId);
			// 	console.log(1111, find, this.$props);
			// 	return  find
			// 	? find.electronicSignature && find.electronicSignature.includes('http://')
			// 	: find.electronicSignature
			// 	? this.url_config + 'image/' + find.electronicSignature
			// 	: '';
			// }
		},
		methods: {
			//预览图片
			previewImage(row) {
				const url = row.includes('http://') ? row : this.url_config + 'image/' + row
				uni.previewImage({
					urls: [url]
				})
			},
			getProjectChilderSystemUserList() {
				this.sendRequest({
					url: 'xmgl/systemUser/getProjectChilderSystemUserList',
					method: 'post',
					data: {
						projectSn: JSON.parse(uni.getStorageSync('projectDetail')).projectSn,
						pageNo: 1,
						pageSize: -1
					},
					success: res => {
						if (res.code == 200) {
							// console.log('项目子账号', result);
							this.projectChilderUserList = res.result;
							const find = this.projectChilderUserList.find(item => item.userId == this.userId);
							this.electronicSignatureName = find ? find.realName : '';
							this.electronicSignatureImage = find
								? find.electronicSignature && find.electronicSignature.includes('http://')
								: find.electronicSignature
								? this.url_config + 'image/' + find.electronicSignature
								: '';
						}
					}
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.electronicImg {
		display: flex;
		align-items: center;
		margin-left: 30rpx;
		margin-top: 10rpx;
		> text {
			flex-shrink: 0;
		}
	}
	 .swiperIcon{
		 width: 260rpx;
		 height: 80rpx;
	 }
</style>