mallSelect.vue 5.0 KB
<template>
	<view class="goods_show">
		<view class="show_title">商品预览</view>
		<view class="cate-content">
			<!-- 左侧 一级分类 -->
			<scroll-view class="cate-left" :scroll-y="true" :style="{ height: `${scrollHeight}px` }">
			  <text v-for="(item, index) in classifyList" :key="index" class="type-nav" :class="{ selected: curIndex == index }" @click="handleSelectNav(index)">{{ item.name }}</text>
			</scroll-view>
			<!-- 右侧 二级分类 -->
			<scroll-view class="cate-right" :scroll-y="true" :style="{ height: `${scrollHeight}px` }">
				<!-- 分类显示列表 -->
			  <GoodsList :goodsList="showProductList" />
				<!-- 空数据显示 -->
				<view v-show="showProductList.length === 0" >
					<u-empty mode="list" />
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import GoodsList from '@/components/goodsList.vue'
	export default {
		name:"mallSelect",
		components: { GoodsList },
		props: { 
			scrollHeight: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				// 商品分类列表
				classifyList: [
					{name: '篮球'}, {name: '饮品'}, {name: '足球'}, {name: '羽毛球'}, {name: '乒乓球'}, {name: '棒球'}, {name: '排球'}, {name: '网球'}
				], 
				showProductList: [
					{id: 1, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 2, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 4, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 5, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 6, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 7, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'},
					{id: 8, pic: 'https://cbu01.alicdn.com/img/ibank/2016/759/755/3743557957_600065101.jpg', name: '今麦郎熟水凉白开饮用核实过后广寒深宫hi哦干哈...'}
				], // 当前展示商品列表
				curIndex: 0, // 一级分类
				activeIndex: 0, // 二级分类
			}
		},
		methods: {
			// 一级分类:选中分类
			handleSelectNav(index) {
			  this.curIndex = index
				this.activeIndex = 0
			},
			// 获取商品列表
			async getShopList() {
				
			},
			// 显示当前商品列表
			showProduct() {
				
			},
			onCellect(id) {
			
			}
		}
	}
</script>

<style lang="scss" scoped>
.goods_show{
	border-radius: 20rpx 20rpx 0 0;
	overflow: hidden;
	.show_title{
		position: relative;
		height: 84rpx;
		box-sizing: border-box;
		border-bottom: 2rpx solid #eee;
		padding-left: 46rpx;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 84rpx;
		background-color: #fff;
		&::before{
			content: '';
			position: absolute;
			top: 50%;
			left: 30rpx;
			transform: translateY(-50%);
			width: 6rpx;
			height: 24rpx;
			border-radius: 20rpx;
			background-color: #FFB336;
		}
	}
}
	
// 分类内容
.cate-content {
	display: flex;
	z-index: 1;
	background: #fff;
}
	// 一级分类+二级分类 20
	.cate-left {
	  height: 100%;
	  display: flex;
	  flex-direction: column;
	  flex: 0 0 23%;
	  background: #f8f8f8;
	  color: #444;
	}
	
	.cate-right {
	  display: flex;
	  flex-direction: column;
	  height: 100%;
	  overflow: hidden;
	  .secondary-nav{
		  position: relative;
		  height: 110rpx;
		  padding: 30rpx;
		  .nav-list{
			  display: inline-block;
			  font-size: 24rpx;
			  color: #666;
			  padding: 10rpx;
			  white-space: nowrap;
			  background-color: #EDEFF2;
			  border-radius: 6rpx;
			  margin-right: 12rpx;
			  &.activeStyle{
				color: #333;
				background-color: rgba(64, 174, 54, .2);
			  }
		  }
		  .showAll{
			  display: flex;
			  justify-content: center;
			  align-items: center;
			  position: absolute;
			  top: 0;
			  right: 0;
			  width: 76rpx;
			  height: 110rpx;
			  background-color: #fff;
		  }
	  }
	  .cate-right-cont {
	    width: 100%;
	    display: flex;
	    flex-flow: row wrap;
	    align-content: flex-start;
	
	    .cate-two-box {
	      width: 100%;
	    }
	  }
	}
	
	// 左侧一级分类
	.type-nav {
	  position: relative;
	  width: 180rpx;
	  height: 110rpx;
	  z-index: 10;
	  display: block;
	  font-size: 28rpx;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  &.selected {
	    background: #fff;
	    color: #FFB336;
	    border-right: none;
	    font-size: 28rpx;
			&::before{
				content: '';
				position: absolute;
				top: 50%;
				left: 0;
				transform: translateY(-50%);
				width: 6rpx;
				height: 24rpx;
				border-radius: 20rpx;
				background-color: #FFB336;
			}
	  }
	}
	
</style>