<template>
	<view class="box">
		<view class="search">
			<view class="searchIpt">
				<input type="text" placeholder="社区名称/业主姓名/业主手机" placeholder-style="color: #999999;font-size: 24rpx;"
					:value="search" @input="search" />
				<image class="sear_icon" src="https://static.hshuishang.com/water_filter/dervice/deriveSearch.png"
					mode="" />
			</view>
		</view>

		<view class="OwnerItem" v-for="(item, index ) in list" :key="index">
			<view class="Name">{{item.name}}</view>
			<view class="rows">
				<view class="rows_tit">申请手机</view>
				<view class="rows_con">{{item.mobile}}</view>
			</view>
			<view class="rows">
				<view class="rows_tit">入住小区</view>
				<view class="rows_con">{{item.community.name}}</view>
			</view>
			<view class="rows">
				<view class="rows_tit">申请类型</view>
				<view class="rows_con" v-if="item.type == 1">业主</view>
				<view class="rows_con" v-if="item.type == 2">家属</view>
				<view class="rows_con" v-if="item.type == 3">租客</view>
				<view class="rows_con" v-if="item.type == 4">访客</view>
			</view>

			<view class="rows">
				<view class="rows_tit">楼宇号</view>
				<view class="rows_con">{{item.facility.name}}</view>
			</view>
			<view class="rows">
				<view class="rows_tit">房屋号</view>
				<view class="rows_con">{{item.room.name}}</view>
			</view>
			<view class="rows">
				<view class="rows_tit">创建时间</view>
				<view class="rows_con time">2025-03-24 15:20</view>
			</view>
			<view class="rows">
				<view class="rows_tit">申请状态</view>
				<view class="rows_con state1" v-if="item.audit === 1">待审核</view>
				<view class="rows_con state2" v-if="item.audit === 2">已通过</view>
				<view class="rows_con state3" v-if="item.audit === 3">未通过</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { request } from '../../../utils';
	import { apiArr } from '../../../api/community';
	export default {
		data() {
			return {
				search: "",
				page_num: 1,
				page_size: 10,
				list: [],
				flag: false,
			}
		},
		methods: {
			search(e) {
				console.log('1231313', e);
				this.search = e.detail.value;
				this.list = [];
				this.page_num = 1;
				this.flag = false;
				this.init();
				
			},

			async init() {
				const { page_num, page_size, list, search } = this;
				let param = {
					page_num,
					page_size,
				};
				if (search !== '') {
					param = {
						page_num,
						page_size,
						name: search,
					};
				}
				const res = await request(apiArr.ownerList, 'POST', param);
				let flag = false
				if (res.rows.length == page_size) {
					flag = true
				} else {
					flag = false
				}
				this.list = list.concat(res.rows || []);
				this.page_num = page_num + 1;
				this.flag = flag;
			},
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: '我的申请',
			});
			this.init();
		},
		
		onReachBottom() {
			if(this.flag){
				this.init()
			}
		},
	}
</script>

<style>
	@import url("./index.css");
</style>