| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import {
- POLICY_CONSENT_VERSION,
- STORAGE_KEY_POLICY_CONSENT,
- } from '@/utils/policy-config.js'
- let policyHostVm = null
- let privacyResolve = null
- export function isPolicyConsented() {
- return uni.getStorageSync(STORAGE_KEY_POLICY_CONSENT) === POLICY_CONSENT_VERSION
- }
- /** 未同意业务协议前,禁止展示分享减价/加价等活动弹窗 */
- export function shouldBlockMarketingPopup() {
- const app = getApp()
- if (app && app.globalData && app.globalData.needPolicyConsent) {
- return true
- }
- return !isPolicyConsented()
- }
- export function setPolicyConsented() {
- uni.setStorageSync(STORAGE_KEY_POLICY_CONSENT, POLICY_CONSENT_VERSION)
- }
- export function registerPolicyHost(vm) {
- policyHostVm = vm
- const app = getApp()
- if (app && app.globalData && app.globalData.needPolicyConsent) {
- vm.tryOpenPolicyModal()
- }
- if (app && app.globalData && app.globalData.needPrivacyPopup) {
- vm.tryOpenPrivacyPopup()
- }
- }
- export function unregisterPolicyHost(vm) {
- if (policyHostVm === vm) {
- policyHostVm = null
- }
- }
- export function requestShowPolicyModal() {
- const app = getApp()
- if (app && app.globalData) {
- app.globalData.needPolicyConsent = true
- }
- if (policyHostVm) {
- policyHostVm.tryOpenPolicyModal()
- }
- }
- export function requestShowPrivacyPopup(resolve) {
- privacyResolve = resolve
- const app = getApp()
- if (app && app.globalData) {
- app.globalData.needPrivacyPopup = true
- }
- if (policyHostVm) {
- policyHostVm.tryOpenPrivacyPopup()
- }
- }
- export function getPrivacyResolve() {
- return privacyResolve
- }
- export function clearPrivacyResolve() {
- privacyResolve = null
- }
- export function clearPrivacyPopupFlag() {
- const app = getApp()
- if (app && app.globalData) {
- app.globalData.needPrivacyPopup = false
- }
- }
|