Compare commits

...

12 Commits

4 changed files with 142 additions and 139 deletions

View File

@@ -41,7 +41,6 @@ const localDevConfig = ({
'local-2': { // 测试平台
uniacid: 2,
domain: 'http://localhost:8050/',
},
'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;

View File

@@ -54,11 +54,14 @@ function loadLangPackSync(lang, path) {
}
}
/**
* 获得当前本地语言
* @returns
*/
function getCurrentLocale() {
return uni.getStorageSync('lang') || "zh-cn";
}
export default {
langList: langConfig.langList,

View File

@@ -158,22 +158,48 @@ export default {
success: (res) => {
// console.log(res)
if (res.needAuthorization) {
// 检查本地存储中是否已经同意过隐私政策
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')
},
//打开弹窗

View File

@@ -2,92 +2,68 @@ export default {
data() {
return {
minScrollTop: 100, // 设置回到顶端按钮显示要求,最小页面滚动距离
wechatQrcode: '', // 公众号二维码
diyRoute: '/pages/index/index',
showPrivacyModal: false // 新增:控制隐私弹窗显示的变量
wechatQrcode: "", // 公众号二维码
diyRoute: "/pages/index/index",
};
},
onLoad(option) {
// #ifdef H5
// H5地图选择位置回调数据
if (option.module && option.module == 'locationPicker') {
option.name = ''; // 清空地址
if (option.module && option.module == "locationPicker") {
option.name = ""; // 清空地址
}
// #endif
this.name = option.name || 'DIY_VIEW_INDEX'; // 根据店铺运营模式,打开平台(shop)或者连锁门店(stroe)页面,接口会自行判断
this.name = option.name || "DIY_VIEW_INDEX"; // 根据店铺运营模式,打开平台(shop)或者连锁门店(stroe)页面,接口会自行判断
},
onShow() {
// 获取关注公众号二维码
this.getFollowQrcode();
// 打开隐私弹窗
this.openPrivacyModal();
// 检查隐私设置并显示弹窗
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);
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 => {
url: "/wechat/api/wechat/followqrcode",
success: (res) => {
if (res.code >= 0 && res.data) {
this.wechatQrcode = res.data.qrcode;
}
}
},
});
},
officialAccountsOpen() {
@@ -114,6 +90,6 @@ export default {
// 阻止事件继续传播
return false;
}
}
},
},
};