<template>
	<view class="classify">
		<view class="item-view" @click="viewGoods({ type: 'all', name: '全部宝贝' })">
			<view>全部宝贝</view>
			<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
		</view>
		<view class="item-view" @click="viewGoods({ type: 'new', name: '新品上架' })">
			<view>新品上架</view>
			<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
		</view>
		<view class="classify-container">
			<view v-for="classifyA in classifyList" :key="classifyA.gc_parent_id" class="classify-view">
				<view class="title">{{ classifyA.gc_parent_name }}</view>
				<view class="classifyA-view">
					<view v-for="classifyB in classifyA.gc_child" :key="classifyB.gc_id" class="classifyB-item u-line-1" @click="viewGoods({ type: classifyB.gc_parent_id, name: classifyB.gc_parent_name })">{{ classifyB.gc_parent_name }}</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			classifyList: [],
		}
	},
	onLoad(option) {
		this.sid = option.id;
		this.getStoreClassifyList();
	},
	methods: {
		viewGoods({ type, name }) {
			console.log(11);
			this.$u.route('pageC/merchant/classifyGoods', { sid: this.sid, cid: type, name: name });
		},
		getStoreClassifyList() {
			this.$u.api.getStoreClassifyList({ id: this.sid }).then(res => {
				this.classifyList = res.data;
			})
		},
	}
};
</script>
<style lang="scss" scoped>
.classify {
	padding-top: 20rpx;
	background-color: #ECECEC;
	min-height: calc(100vh - var(--window-top));
	.item-view {
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 35rpx 30rpx;
		font-size: 30rpx;
		color: rgba(51,51,51,1);
		background-color: #FFFFFF;
	}
	.classify-container {
		.classify-view {
			padding: 30rpx 35rpx;
			background-color: #FFFFFF;
			margin-bottom: 20rpx;
			.title {
				font-size: 30rpx;
				color: rgba(51,51,51,1);
				margin-bottom: 34rpx;
			}
			.classifyA-view {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				.classifyB-item {
					width: 335rpx;
					height: 74rpx;
					line-height: 74rpx;
					background: rgba(255,241,230,1);
					padding: 0 20rpx;
					font-size: 30rpx;
					color: rgba(51,51,51,1);
					margin-bottom: 20rpx;
				}
			}
		}
	}
}
</style>