hookehuyr

refactor(onboarding): 简化家庭入驻导航流程,移除老旧return_url回跳逻辑

- 移除多个页面中冗余的normalizeReturnUrl导入与return_url状态管理代码
- 统一家庭创建、加入以及用户资料补全后的跳转规则,不再回跳扫码详情页
- 重构Welcome与AddProfile页面的参数传递逻辑,使用from=welcome替代老旧传参方式
...@@ -179,7 +179,6 @@ import BASE_URL from '@/utils/config' ...@@ -179,7 +179,6 @@ import BASE_URL from '@/utils/config'
179 const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg' 179 const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
180 // 获取接口信息 180 // 获取接口信息
181 import { updateUserProfileAPI } from '@/api/user' 181 import { updateUserProfileAPI } from '@/api/user'
182 -import { normalizeReturnUrl } from '@/utils/returnUrl'
183 import { buildUpdateUserProfilePayload } from '@/utils/userProfile' 182 import { buildUpdateUserProfilePayload } from '@/utils/userProfile'
184 // 导入主题颜色 183 // 导入主题颜色
185 import { THEME_COLORS } from '@/utils/config' 184 import { THEME_COLORS } from '@/utils/config'
...@@ -204,7 +203,7 @@ const formData = reactive({ ...@@ -204,7 +203,7 @@ const formData = reactive({
204 const registerSourceParams = reactive({ 203 const registerSourceParams = reactive({
205 reg_source: '', 204 reg_source: '',
206 reg_stage_id: '', 205 reg_stage_id: '',
207 - return_url: '', 206 + from: '',
208 }) 207 })
209 208
210 /** 209 /**
...@@ -401,10 +400,21 @@ const handleSave = async () => { ...@@ -401,10 +400,21 @@ const handleSave = async () => {
401 icon: 'success', 400 icon: 'success',
402 }) 401 })
403 setTimeout(() => { 402 setTimeout(() => {
404 - // 从扫码打卡链路进入补资料页时,保存成功后需要原路回到关卡详情继续扫码。 403 + // Welcome 进入补资料页时,保存成功后要回 Welcome 继续完成家庭选择,
405 - if (registerSourceParams.return_url) { 404 + // 不能直接去首页,否则没有家庭的用户会被首页再打回 Welcome。
405 + if (registerSourceParams.from === 'welcome') {
406 + const params = new URLSearchParams()
407 +
408 + if (registerSourceParams.reg_source) {
409 + params.set('reg_source', registerSourceParams.reg_source)
410 + }
411 + if (registerSourceParams.reg_stage_id) {
412 + params.set('reg_stage_id', registerSourceParams.reg_stage_id)
413 + }
414 +
415 + const query = params.toString()
406 Taro.redirectTo({ 416 Taro.redirectTo({
407 - url: normalizeReturnUrl(registerSourceParams.return_url), 417 + url: query ? `/pages/Welcome/index?${query}` : '/pages/Welcome/index',
408 }) 418 })
409 return 419 return
410 } 420 }
...@@ -423,7 +433,7 @@ const handleSave = async () => { ...@@ -423,7 +433,7 @@ const handleSave = async () => {
423 useLoad(options => { 433 useLoad(options => {
424 registerSourceParams.reg_source = options?.reg_source || '' 434 registerSourceParams.reg_source = options?.reg_source || ''
425 registerSourceParams.reg_stage_id = options?.reg_stage_id || '' 435 registerSourceParams.reg_stage_id = options?.reg_stage_id || ''
426 - registerSourceParams.return_url = normalizeReturnUrl(options?.return_url || '') 436 + registerSourceParams.from = options?.from || ''
427 }) 437 })
428 </script> 438 </script>
429 439
......
...@@ -226,7 +226,6 @@ import { Tips, Photograph, Right, IconFont } from '@nutui/icons-vue-taro' ...@@ -226,7 +226,6 @@ import { Tips, Photograph, Right, IconFont } from '@nutui/icons-vue-taro'
226 import BASE_URL from '@/utils/config' 226 import BASE_URL from '@/utils/config'
227 // 接口信息 227 // 接口信息
228 import { createFamilyAPI } from '@/api/family' 228 import { createFamilyAPI } from '@/api/family'
229 -import { normalizeReturnUrl } from '@/utils/returnUrl'
230 // 区域信息 229 // 区域信息
231 import { SHANGHAI_REGION } from '@/utils/config' 230 import { SHANGHAI_REGION } from '@/utils/config'
232 231
...@@ -251,7 +250,6 @@ const districtColumns = ref(SHANGHAI_REGION) ...@@ -251,7 +250,6 @@ const districtColumns = ref(SHANGHAI_REGION)
251 const familyAvatar = ref('') 250 const familyAvatar = ref('')
252 const focusedIndex = ref(-1) 251 const focusedIndex = ref(-1)
253 const inputRefs = ref([]) 252 const inputRefs = ref([])
254 -const returnUrl = ref('')
255 253
256 const isFormValid = computed(() => { 254 const isFormValid = computed(() => {
257 return ( 255 return (
...@@ -538,13 +536,7 @@ const handleCreateFamily = async () => { ...@@ -538,13 +536,7 @@ const handleCreateFamily = async () => {
538 showToast('创建成功', 'success') 536 showToast('创建成功', 'success')
539 537
540 setTimeout(() => { 538 setTimeout(() => {
541 - if (returnUrl.value) { 539 + // 扫码准入链路已经不要求回原详情页,创建家庭成功后直接进入首页即可。
542 - Taro.redirectTo({
543 - url: normalizeReturnUrl(returnUrl.value),
544 - })
545 - return
546 - }
547 -
548 Taro.navigateTo({ 540 Taro.navigateTo({
549 url: '/pages/Dashboard/index', 541 url: '/pages/Dashboard/index',
550 }) 542 })
...@@ -559,8 +551,4 @@ const handleCreateFamily = async () => { ...@@ -559,8 +551,4 @@ const handleCreateFamily = async () => {
559 showToast('网络错误,请重试', 'none') 551 showToast('网络错误,请重试', 'none')
560 } 552 }
561 } 553 }
562 -
563 -Taro.useLoad(options => {
564 - returnUrl.value = normalizeReturnUrl(options?.return_url || '')
565 -})
566 </script> 554 </script>
......
...@@ -182,7 +182,6 @@ import Taro from '@tarojs/taro' ...@@ -182,7 +182,6 @@ import Taro from '@tarojs/taro'
182 import { My, Check, IconFont } from '@nutui/icons-vue-taro' 182 import { My, Check, IconFont } from '@nutui/icons-vue-taro'
183 // 获取接口信息 183 // 获取接口信息
184 import { searchFamilyByPassphraseAPI, joinFamilyAPI } from '@/api/family' 184 import { searchFamilyByPassphraseAPI, joinFamilyAPI } from '@/api/family'
185 -import { normalizeReturnUrl } from '@/utils/returnUrl'
186 // 导入主题颜色 185 // 导入主题颜色
187 import { THEME_COLORS } from '@/utils/config' 186 import { THEME_COLORS } from '@/utils/config'
188 // 默认头像 187 // 默认头像
...@@ -208,7 +207,6 @@ const pageSize = ref(10) ...@@ -208,7 +207,6 @@ const pageSize = ref(10)
208 const hasMoreData = ref(true) 207 const hasMoreData = ref(true)
209 const isLoadingMore = ref(false) 208 const isLoadingMore = ref(false)
210 const totalFamilies = ref([]) 209 const totalFamilies = ref([])
211 -const returnUrl = ref('')
212 210
213 const handleInputChange = (index, value) => { 211 const handleInputChange = (index, value) => {
214 // 允许输入多个字符,但只保留第一个有效字符(汉字、数字、大小写字母),兼容输入法 212 // 允许输入多个字符,但只保留第一个有效字符(汉字、数字、大小写字母),兼容输入法
...@@ -396,13 +394,8 @@ const confirmJoinFamily = async () => { ...@@ -396,13 +394,8 @@ const confirmJoinFamily = async () => {
396 }) 394 })
397 395
398 setTimeout(() => { 396 setTimeout(() => {
399 - if (returnUrl.value) { 397 + // 无论是单个家庭直加入,还是弹窗确认加入,
400 - Taro.redirectTo({ 398 + // 现在成功后都统一进入首页,不再做扫码详情回跳。
401 - url: normalizeReturnUrl(returnUrl.value),
402 - })
403 - return
404 - }
405 -
406 Taro.redirectTo({ 399 Taro.redirectTo({
407 url: '/pages/Dashboard/index', 400 url: '/pages/Dashboard/index',
408 }) 401 })
...@@ -476,13 +469,7 @@ const handleJoinFamily = async () => { ...@@ -476,13 +469,7 @@ const handleJoinFamily = async () => {
476 }) 469 })
477 470
478 setTimeout(() => { 471 setTimeout(() => {
479 - if (returnUrl.value) { 472 + // 这里和弹窗确认加入保持同一落点,避免两条加入分支跳转语义不一致。
480 - Taro.redirectTo({
481 - url: normalizeReturnUrl(returnUrl.value),
482 - })
483 - return
484 - }
485 -
486 Taro.redirectTo({ 473 Taro.redirectTo({
487 url: '/pages/Dashboard/index', 474 url: '/pages/Dashboard/index',
488 }) 475 })
...@@ -504,10 +491,6 @@ const handleJoinFamily = async () => { ...@@ -504,10 +491,6 @@ const handleJoinFamily = async () => {
504 } 491 }
505 } 492 }
506 493
507 -Taro.useLoad(options => {
508 - returnUrl.value = normalizeReturnUrl(options?.return_url || '')
509 -})
510 -
511 // 加载更多家庭数据 494 // 加载更多家庭数据
512 const loadMoreFamilies = async () => { 495 const loadMoreFamilies = async () => {
513 if (isLoadingMore.value || !hasMoreData.value) { 496 if (isLoadingMore.value || !hasMoreData.value) {
......
...@@ -55,7 +55,7 @@ import { reactive, computed } from 'vue' ...@@ -55,7 +55,7 @@ import { reactive, computed } from 'vue'
55 import Taro, { useLoad } from '@tarojs/taro' 55 import Taro, { useLoad } from '@tarojs/taro'
56 import './index.less' 56 import './index.less'
57 import RichTextRenderer from '@/components/RichTextRenderer.vue' 57 import RichTextRenderer from '@/components/RichTextRenderer.vue'
58 -import { getCurrentPageFullPath, handleSharePageAuth } from '@/utils/authRedirect' 58 +import { handleSharePageAuth } from '@/utils/authRedirect'
59 import { getMyFamiliesAPI } from '@/api/family' 59 import { getMyFamiliesAPI } from '@/api/family'
60 import { getScanStageDetailAPI, submitScanCheckinAPI } from '@/api/map_activity' 60 import { getScanStageDetailAPI, submitScanCheckinAPI } from '@/api/map_activity'
61 import { getUserProfileAPI } from '@/api/user' 61 import { getUserProfileAPI } from '@/api/user'
...@@ -74,7 +74,6 @@ const detail = reactive({ ...@@ -74,7 +74,6 @@ const detail = reactive({
74 id: '', 74 id: '',
75 regSource: '', 75 regSource: '',
76 regStageId: '', 76 regStageId: '',
77 - returnUrl: '',
78 openid: '', 77 openid: '',
79 entryMode: 'scan_before_submit', 78 entryMode: 'scan_before_submit',
80 entrySceneRaw: '', 79 entrySceneRaw: '',
...@@ -128,10 +127,10 @@ const normalizedRichTextContent = computed(() => { ...@@ -128,10 +127,10 @@ const normalizedRichTextContent = computed(() => {
128 const navigateToWelcome = () => { 127 const navigateToWelcome = () => {
129 // 扫码入口沿用首页广告位的判断路线: 128 // 扫码入口沿用首页广告位的判断路线:
130 // 先判断是否有家庭,没有则先去 Welcome,再由 Welcome 决定补资料/创建家庭/加入家庭。 129 // 先判断是否有家庭,没有则先去 Welcome,再由 Welcome 决定补资料/创建家庭/加入家庭。
130 + // 现在这条链路不再要求“完成后回到当前详情页继续扫码”,而是完成家庭准入后回首页。
131 const params = new URLSearchParams({ 131 const params = new URLSearchParams({
132 reg_source: detail.regSource, 132 reg_source: detail.regSource,
133 reg_stage_id: detail.regStageId, 133 reg_stage_id: detail.regStageId,
134 - return_url: detail.returnUrl,
135 }) 134 })
136 135
137 Taro.redirectTo({ 136 Taro.redirectTo({
...@@ -427,8 +426,6 @@ const initPage = options => { ...@@ -427,8 +426,6 @@ const initPage = options => {
427 detail.regStageId = options.reg_stage_id || '' 426 detail.regStageId = options.reg_stage_id || ''
428 detail.entrySceneRaw = sceneParams.rawScene || '' 427 detail.entrySceneRaw = sceneParams.rawScene || ''
429 detail.entryMode = resolveEntryMode(sceneParams, options) 428 detail.entryMode = resolveEntryMode(sceneParams, options)
430 - // 当前页路径会透传给补资料页,提交成功后用于回跳续扫。
431 - detail.returnUrl = `/${getCurrentPageFullPath()}`
432 detail.id = detailId 429 detail.id = detailId
433 430
434 loadStageDetail() 431 loadStageDetail()
......
...@@ -148,7 +148,6 @@ import BottomNav from '@/components/BottomNav.vue' ...@@ -148,7 +148,6 @@ import BottomNav from '@/components/BottomNav.vue'
148 import AdOverlay from '@/components/AdOverlay.vue' 148 import AdOverlay from '@/components/AdOverlay.vue'
149 // 获取接口信息 149 // 获取接口信息
150 import { getUserProfileAPI } from '@/api/user' 150 import { getUserProfileAPI } from '@/api/user'
151 -import { appendReturnUrlParam, normalizeReturnUrl } from '@/utils/returnUrl'
152 import { isUserProfileComplete } from '@/utils/userProfile' 151 import { isUserProfileComplete } from '@/utils/userProfile'
153 // 导入主题颜色 152 // 导入主题颜色
154 import { THEME_COLORS } from '@/utils/config' 153 import { THEME_COLORS } from '@/utils/config'
...@@ -160,7 +159,6 @@ const userAge = ref(null) ...@@ -160,7 +159,6 @@ const userAge = ref(null)
160 const userInfo = ref({}) 159 const userInfo = ref({})
161 const canCreateFamily = ref(true) 160 const canCreateFamily = ref(true)
162 const hasProfile = ref(false) 161 const hasProfile = ref(false)
163 -const returnUrl = ref('')
164 const regSource = ref('') 162 const regSource = ref('')
165 const regStageId = ref('') 163 const regStageId = ref('')
166 164
...@@ -243,10 +241,9 @@ useDidShow(async () => { ...@@ -243,10 +241,9 @@ useDidShow(async () => {
243 }) 241 })
244 242
245 const handleNavigate = url => { 243 const handleNavigate = url => {
246 - const nextUrl = appendReturnUrl(url)
247 -
248 if (!hasProfile.value) { 244 if (!hasProfile.value) {
249 - // 显示个人信息收集说明弹窗 245 + // 扫码准入链路里,缺资料时要先去补资料页,
246 + // 补完后再回 Welcome,让用户继续选择“创建家庭”或“加入家庭”。
250 pendingNavigateUrl.value = buildAddProfileUrl() 247 pendingNavigateUrl.value = buildAddProfileUrl()
251 showPrivacyDialog.value = true 248 showPrivacyDialog.value = true
252 return 249 return
...@@ -260,7 +257,7 @@ const handleNavigate = url => { ...@@ -260,7 +257,7 @@ const handleNavigate = url => {
260 } 257 }
261 } 258 }
262 259
263 - navigateTo(nextUrl) 260 + navigateTo(url)
264 } 261 }
265 262
266 // Dialog事件处理方法 263 // Dialog事件处理方法
...@@ -284,22 +281,18 @@ const onAgeConfirm = () => { ...@@ -284,22 +281,18 @@ const onAgeConfirm = () => {
284 useLoad(options => { 281 useLoad(options => {
285 // 处理分享页面的授权逻辑 282 // 处理分享页面的授权逻辑
286 handleSharePageAuth(options) 283 handleSharePageAuth(options)
287 - returnUrl.value = normalizeReturnUrl(options?.return_url || '')
288 regSource.value = options?.reg_source || '' 284 regSource.value = options?.reg_source || ''
289 regStageId.value = options?.reg_stage_id || '' 285 regStageId.value = options?.reg_stage_id || ''
290 }) 286 })
291 287
292 -const appendReturnUrl = url => {
293 - return appendReturnUrlParam(url, returnUrl.value)
294 -}
295 -
296 const buildAddProfileUrl = () => { 288 const buildAddProfileUrl = () => {
297 - if (!returnUrl.value && !regSource.value && !regStageId.value) { 289 + if (!regSource.value && !regStageId.value) {
298 return '/pages/AddProfile/index' 290 return '/pages/AddProfile/index'
299 } 291 }
300 292
301 - // 从扫码链路进入 Welcome 时,补资料完成后应该先回 Welcome, 293 + // from=welcome 只表达一件事:
302 - // 继续完成创建/加入家庭,最后再由家庭流程回到打卡详情页。 294 + // AddProfile 保存成功后先回 Welcome,不直接去首页,
295 + // 因为用户还没完成“创建家庭 / 加入家庭”这个关键分支。
303 const params = new URLSearchParams() 296 const params = new URLSearchParams()
304 if (regSource.value) { 297 if (regSource.value) {
305 params.set('reg_source', regSource.value) 298 params.set('reg_source', regSource.value)
...@@ -307,28 +300,11 @@ const buildAddProfileUrl = () => { ...@@ -307,28 +300,11 @@ const buildAddProfileUrl = () => {
307 if (regStageId.value) { 300 if (regStageId.value) {
308 params.set('reg_stage_id', regStageId.value) 301 params.set('reg_stage_id', regStageId.value)
309 } 302 }
310 - params.set('return_url', buildWelcomeReturnUrl()) 303 + params.set('from', 'welcome')
311 304
312 return `/pages/AddProfile/index?${params.toString()}` 305 return `/pages/AddProfile/index?${params.toString()}`
313 } 306 }
314 307
315 -const buildWelcomeReturnUrl = () => {
316 - const params = new URLSearchParams()
317 -
318 - if (regSource.value) {
319 - params.set('reg_source', regSource.value)
320 - }
321 - if (regStageId.value) {
322 - params.set('reg_stage_id', regStageId.value)
323 - }
324 - if (returnUrl.value) {
325 - params.set('return_url', returnUrl.value)
326 - }
327 -
328 - const query = params.toString()
329 - return query ? `/pages/Welcome/index?${query}` : '/pages/Welcome/index'
330 -}
331 -
332 /** 308 /**
333 * 定义分享给朋友的内容 309 * 定义分享给朋友的内容
334 * @returns {Object} 分享配置对象 310 * @returns {Object} 分享配置对象
......