<template>
	<view class="">
		<view class="card">
			<scroll-view  style="margin: 40rpx;">
				<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="性别:"><text v-text="form.sex==1?'男':'女'"></text></u-form-item>
					<u-form-item label="联系方式：">
						<u-input v-model="form.tel"  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.createDate"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item v-if="!$isEmpty(form.imageUri)" label="人脸照片:" label-position="top">
						<image  @click="previewImg" style="width: 300rpx;height: 300rpx;" :src="form.fastDfsServer+form.imageUri" ></image>
					</u-form-item>
					<u-form-item v-else label="人脸照片" >
						<text>暂无</text>
					</u-form-item>
				</u-form>
			</scroll-view>
		</view>
		<view class="" style="height: 150rpx;"></view>
		<view class="footer-fixed">
			<u-grid :col="3">
				<u-grid-item @click="toItem(1)">
					<u-icon name="plus-circle-fill" color='#19be6b' :size="50"></u-icon>
					<view class="grid-text">新增</view>
				</u-grid-item>
				<u-grid-item @click="toItem(2)">
					<u-icon name="edit-pen-fill" color="#2979ff" :size="50"></u-icon>
					<view class="grid-text">修改</view>
				</u-grid-item>
				<u-grid-item @click="deleteRoom">
					<u-icon name="trash-fill" color="#fa3534" :size="50"></u-icon>
					<view class="grid-text">删除</view>
				</u-grid-item>
			</u-grid>
		</view>
		<navigator url="../index/index" open-type="switchTab"  class="cuIcon cu-btn round" style="background-color: rgba(0,0,0,.2);color: #FFFFFF;position: fixed;right: 3%;bottom: 20%;width: 80rpx;height: 80rpx;">
			<text class="cuIcon-home" style="font-size: 40rpx;"></text>
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				labelStyle:{
					"fontWeight":"600"
				},
				form:{}
			}
		},
		onLoad(options) {
			
		},
		onShow() {
			this.form=getApp().globalData.userDetail
		},
		methods: {
			previewImg(){
				let url=this.form.fastDfsServer+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">
	.card{
		background-color: #FFFFFF;
		margin: 30rpx;
		border-radius: 20rpx;
	}
</style>
