<template>
<view>
	<!-- 第一种样式  人员管理-->
	<block v-if="datainfo.length>0">
		<!-- 人员管理 -->
		<block v-if="type=='people'">
			<view class="carlist" v-for="(ite,idx) in datainfo" :key="idx" @click="getDetail">
				<view class="ctop flexc">
					<image :src="hicoa" class="imgs" v-if="ite.type==1"></image>
					<image :src="hicob" class="imgs" v-if="ite.type==2"></image>
					<view class="tit">一号楼3单元1101</view>
					<view class="flex1"></view>
					<view class="txt ca" v-if="ite.type==1">业主</view>
					<view class="txt cb" v-if="ite.type==2">租户</view>
				</view>
				<view class="plists">
					<view class="plist">
						<image :src="man" class="head" v-if="ite.sex==0"></image>
						<image :src="woman" class="head" v-else></image>
						<view class="flex1">
							<view class="ptit">张伟<view class="btn btnc ml10" v-if="ite.hzflag">户主</view></view>
							<view class="ptxt">身份证号 | 41072719880603022X</view>
							<view class="flexc">
								<view class="ptxt">性别 | {{ite.sex==0?'男':'女'}}</view>
								<view class="ptxt">年龄 | 36岁</view>
							</view>
							<view class="flexc">
								<view class="ptxt">身高 | 165cm</view>
								<view class="ptxt">体重 | 67kg</view>
							</view>
						</view>
					</view>
					<view class="plist" v-if="ite.zhanflag">
						<image :src="man" class="head" v-if="ite.sex==0"></image>
						<image :src="woman" class="head" v-else></image>
						<view class="flex1">
							<view class="ptit">张伟<view class="btn btnc ml10" v-if="ite.hzflag">户主</view></view>
							<view class="ptxt">身份证号 | 41072719880603022X</view>
							<view class="flexc">
								<view class="ptxt">性别 | {{ite.sex==0?'男':'女'}}</view>
								<view class="ptxt">年龄 | 36岁</view>
							</view>
							<view class="flexc">
								<view class="ptxt">身高 | 165cm</view>
								<view class="ptxt">体重 | 67kg</view>
							</view>
						</view>
					</view>
					<image :src="upimg" :class="ite.zhanflag?'act':''" class="upimg" @click="getZhan(idx)"></image>
				</view>
			</view>
		</block>
		<view class="shax">{{wtdt}}</view>
	</block>
	
	<!-- 无数据 -->
	<view class="nodata" v-else>
		<image :src="noiconpimg"></image>
		<view>
			暂无数据
		</view>
	</view>
</view>
</template>

