diff --git a/.local.config.js b/.local.config.js index 2510dc4..4bd39c8 100644 --- a/.local.config.js +++ b/.local.config.js @@ -41,8 +41,7 @@ const localDevConfig = ({ 'local-2': { // 测试平台 uniacid: 2, domain: 'http://localhost:8050/', - }, - '47': { // 修改弹窗 + '47': { // 修改弹窗 uniacid: 47, domain: 'https://5g.aigc-quickapp.com/', }, @@ -51,5 +50,4 @@ const localDevConfig = ({ domain: 'https://xcx.aigc-quickapp.com/', }, })['47']; // 选择要使用的环境配置 - export default localDevConfig; \ No newline at end of file diff --git a/components/privacy-popup/privacy-popup.vue b/components/privacy-popup/privacy-popup.vue index 0a53959..35fb347 100644 --- a/components/privacy-popup/privacy-popup.vue +++ b/components/privacy-popup/privacy-popup.vue @@ -158,22 +158,48 @@ export default { success: (res) => { // console.log(res) if (res.needAuthorization) { - this.popUp() - // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗 - this.closeOtherPagePopUp(this.disPopUp) + // 检查本地存储中是否已经同意过隐私政策 + const privacyAgreed = uni.getStorageSync('privacyAgreed'); + if (!privacyAgreed) { + this.popUp() + // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗 + this.closeOtherPagePopUp(this.disPopUp) + } else { + this.$emit('agree') + } } else { this.$emit('agree') } }, }); } else { - this.$emit('agree') + // 检查本地存储中是否已经同意过隐私政策 + const privacyAgreed = uni.getStorageSync('privacyAgreed'); + if (privacyAgreed) { + this.$emit('agree'); + } else { + this.popUp() + // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗 + this.closeOtherPagePopUp(this.disPopUp) + } } // #endif // #ifdef QUICKAPP-WEBVIEW this.getPrivacySettingByQuickApp(); // #endif + + // #ifdef H5 || WEB + // 检查本地存储中是否已经同意过隐私政策 + const privacyAgreed = uni.getStorageSync('privacyAgreed'); + if (privacyAgreed) { + this.$emit('agree'); + } else { + this.popUp() + // 额外逻辑:当前页面的隐私弹窗弹起的时候,关掉其他页面的隐私弹窗 + this.closeOtherPagePopUp(this.disPopUp) + } + // #endif }, //初始化监听程序 curPageShow() { @@ -261,6 +287,8 @@ export default { this.privacyResolves.clear() //关闭弹窗 this.disPopUp() + // 保存用户授权状态到本地存储,无论同意还是不同意,都不再重复弹出 + uni.setStorageSync('privacyAgreed', true); //退出小程序 uni.showModal({ content: '未同意隐私协议,无法使用相关功能', @@ -281,10 +309,8 @@ export default { //关闭弹窗 this.disPopUp() - // #ifdef QUICKAPP-WEBVIEW || H5 || WEB - // 保存用户授权状态到本地存储,用于快应用Webview组件中的H5方式处理 + // 保存用户授权状态到本地存储,用于所有环境 uni.setStorageSync('privacyAgreed', true); - // #endif this.$emit('agree') }, //打开弹窗 diff --git a/pages/index/public/js/index.js b/pages/index/public/js/index.js index b3a6a79..370894c 100644 --- a/pages/index/public/js/index.js +++ b/pages/index/public/js/index.js @@ -1,119 +1,95 @@ export default { - data() { - return { - minScrollTop: 100, // 设置回到顶端按钮显示要求,最小页面滚动距离 - wechatQrcode: '', // 公众号二维码 - diyRoute: '/pages/index/index', - showPrivacyModal: false // 新增:控制隐私弹窗显示的变量 - }; - }, - onLoad(option) { - // #ifdef H5 - // H5地图选择位置回调数据 - if (option.module && option.module == 'locationPicker') { - option.name = ''; // 清空地址 - } - // #endif - this.name = option.name || 'DIY_VIEW_INDEX'; // 根据店铺运营模式,打开平台(shop)或者连锁门店(stroe)页面,接口会自行判断 - - }, - onShow() { - // 获取关注公众号二维码 - this.getFollowQrcode(); - - // 打开隐私弹窗 - this.openPrivacyModal(); - }, - mounted() { - // 监听图片、文字、商品列表等组件的点击事件 - this.unsubscribe = this.$eventBus?.onMany([ - 'rubik-cube-tap', - 'picture-tap', - 'text-tap', - 'goods-list-tap', - 'presale-tap', - 'notes-tap', - 'merch-list-tap', - 'map-tap', - 'img-ads-tap', - 'many-goods-list-tap', - 'search-tap', - ], this._handleDiyGroupInteractionEvent); - }, - beforeDestroy() { - // 移除图片点击事件监听 - if (this.unsubscribe) this.unsubscribe(); - }, - methods: { - // 检查隐私设置(保留原有逻辑,如果不需要可删除) - checkPrivacySetting() { - setTimeout(() => { - if (this.$refs.privacyPopup) { - this.$refs.privacyPopup.proactive(); - } - }, 100); - }, - - // 新增:打开隐私弹窗的方法 - openPrivacyModal() { - // 延迟一点执行,防止页面加载卡顿 - setTimeout(() => { - this.showPrivacyModal = true; - }, 500); - }, - - // 新增:处理用户点击“同意并继续” - handlePrivacyAgree() { - this.showPrivacyModal = false; - // 这里可以添加保存到本地存储的逻辑,表示用户已同意 - uni.setStorageSync('hasAgreedPrivacy', true); - }, - - // 新增:处理用户点击“不同意” - handlePrivacyDisagree() { - this.showPrivacyModal = false; - // 如果不同意,通常退出小程序或关闭页面 - uni.navigateBack({ - delta: 1 - }); - }, - - // 关注公众号 - getFollowQrcode() { - if (!this.$util.isWeiXin()) return; - this.$api.sendRequest({ - url: '/wechat/api/wechat/followqrcode', - success: res => { - if (res.code >= 0 && res.data) { - this.wechatQrcode = res.data.qrcode; - } - } - }); - }, - officialAccountsOpen() { - this.$refs.officialAccountsPopup.open(); - }, - officialAccountsClose() { - this.$refs.officialAccountsPopup.close(); - }, - // 统一处理点击及触摸事件 - _handleDiyGroupInteractionEvent(payload) { - // #ifdef H5 - // 如果是 H5 环境,直接返回 true 继续传播 - return true; - // #endif - - // 如果已登录,直接返回 true 继续传播 - if (this.storeToken) { - return true; - } - - // 打开登录弹窗 - // console.log('==> _handleDiyGroupInteractionEvent, 未登录,打开登录弹窗', { payload }) - this.$refs.login?.open(); - - // 阻止事件继续传播 - return false; - } + data() { + return { + minScrollTop: 100, // 设置回到顶端按钮显示要求,最小页面滚动距离 + wechatQrcode: "", // 公众号二维码 + diyRoute: "/pages/index/index", + }; + }, + onLoad(option) { + // #ifdef H5 + // H5地图选择位置回调数据 + if (option.module && option.module == "locationPicker") { + option.name = ""; // 清空地址 } -}; \ No newline at end of file + // #endif + this.name = option.name || "DIY_VIEW_INDEX"; // 根据店铺运营模式,打开平台(shop)或者连锁门店(stroe)页面,接口会自行判断 + }, + onShow() { + // 获取关注公众号二维码 + this.getFollowQrcode(); + // 检查隐私设置并显示弹窗 + this.checkPrivacySetting(); + }, + mounted() { + // 监听图片、文字、商品列表等组件的点击事件 + this.unsubscribe = this.$eventBus?.onMany( + [ + "rubik-cube-tap", + "picture-tap", + "text-tap", + "goods-list-tap", + "presale-tap", + "notes-tap", + "merch-list-tap", + "map-tap", + "img-ads-tap", + "many-goods-list-tap", + "search-tap", + ], + this._handleDiyGroupInteractionEvent, + ); + }, + beforeDestroy() { + // 移除图片点击事件监听 + if (this.unsubscribe) this.unsubscribe(); + }, + methods: { + // 检查隐私设置 + checkPrivacySetting() { + // 延迟执行,确保组件已经挂载 + setTimeout(() => { + if (this.$refs.privacyPopup) { + this.$refs.privacyPopup.proactive(); + } + }, 100); + }, + // 关注公众号 + getFollowQrcode() { + if (!this.$util.isWeiXin()) return; + this.$api.sendRequest({ + url: "/wechat/api/wechat/followqrcode", + success: (res) => { + if (res.code >= 0 && res.data) { + this.wechatQrcode = res.data.qrcode; + } + }, + }); + }, + officialAccountsOpen() { + this.$refs.officialAccountsPopup.open(); + }, + officialAccountsClose() { + this.$refs.officialAccountsPopup.close(); + }, + // 统一处理点击及触摸事件 + _handleDiyGroupInteractionEvent(payload) { + // #ifdef H5 + // 如果是 H5 环境,直接返回 true 继续传播 + return true; + // #endif + + // 如果已登录,直接返回 true 继续传播 + if (this.storeToken) { + return true; + } + + // 打开登录弹窗 + // console.log('==> _handleDiyGroupInteractionEvent, 未登录,打开登录弹窗', { payload }) + this.$refs.login?.open(); + + // 阻止事件继续传播 + return false; + }, + }, +};