fix(merch/detail): 修复头部高度重复初始化的问题

添加headerHeightInited标记,避免merch数据更新时重复调用初始化方法
This commit is contained in:
2026-05-29 14:35:52 +08:00
parent a443121426
commit 1edda80d21

View File

@@ -321,16 +321,19 @@ export default {
data() { data() {
return { return {
headerHeight: 320, headerHeight: 320,
screenWidth: uni.getSystemInfoSync().windowWidth screenWidth: uni.getSystemInfoSync().windowWidth,
headerHeightInited: false
}; };
}, },
mixins: [list], mixins: [list],
watch: { watch: {
merch: { merch: {
handler() { handler() {
this.$nextTick(() => { if (!this.headerHeightInited) {
this.initHeaderHeight(); this.$nextTick(() => {
}); this.initHeaderHeight();
});
}
}, },
deep: true deep: true
} }
@@ -349,8 +352,9 @@ export default {
setTimeout(() => { setTimeout(() => {
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
query.select('.head-wrap').boundingClientRect(rect => { query.select('.head-wrap').boundingClientRect(rect => {
if (rect) { if (rect && rect.height > 0) {
this.headerHeight = (rect.height / this.screenWidth) * 750; this.headerHeight = (rect.height / this.screenWidth) * 750;
this.headerHeightInited = true;
} }
}).exec(); }).exec();
}, 100); }, 100);