huaanglimeng/app.js

53 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

App({
onShow: function (options) {
// 检查是否从分享卡片进入 (场景值 1007, 1008)
if (options && (options.scene === 1007 || options.scene === 1008)) {
console.log('[App] 用户通过分享卡片进入');
// 获取来源用户ID保留结构暂不使用
const fromUserId = options.query && options.query.fromUserId;
if (fromUserId) {
console.log('[App] 来源用户ID:', fromUserId);
}
// 只做欢迎提示,不发积分
wx.showToast({
title: '欢迎进入今日命运场 ✨',
icon: 'none',
duration: 2000
});
}
},
onLaunch: function () {
console.log('小程序启动啦!');
// 检查隐私协议同意状态
const agreed = wx.getStorageSync('privacyAgreed');
if (!agreed) {
wx.onAppRoute((res) => {
const isAgreed = wx.getStorageSync('privacyAgreed');
if (isAgreed) return;
if (res.path !== 'pages/privacy-agree/privacy-agree' &&
res.path !== 'pages/privacy/privacy') {
wx.reLaunch({
url: '/pages/privacy-agree/privacy-agree'
});
}
});
wx.reLaunch({
url: '/pages/privacy-agree/privacy-agree'
});
}
}
});