<template>
	<view class="container" @click="headerEnterClick" :data-id="item.community_id" :data-name="item.name" >
		<image class="left_logo" :src="item.pic" mode="aspectFill" />
		<view :class="['right', isLast && 'no_bottom']">
			<view class="header">
				<view class="title">{{item.name}}</view>
				<view class="distance" v-if="item.distance">{{item.distance}}</view>
			</view>
			<view class="center">物业公司：{{item.shop && item.shop.shop_name || item.property}}</view>
			<view class="address">
				<image class="address_icon"
					src="https://static.hshuishang.com/community/_assets/Group_50.png" mode="" />
				<view class="text-container">
					<text>{{item.addr}}</text>
				</view>
			</view>
			<view class="bottom">
				<view class="bottom_left">
					<view class="btn" @click.stop="handleOptionClick">
						<image class="btn_icon" src="https://static.hshuishang.com/community/_assets/Send.png"
							mode="aspectFill" />
						导航
					</view>
					<view class="btn mobile" @click.stop="headlePhoneClick">
						<image class="btn_icon"
							src="https://static.hshuishang.com/community/_assets/Phone-telephone.png" mode="" />
						电话
					</view>
				</view>
				<view class="bottom_right" @click.stop="headerEnterClick" v-if="joinType == 1">前往预定</view>
				<view class="bottom_right" @click.stop="headerEnterClick" v-if="joinType == 2">进入小区</view>
				<view class="bottom_right" @click.stop="chooseClick" v-if="joinType == 3" :data-id="item.community_id"
					:data-name="item.name">选择小区</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { picUrl, NavgateTo } from '../../utils';
	export default {
		props: {
			item: { // 循环项
				type: Object,
				default: null,
				required: false,
			},
			type: {
				type: String,
				default: '',
				required: false,
			},
			isLast: {
				type: Boolean,
				default: false,
				required: false,
			},
			joinType: {
				type: String,
				default: "2",
				required: false,
			}


		},
		data() {
			return {
				picUrl,
			}
		},
		methods: {
			//拨打电话触发事件
			headlePhoneClick() {
				uni.makePhoneCall({
					phoneNumber: this.item.tel
				})
			},
			
			
			// 导航
			handleOptionClick() {
				const { item } = this;
				let openParmas = {
					latitude: Number(item.lat),
					longitude: Number(item.lng),
					name: item.name,
					address: item.addr,
				};
				uni.openLocation(openParmas);
			},
			
			//进入小区
			headerEnterClick(e) {
				const { item, type } = this;
				console.log('123131', this.joinType)
				if (type) {
					console.log('共享空间点击事件');
					return;
				};
				if (this.joinType == 3) {
					console.log('123131', e);
					this.chooseClick(e);
					return;
				}
				NavgateTo(`/packages/community/communityDetail/index?title=${item.name}&id=${item.community_id}`, { isLogin: false })
			},
			
			//选择小区
			chooseClick(e){
				console.log('chooseClick12313', e);
				let community_id = e.currentTarget.dataset.id;
				let name = e.currentTarget.dataset.name;
				let that= this
				uni.setStorageSync('currentCommunity', name)
				uni.setStorageSync('currentCommunityId', community_id)
				uni.navigateBack({
						delta:1
				})
			},
			
			

		},


	}
</script>

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