chore:启动广告,后台开启首次弹出,每一次重新进入小程序后都会弹出广告
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user