<template>
	<view class="container instrument clearfix">
		<tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading	="true" :loadingType="5"></tui-skeleton>
		<template v-else>
			<view class="instrument-btn" v-if="buttonName" :style="{paddingBottom :isIphoneX ? '68rpx' : '34rpx'}">
				<view class="btn" @click="ButtonNavigateTo(buttonLinkType,buttonLinkParam.id,buttonLink,buttonLinkKeyword)">{{ buttonName }}</view>
			</view>
			<view class="banner clearfix">
				<view class="banner-image">
					<image :src="banner" mode=""></image>
				</view>
				<view class=content v-if="linkId == 6">
					<text>{{ content }}</text>
				</view>
			</view>
			<view class="instrument-list clearfix" :style="{paddingBottom :isIphoneX ? '83px' : '34px'}">
				<view class="list-item-cell" v-for="(item,index) in list" :key="index">
					<view class="list-item-title">
						<view class="title" :class="item.link ? 'float' : ''">
							<text>{{ item.title }}</text>
						</view>
						<view class="more" v-if="item.link" @click="NavToDetailPage(item)">
							<text>查看更多</text>
							<text class="iconfont icon-xiangyou"></text>
						</view>
					</view>
					<view class="list-item-pros">
						<view class="item-pros" v-for="(pros,prosIndex) in item.floorData" :key="prosIndex" @click="NavToDetailPage(pros)">
							<view class="item-pros-image">
								<image :src="pros.image" mode=""></image>
							</view>
							<view class="item-pros-name">{{ pros.title }}</view>
						</view>
					</view>
				</view>
			</view>
		</template>
		<!-- 侧边 -->
		<scroll-top :isScrollTop="isScrollTop" :bottom="200"></scroll-top>
	</view>
</template>

<script>
	export default{
		components:{
			
		},
		data(){
			return{
				isIphoneX:this.$store.state.isIphoneX,
				banner:'',
				list:[],
				linkId:0,
				isScrollTop:false,
				linkTitle:'',
				skeletonShow:true,
				content:'',
				buttonName:'',
				buttonLink:'',
				buttonLinkType:'',
				buttonLinkParam:{},
				buttonLinkKeyword:''
			}
		},		
		onLoad(option) {
			console.log(option)
			let _self = this
			this.linkId = option.linkId
			this.linkTitle = option.title
			this.GetPageTopicInfo()
		},
		methods:{
			GetPageTopicInfo(){//获取数据
				this.ProductService.GetPageTopic({pageId:this.linkId, source:2}).then(response =>{
					let { floorList, page } = response.data
					this.list = floorList
                    this.banner = page.image
                    this.content = page.content
                    this.buttonLink = page.buttonLink
                    this.buttonName = page.buttonName
                    this.buttonLinkType = page.linkType
                    this.buttonLinkParam = page.linkParam
                    this.buttonLinkKeyword = page.keywords
                    uni.setNavigationBarTitle({title:page.title})
					this.skeletonShow = false
				}).catch(error =>{
					this.$util.msg(error.msg,2000)
				})
			},
			NavToDetailPage(pros) {//跳转
				if(pros.linkType){
					const typeMap = {
					 	1:`/pages/goods/goods-instrument?linkId=${pros.linkParam.id}&title=${pros.title}`,
					 	2:`/pages/goods/instrument-details?id=${pros.linkParam.id}`,
						4:`/pages/h5/activity/activity?title=${pros.crmTitle}&link=${pros.crmLink}`,
					 	5:`/pages/goods/product?id=${pros.linkParam.id}`,
					 	// 7:`/pages/supplier/user/my-shop?shopId=${pros.linkParam.id}`,
					 	8:'/pages/h5/activity/activity-list',
					 	9:'/pages/second/form/introduce',
					 	10:'/pages/second/product/product-list',
					 	11:'/pages/second/form/form',
					 	12:`/pages/search/search?keyWord=${pros.linkParam.keyword}`,
					 	13:`/pages/h5/article/path?link=${pros.link}`,
					 	14:`/pages/h5/article/path?link=${pros.link}`,
					 	15:`/pages/h5/article/path?link=${pros.link}`,
					 	17:'/pages/login/register-select',
					 	18:`/pages/h5/article/path?link=${pros.link}`,
					 	19:`/pages/search/search-supplier?keyWord=${pros.linkParam.keyword}`
					}
					const url = typeMap[pros.linkType]
					uni.navigateTo({
					  	url:url
					})
				}
			},
			ButtonNavigateTo(linkType,linkId,linkHref,keyword) {//跳转
				this.$api.BannerNavigateTo(linkType,linkId,linkHref,keyword)
			}
		},
		onPageScroll(e){//实时获取到滚动的值
			if(e.scrollTop>600){
				this.isScrollTop = true
			}else{
				this.isScrollTop = false
			}	
		},
		onShow() {

		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F7F7F7;
	}
	.instrument{
		width: 100%;
		height: auto;
		.banner{
			box-sizing: border-box;
			padding:24rpx;
			width: 100%;
			.banner-image{
				width: 100%;
				height: 248rpx;
				border-radius: 16rpx;
				float: left;
				image{
					width: 100%;
					height: 248rpx;
					border-radius: 16rpx;
				}
			}
			.content{
				width: 100%;
				margin-top: 10rpx;
				float: left;
				box-sizing: border-box;
				background-color: #FFFFFF;
				font-size: $font-size-26;
				color: #666666;
				text-align: justify;
				line-height: 36rpx;
			}
		}
		.instrument-btn{
			width: 100%;
			box-sizing: border-box;
			padding: 7rpx 24rpx;
			background-color: #FFFFFF;
			position: fixed;
			bottom: 0;
			left: 0;
			z-index: 999;
			.btn{
				width: 100%;
				height: 100%;
				background-image: $btn-confirm;
				line-height: 84rpx;
				border-radius: 42rpx;
				text-align: center;
				font-size: 26rpx;
				color: #FFFFFF;
			}
		}
		.instrument-list{
			width: 100%;
			height: auto;
			box-sizing: border-box;
			padding: 0 24rpx;
			.list-item-cell{
				width: 100%;
				height: auto;
				float: left;
				.list-item-title{
					width: 100%;
					height: 88rpx;
					line-height: 88rpx;
					float: left;
					.title{
						font-size: $font-size-28;
						line-height: 80rpx;
						color: $text-color;
						font-weight: bold;
						&.float{
							float: left;
						}
					}
					.more{
						font-size: $font-size-26;
						line-height: 80rpx;
						color: #999999;
						height: 80rpx;
						float: right;
						.icon-xiangyou{
							font-size: $font-size-28;
							margin-left: 10rpx;
						}
					}
				}
				.list-item-pros{
					width: 100%;
					height: auto;
					float: left;
					.item-pros{
						width: 340rpx;
						height: 414rpx;
						float: left;
						margin-right: 20rpx;
						margin-bottom: 20rpx;
						background-color: #FFFFFF;
						border-radius: 16rpx;
						&:nth-child(2n){
							margin-right: 0;
						}
						.item-pros-image{
							width: 340rpx;
							height: 340rpx;
							float: left;
							image{
								width: 340rpx;
								height: 340rpx;
								display: block;
								border-radius: 16rpx 16rpx 0 0;
							}
						}
						.item-pros-name{
							width: 100%;
							height: 74rpx;
							line-height: 74rpx;
							box-sizing: border-box;
							padding: 0 24rpx;
							white-space: normal;
							word-break: break-all;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 1;
							text-align: center;
							font-size: $font-size-26;
							line-height: 74rpx;
							text-align: center;
						}
					}
				}
			}
		}
	}
</style>
