diff --git a/pages_promotion/merch/detail.vue b/pages_promotion/merch/detail.vue index 122774c..6aaaec5 100644 --- a/pages_promotion/merch/detail.vue +++ b/pages_promotion/merch/detail.vue @@ -322,7 +322,8 @@ export default { return { headerHeight: 320, screenWidth: uni.getSystemInfoSync().windowWidth, - changeStyleDebounce: null + changeStyleDebounce: null, + headerHeightInited: false }; }, mixins: [list], @@ -337,7 +338,9 @@ export default { if (res.code >= 0 && res.data) { this.merch = res.data; this.$nextTick(() => { - this.initHeaderHeight(); + if (!this.headerHeightInited) { + this.initHeaderHeight(); + } }); } } @@ -353,10 +356,13 @@ export default { } }, initHeaderHeight() { + if (!this.merch || !this.merch.merch_name) return; + if (this.headerHeightInited) return; const query = uni.createSelectorQuery().in(this); query.select('.head-wrap').boundingClientRect(rect => { if (rect && rect.height > 0) { this.headerHeight = (rect.height / this.screenWidth) * 750; + this.headerHeightInited = true; } }).exec(); },