<template>
	<view class="page">
		<image class="tpbg" src="https://t17.9026.com/web/statics/image/index/3.png" mode=""></image>
		<app-nav-bar v-if="true"
		             :fixed="true"
		             :background-color="''"
		             :xStyle="1"
		             :hasMallSetting="2"
					 :hasHeight="true"
					 @headHeight="headHeight"
		></app-nav-bar>
		<view class="w" :style="{'height':navbarHeight}"></view>
		<view class="center">
			<view class="main-left tagf">
				<view class="tag" :class="{'active':activeIndex===index?true:false}" v-for="(item,index) in classList" :key="index" @click="selectTag(index)">
					{{item.name}}
				</view>
			</view>
			<view class="item" v-for="(item,index) in CompositionList" :key="index" @click="goPage(item.id)">
				<view class="main-between img">
					<view style="width: 419rpx;height: 281rpx;">
						<image style="width: 420rpx;height: 420rpx;" :src="item.cover_img" mode=""></image>
					</view>
					<view style="width: 206rpx;">
						<image style="width: 206rpx;height: 206rpx;" :src="item.banner_imgs[0].banner_imgs" mode=""></image>
						<image style="width: 206rpx;height: 206rpx;" :src="item.banner_imgs[1].banner_imgs" mode=""></image>
					</view>
				</view>
				<view class="main-between pl" >
					<view class="main-between-y">
						<view class="title t-omit">{{item.name}}</view>
						<view class="desc">已售:{{item.sale_num}}套 | {{item.collect_num}}人收藏</view>
						<view class="price"><text>￥</text>{{item.actual_price}}</view>
					</view>
					<view class="cross-bottom arrow-right">
						<image src="https://t17.9026.com/web/statics/image/index/arrow-right-gray.png" mode=""></image>
					</view>
				</view>
			</view>
			<view class="no-more" v-if="noMore && CompositionList.length>0">没有更多了...</view>
			<appNoData v-if="CompositionList.length==0" :background="'#f8f8f8'" :title="'该分类暂无套装'"></appNoData>
		</view>
	</view>
</template>

<script>
	import appNavBar from '@/components/page-component/index/app-nav-bar.vue';
	import appNoData from '@/components/page-component/app-no-goods/app-no-goods.vue';
	export default {
		components:{
			appNavBar,
			appNoData
		},
		data() {
			return {
				activeIndex:0,
				navbarHeight:'',
				
				classList:[],
				CompositionList:[],
				noMore:false,
			};
		},
		onLoad(option) {
			this.getCompositionClass(option.cat_id)
			this.getCompositionList(option.cat_id)
		},
		methods:{
			selectTag(index){
				this.activeIndex=index
				this.getCompositionList(this.classList[index].id)
			},
			headHeight(e){
				this.navbarHeight=e+'px'
			},
			goPage(id){
				uni.navigateTo({
					url:'/pages/case/projectInfo?id='+id
				})
			},
			getCompositionClass(cat_id){
				this.$request({
					url: this.$api.composition.cat_list,
					method:'post'
				}).then(res=>{
					if(res.code===0){
						this.classList=res.data
						this.classList.splice(0,0,{id:'',name:'全部'})
					}
					for (let i = 0; i < this.classList.length; i++) {
						if(this.classList[i].id==cat_id){
							this.activeIndex=i
						}
					}
				})
			},
			getCompositionList(cat_id=''){
				this.$request({
					url:this.$api.composition.list,
					method:'post',
					data:{
						cat_id:cat_id
					}
				}).then(res=>{
					if(res.code===0){
						this.CompositionList=res.data.list
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.no-more {
		font-size: 24rpx;
		font-weight: 500;
		color: #666666;
		margin-top: 37rpx;
		text-align: center;
	}
	.page{
		position: relative;
		min-height: 100vh;
	}
	.tpbg{
		width: 750rpx;
		height: 368rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: -1;
	}
	.w{
		width: 750rpx;
	}
	.center{
		width: 750rpx;
		height: auto;
		background: #F8F8F8;
		border-radius: 20rpx;
		overflow: hidden;
		padding: 36rpx;
		.tagf{
			padding-bottom: 26rpx;
		}
		.tag{
			min-width: 131rpx;
			height: 51rpx;
			background: #EFEFEF;
			border-radius: 10rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;
			text-align: center;
			line-height: 51rpx;
			padding: 0 15rpx;
			margin-right: 20rpx;
		}
		.active{
			background: #A18353;
			color: #FFFFFF;
		}
		.item{
			width: 678rpx;
			height: auto;
			background: #FFFFFF;
			border-radius: 8rpx;
			margin:0 auto 24rpx;
			padding: 27rpx 22rpx;
			.img{
				height: 420rpx;
				border-radius: 10rpx;
				overflow: hidden;
			}
			.pl{
				margin-top: 25rpx;
				.title{
					width: 620rpx;
					font-size: 32rpx;
					font-weight: bold;
					color: #222222;
				}
				.desc{
					font-size: 22rpx;
					font-weight: 500;
					color: #999999;
					margin: 10rpx 0 13rpx;
				}
				.price{
					text{
						font-size: 28rpx;
					}
					font-size: 38rpx;
					font-weight: 500;
					color: #F93F3F;
				}
				.arrow-right{
					image{
						width: 15rpx;
						height: 26rpx;
					}
				}
			}
		}
	}
</style>
