chore:二级标题按钮白色背景和一级标题对齐

This commit is contained in:
2026-07-23 16:51:00 +08:00
parent 658396c9a3
commit c99d808051
2 changed files with 27 additions and 36 deletions

View File

@@ -6,7 +6,7 @@
</view>
<block v-if="value.template == 99">
<view class="second-category-btns" :style="oneCategoryHeightStyle">
<view class="second-category-btns">
<view class="second-category-btn"
v-for="(one, oneIndex) in category.child_list"
:key="oneIndex"
@@ -517,10 +517,6 @@ export default {
type: Object,
default: null
},
oneCategoryHeight: {
type: Number,
default: 0
}
},
mixins: [DiyMinx],
data() {
@@ -587,12 +583,6 @@ export default {
isGroupedDisplay() {
return this.value.template == 1 && this.value.level == 3;
},
oneCategoryHeightStyle() {
if (this.oneCategoryHeight > 0) {
return 'height:' + this.oneCategoryHeight + 'px';
}
return '';
}
},
created() {
this.type = this.value.template == 1 || this.value.template == 99 ? 'category' : 'goods';
@@ -646,9 +636,6 @@ export default {
}
},
watch: {
oneCategoryHeight: function () {
this.$forceUpdate();
},
oneCategorySelect: function () {
this.scrollTop = -1;
this.goodsList = [];
@@ -2404,7 +2391,7 @@ export default {
align-items: center;
justify-content: flex-start;
padding: 20rpx 20rpx 20rpx 24rpx;
min-height: 96rpx;
height: 100rpx;
background: #fff;
border-bottom: 1rpx solid #f0f0f0;
box-sizing: border-box;

View File

@@ -100,7 +100,7 @@
</view>
</view>
</view>
<view class="content-box" v-else-if="categoryTree">
<view class="content-box" v-if="categoryTree">
<block v-if="categoryTree.length">
<scroll-view scroll-y="true" class="tree-wrap">
<view class="category-item-wrap">
@@ -119,7 +119,8 @@
<view class="category-item" v-for="(item, index) in categoryTree" :key="index" :class="[
{ select: select == index },
{ 'border-bottom': value.template == 4 && select + 1 === index },
{ 'border-top': value.template == 4 && select - 1 === index }
{ 'border-top': value.template == 4 && select - 1 === index },
{ 'first-category-item': index == 0 && value.template == 99 }
]" @tap.stop="switchOneCategory(index)">
<view class="">{{ item.category_name }}</view>
</view>
@@ -136,7 +137,6 @@
:oneCategorySelect="oneCategorySelect" :isList="isList"
:currentOneCategory="categoryTree && categoryTree[select] ? categoryTree[select] : null"
:lastSecondCategoryName="lastSecondCategoryName"
:oneCategoryHeight="oneCategoryItemHeight"
@tologin="toLogin" @selectsku="selectSku($event, 0)" @addCart="addCartPoint"
@saveSecondCategory="saveSecondCategoryName"></diy-category-item>
</scroll-view>
@@ -164,6 +164,7 @@
<diy-category-item :category="item" :value="value" ref="categoryItem" :index="index"
:select="select" :oneCategorySelect="oneCategorySelect" :isList="isList"
:lastSecondCategoryName="value.template == 99 ? lastSecondCategoryName : ''"
:currentOneCategory="categoryTree && categoryTree[select] ? categoryTree[select] : null"
@tologin="toLogin" @selectsku="selectSku($event, index)" @addCart="addCartPoint"
@loadfinish="getHeightArea" @saveSecondCategory="saveSecondCategoryName"></diy-category-item>
</view>
@@ -265,8 +266,7 @@ export default {
// 用 categoryTreeLoading 区分"还在请求"和"真的没分类", 请求未完成时
// 显示骨架占位而非空态文案
categoryTreeLoading: true,
// 模板99: 左侧一级分类选中项的高度,用于同步右侧二级分类按钮区域的高度
oneCategoryItemHeight: 0
};
},
created() {
@@ -305,11 +305,9 @@ export default {
// 组件刷新监听
componentRefresh: function (nval) { },
categoryTreeLoading: function (nval, oval) {
if (nval === false && oval === true && this.value.template == 99) {
if (nval === false && oval === true) {
this.$nextTick(() => {
setTimeout(() => {
this.measureFirstCategoryItemHeight();
}, 500);
if (!this.heightArea.length) this.getHeightArea(-1);
});
}
}
@@ -386,18 +384,7 @@ export default {
this.$store.dispatch('getCartNumber');
if (!this.heightArea.length) this.getHeightArea(-1);
},
measureFirstCategoryItemHeight() {
if (this.value.template != 99) return;
const query = uni.createSelectorQuery().in(this);
query
.selectAll('.tree-wrap .category-item')
.boundingClientRect(data => {
if (data && data.length > 0 && data[0].height) {
this.oneCategoryItemHeight = data[0].height;
}
})
.exec();
},
/**
* 获取高度区间
*
@@ -1074,6 +1061,8 @@ export default {
}
}
@keyframes category-skeleton-shimmer {
0% {
background-position: 100% 50%;
@@ -1649,6 +1638,21 @@ export default {
}
}
// 模板99: 第一个分类项固定高度,与右侧二级分类按钮区域对齐
.tree-wrap .category-item.first-category-item {
height: 100rpx;
display: flex;
align-items: center;
white-space: nowrap;
overflow: hidden;
view {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.content-wrap {
background: #f5f5f5;
padding: 0;