diff --git a/components/popup-notice/popup-notice.js b/components/popup-notice/popup-notice.js index 3b0d2bf..0c1cfc3 100644 --- a/components/popup-notice/popup-notice.js +++ b/components/popup-notice/popup-notice.js @@ -71,28 +71,26 @@ Component({ } if (hasImages) { - const processed = []; const screenWidth = wx.getSystemInfoSync().windowWidth; - const containerWidth = screenWidth * 0.86; - const imageWidth = Math.max(containerWidth - 60, 200); - for (let i = 0; i < safeImages.length; i++) { - const img = safeImages[i]; - const fullUrl = this.getFullImageUrl(img.url); - let imageHeight = 200; + const containerWidth = Math.min(screenWidth * 0.86, 310); + const imageWidth = Math.max(containerWidth - 30, 200); + // 先立刻用默认高度展示,避免 getImageInfo 慢/失败时空白 + const processed = safeImages.map((img) => ({ + url: this.getFullImageUrl(img.url), + text: img.text, + height: 280, + })); + this.setData({ processedImages: processed }); + for (let i = 0; i < processed.length; i++) { + const fullUrl = processed[i].url; try { const res = await this.getImageInfoPromise(fullUrl); const realHeight = (imageWidth * res.height) / res.width; - imageHeight = realHeight; + this.setData({ [`processedImages[${i}].height`]: realHeight }); } catch (e) { console.error('获取图片信息失败', fullUrl, e); } - processed.push({ - url: fullUrl, - text: img.text, - height: imageHeight, - }); } - this.setData({ processedImages: processed }); } }, diff --git a/components/popup-notice/popup-notice.wxss b/components/popup-notice/popup-notice.wxss index c6067d2..c4afc70 100644 --- a/components/popup-notice/popup-notice.wxss +++ b/components/popup-notice/popup-notice.wxss @@ -17,7 +17,8 @@ .popup-container { width: 86%; max-width: 620rpx; - height: auto; + /* 必须给明确高度:scroll-view 依赖父级高度,height:auto 会导致图片区塌成 0 */ + height: 68vh; max-height: 68vh; background: white; border-radius: 28rpx; @@ -80,16 +81,14 @@ } .scroll-wrapper { - flex: 1 1 auto; - min-height: 120rpx; - max-height: 48vh; + flex: 1; + min-height: 0; overflow: hidden; width: 100%; } .scroll-view { height: 100%; - max-height: 48vh; width: 100%; padding: 0; } diff --git a/pages/accept-order/accept-order.js b/pages/accept-order/accept-order.js index 7a54565..77b20dc 100644 --- a/pages/accept-order/accept-order.js +++ b/pages/accept-order/accept-order.js @@ -120,6 +120,7 @@ Page({ this.persistPageCache(); this._skipShowRefresh = true; await this.loadMyZhidingOrders(true); + this.tryShowAcceptOrderPopup(); return; } @@ -131,13 +132,16 @@ Page({ this.persistPageCache(banner); app.globalData._acceptOrderSessionReady = true; - if (!app.globalData._acceptOrderPopupDone) { - PopupService.checkAndShow(this, 'jiedan'); - app.globalData._acceptOrderPopupDone = true; - } + this.tryShowAcceptOrderPopup(); this._skipShowRefresh = true; }, + tryShowAcceptOrderPopup() { + if (app.globalData._acceptOrderPopupDone) return; + app.globalData._acceptOrderPopupDone = true; + PopupService.checkAndShow(this, 'jiedan'); + }, + persistPageCache(extra = {}) { const d = this.data; app.globalData._acceptOrderPageCache = {