From 46ed573221140f2b530328d8c971090e085ea986 Mon Sep 17 00:00:00 2001 From: zpc Date: Mon, 13 Apr 2026 19:27:52 +0800 Subject: [PATCH] 213 --- uniapp/App.vue | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/uniapp/App.vue b/uniapp/App.vue index cf4e982..4cd26fb 100644 --- a/uniapp/App.vue +++ b/uniapp/App.vue @@ -45,8 +45,14 @@ let inviterId = null // 1. 扫码进入:解析 scene 参数(inviter={userId}) - if (options.scene) { - const scene = decodeURIComponent(options.scene) + // 注意:options.scene 是微信启动场景值(数字,如1048), + // 自定义 scene 参数在 options.query.scene 中(字符串) + const sceneStr = (options.query && options.query.scene) + ? String(options.query.scene) + : (typeof options.scene === 'string' ? options.scene : '') + + if (sceneStr) { + const scene = decodeURIComponent(sceneStr) console.log('[App] 扫码 scene 解码后:', scene) const match = scene.match(/inviter=(\d+)/) if (match) { @@ -57,9 +63,10 @@ } } - // 2. 分享链接进入:解析 inviterId 参数 - if (!inviterId && options.inviterId) { - inviterId = options.inviterId + // 2. 分享链接进入:解析 inviterId 参数(query 中直接带 inviterId) + const queryInviterId = (options.query && options.query.inviterId) || options.inviterId + if (!inviterId && queryInviterId) { + inviterId = queryInviterId console.log('[App] 从query参数获取inviterId:', inviterId) }