2022-04-06 16:08:26 +08:00
|
|
|
<template>
|
2022-04-16 22:04:02 +08:00
|
|
|
<view class="container">
|
2022-04-11 23:02:08 +08:00
|
|
|
<view class="search-wrap">
|
|
|
|
<u-search placeholder="搜索" disabled height="32" :show-action="false" @click="handleSearchClick"></u-search>
|
|
|
|
</view>
|
|
|
|
<view class="category-box">
|
|
|
|
<view class="box-left">
|
|
|
|
<u-list @scrolltolower="scrolltolower">
|
2022-04-16 22:04:02 +08:00
|
|
|
<u-list-item class="category-item" v-for="(item, index) in categoryList" :key="item.id">
|
|
|
|
<view class="item-title" :class="{ active: currentIndex === index }" @click="handleCategoryClick(index)">
|
|
|
|
<text>{{ item.name }}</text>
|
2022-04-11 23:02:08 +08:00
|
|
|
</view>
|
|
|
|
</u-list-item>
|
|
|
|
</u-list>
|
|
|
|
</view>
|
|
|
|
<view class="box-right">
|
|
|
|
<view class="category-image">
|
|
|
|
<u--image :showLoading="true" :src="categoryList[currentIndex].image" width="530rpx" height="160rpx" @click="click"></u--image>
|
|
|
|
</view>
|
2022-04-17 14:43:07 +08:00
|
|
|
<view class="sub-category-box" v-for="(item, index) in categoryList[currentIndex].children" :key="item.id">
|
|
|
|
<view class="sub-category-header">
|
|
|
|
<view class="title">{{ item.title }}</view>
|
|
|
|
<view class="more">查看更多</view>
|
|
|
|
</view>
|
|
|
|
<u-grid class="sub-category-grid" col="3">
|
|
|
|
<u-grid-item v-for="(subItem, index) in item.category" :key="subItem.id">
|
|
|
|
<view class="sub-category-item">
|
|
|
|
<u-icon name="photo" :size="80"></u-icon>
|
|
|
|
<text class="sub-category-title">{{ subItem.title }}</text>
|
2022-04-11 23:02:08 +08:00
|
|
|
</view>
|
2022-04-17 14:43:07 +08:00
|
|
|
</u-grid-item>
|
|
|
|
</u-grid>
|
2022-04-11 23:02:08 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
2022-04-16 22:04:02 +08:00
|
|
|
</view>
|
2022-04-06 16:08:26 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-16 22:04:02 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
currentIndex: 0,
|
2022-04-17 14:43:07 +08:00
|
|
|
categoryList: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
this.categoryList.push({
|
|
|
|
id: i,
|
|
|
|
image: '',
|
|
|
|
name: '商品分类' + i,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
title: '分类' + i + '-1',
|
|
|
|
category: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-1-1'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-1-2'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-1-3'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
title: '分类' + i + '-2',
|
|
|
|
category: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-2-1'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-2-2'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
image: '',
|
|
|
|
title: '分类' + i + '-2-3'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2022-04-16 22:04:02 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleSearchClick(e) {
|
2022-04-17 14:43:07 +08:00
|
|
|
uni.$u.route('/pages/search/search')
|
2022-04-16 22:04:02 +08:00
|
|
|
},
|
|
|
|
handleCategoryClick(index) {
|
|
|
|
if (this.currentIndex !== index) {
|
|
|
|
this.currentIndex = index
|
2022-04-11 23:02:08 +08:00
|
|
|
}
|
2022-04-16 22:04:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-06 16:08:26 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-04-17 14:43:07 +08:00
|
|
|
.container {
|
|
|
|
height: calc(100vh - 50px);
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2022-04-11 23:02:08 +08:00
|
|
|
.search-wrap {
|
|
|
|
background: $custom-bg-color;
|
|
|
|
padding: 20rpx;
|
|
|
|
}
|
|
|
|
|
2022-04-16 22:04:02 +08:00
|
|
|
.category-box {
|
2022-04-11 23:02:08 +08:00
|
|
|
display: flex;
|
2022-04-16 22:04:02 +08:00
|
|
|
.box-left {
|
2022-04-11 23:02:08 +08:00
|
|
|
width: 180rpx;
|
|
|
|
padding-top: 20rpx;
|
|
|
|
border-right: $custom-border-style;
|
2022-04-16 22:04:02 +08:00
|
|
|
.category-item {
|
2022-04-11 23:02:08 +08:00
|
|
|
border-bottom: $custom-border-style;
|
|
|
|
padding: 20rpx 0;
|
2022-04-16 22:04:02 +08:00
|
|
|
.item-title {
|
2022-04-11 23:02:08 +08:00
|
|
|
padding-left: 30rpx;
|
|
|
|
font-size: 30rpx;
|
2022-04-16 22:04:02 +08:00
|
|
|
&.active {
|
2022-04-11 23:02:08 +08:00
|
|
|
border-left: 6rpx solid $u-primary;
|
|
|
|
font-weight: 700;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-16 22:04:02 +08:00
|
|
|
.box-right {
|
2022-04-17 14:43:07 +08:00
|
|
|
width: 570rpx;
|
2022-04-16 22:04:02 +08:00
|
|
|
.category-image {
|
2022-04-11 23:02:08 +08:00
|
|
|
padding: 20rpx;
|
|
|
|
}
|
|
|
|
|
2022-04-17 14:43:07 +08:00
|
|
|
.sub-category-box {
|
|
|
|
.sub-category-header {
|
2022-04-16 22:04:02 +08:00
|
|
|
@include flex-space-between;
|
2022-04-17 14:43:07 +08:00
|
|
|
padding: 20rpx;
|
2022-04-11 23:02:08 +08:00
|
|
|
|
2022-04-17 14:43:07 +08:00
|
|
|
.title {
|
|
|
|
font-size: 28rpx;
|
|
|
|
font-weight: 700;
|
|
|
|
}
|
|
|
|
.more {
|
|
|
|
font-size: 22rpx;
|
|
|
|
color: #939393;
|
2022-04-11 23:02:08 +08:00
|
|
|
}
|
2022-04-17 14:43:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.sub-category-grid {
|
|
|
|
padding: 0 15rpx;
|
|
|
|
|
|
|
|
.sub-category-item {
|
|
|
|
@include flex-center(column);
|
|
|
|
background: #fff;
|
2022-04-11 23:02:08 +08:00
|
|
|
|
2022-04-17 14:43:07 +08:00
|
|
|
.sub-category-image {
|
|
|
|
border-radius: 10rpx;
|
|
|
|
/deep/ * {
|
|
|
|
border-radius: 10rpx;
|
|
|
|
}
|
2022-04-11 23:02:08 +08:00
|
|
|
}
|
2022-04-17 14:43:07 +08:00
|
|
|
|
|
|
|
.sub-category-title {
|
|
|
|
margin: 15rpx 0;
|
|
|
|
font-size: 24rpx;
|
2022-04-11 23:02:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-06 16:08:26 +08:00
|
|
|
</style>
|