<script>
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	import config from '@/config'
	export default{
		props:{
			datainfo: {
				type: Array,
				default () {
					return []
				}
			},
			wtdt:{
				type:String,
				default () {
					return ''
				}
			},
			type:{
				type:String,
				default () {
					return 0
				}
			},
			topval:{
				type:String,
				default () {
					return ''
				}
			}
		},
		data(){
			return{
				noiconpimg:require("@/static/nodata.png"),
				hicoa:require("@/health/static/health/hicoa.png"),
				hicob:require("@/health/static/health/hicob.png"),
				man:require("@/work/static/people/man.png"),
				woman:require("@/work/static/people/woman.png"),
				upimg:require("@/static/images/home/up.png"),
				
				baseUrl:config.baseUrl,
				delBtnWidth:66,//左滑默认宽度
			}
		},
		mounted() {
			
		},
		methods:{
			checkPermi, checkRole,
			getDetail(e){
				this.$emit('getDetail',e)
			},
			getAddFn(e){
				this.$emit('getAddFn',e)
			},
			getReadlist(e){
				this.$emit('getReadlist',e)
			},
			getZhan(idx){
				// var obj=JSON.parse(JSON.stringify(this.datainfo))[idx]
				// obj.zhanflag=!obj.zhanflag;
				// this.datainfo.splice(idx,1,obj);
				this.datainfo[idx].zhanflag=!this.datainfo[idx].zhanflag
			},
			getPreview(idx,arr) {
				var newArr=[];
				arr.forEach(ite=>{
					var ds=this.baseUrl+ite
					newArr.push(ds)
				})
				uni.previewImage({
					urls: newArr,
					current:idx,
					success: function(data) {},
					fail: function(err) {}
				});
			},
			//开始触摸滑动
			drawStart(e) {
				// console.log("开始触发");
				var touch = e.touches[0];
				this.startX = touch.clientX;
			},
			//触摸滑动
			drawMove(e) {
				// console.log("滑动");
				for (var index in this.datainfo) {
					// this.csListArrl[index].right=0
					this.$set(this.datainfo[index],'right',0);
				}
				var idx=e.currentTarget.dataset.idx
				var touch = e.touches[0];
				var item = this.datainfo[idx];
				var disX = this.startX - touch.clientX;
				if (disX >= 20) {
				        if (disX > this.delBtnWidth) {
					    disX = this.delBtnWidth;
				        }
						// this.csListArrl[idx].right=disX
				        this.$set(this.datainfo[idx],'right',disX);
				} else {
					// this.csListArrl[idx].right=0
					this.$set(this.datainfo[idx],'right',0);
				}
			},
			//触摸滑动结束
			drawEnd(e) {
				// console.log("滑动结束");
				var idx=e.currentTarget.dataset.idx
				var item = this.datainfo[idx];
				if (item.right >= this.delBtnWidth / 2) {
					// this.datainfo[idx].right=this.delBtnWidth
					this.$set(this.datainfo[idx],'right',this.delBtnWidth);
				} else {
					this.datainfo[idx].right=0
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.flex{display: flex;}
.flexc{display: flex;align-items: center;}
.mb10{margin-bottom: 20rpx;}
.carlist{background: #FFFFFF;border-radius: 20rpx;margin-bottom: 24rpx;
	.ctop{border-bottom: 2rpx solid #E5E5E5;padding: 24rpx 24rpx 22rpx;
		.imgs{width: 40rpx;height: 42rpx;margin-right: 32rpx;}
		.tit{font-size: 30rpx;color: #272727;font-weight: bold;margin-right: 20rpx;}
		.txt{font-weight: 500;font-size: 26rpx;
			&.ca{color: #3565ED;}
			&.cb{color: #FE5A0E;}	
			&.cc{color: #28C529;}	
		}
		.txta{font-weight: 500;font-size: 24rpx;color: #AAAAAA;}
		.num{font-size: 24rpx;color: #AAAAAA;}
	}
	.plists{padding: 30rpx 24rpx 6rpx;
		.plist{background: linear-gradient(-90deg, #F2F5FF 0%, #FBFDFF 100%);border-radius: 20rpx;border: 2rpx solid #E6E6E6;margin-bottom: 24rpx;padding: 18rpx 26rpx 4rpx;display: flex;
		.head{width: 96rpx;height: 98rpx;margin-right: 32rpx;flex: 0 0 auto;margin-top: 36rpx;}
		.ptit{font-weight: bold;font-size: 30rpx;color: #272727;display: flex;align-items: center;margin-bottom: 14rpx;}	
		.ptxt{font-weight: 500;font-size: 26rpx;color: #666666;line-height: 36rpx;margin-bottom: 14rpx;min-width: 176rpx;}
		}
	}
	.upimg{width: 26rpx;height: 22rpx;display: block;transform: rotate(180deg);transition: all 0.3s;margin: 0 auto 18rpx;
		&.act{transform: rotate(0deg);}
	}
	.btn{height: 34rpx;border-radius: 18rpx;display: flex;align-items: center;justify-content: center;padding: 0 10rpx;font-size: 22rpx;margin-right: 24rpx;
		&.btna{border: 2rpx solid #06C770;color: #06C770;}
		&.btnb{border: 2rpx solid #3565ED;color: #3565ED;}
		&.btnc{border: 2rpx solid #FE5A0E;color: #FE5A0E;}
		&.btnbga{border: 1px solid #0156FE;color: #3565ED;background: #DFEAFF;height: 36rpx;}
		&.btnbgb{border: 1px solid #C1C1C1;color: #666666;background: #F1F1F1;height: 36rpx;}
		&.btnbgc{border: 1px solid #FE5A0E;color:#FE5A0E;background:#FFEEE6;height: 36rpx;}
	}
}



// 无数据
.nodata{display: flex;flex-direction: column;align-items: center;
	image{width: 440rpx;height: 440rpx;}
	view{font-size: 30rpx;color: #666666;font-weight: bold;}
}
</style>