<template>
	<view class="page">
		<view class="tpbg">
			<uni-nav-bar left-icon="back" backgroundColor="transparent" :border="false" color="#555555" @clickLeft="back" :statusBar="true"></uni-nav-bar>
		</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>
	let _this
	// import appNavBar from '@/components/index/app-nav-bar.vue';
	import appNoData from '@/components/index/app-no-goods.vue';
	export default {
		components:{
			// appNavBar,
			appNoData
		},
		data() {
			return {
				activeIndex:0,
				navbarHeight:'',
				
				classList:[],
				CompositionList:[],
				noMore:false,
			};
		},
		onLoad(option) {
			_this=this
			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/program/program?id='+id
				})
			},
			getCompositionClass(cat_id){
				_this.$post('plugin/composition/api/index/cat-list',{
					success(res){
						if(res.code===0){
							this.classList=res.data.list
							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
							}
						}
					}
				})	
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			getCompositionList(cat_id=''){
				let dk_estate_id = uni.getStorageSync('dk_estate_id') ? uni.getStorageSync('dk_estate_id') : 0;
				_this.$post('plugin/composition/api/index/cat-list',{
					data:{
						cat_id:cat_id,
						estate_id: 0
					},
					success(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;
		background-image: url("https://t17.9026.com/web/statics/image/index/3.png");
		background-size: 100%;
	}
	.w{
		width: 750rpx;
	}
	.center{
		border-radius: 30rpx;
		overflow: hidden;
		margin-top: 368rpx;
		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>
