<template>
	<view class="container">
		<view class="tabs">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==current?'text-base cur text-xl text-bold ':'text-lg'"
						v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view style="height: 100%;">
			<swiper style="height: 100%;" :current="current" @change="swiperChange" @animationfinish="animationfinish">
				<swiper-item>
					<scroll-view scroll-y style="height: 100%;">
						<shop-info v-if="current==0&&id!=''" ref="shopInfo" :shopId="id"></shop-info>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y style="height: 100%;">
						<shop-activity v-if="current==1&&id!=''" ref="mallInfo" :shopId="id"></shop-activity>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<navigator hover-class="none" :url="'/pagesD/pages/menu/menu?shopId='+id" class="homeBtn">
			<view class="flex">
				<image src="/static/icon/goOrder.png" style="width: 36upx;height: 36upx;" />
				<text class="margin-left-10">点餐</text>
			</view>
		</navigator>
	</view>
</template>
<script>
	import shopActivity from "./comps/shop-activity.vue"
	import shopInfo from "./comps/shop-info.vue"
	export default {
		components:{
			shopInfo,shopActivity
		},
		data() {
			return {
				id: '',
				detail: {},
				tags: [],

				current: 0,
				swiperCurrent: 0,
				tabs: [{
						name: '商户信息',
						value: 0
					},
					{
						name: '商户活动',
						value: 1
					}
				],
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		methods: {
			tabChange(index) {
				this.current = index
			},
			swiperChange(e) {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				this.current = e.detail.current
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.swiperCurrent = current;
				this.current = current;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.text-xl {
		font-size: 34rpx;
	}

	.container {
		height: calc(100vh);
		background-color: #F6F6F6;
		padding: 78rpx 0rpx 0rpx;

		.tabs {
			position: fixed;
			top: -12rpx;
			left: 0;
			width: 100%;
			background-color: #FFFFFF;
			box-sizing: border-box;
			z-index: 3;
		}
	}
</style>
