chore:启动广告,后台开启首次弹出,每一次重新进入小程序后都会弹出广告

This commit is contained in:
2026-10-10 11:20:36 +08:00
parent dd15ff8ea4
commit 447f7cd7b5
3 changed files with 12 additions and 13 deletions

View File

@@ -257,7 +257,7 @@ const localDevConfig = ({
// })['2811']; // 本地
// })['5g-317']; // 电磁兼容
// })['5g-351']; //
})['2881']; // 本地
})['2843']; // 本地
// })['local-2']; // 本地
// })['local-11']; // 本地
// })['1-test']; // test

View File

@@ -8,6 +8,7 @@
// PR-MULTI-TURN-KEY-BINDING (2026-09-18): AI 客服会话 key 切换
// 登录态恢复后通知 aiService 清旧 user key,避免串会话
import aiService from 'common/js/ai-service.js';
import { markNeedStartupAd } from 'common/js/startup-ad.js';
// 记录 App 是否已至少展示过一次: 首次 onShow = 启动展示(由 onLaunch 完成初始化),
// 之后每一次 onShow(含微信 ... 菜单"重新进入小程序"、从后台切回)都视为"重新进入"。
@@ -512,6 +513,8 @@
// 之后每次 onShow(含 ... 重新进入、从后台切回前台)都视为重新进入,主动失效缓存并重新对齐。
if (_appHasShown) {
try { Lang.onAppReentry(); } catch (e) {}
// 重新进入小程序(从后台切回 / "重新进入小程序"菜单): 标记需要弹出启动广告
try { markNeedStartupAd(); } catch (e) {}
}
_appHasShown = true;

View File

@@ -2,6 +2,7 @@ import WxMap from 'common/js/map-wx-jssdk.js';
import Config from '@/common/js/config.js';
import util from '@/common/js/util.js';
import { classifyHttpError, httpErrorKey } from '@/common/js/http-error.js';
import { consumeNeedStartupAd, isColdLaunchPending } from '@/common/js/startup-ad.js';
let systemInfo = util.getDeviceInfo();
@@ -298,20 +299,16 @@ export default {
async: false
});
this.adv = res.value
// 弹框形式,首次弹出 1,每次弹出 0
// 弹框形式(后台"首次弹出"等配置), 这里统一为: 每次(重新)进入小程序都弹出
// 通过 App 层"重新进入"信号 + 首屏首次加载来判定, 不再依赖持久化缓存计数,
// 否则关闭广告后计数变为 -1, 第二次进入不会弹出, 必须清缓存才能再弹。
if (this.adv.advshow == 1) {
setTimeout(() => {
if (res.value.advtype == 1) {
var popwindow_count = uni.getStorageSync(this.id + this.name + '_popwindow_count');
if ((this.$refs.uniPopupWindow && popwindow_count == '') || (
this.$refs.uniPopupWindow && popwindow_count == 1)) {
this.$refs.uniPopupWindow.open();
uni.setStorageSync(this.id + this.name + '_popwindow_count', 1);
}
} else if (res.value.advtype == 0) {
if (!this.$refs.uniPopupWindow) return;
const reenter = consumeNeedStartupAd(); // 从后台切回 / "重新进入小程序"
const firstLaunch = isColdLaunchPending(); // 本 app 进程首次冷启动(只一次)
if (reenter || firstLaunch) {
this.$refs.uniPopupWindow.open();
uni.setStorageSync(this.id + this.name + '_popwindow_count', 0);
}
}, 500);
}
@@ -544,7 +541,6 @@ export default {
},
closePopupWindow() {
this.$refs.uniPopupWindow.close();
uni.setStorageSync(this.id + this.name + '_popwindow_count', -1);
},
closeCollectPopupWindow() {
this.$refs.collectPopupWindow.close();