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">
|
2022-04-19 17:58:39 +08:00
|
|
|
<view>
|
|
|
|
<view class="category-item" v-for="(item, index) in categoryList" :key="item.id">
|
2022-04-16 22:04:02 +08:00
|
|
|
<view class="item-title" :class="{ active: currentIndex === index }" @click="handleCategoryClick(index)">
|
|
|
|
<text>{{ item.name }}</text>
|
2022-04-11 23:02:08 +08:00
|
|
|
</view>
|
2022-04-19 17:58:39 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
2022-04-11 23:02:08 +08:00
|
|
|
</view>
|
|
|
|
<view class="box-right">
|
2022-04-19 17:58:39 +08:00
|
|
|
<image class="category-image" :showLoading="true" :src="categoryList[currentIndex].image" width="530rpx" height="160rpx" @click="click"></image>
|
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">
|
2022-04-19 17:58:39 +08:00
|
|
|
<u-grid-item v-for="(subItem, subIndex) in item.category" :key="subItem.id">
|
2022-04-17 14:43:07 +08:00
|
|
|
<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,
|
2022-04-19 17:58:39 +08:00
|
|
|
image: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
|
2022-04-17 14:43:07 +08:00
|
|
|
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
|
|
|
|
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-19 17:58:39 +08:00
|
|
|
width: 200rpx;
|
2022-04-11 23:02:08 +08:00
|
|
|
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;
|
2022-04-19 17:58:39 +08:00
|
|
|
font-size: 28rpx;
|
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-19 17:58:39 +08:00
|
|
|
flex: 1;
|
2022-04-16 22:04:02 +08:00
|
|
|
.category-image {
|
2022-04-19 17:58:39 +08:00
|
|
|
width: 510rpx;
|
|
|
|
height: 160rpx;
|
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-19 17:58:39 +08:00
|
|
|
padding: 30rpx 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-title {
|
|
|
|
margin: 15rpx 0;
|
|
|
|
font-size: 24rpx;
|
2022-04-11 23:02:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-06 16:08:26 +08:00
|
|
|
</style>
|