<template>
	<view class="container">
		<view class="empty" v-if="false">
			<image src="http://192.168.0.172:5500/com_newEmpty.png" alt="" />
			没有添加任何房产

		</view>

		<div class="communityList">
			<div class="communityItem" v-for="item in communityList">
				<div class="communityItem_left">
					<div class="communityItem_left_img">
						<image src="http://192.168.0.172:5500/test.png"></image>
					</div>
					<div class="communityItem_left_msg" @click="toUpview(item)">
						<div class="communityItem_left_msg_tit">{{item.name}}<span>（ {{item.room_owner_list.length}}
								）</span></div>
						<div class="communityItem_left_msg_msg">{{item.addr}}</div>
					</div>
				</div>
				<div class="communityItem_right">
					<image src="http://192.168.0.172:5500/com_check1.png"></image>
				</div>
			</div>
		</div>

		<div class="addBtn" @click="addCommunity">添加我的房产</div>
	</view>
</template>

<script>
	import {
		request,
		NavgateTo,
		isPhone
	} from '../../../utils';
	import {
		apiArr
	} from '../../../api/community';
	export default {
		data() {
			return {
				communityList: [],
				page_num: 1,
				page_size: 10,
			}
		},
		methods: {
			addCommunity() {
				NavgateTo("/packages/community/addCommunity/index")
			},
			async getList() {
				await request(apiArr.commInfo, "POST", {
					user_id: uni.getStorageSync('userId'),
					longitude: uni.getStorageSync('location').lng,
					latitude: uni.getStorageSync('location').lat,
					page_num: this.page_num,
					page_size: this.page_size
				}).then(res => {
					this.communityList = res.rows
					console.log(res)
				})
			},
			toUpview(item) {
				uni.setStorageSync('changeCommData', { id: item.community_id, name: item.name });
				NavgateTo("/packages/community/index/index")
			}
		},

		onLoad(options) {
			this.getList();
		},

		onReachBottom() {},
	}
</script>

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