chore:现在左侧一级题的高度会根据字数自动调节,右侧二级标题的白色背景高度会随着左侧选中项的高度自动改变,保持两侧高度一致。
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
</view>
|
||||
|
||||
<block v-if="value.template == 99">
|
||||
<view class="second-category-btns">
|
||||
<view class="second-category-btns" :style="oneCategoryHeight > 0 ? { height: oneCategoryHeight + 'px' } : {}">
|
||||
<view class="second-category-btn"
|
||||
v-for="(one, oneIndex) in category.child_list"
|
||||
:key="oneIndex"
|
||||
@@ -516,6 +516,10 @@ export default {
|
||||
currentOneCategory: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
oneCategoryHeight: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
mixins: [DiyMinx],
|
||||
@@ -2388,17 +2392,12 @@ export default {
|
||||
.second-category-btns {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
height: 96rpx;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
// #ifdef H5
|
||||
padding: 0rpx 10rpx 0rpx 24rpx;
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
padding: 0rpx 20rpx 0rpx;
|
||||
// #endif
|
||||
justify-content: flex-start;
|
||||
padding: 20rpx 20rpx 20rpx 24rpx;
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.second-category-btn {
|
||||
padding: 10rpx 24rpx;
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
: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>
|
||||
@@ -263,7 +264,9 @@ export default {
|
||||
// 修复体验: 进入页面初期显示 "暂未分类" 然后又变成有数据的体验很差
|
||||
// 用 categoryTreeLoading 区分"还在请求"和"真的没分类", 请求未完成时
|
||||
// 显示骨架占位而非空态文案
|
||||
categoryTreeLoading: true
|
||||
categoryTreeLoading: true,
|
||||
// 模板99: 左侧一级分类选中项的高度,用于同步右侧二级分类按钮区域的高度
|
||||
oneCategoryItemHeight: 0
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -296,6 +299,7 @@ export default {
|
||||
})
|
||||
.exec();
|
||||
if (this.value.template == 1) this.getHeightArea(-1);
|
||||
if (this.value.template == 99) this.getOneCategoryItemHeight(0);
|
||||
}, 500);
|
||||
},
|
||||
watch: {
|
||||
@@ -530,6 +534,23 @@ export default {
|
||||
this.select = index;
|
||||
this.categoryId = 'category-' + index;
|
||||
this.scrollLock = true;
|
||||
this.getOneCategoryItemHeight(index);
|
||||
},
|
||||
getOneCategoryItemHeight(index) {
|
||||
if (!query || typeof query.selectAll !== 'function') {
|
||||
query = uni.createSelectorQuery && uni.createSelectorQuery().in(this);
|
||||
}
|
||||
if (!query || typeof query.selectAll !== 'function') {
|
||||
return;
|
||||
}
|
||||
query
|
||||
.selectAll('.category-item-wrap .category-item')
|
||||
.boundingClientRect(data => {
|
||||
if (data && data.length > index && data[index].height) {
|
||||
this.oneCategoryItemHeight = data[index].height;
|
||||
}
|
||||
})
|
||||
.exec();
|
||||
},
|
||||
saveSecondCategoryName(name) {
|
||||
this.lastSecondCategoryName = name;
|
||||
@@ -1591,13 +1612,13 @@ export default {
|
||||
.tree-wrap .category-item {
|
||||
padding: 30rpx 16rpx;
|
||||
background-color: #f5f5f5;
|
||||
height: 96rpx;
|
||||
box-sizing: border-box;
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
|
||||
view {
|
||||
color: #333;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.3;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
&.select {
|
||||
|
||||
Reference in New Issue
Block a user