<template>
	<view class="content_box" :style="{marginTop:  navBarHeight+'px'}">
		<view class="u-flex u-col-center wrapper-box">
			<view class="scroll-box" style="background-color: #F6F6F6;">
				<scroll-view class="left u-flex-col u-col-center" enable-back-to-top scroll-y>
					<view class="type-list u-ellipsis-1" :class="[{ 'list-active': listId == index }]" v-for="(item, index) in categoryData" :key="index" @tap="onType(index,item)">
						<!-- <view class="line" :class="[{ 'line-active': listId == index }]"></view> -->
						{{ item.name }}
					</view>
					<view class="hack-tabbar"></view>
				</scroll-view>
			</view>
			<view style="height: 100%;width:calc(100% - 200upx);">
				<view class="subtitle">
					{{item.name}}
				</view>
				<scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation>
					<!-- <view class="right" v-if="categoryData.length">
						<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image" mode="aspectFill"></image>

						<view class="item-list" v-for="(list, index1) in categoryData[listId].children" :key="index1">
							<view class="type-box u-flex u-row-between u-col-center">
								<text class="type-title">{{ list.name }}</text>
								<view class="more u-flex u-col-center" @tap="jump('/pages/goods/list', { id: list.id })">
									<text>查看更多</text>
									<view class="u-iconfont uicon-arrow-right" style="color: #999;font-size: 28rpx;"></view>
								</view>
							</view>
							<view class="item-box u-flex">
								<view class="u-flex-col goods-item" @tap="jump('/pages/goods/list', { id: mlist.id })" v-for="(mlist, index2) in list.children" :key="index2">
									<image class="item-img" lazy-load :src="mlist.image" mode="aspectFill"></image>
									<view class="item-title u-ellipsis-1 ">{{ mlist.name }}</view>
								</view>
							</view>
						</view>

						
						<shopro-empty
							v-show="!categoryData[listId].children.length"
							:image="$IMG_URL + '/imgs/empty/empty_goods.png'"
							tipText="暂无该商品，还有更多好货等着你噢~"
						></shopro-empty>
						<view class="hack-tabbar"></view>
					</view> -->
					<view class="shopList">
						<view class="shopItem" v-for="(item,index) in shopList" :key="index">
							<view class="shopImg">
								<image :src="item.img" mode="widthFix"></image>
							</view>
							<view class="infoBox">
								<view class="shopTitle">
									<image src="/static/images/xinp.png" mode="widthFix"></image>
									<text>{{item.title}}</text>
								</view>
								<view class="progress">
									<u-line-progress active-color="#F0D2A0" 
									:show-percent="false" height="20"
									style="flex:1"
									 inactive-color="#F6EEE6" :percent="70"></u-line-progress>
									<text>已售{{item.num}}套</text>
								</view>
								<view class="price">
									<view class="priceInfo">
										<text class="mainPrice">￥{{item.mainprice}}</text>
										<text class="subPrice">￥{{item.subprice}}</text>
									</view>
									<view class="btn">去抢购</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
export default {
	components: {},
	data() {
		return {
			listId: 0,
			categoryData: {},
			navBarTop:0,
			navBarHeight:0,
			shopList:[
				{
					img:'/static/images/shopdesc.png',
					title:'SK-II 熬夜肌肤“重启”秘籍 熬夜肌SK-II 熬夜肌肤“重启”秘籍 熬夜肌',
					num:288,
					mainprice:389.00,
					subprice:999.00
				},
				{
					img:'/static/images/shopdesc.png',
					title:'SK-II 熬夜肌肤“重启”秘籍 熬夜肌SK-II 熬夜肌肤“重启”秘籍 熬夜肌',
					num:288,
					mainprice:389.00,
					subprice:999.00
				},
				{
					img:'/static/images/shopdesc.png',
					title:'SK-II 熬夜肌肤“重启”秘籍 熬夜肌SK-II 熬夜肌肤“重启”秘籍 熬夜肌',
					num:288,
					mainprice:389.00,
					subprice:999.00
				},
				{
					img:'/static/images/shopdesc.png',
					title:'SK-II 熬夜肌肤“重启”秘籍 熬夜肌SK-II 熬夜肌肤“重启”秘籍 熬夜肌',
					num:288,
					mainprice:389.00,
					subprice:999.00
				}
			],
			item:{}
		};
	},
	computed: {},
	props: {
		categoryStyleId: {
			type: Number,
			default: 0
		}
	},
	async created() {
		let statuBar = uni.getSystemInfoSync().statusBarHeight;
		let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
		
		this.navBarTop = menuButtonInfo.top;
		this.navBarHeight = menuButtonInfo.height;
		console.log('%c当前分类：三级分类', 'color:green;background:yellow');
		await this.getCategory();
	},
	
	methods: {
		getCategory() {
			this.$http('category.detail', {
				id: this.categoryStyleId
			}).then(res => {
				if (res.code === 1) {
					this.categoryData = res.data.children;
					this.item = this.categoryData[0]
				}
			});
		},
		onType(id,item) {
			this.item=item
			this.listId = id;
		},
		// 路由跳转
		jump(path, parmas) {
			this.$Router.push({
				path: path,
				query: parmas
			});
		}
	}
};
</script>

