|
|
|
<template>
|
|
|
|
<view class="content_box">
|
|
|
|
<view style="display: flex;align-items: center;">
|
|
|
|
<view style="flex: 1;">
|
|
|
|
|
|
|
|
<sh-grid-swiper
|
|
|
|
:list="categoryData"
|
|
|
|
:oneRowNum="5"
|
|
|
|
:isIndex="false"
|
|
|
|
ref="swiper"
|
|
|
|
@catagory="catagoryClick"
|
|
|
|
></sh-grid-swiper>
|
|
|
|
</view>
|
|
|
|
<wyb-drop-down
|
|
|
|
ref="dropDown"
|
|
|
|
minHeight="400"
|
|
|
|
:categoryData="categoryData"
|
|
|
|
:options="options"
|
|
|
|
@show="showHandle"
|
|
|
|
>
|
|
|
|
<view class="dropDown">
|
|
|
|
<view class="item" v-for="(item,index) in categoryData" @click="catagoryClick1(item,index)" :key="index">
|
|
|
|
<image class="tab-img" :src="item.image"></image>
|
|
|
|
<text class="">{{ item.name }}</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</wyb-drop-down>
|
|
|
|
<!-- <view @click="zhankai" class="zhankai">
|
|
|
|
<text>{{scroll?'展':"收"}}</text>
|
|
|
|
<text>{{scroll?'开':"起"}}</text>
|
|
|
|
</view> -->
|
|
|
|
</view>
|
|
|
|
<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-flex u-col-center"
|
|
|
|
:class="[{ 'list-active': listId == item.id }]"
|
|
|
|
v-for="(item, index) in twoData"
|
|
|
|
:key="index"
|
|
|
|
@tap="onType(item)"
|
|
|
|
>
|
|
|
|
<view class="u-ellipsis-1 list-item" :class="[{ 'line-active': listId == item.id }]">{{ item.name }}</view>
|
|
|
|
</view>
|
|
|
|
<view class="hack-tabbar"></view>
|
|
|
|
</scroll-view>
|
|
|
|
</view>
|
|
|
|
<view style="height: 100%;width: 100%;">
|
|
|
|
<scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation>
|
|
|
|
<view class="right" style="width: calc(100vw - 200rpx);" v-if="categoryData.length">
|
|
|
|
<!-- <image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image" lazy-load mode="aspectFill"></image> -->
|
|
|
|
<!-- <view class="type-box u-flex u-col-center u-row-center">
|
|
|
|
<view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view>
|
|
|
|
<text class="type-title">{{ categoryData[listId].name }}</text>
|
|
|
|
<view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view>
|
|
|
|
</view> -->
|
|
|
|
<!-- <view class="item-list">
|
|
|
|
<view class="item-box u-flex">
|
|
|
|
<view
|
|
|
|
class="u-flex-col u-col-center goods-item"
|
|
|
|
@tap="jump('/pages/goods/list', { id: list.id })"
|
|
|
|
v-for="(list, index1) in categoryData[listId].children"
|
|
|
|
:key="index1"
|
|
|
|
>
|
|
|
|
<image class="item-img" lazy-load :src="list.image" mode="aspectFill"></image>
|
|
|
|
<view class="item-title u-ellipsis-1 ">{{ list.name }}</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<shopro-empty
|
|
|
|
v-show="!categoryData[listId].children.length"
|
|
|
|
:image="$IMG_URL + '/imgs/empty/empty_goods.png'"
|
|
|
|
marginTop="200rpx"
|
|
|
|
tipText="暂无该商品,还有更多好货等着你噢~"
|
|
|
|
></shopro-empty>
|
|
|
|
<view class="hack-tabbar"></view>
|
|
|
|
</view> -->
|
|
|
|
<goodsList :typeId="listId"></goodsList>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</scroll-view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import wybDropDown from '@/components/wyb-drop-down/wyb-drop-down.vue'
|
|
|
|
import shGridSwiper from './item.vue';
|
|
|
|
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
|
|
|
|
import goodsList from '@/components/listcomponent.vue'
|
|
|
|
export default {
|
|
|
|
components: {shGridSwiper,wybDropDown,goodsList},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listId: 0,
|
|
|
|
categoryData: [
|
|
|
|
|
|
|
|
],
|
|
|
|
twoData:[],
|
|
|
|
options: [{
|
|
|
|
custom: true // 该栏目开启自定义模式
|
|
|
|
}],
|
|
|
|
selectedItem:{}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
props: {
|
|
|
|
categoryStyleId: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
console.log('%c当前分类:二级分类', 'color:green;background:yellow');
|
|
|
|
this.getCategory();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
showHandle(val){
|
|
|
|
console.log("yuyu",val)
|
|
|
|
this.$emit('isDrop',val)
|
|
|
|
},
|
|
|
|
catagoryClick1(i,index){
|
|
|
|
console.log(i,this.categoryData,this.$refs.swiper.newList,"--==");
|
|
|
|
console.log(index%5);
|
|
|
|
let firstIndex;
|
|
|
|
let secondIndex;
|
|
|
|
let arr = this.$refs.swiper.newList
|
|
|
|
arr.forEach((item,index)=>{
|
|
|
|
item.forEach((q,w)=>{
|
|
|
|
if(i.id == q.id ){
|
|
|
|
console.log(item,index,w,"5656")
|
|
|
|
firstIndex = index;
|
|
|
|
secondIndex = w;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.$refs.swiper.getjump(i,firstIndex,secondIndex)
|
|
|
|
},
|
|
|
|
catagoryClick(i){
|
|
|
|
// let index = this.categoryData.findIndex(item=>{
|
|
|
|
// return item.name==i.name
|
|
|
|
// })
|
|
|
|
// this.onType(index)
|
|
|
|
console.log(i,"gygy")
|
|
|
|
this.selectedItem = i
|
|
|
|
this.twoData = i.children
|
|
|
|
if(this.twoData.length>0){
|
|
|
|
this.listId = this.twoData[0].id;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$refs.dropDown.dropDown=false;
|
|
|
|
this.$refs.dropDown.dropOver = false;
|
|
|
|
},
|
|
|
|
zhankai(){
|
|
|
|
this.$refs.dropDown.dropDown=true
|
|
|
|
},
|
|
|
|
getCategory() {
|
|
|
|
this.$http('category.detail', {
|
|
|
|
id: this.categoryStyleId
|
|
|
|
}).then(res => {
|
|
|
|
if (res.code === 1) {
|
|
|
|
|
|
|
|
this.categoryData = res.data.children;
|
|
|
|
console.log(this.categoryData[this.listId],"iiiii",this.listId)
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onType(item) {
|
|
|
|
console.log(item)
|
|
|
|
this.listId = item.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 {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
overflow: hidden;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.wrapper-box {
|
|
|
|
flex: 1;
|
|
|
|
margin-top: 1upx;
|
|
|
|
// height: 100%;
|
|
|
|
height: calc(100% - 160rpx);
|
|
|
|
}
|
|
|
|
|
|
|
|
.scroll-box {
|
|
|
|
height: 100%;
|
|
|
|
flex: 1;
|
|
|
|
background: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.left {
|
|
|
|
width: 200upx;
|
|
|
|
height: 100%;
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
.list-active {
|
|
|
|
background: #fff;
|
|
|
|
color: #ffff !important;
|
|
|
|
}
|
|
|
|
.list-item {
|
|
|
|
width: 180rpx;
|
|
|
|
height: 64rpx;
|
|
|
|
line-height: 64rpx;
|
|
|
|
padding-left: 14rpx;
|
|
|
|
text-align: center;
|
|
|
|
font-size:22rpx;
|
|
|
|
}
|
|
|
|
.line-active {
|
|
|
|
width: 180rpx;
|
|
|
|
height: 64rpx;
|
|
|
|
// background: #17C161;
|
|
|
|
border-radius: 0rpx 32rpx 32rpx 0rpx;
|
|
|
|
color: #17C161;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.type-list {
|
|
|
|
height: 100rpx;
|
|
|
|
position: relative;
|
|
|
|
width: 200rpx;
|
|
|
|
font-size: 28upx;
|
|
|
|
font-weight: 400;
|
|
|
|
color: rgba(102, 102, 102, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.right {
|
|
|
|
// padding: 0 30upx;
|
|
|
|
flex: 1;
|
|
|
|
min-height: 100%;
|
|
|
|
|
|
|
|
.type-img {
|
|
|
|
width: 505rpx;
|
|
|
|
height: 150rpx;
|
|
|
|
background: #ccc;
|
|
|
|
margin-top: 30rpx;
|
|
|
|
border-radius: 10rpx;
|
|
|
|
}
|
|
|
|
.type-box {
|
|
|
|
height: 84rpx;
|
|
|
|
|
|
|
|
.type-title {
|
|
|
|
font-size: 28rpx;
|
|
|
|
font-weight: bold;
|
|
|
|
padding: 0 16rpx;
|
|
|
|
}
|
|
|
|
.more {
|
|
|
|
font-size: 26rpx;
|
|
|
|
color: #999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-list {
|
|
|
|
.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;
|
|
|
|
border-radius: 6rpx;
|
|
|
|
background: #f5f5f5;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-title {
|
|
|
|
font-size: 24rpx;
|
|
|
|
margin-top: 10rpx;
|
|
|
|
width: 150rpx;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.zhankai{
|
|
|
|
background:#fff;
|
|
|
|
display: flex;flex-direction: column;
|
|
|
|
justify-content: space-around;align-items: center;
|
|
|
|
padding:0 40rpx;
|
|
|
|
box-shadow: -2px 0px 8px 0px rgba(31,32,14,0.05);
|
|
|
|
height: 100%;
|
|
|
|
margin-top: -16rpx;
|
|
|
|
}
|
|
|
|
.dropDown{
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
// padding-top:170rpx;
|
|
|
|
// padding-bottom:50rpx;
|
|
|
|
// background-image: linear-gradient(to top, #d6e4de 0%, #9de4c5 100%);
|
|
|
|
.item{
|
|
|
|
width:20%;
|
|
|
|
display:flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
}
|
|
|
|
.tab-img {
|
|
|
|
width: 98rpx;
|
|
|
|
height: 98rpx;
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
text{
|
|
|
|
font-size:24rpx;
|
|
|
|
color:#333333;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|