<template>
	<view class="">
		<view class="cu-card case card" v-for="(item,index) in list" :key="index" @click="goDetail(item.id)">
			<view class="cu-item shadow">
				<view class="image">
					<image style="width: 100%;height: 350rpx;" :src="item.logo"></image>
				</view>
				<view class="content">
					<view class="top">
						<text class="title">{{item.mallName}}</text>
						<view v-if="item.intro" class="desc text-cut-2">
							{{item.intro}}
						</view>
					</view>
					<view class="bottom">
						<view class="">
							<image src="@/static/icon/map1.png" mode=""></image>
							<text>距离 {{distance(item.address)}} km</text>
						</view>
						<view class="" @click.stop="checkLine(item)">
							<image style="width: 40rpx;height: 40rpx;" src="@/static/icon/lx.png" mode=""></image>
							<text>查看路线</text>
						</view>
						<view class="">
							<image src="@/static/icon/activitys.png" mode=""></image>
							<text>{{item.activityNums}}个活动</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			list:Array
		},
		data(){
			return {
				
			}
		},
		computed:{
			distance() {
				return (address) => {
					let location= address.split(",")
					let lat1=location[1]
					let lng1=location[0]
					
					if (this.vuex_location!=null) {
						let distance=this.$util.calculateDistance(lat1,lng1,this.vuex_location.latitude,this.vuex_location.longitude)
						console.log(distance);
						return distance
					}else{
						return 0
					}
					
				};
			},
		},
		methods:{
			checkLine(item){
				uni.openLocation({
					latitude:parseFloat(item.latitude),
					longitude:parseFloat(item.longitude),
					name:item.mallName,
					address:item.location
				})
			},
			goDetail(id){
				uni.navigateTo({
					url:"/pages/activity/activity?id="+id
				})
			}
		}
	}
</script>

<style lang="scss">
	.card{
		background-color: #FFFFFF;
		border-bottom: 1rpx solid #ececec;
	}
	
	.card:last-child{
		border: none;
	}
	
	.content{
		display: flex;
		flex-direction: column;
		.top{
			.title{
				font-weight: 800;
				font-size: 28rpx;
			}
			.desc{
				margin-top: 10rpx;
				color: #919191;
				font-size: 24rpx;
			}
		}
		
		.bottom{
			margin-top: 20rpx;
			display: flex;
			width: 100%;
			
			view{
				width: calc(100% / 3);
				display: flex;
				align-items: center;
				image{
					width: 30rpx;
					height: 30rpx;
				}
				
				text{
					font-size: 28rpx;
					margin-left: 6rpx;
				}
			}
			
			view:nth-child(1){
				justify-content: flex-start;
			}
			view:nth-child(2){
				justify-content: center;
			}
			view:nth-child(3){
				justify-content: flex-end;
			}
		}
	}
</style>
