<template>
	<view class="discountsDetail">
		<zs-choose-tab></zs-choose-tab>
		
		<!-- 内容 -->
			<zs-list  class="store-box" mt="0" @load="loadMore" :status="status">
			<view class="item" v-for="(item,index) in list" :key="index">
				<!-- <image :src="item.src" mode="" class="icon" @click="goDetail(item)"></image> -->
				<zs-img :src="item.logoPath" width="200rpx" height="200rpx" radius="full" @click.native="goDetail(item)"></zs-img>
				<view class="info">
					<view class="title">
						{{item.shopVo.shopName}}
					</view>
					<view class="desc">
						2人24菜12嫩牛肉、精品千层肚、嫩肉
						片、老肉片、午餐肉24菜12嫩牛肉、精品千层肚、嫩肉
						片、老肉片、午餐肉24菜12嫩牛肉、精品千层肚、嫩肉
						片、老肉片、午餐肉
					</view>
					<view class="price-box">
						<view class="left">
							<view class="unit">
								￥
							</view>
							<view class="price">
								50
							</view>
							<view class="old-price">
								市场价 ￥299
							</view>
						</view>
						
						<view class="right">
							销量5999
						</view>
					</view>
				</view>
			</view>
			</zs-list>
		

		
	</view>
</template>

<script>
	import { search } from '@/api/shop.js';
	export default {
		options: { styleIsolation: 'shared' },
		data() {
			return {
				longitude: '',
				latitude: '',
				destination: '',
				_mapContext: null,
				status:'more',
				list: [],
				btnText:'去使用',
				banner:'',
				filterResultData: [],
				query:{
					menuId:'',
					queryName:'',
					'location.lat':0,
					'location.lon':0,
					pageCurrent:1,
					pageSize:10
				}
			}
		},
		methods: {
	
			goDetail(item){
				uni.setStorageSync('shopInfo',JSON.stringify(item))
				uni.navigateTo({
					url:'../shopDetail/shopDetail'
				})
			},
			loadMore(){
				this.search()
			},
			search() {
				return new Promise((resolve,reject)=>{
					if(this.status == 'noMore') return
					this.status = 'loading'
					search(this.query).then(res=>{
						if(res.state == 'Success'){
							this.list = this.list.concat(res.content.records)
							if(this.list.length >= res.content.total){
								this.status = 'noMore'
							}else{
								this.status = 'more'
								this.query.pageCurrent++
							}
							resolve()
						}
					})
				})
			},
		},
		onPullDownRefresh() {
			this.query.pageCurrent = 1
			this.list = []
			this.status = 'more'
			this.search().then(()=>{
				uni.stopPullDownRefresh()
			})
		},
		onLoad(option) {
			let that = this
			const eventChannel = this.getOpenerEventChannel();
			if(JSON.stringify(eventChannel) !=='{}'){
				eventChannel.on('banner', function(data) {
					that.banner = data
				})
			}
			uni.setNavigationBarTitle({
				title: option.title
			});
			this.query.menuId = option.id
			let location = JSON.parse(uni.getStorageSync('location'))
			this.query['location.lat'] = location.latitude
			this.query['location.lon'] = location.longitude
			this.search()

		},
		
	}
</script>

<style lang="scss">

	.bar-item-text {
		max-width: 250rpx !important;
	}

	.screen-bar::after {
		display: none;
	}
	.discountsDetail  cc-drop-down-menu .screen-bar{
		// position: fixed;
		top: 0%;
		left: 0;
		width: 100%;
	}
	.discountsDetail {
		background: #F9F9F9;
		padding-top: 80rpx;
		.banner{
			width: 100%;
			height: 310rpx;
			position: relative;
			z-index: 99;
		}

		.zs-list {
			margin: 0 24rpx;
			.item {
				display: flex;
				padding: 24rpx;
				background: #fff;
				border-radius: 16rpx;
				margin: 20rpx 0 0;
				.icon{
					border-radius: 16px;
				}	
				.info{
					flex: 1;
					padding-left: 20rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					position: relative;
					.title{
						font-size: 28rpx;
						font-weight: bold;
						width: 340rpx;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						margin-top: 10rpx;
					}
					
					.desc{
						font-size: 24rpx;
						color: #AAAAAA;
						overflow: hidden;
						text-overflow: ellipsis;
						/* 弹性伸缩盒子模型显示 */
						display: -webkit-box;
						/* 限制在一个块元素显示的文本的行数 */
						-webkit-line-clamp: 2;
						/* 设置或检索伸缩盒对象的子元素的排列方式 */
						-webkit-box-orient: vertical;
					}
					
					.price-box{
						display: flex;
						justify-content: space-between;
						align-items: center;
						.left{
							display: flex;
							align-items: flex-end;
							.unit{
								font-size: 20rpx;
								color: #FF4D3A;
								font-weight: bold;
							}
							.price{
								font-size: 32rpx;
								color: #FF4D3A;
								font-weight: bold;
							}
							.old-price{
								font-size: 20rpx;
								color: #AAAAAA;
								text-decoration: line-through;
								margin-left: 12rpx;
							}
						}
						.right{
							font-size: 24rpx;
							color: #AAAAAA;
						}
					}
					
				}
			}
		}

	}
</style>