<template>
	<view class="">
		<view class="data" v-for="(item, index) in list" :key="index" >
			<view class="top">
				<view class="left">
					<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
					<view class="title">{{item.residentialName}}-{{item.buildingName}}-{{item.unitName}}-{{item.roomName}}</view>
				</view>
			</view>
			<view class="item">
				<view class="left">
					<view  data-aid="undefined">
					  <image v-if="!$isEmpty(item.imageUri)" mode="aspectFill" :src="item.imageUri"></image>
					  <image v-else="" mode="aspectFill" src="http://139.9.103.171:1888/img/image/head.png"></image>
					</view>
					<view class="content" data-aid="undefined">
						<view >姓名：{{item.name}}</view>
						<view >手机：{{item.tel}}</view>
						<view >创建时间：{{item.createDate}}</view>
						<view v-if="item.type==0">身份：业主</view>
						<view v-if="item.type==1">身份：家属</view>
						<view v-if="item.type==2">身份：租户</view>
						<view v-if="item.type==3">身份：访客</view>
					</view>
				</view>
			</view>
			<view class="bottom" >
				<!-- 业主可以编辑所有人，其他只可以编辑自己 -->
				<view v-if="showEdit(item)" @click.stop="edit(item)" class="cu-btn line-btn round sm margin-right-sm"  >
					编辑
				</view>
				<!-- 小程序审核时，不要出现人脸功能 -->
				<!-- 业主可以激活所有人的人脸，其他只可以操作自己 -->
				<navigator v-if="showActiveFace(item)" class="cu-btn line-btn round sm margin-right-sm"  @click.stop="activeFace(item)">
					人脸激活
				</navigator>
				<!-- 自己不能删除自己，业主可以删除成员，但是也不能删除自己 -->
				<view v-if="vuex_relationshipType==0&&item.type!=0" class="cu-btn bg-btn sm round" @click.stop="deleteUserById(item.id)">
					删除
				</view>
			</view>
		</view>
		
		<!-- 有自己房屋的人才可以显示添加家人的功能按钮 -->
		<navigator url="add/add" v-if="!$isEmpty(vuex_own_room_list)" class=" footer-fixed" >
			<view class="cu-btn  flex  text-lg bg-red-btn" style="padding: 46rpx 0;">
				添加家人
			</view>
		</navigator>
<!-- 		<navigator url="add/add" v-if="!$isEmpty(vuex_own_room_list)" class="cuIcon cu-btn round base-bg-color" style="position: fixed;bottom: 20%;left: 20rpx;width: 88rpx;height: 88rpx;">
			<text class="cuIcon-add" style="font-size: 60rpx;"></text>
		</navigator> -->
	</view>
</template>

<script>
export default {
	props:{
		list:Array
	},
	data() {
		return {
			//小程序的审核状态
			appletType:0
		};
	},
	created() {
		this.appletType=uni.getStorageSync("appletType")
	},
	computed:{
		 showEdit() {
			return item => {
				if (this.vuex_relationshipType==0) {
					return true
				}else {
					if (this.vuex_member.name==item.name || this.vuex_member.tel==item.tel) {
						 return true
					}else{
						return false
					}
				}
			};
		},
		showActiveFace(){
			//小程序的审核状态为1才显示人脸模块，
			return item => {
				if (this.appletType==1) {
					if (this.vuex_relationshipType==0) {
						return true
					}
					if (this.vuex_member.name==item.name || this.vuex_member.tel==item.tel) {
						 return true
					}else{
						return false
					}
				}
				return false
			};
		}
	},
	methods:{
		edit(item){
			let params={
				user_id:item.id,
				name:item.name,
				tel:item.tel,
				room_name:item.roomName,
				type:item.type,
				id_card:item.idCard || '',
				sex:item.sex,
				nationality:item.nationality || '',
				image_uri:item.imageUri || '',
				passport_img_uri:item.passportImgUri || '',
				entry_img_uri:item.entryImgUri || ''
			}
			if (this.vuex_relationshipType==0) {
				//业主身份操作
				params['operUserType']=0
			}else{
				//不是业主身份操作
				params['operUserType']=item.type
			}
			uni.navigateTo({
				url:"/pages/myFamily/editFamily/editFamily"+this.$u.queryParams(params)
			})
		},
		activeFace(item){
			let params={
				room_id:item.roomId,
				user_id:item.id,
				name:item.name,
				tel:item.tel,
				room_name:item.roomName,
				type:item.type,
				id_card:item.idCard || '',
				sex:item.sex,
				nationality:item.nationality || '',
				image_uri:item.imageUri || '',
				passport_img_uri:item.passportImgUri || '',
				entry_img_uri:item.entryImgUri || ''
			}
			uni.navigateTo({
				url:"/pages/myFamily/activateFace/activateFace"+this.$u.queryParams(params)
			})
		},
		deleteUserById(id) {
			this.$emit('deleteUserById',id)
		},
	}
};
</script>

<style lang="scss" scoped>
.data {
	background-color: #FFFFFF;
	width: 720rpx;
	margin:10rpx auto;
	border-radius: 6rpx;
	box-sizing: border-box;
	padding: 20rpx;
	font-size: 28rpx;
	border-bottom: 1rpx solid #d1d1d1;
	.top {
		display: flex;
		justify-content: space-between;
		border-bottom: 1rpx dashed #DEDEDE;
		padding-bottom: 20rpx;
		.left {
			display: flex;
			align-items: center;
			.title {
				margin: 0 10rpx;
				font-size: 32rpx;
			}
		}
	}
	.item {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin: 40rpx 0 20rpx 0;
		.left {
			display: flex;
			image {
				width: 130rpx;
				height: 130rpx;
				border-radius: 50%;
			}
			.content {
				padding-left: 30rpx;
				view{
					padding-bottom: 16rpx;
				}
			}
		}
	}
	.bottom {
		display: flex;
		margin-top: 20rpx;
		justify-content: flex-end;
		align-items: center;
	}
}
</style>
