<template>
	<view class="">
		<view class="card">
			<u-form :label-style="labelStyle" label-width="220" :model="form" ref="uForm">
				<u-form-item label="姓名:"><u-input v-model="form.name" placeholder="暂无信息" disabled/></u-form-item>
				<u-form-item label="性别:">
					<view>
						<text class="" v-if="form.sex==0">未知</text>
						<text class="" v-else-if="form.sex==1">男</text>
						<text class="" v-else-if="form.sex==2">女</text>
					</view>
				</u-form-item>
				<u-form-item label="联系方式：">
					<u-input v-model="form.phone"  placeholder="暂无信息" disabled></u-input>
				</u-form-item>
				<u-form-item label="证件号码：">
					<u-input v-model="form.idCard"  placeholder="暂无信息" disabled></u-input>
				</u-form-item>
				<u-form-item label="人脸审核状态：">
					<view class='cu-tag radius bg-red' v-if="form.checkState==-1">
						<text>待上传</text>
					</view>
					<view class='cu-tag radius bg-orange' v-if="form.checkState==0">
						<text>待审核</text>
					</view>
					<view class='cu-tag radius bg-green' v-if="form.checkState==1">
						<text>审核通过</text>
					</view>
					<view class='cu-tag radius bg-red' v-if="form.checkState==2">
						<text>审核通过</text>
					</view>
				</u-form-item>
				<u-form-item label="住户类型：">
					<view class='cu-tag radius bg-blue' >
						<text class="" v-if="form.type==0">业主</text>
						<text class="" v-else-if="form.type==1">成员</text>
						<text class="" v-else-if="form.type==2">租客</text>
					</view>
				</u-form-item>
				<u-form-item label-width="160" label="房屋信息：">
					<text >{{form.residentialName}}-{{form.buildingName}}-{{form.unitName}}-{{form.roomName}}</text>
				</u-form-item>
				<u-form-item label-width="160" label="创建时间：">
					<u-input v-model="form.createTime"  placeholder="暂无信息" disabled></u-input>
				</u-form-item>
				<u-form-item v-if="form.imageUri" label="人脸照片:" label-position="top">
					<image  @click="$util.preview(faceImg)" style="width: 300rpx;height: 300rpx;" :src="faceImg" ></image>
				</u-form-item>
				<u-form-item v-else label="人脸照片" >
					<text>暂无</text>
				</u-form-item>
			</u-form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				labelStyle:{
					"fontWeight":"600"
				},
				form:{},
				faceImg:''
			}
		},
		onLoad(options) {
			this.fetchData(options.id)
		},
		methods: {
			fetchData(id){
				let params = {
					id: id
				};
				this.$api.user.detail(params).then(res=>{
					this.form=res.data
					this.faceImg=res.data.imageUri
				})
			},
			previewImg(){
				let url=this.form.imageUri
				let imgArr=[url]
				uni.previewImage({
					urls:imgArr
				})
			},
			toItem(index){
				let url=''
				switch (index){
					case 1:
					//新增
						this.$u.toast('暂未开放')
						// uni.navigateTo({
						// 	url:"add"
						// })
						break;
					case 2:
					//修改
						uni.navigateTo({
							url:"add?id="+this.form.id
						})
						break;
					default:
						break;
				}
				if (!this.$isEmpty(url)) {
					uni.navigateTo({
						url:url
					})
				}
			},
			deleteRoom(){
				let item =this.form
				this.$dialog.showModal('确定要删除此项吗?').then(res=>{
					this.$api.user.del({id:item.id}).then(res=>{
						if (res.data==true) {
							this.$dialog.showModal('删除成功',false).then(res=>{
								uni.navigateBack({
									delta:1
								})
							})
						}else{
							this.$u.toast('删除失败')
						}
					})
					
				})
			}
			
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FFFFFF;
	}
	.card{
		background-color: #FFFFFF;
		margin: 10rpx 50rpx;
		border-radius: 20rpx;
	}
</style>