<style lang="scss">
.hack-tabbar {
	height: calc(100rpx + env(safe-area-inset-bottom) / 2);
	width: 100%;
}
.content_box {
	margin-top: 1upx;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	height: calc(100% - 88upx);
	
}

.wrapper-box {
	flex: 1;
	margin-top: 1upx;
	height: 100%;
}

.scroll-box {
	height: 100%;
	flex: 1;
	background: #21222B;
}

.left {
	width: 200upx;
	height: 100%;
	flex: 1;
	background: #1A1A22;
	.list-active {
		background: #21222B;
		color: #FFFFFF !important;
		// font-weight: bold !important;
	}

	.line-active {
		background: #e6b873;
	}

	.type-list {
		height: 84upx;
		position: relative;
		width: 200rpx;
		padding-left: 25rpx;
		line-height: 84rpx;
		font-size: 28upx;
		font-weight: 400;
		color:#808292;
		// color: rgba(102, 102, 102, 1);

		.line {
			width: 10upx;
			height: 100%;
			position: absolute;
			left: 0;
		}
	}
}

.right {
	padding: 0 30upx;
	flex: 1;
	height: 100%;

	.type-img {
		width: 505rpx;
		height: 150rpx;
		background: #ccc;
		border-radius: 10rpx;
		margin-top: 30rpx;
	}

	.item-list {
		.type-box {
			height: 84rpx;

			.type-title {
				font-size: 28rpx;
				font-weight: bold;
			}

			.more {
				font-size: 26rpx;
				color: #999;
			}
		}

		.item-box {
			flex-wrap: wrap;

			.goods-item {
				margin-right: 20rpx;
				margin-bottom: 20rpx;

				&:nth-child(3n) {
					margin-right: 0;
				}

				.item-img {
					width: 150rpx;
					height: 150rpx;
					background: #f5f5f5;
					border-radius: 6rpx;
				}

				.item-title {
					font-size: 24rpx;
					line-height: 24rpx;
					margin-top: 10rpx;
					width: 150rpx;
					text-align: center;
				}
			}
		}
	}
}
.subtitle{
	font-size: 30upx;
	font-family: Alibaba PuHuiTi;
	font-weight: 400;
	color: #FFFFFF;
	margin:20upx;
}
.shopList{
		padding-bottom: 35rpx;
		
		.shopItem{
			// height: 650px;
			margin:0 22upx;
			margin-bottom: 24upx;
			background: #FFFFFF;
			box-shadow: 0upx 6upx 16upx 0upx rgba(25,25,25,0.05);
			border-radius: 20upx;
			overflow: hidden;
			.shopImg{
				width:100%;
				background: #D3D3D3;
				box-shadow: 0upx 6upx 16upx 0upx rgba(25,25,25,0.05);
				border-radius: 20upx 20upx 0upx 0upx;
				image{
					height:auto;
					
					width:100%;
				}
			}
			.infoBox{
				margin-top: 20upx;
				.shopTitle{
					display: flex;
					align-items: center;
					
					image{
						width:180upx;
						height:auto
					}
					text{
						font-size: 34upx;
						color: #333333;
						text-overflow: ellipsis;
						overflow: hidden;
						white-space: nowrap;
						margin-left: 22upx;
					}
				}
				.progress{
					display: flex;
					align-items: center;
					padding:0 20upx;
					margin: 25upx 0;
					text{
						margin-left: 24upx;
						font-size: 24upx;
						color: #333333;
					}
				}
				.price{
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding:0 30upx;
					margin-bottom: 30upx;
					.mainPrice{
						font-size: 34upx;
						color: #111111;
						font-weight: bold;
					}
					.subPrice{
						font-size: 24upx;
						text-decoration: line-through;
						color: #C4BFBC;
						margin-left:20upx;
					}
					.btn{
						padding:20upx 45upx;
						background: #111111;
						border: 1px solid #EAEAEA;
						border-radius: 33px;
						font-size: 30upx;
						color: #FFFFFF;
					}
				}
			}
		}
		
	}
</style>
