<!--
 * @Title: 
 * @Description: 家庭成员清单
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="item in list" :key="item.id">
					<template v-slot:body>
						<uni-card v-if="item.isHouseholder" title="户主" :is-shadow="false">
							<view class="list-item-block">
								<view class="line">
									<uni-icons class="input-uni-icon" type="person" size="18" color="orangered" />
									<text class="content">{{item.personName}}</text>
								</view>
								<view class="line">
									<uni-icons class="input-uni-icon" type="phone" size="18" color="orangered" />
									<text class="content">{{item.personId}}</text>
								</view>
							</view>
						</uni-card>
						<uni-card v-else title="家庭成员" :is-shadow="false">
							<view class="list-item-block">
								<view class="line">
									<uni-icons class="input-uni-icon" type="person" size="18" color="orangered" />
									<text class="content">{{item.personName}}</text>
								</view>
								<view class="line">
									<uni-icons class="input-uni-icon" type="phone" size="18" color="orangered" />
									<text class="content">{{item.personId}}</text>
								</view>
							</view>
						</uni-card>
					</template>
				</uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';
	export default {
		components: {},
		onLoad(option) {
			this.query = {};
			this.query['personId'] = option.personId;
			this.getList();
		},
		data() {
			return {
				title: '家庭成员表',
				list: [],
				query: {},
			}
		},
		computed: {},
		onShow() {},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getList(params = {}) {
				let postData = Object.assign(params, this.query);
				let that = this;
				http.request({
					url: '/galaxy-business/yj/resident/family/list',
					method: 'GET',
					data: postData,
				}).then(res => {
					if (res.data != null) {
						that.list = res.data;
						// that.list = res.data.map(item => {
						// 	let id = item.personId.replace(/^(\d{6})\d+(\d{4})$/, '$1******$2')
						// 	return {
						// 		'id': item.id,
						// 		'isHouseholder':item.isHouseholder,
						// 		'personName':item.personName,
						// 		'personId':id
						// 	}
						// })
					}
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>