hookehuyr

fix: 扫码打卡详情页兼容 scene 参数入口

...@@ -59,7 +59,7 @@ import { getCurrentPageFullPath } from '@/utils/authRedirect' ...@@ -59,7 +59,7 @@ import { getCurrentPageFullPath } from '@/utils/authRedirect'
59 import { getMyFamiliesAPI } from '@/api/family' 59 import { getMyFamiliesAPI } from '@/api/family'
60 import { getScanStageDetailAPI, submitScanCheckinAPI } from '@/api/map' 60 import { getScanStageDetailAPI, submitScanCheckinAPI } from '@/api/map'
61 import { verifyCheckinRangeWithCurrentLocation } from '@/utils/checkinLocation' 61 import { verifyCheckinRangeWithCurrentLocation } from '@/utils/checkinLocation'
62 -import { parseScanCheckinParams } from '@/utils/scanCheckin' 62 +import { parseScanCheckinParams, parseScanCheckinSceneParams } from '@/utils/scanCheckin'
63 63
64 const defaultCover = 64 const defaultCover =
65 'https://cdn.ipadbiz.cn/lls_prog/images/check_detail_img.png?imageMogr2/strip/quality/60' 65 'https://cdn.ipadbiz.cn/lls_prog/images/check_detail_img.png?imageMogr2/strip/quality/60'
...@@ -276,8 +276,10 @@ const applyStageDetail = stageDetail => { ...@@ -276,8 +276,10 @@ const applyStageDetail = stageDetail => {
276 } 276 }
277 277
278 useLoad(options => { 278 useLoad(options => {
279 - detail.activityId = options.activityId || options.activity_id || '' 279 + const sceneParams = parseScanCheckinSceneParams(options.scene || '')
280 - const detailId = options.detailId || options.id || '' 280 +
281 + detail.activityId = sceneParams.activityId || options.activityId || options.activity_id || ''
282 + const detailId = sceneParams.detailId || options.detailId || options.id || ''
281 detail.regSource = options.reg_source || '' 283 detail.regSource = options.reg_source || ''
282 detail.regStageId = options.reg_stage_id || '' 284 detail.regStageId = options.reg_stage_id || ''
283 // 当前页路径会透传给补资料页,提交成功后用于回跳续扫。 285 // 当前页路径会透传给补资料页,提交成功后用于回跳续扫。
......
1 /** 1 /**
2 + * @description 解析小程序码进入扫码打卡详情页时的 scene 参数
3 + * @param {string} rawScene - scene 原始值,兼容 `detailId,activityId` 和 querystring 两种格式
4 + * @returns {{activityId:string, detailId:string, rawScene:string}}
5 + */
6 +export const parseScanCheckinSceneParams = (rawScene = '') => {
7 + const normalizedScene = safeDecodeURIComponent(String(rawScene || '').trim())
8 +
9 + if (!normalizedScene) {
10 + return {
11 + activityId: '',
12 + detailId: '',
13 + rawScene: '',
14 + }
15 + }
16 +
17 + if (!normalizedScene.includes('=') && normalizedScene.includes(',')) {
18 + const [detailId = '', activityId = ''] = normalizedScene.split(',').map(item => item.trim())
19 +
20 + return {
21 + activityId,
22 + detailId,
23 + rawScene: normalizedScene,
24 + }
25 + }
26 +
27 + const rawParams = parseQueryString(normalizedScene)
28 +
29 + return {
30 + activityId: pickFirstAvailableValue(rawParams, ['activity_id', 'activityId', 'id']),
31 + detailId: pickFirstAvailableValue(rawParams, ['detail_id', 'detailId', 'stage_id', 'stageId']),
32 + rawScene: normalizedScene,
33 + }
34 +}
35 +
36 +/**
2 * @description 从扫码结果中提取打卡接口所需参数 37 * @description 从扫码结果中提取打卡接口所需参数
3 * @param {string} rawScanResult - 微信扫码返回的原始结果,可能是完整URL,也可能是纯查询串 38 * @param {string} rawScanResult - 微信扫码返回的原始结果,可能是完整URL,也可能是纯查询串
4 * @returns {{activityId:string, detailId:string, rawParams:Object}} 39 * @returns {{activityId:string, detailId:string, rawParams:Object}}
......