<template>
	<view class="special-content clearfix">
		<view class="swiper-banner-title">商品专题</view>
		<view class="swiper-banner-box" >
			<swiper class="tui-banner-swiper tui-banner tui-skeleton-fillet" :autoplay="true" :interval="5000" :duration="500"  @change="swiperChange" :circular="true">
				<swiper-item v-for="(item,index) in bannerList" :key="index" @click="NavToDetailPage(item)">
					<image :src="item.image" class="tui-slide-image" mode="scaleToFill"/>
				</swiper-item>
			</swiper>
			<view class="swiper__dots-box" v-if="bannerList.length > 1">
				<view v-for="(item,idx) in bannerList" 
					  :key="idx" 
					  :class="[idx===current?'swiper__dots-long':'none']" 
					  :data-index="current" class="swiper__dots-item">
				</view>	  
			</view>
		</view>
		<view class="swiper-goods-box">
			<view class="goods-box-item" v-for="(item,index) in productList" :key="index" @click="NavToDetailPage(item)">
				<image :src="item.image" mode="" class="box-item-image"></image>
				<view class="box-item-mask">{{ item.title }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name:"specialContent",
		props:{
			list:{
				type:Array
			},
			listB:{
				type:Array
			}
			
		},
		data() {
			return{
				current:0,
				bannerList:[],
				productList:[]
			}
		},
		created(){
			this.initData(this.list,this.listB)
		},
		computed: {
	
		},
		methods:{
			initData(list,listB){
				this.bannerList = list
				this.productList = listB
			},
			swiperChange(e) {//轮播图切换
				const index = e.detail.current;
				this.current = index;
			},
			NavToDetailPage(floor) {//跳转
				switch(floor.linkType){
					case 1://二级页面
						this.$api.navigateTo(`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}&title=${floor.title}`)
						break;
					case 2://搜索项目仪器 
						this.$api.navigateTo(`/pages/search/search-instrument?linkId=${floor.linkParam.id}`)
						break;
					case 3://直播页面
						this.$api.navigateTo(``)
						break;
					case 4://自由页面
						this.$api.navigateTo(`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}`)
						break;
					case 5://商品详情
						this.$api.navigateTo(`/pages/goods/product?id=${floor.linkParam.id}`)
						break;
					case 6://仪器项目详情
						this.$api.navigateTo(`/pages/goods/instrument-details?id=${floor.linkParam.id}`)
						break;
					case 7://供应商主页 
						this.$api.navigateTo(`/supplier/pages/user/my-shop?shopId=${floor.linkParam.id}`)
						break;
					case 8://专题活动页
						this.$api.navigateTo(`/h5/pages/activity/activity-list`)
						break;
					case 9://二手市场介绍
						this.$api.navigateTo(`/second/pages/form/introduce`)
						break;
					case 10://二手商品列表
						this.$api.navigateTo(`/second/pages/product/product-list`)
						break;
					case 11://二手商品发布
						this.$api.navigateTo(`/second/pages/form/form`)
						break;
					case 12://商品搜索
						this.$api.navigateTo(`/pages/search/search?keyWord=${floor.title}`)
						break;
					case 13://信息详情
						this.$api.navigateTo(`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}`)
						break;
					case 14://品牌招商介绍页 
						this.$api.navigateTo(`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}`)
						break;
					case 15://维修保养介绍页 
						this.$api.navigateTo(`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}`)
						break;
					case 16://首页
						this.$api.switchTabTo(`/pages/tabBar/home/index`)
						break;
					case 17://注册页 
						this.$api.navigateTo(`/pages/login/register-select`)
						break;
					case 18://信息中心
						this.$api.navigateTo(`/pages/login/register-select`)
						break;
					case 19://供应商列表
						this.$api.navigateTo(`/pages/login/register-select`)
						break;
				}
			}
		}
	}
</script>

<style lang="scss">
	.special-content{
		background-color: #F7F7F7;
		width: 100%;
		height: auto;
		box-sizing: border-box;
		padding: 0 24rpx;
	}
	.swiper-banner-box{
		width: 100%;
		height: 284rpx;
		background:#F7F7F7;
		position: relative;
		background-size: cover;
		float: left;
		margin: 20rpx 0;
	}	
	.swiper-banner-title{
		width: 100%;
		float: left;
		font-size: 34rpx;
		font-weight: bold;
		text-align: left;
		line-height: 49rpx;
		color: #333;
		ackground:#F7F7F7;
	}
	.tui-banner-swiper {
		width: 700rpx;
		margin: 0 auto;
		height: 284rpx;
		border-radius: 2rpx;
		overflow: hidden;
		transform: translateY(0);
		box-shadow:0px 3px 6px rgba(225,86,22,0.08);
		.banner-item{
			border-radius: 16rpx;
		}
		.tui-slide-image {
			width: 100%;
			height: 284rpx;
			display: block;
			border-radius: 2rpx;
		}
	}
	.swiper__dots-box{
		position: absolute;
		bottom: 30rpx;
		left: 0;
		right: 0;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		.swiper__dots-item{
			width: 8rpx;
			height: 8rpx;
			border-radius: 100%;
			margin-left: 6px;
			background-color:rgba(255,255,255,.7);
		}
		.swiper__dots-long{
			width: 35rpx;
			height: 8rpx;
			border-radius: 4rpx;
			background-color: #ffff;
			transition: all 0.4s;
		}
	}
	.swiper-goods-box{
		width: 100%;
		height: auto;
		float: left;
		.goods-box-item{
			width: 340rpx;
			height: 340rpx;
			float: left;
			margin-right: 20rpx;
			margin-bottom: 20rpx;
			&:nth-child(2n){
				margin-right: 0;
			}
			position: relative;
			.box-item-image{
				width: 340rpx;
				height: 340rpx;
				display: block;
			}
			.box-item-mask{
				width: 100%;
				height: 64rpx;
				background: rgba(0,0,0,.36);
				line-height: 64rpx;
				font-size: $font-size-26;
				text-align: center;
				color: #FFFFFF;
				position: absolute;
				bottom: 0;
				left: 0;
				box-sizing: border-box;
				padding:0 20rpx;
				white-space: normal;
				word-break: break-all;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 1;
			}
		}
	}
</style>
