From b14032149ef07960baf49231cc9449ed3b1ae1eb Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Sat, 10 Oct 2026 11:35:55 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E5=90=AF=E5=8A=A8=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=EF=BC=8C=E5=90=8E=E5=8F=B0=E5=BC=80=E5=90=AF=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E5=BC=B9=E5=87=BA=EF=BC=8C=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=90=8E=E4=BC=9A?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=B9=BF=E5=91=8A=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后台开启每次弹出,每次重新进入小程序都会弹出广告 --- common/js/diy.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/common/js/diy.js b/common/js/diy.js index 7fd5826..d7710f9 100644 --- a/common/js/diy.js +++ b/common/js/diy.js @@ -299,16 +299,25 @@ export default { async: false }); this.adv = res.value - // 弹框形式(后台"首次弹出"等配置), 这里统一为: 每次(重新)进入小程序都弹出 - // 通过 App 层"重新进入"信号 + 首屏首次加载来判定, 不再依赖持久化缓存计数, - // 否则关闭广告后计数变为 -1, 第二次进入不会弹出, 必须清缓存才能再弹。 + // 后台配置: advshow=1 开启启动广告; advtype 决定弹出策略 + // advtype == 1: 首次弹出 —— 仅第一次进入小程序弹出(持久化标记, 清缓存后可再弹) + // advtype == 0: 每次弹出 —— 每次"重新进入小程序"都弹出(不含 Tab 切换回首页) if (this.adv.advshow == 1) { setTimeout(() => { if (!this.$refs.uniPopupWindow) return; - const reenter = consumeNeedStartupAd(); // 从后台切回 / "重新进入小程序" - const firstLaunch = isColdLaunchPending(); // 本 app 进程首次冷启动(只一次) - if (reenter || firstLaunch) { - this.$refs.uniPopupWindow.open(); + if (res.value.advtype == 1) { + // 首次弹出: 从未展示过才弹 + var popwindow_count = uni.getStorageSync(this.id + this.name + '_popwindow_count'); + if (popwindow_count == '' || popwindow_count == 0) { + this.$refs.uniPopupWindow.open(); + uni.setStorageSync(this.id + this.name + '_popwindow_count', 1); + } + } else { + // 每次弹出: 冷启动首次 或 真正"重新进入小程序"(App 前后台切换)时弹出, + // 由 App.onShow 在重新进入时置位的信号驱动, 切 Tab 不会触发 App.onShow 故不弹 + if (consumeNeedStartupAd() || isColdLaunchPending()) { + this.$refs.uniPopupWindow.open(); + } } }, 500); }