chore:还原到模板3二级分类按钮正常

This commit is contained in:
2026-07-18 10:31:35 +08:00
parent b410597d9c
commit d8816bbe42

View File

@@ -180,7 +180,7 @@
<view class="categoty-goods-wrap" v-if="loadType == 'part'" <view class="categoty-goods-wrap" v-if="loadType == 'part'"
:style="'padding-top:' + (value.search ? 0 : '20rpx')"> :style="'padding-top:' + (value.search ? 0 : '20rpx')">
<!-- 分类筛选 --> <!-- 分类筛选 -->
<block v-if="value.goodsLevel == 2 && (value.template == 4 ? (currentOneCategory && currentOneCategory.child_list) : category.child_list)"> <block v-if="category.child_list && value.goodsLevel == 2">
<view class="screen-category-wrap"> <view class="screen-category-wrap">
<scroll-view scroll-x="true" class="screen-category" <scroll-view scroll-x="true" class="screen-category"
:class="{ 'screen-category-4': value.template == 4 }" :scroll-with-animation="true" :class="{ 'screen-category-4': value.template == 4 }" :scroll-with-animation="true"
@@ -189,7 +189,7 @@
@tap.stop="selectCategory(-1)">{{ $lang('components-diy.diy-category-item.all') }}</view> @tap.stop="selectCategory(-1)">{{ $lang('components-diy.diy-category-item.all') }}</view>
<view class="item" :id="'category-2-' + oneIndex" <view class="item" :id="'category-2-' + oneIndex"
:class="{ selected: categoryId == oneIndex }" @tap.stop="selectCategory(oneIndex)" :class="{ selected: categoryId == oneIndex }" @tap.stop="selectCategory(oneIndex)"
v-for="(one, oneIndex) in (value.template == 4 ? currentOneCategory.child_list : category.child_list)" :key="oneIndex"> v-for="(one, oneIndex) in category.child_list" :key="oneIndex">
{{ one.category_name }} {{ one.category_name }}
</view> </view>
</scroll-view> </scroll-view>
@@ -201,7 +201,7 @@
:class="{ 'screen-category-4': value.template == 4 }"> :class="{ 'screen-category-4': value.template == 4 }">
<view class="title">{{ $lang('components-diy.diy-category-item.all') }}</view> <view class="title">{{ $lang('components-diy.diy-category-item.all') }}</view>
<view class="item" :class="{ selected: categoryId == oneIndex }" <view class="item" :class="{ selected: categoryId == oneIndex }"
@tap.stop="selectCategory(oneIndex)" v-for="(one, oneIndex) in (value.template == 4 ? currentOneCategory.child_list : category.child_list)" @tap.stop="selectCategory(oneIndex)" v-for="(one, oneIndex) in category.child_list"
:key="oneIndex"> :key="oneIndex">
{{ one.category_name }} {{ one.category_name }}
</view> </view>
@@ -630,7 +630,6 @@ export default {
}, },
watch: { watch: {
oneCategorySelect: function () { oneCategorySelect: function () {
if (this.index != this.select) return;
this.scrollTop = -1; this.scrollTop = -1;
this.goodsList = []; this.goodsList = [];
this.selectCategory(-1); this.selectCategory(-1);
@@ -638,7 +637,6 @@ export default {
select: function () { select: function () {
if (this.index == this.select) { if (this.index == this.select) {
this.scrollTop = 0; this.scrollTop = 0;
this.categoryId = -1;
if (this.pageIndex == 0) { if (this.pageIndex == 0) {
this.getGoodsList(); this.getGoodsList();
} else if (this.$refs.loadingCover && this.loadType == 'part') { } else if (this.$refs.loadingCover && this.loadType == 'part') {
@@ -742,14 +740,13 @@ export default {
sort = 'desc'; sort = 'desc';
} }
} }
const childList = this.value.template == 4 && this.currentOneCategory ? this.currentOneCategory.child_list : this.category.child_list;
const baseCategoryId = this.value.template == 4 && this.currentOneCategory ? this.currentOneCategory.category_id : this.category.category_id;
this.$api.sendRequest({ this.$api.sendRequest({
url: '/api/goodssku/pageByCategory', url: '/api/goodssku/pageByCategory',
data: { data: {
page: this.pageIndex, page: this.pageIndex,
page_size: this.pageSize, page_size: this.pageSize,
category_id: this.categoryId != -1 ? childList[this.categoryId].category_id : baseCategoryId, category_id: this.categoryId != -1 ? this.category.child_list[this.categoryId]
.category_id : this.category.category_id,
order: order, order: order,
sort: sort sort: sort
}, },
@@ -1057,7 +1054,6 @@ export default {
* @param {Object} action * @param {Object} action
*/ */
switchCategory(action) { switchCategory(action) {
const childList = this.value.template == 4 && this.currentOneCategory ? this.currentOneCategory.child_list : this.category.child_list;
if (action == 'prev') { if (action == 'prev') {
if (this.categoryId == -1) { if (this.categoryId == -1) {
let index = this.index - 1; let index = this.index - 1;
@@ -1068,7 +1064,7 @@ export default {
this.selectCategory(index); this.selectCategory(index);
} }
} else { } else {
if (this.categoryId == -1 || (childList && this.categoryId == childList.length - 1)) { if (this.categoryId == -1 || (this.category.child_list && this.categoryId == this.category.child_list.length - 1)) {
let index = this.index + 1; let index = this.index + 1;
this.$emit('switch', index); this.$emit('switch', index);
} else { } else {
@@ -2242,7 +2238,6 @@ export default {
flex: 1; flex: 1;
height: 0; height: 0;
transform: translateX(0px); transform: translateX(0px);
margin-top: -50rpx;
} }
} }
@@ -2259,7 +2254,7 @@ export default {
.screen-category { .screen-category {
flex: 1; flex: 1;
width: 0; width: 0;
padding: 0 0 10rpx 0; padding: 0 0 20rpx 0;
white-space: nowrap; white-space: nowrap;
height: 60rpx; height: 60rpx;
@@ -2269,7 +2264,7 @@ export default {
background: #f5f5f5; background: #f5f5f5;
color: #666; color: #666;
margin-right: 20rpx; margin-right: 20rpx;
border-radius: 8rpx; border-radius: 40rpx;
&.selected { &.selected {
background-color: $base-color; background-color: $base-color;
@@ -2338,17 +2333,14 @@ export default {
} }
.screen-category-4 .item { .screen-category-4 .item {
background-color: #fff !important; background-color: #f2f2f2 !important;
padding: 16rpx 40rpx; padding: 10rpx 24rpx;
line-height: 1; line-height: 1;
font-size: 28rpx; font-size: $font-size-tag;
border: 1rpx solid #eee;
border-radius: 12rpx !important;
&.selected { &.selected {
background-color: $base-color !important; background-color: var(--main-color-shallow) !important;
color: #fff; color: var(--main-color);
border-color: $base-color;
} }
} }