|
|
@@ -9,6 +9,7 @@
|
|
|
import UpsellShare from "@/pages/home/components/upsell-share.vue";
|
|
|
import ReduceShare from "@/pages/home/components/reduce-share.vue";
|
|
|
import { eventBus } from "@/utils/event-bus";
|
|
|
+import { shouldBlockMarketingPopup } from "@/utils/policy-consent-manager.js";
|
|
|
|
|
|
export default {
|
|
|
name: "ActivityHost",
|
|
|
@@ -30,27 +31,43 @@ export default {
|
|
|
return {
|
|
|
loginSuccessHandler: null,
|
|
|
appShowActivityHandler: null,
|
|
|
+ policyAcceptedHandler: null,
|
|
|
+ pendingLoginData: null,
|
|
|
+ pendingPageOptions: null,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
this.bindLoginSuccess();
|
|
|
this.bindAppShowActivity();
|
|
|
+ this.bindPolicyAccepted();
|
|
|
this.tryOpenPendingActivity();
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.unbindLoginSuccess();
|
|
|
this.unbindAppShowActivity();
|
|
|
+ this.unbindPolicyAccepted();
|
|
|
},
|
|
|
methods: {
|
|
|
bindLoginSuccess() {
|
|
|
if (this.loginSuccessHandler) return;
|
|
|
|
|
|
this.loginSuccessHandler = (data) => {
|
|
|
- this.openByLoginSuccess(data);
|
|
|
+ if (shouldBlockMarketingPopup()) {
|
|
|
+ this.pendingLoginData = data || null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
const app = getApp();
|
|
|
if (app && app.globalData) {
|
|
|
app.globalData.isColdLaunch = false;
|
|
|
}
|
|
|
+ // 优先处理带参数的入口(如分享减价链接),避免与 storage 重复弹窗
|
|
|
+ if (this.pendingPageOptions) {
|
|
|
+ const options = this.pendingPageOptions;
|
|
|
+ this.pendingPageOptions = null;
|
|
|
+ this.openByPageOptions(options);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.openByLoginSuccess(data);
|
|
|
};
|
|
|
eventBus.on("loginSuccess", this.loginSuccessHandler);
|
|
|
},
|
|
|
@@ -58,6 +75,10 @@ export default {
|
|
|
if (this.appShowActivityHandler) return;
|
|
|
|
|
|
this.appShowActivityHandler = (data) => {
|
|
|
+ if (shouldBlockMarketingPopup()) {
|
|
|
+ this.pendingLoginData = data || null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.openByLoginSuccess(data);
|
|
|
};
|
|
|
eventBus.on("appShowActivity", this.appShowActivityHandler);
|
|
|
@@ -72,7 +93,21 @@ export default {
|
|
|
eventBus.off("appShowActivity", this.appShowActivityHandler);
|
|
|
this.appShowActivityHandler = null;
|
|
|
},
|
|
|
+ bindPolicyAccepted() {
|
|
|
+ if (this.policyAcceptedHandler) return;
|
|
|
+ this.policyAcceptedHandler = () => {
|
|
|
+ this.flushPendingMarketingPopups();
|
|
|
+ };
|
|
|
+ eventBus.on("policyAccepted", this.policyAcceptedHandler);
|
|
|
+ },
|
|
|
+ unbindPolicyAccepted() {
|
|
|
+ if (!this.policyAcceptedHandler) return;
|
|
|
+ eventBus.off("policyAccepted", this.policyAcceptedHandler);
|
|
|
+ this.policyAcceptedHandler = null;
|
|
|
+ },
|
|
|
tryOpenPendingActivity() {
|
|
|
+ if (shouldBlockMarketingPopup()) return;
|
|
|
+
|
|
|
const token = uni.getStorageSync("token");
|
|
|
const upsellCode = uni.getStorageSync("upsellCode");
|
|
|
const reduceCode = uni.getStorageSync("reduceCode");
|
|
|
@@ -81,6 +116,11 @@ export default {
|
|
|
this.openByLoginSuccess();
|
|
|
},
|
|
|
openByLoginSuccess(data) {
|
|
|
+ if (shouldBlockMarketingPopup()) {
|
|
|
+ this.pendingLoginData = data || null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
const upsellCode = uni.getStorageSync("upsellCode") || data?.params?.upsellCode;
|
|
|
const reduceCode = uni.getStorageSync("reduceCode") || data?.params?.reduceCode;
|
|
|
|
|
|
@@ -95,6 +135,14 @@ export default {
|
|
|
handlePageOptions(options = {}, isColdLaunch = false) {
|
|
|
if (isColdLaunch) return;
|
|
|
|
|
|
+ if (shouldBlockMarketingPopup()) {
|
|
|
+ this.pendingPageOptions = options;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.openByPageOptions(options);
|
|
|
+ },
|
|
|
+ openByPageOptions(options = {}) {
|
|
|
const params = this.parseEntryParams(options);
|
|
|
if (this.enableUpsell && params.upsellCode) {
|
|
|
this.$refs.shareRef?.open(params.upsellCode);
|
|
|
@@ -107,6 +155,22 @@ export default {
|
|
|
}
|
|
|
this.$emit("refresh-order");
|
|
|
},
|
|
|
+ flushPendingMarketingPopups() {
|
|
|
+ if (shouldBlockMarketingPopup()) return;
|
|
|
+
|
|
|
+ if (this.pendingPageOptions) {
|
|
|
+ const options = this.pendingPageOptions;
|
|
|
+ this.pendingPageOptions = null;
|
|
|
+ this.openByPageOptions(options);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const token = uni.getStorageSync("token");
|
|
|
+ if (!token) return;
|
|
|
+
|
|
|
+ this.openByLoginSuccess(this.pendingLoginData);
|
|
|
+ this.pendingLoginData = null;
|
|
|
+ },
|
|
|
parseEntryParams(options = {}) {
|
|
|
if (!options.scene) return options;
|
|
|
|