feat(invite): 优化邀请参数解析和处理逻辑
- 重构 invite 工具函数,增强参数解析能力 - 添加参数调试工具,便于排查问题 - 优化用户登录后的邀请关系处理流程- 调整 API调用,统一使用 dealerId替代 refereeId - 移除未使用的导入和冗余代码
This commit is contained in:
20
src/app.ts
20
src/app.ts
@@ -6,7 +6,7 @@ import './app.scss'
|
||||
import {loginByOpenId} from "@/api/layout";
|
||||
import {TenantId} from "@/config/app";
|
||||
import {saveStorageByLoginUser} from "@/utils/server";
|
||||
import {parseInviteParams, saveInviteParams, trackInviteSource, handleInviteRelation} from "@/utils/invite";
|
||||
import {parseInviteParams, saveInviteParams, trackInviteSource, handleInviteRelation, debugInviteInfo} from "@/utils/invite";
|
||||
|
||||
function App(props: { children: any; }) {
|
||||
const reload = () => {
|
||||
@@ -57,12 +57,13 @@ function App(props: { children: any; }) {
|
||||
// 处理启动参数
|
||||
const handleLaunchOptions = (options: any) => {
|
||||
try {
|
||||
console.log('小程序启动参数:', options)
|
||||
console.log('=== 小程序启动参数处理开始 ===')
|
||||
console.log('完整启动参数:', JSON.stringify(options, null, 2))
|
||||
|
||||
// 解析邀请参数
|
||||
const inviteParams = parseInviteParams(options)
|
||||
if (inviteParams) {
|
||||
console.log('检测到邀请参数:', inviteParams)
|
||||
console.log('✅ 成功检测到邀请参数:', inviteParams)
|
||||
|
||||
// 保存邀请参数到本地存储
|
||||
saveInviteParams(inviteParams)
|
||||
@@ -73,12 +74,21 @@ function App(props: { children: any; }) {
|
||||
// 显示邀请提示
|
||||
setTimeout(() => {
|
||||
Taro.showToast({
|
||||
title: '检测到邀请信息',
|
||||
title: `检测到邀请信息 ID:${inviteParams.inviter}`,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
duration: 3000
|
||||
})
|
||||
}, 1000)
|
||||
|
||||
// 打印调试信息
|
||||
setTimeout(() => {
|
||||
debugInviteInfo()
|
||||
}, 2000)
|
||||
} else {
|
||||
console.log('❌ 未检测到邀请参数')
|
||||
}
|
||||
|
||||
console.log('=== 小程序启动参数处理结束 ===')
|
||||
} catch (error) {
|
||||
console.error('处理启动参数失败:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user