hookehuyr

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

- 移除多个页面中冗余的normalizeReturnUrl导入与return_url状态管理代码
- 统一家庭创建、加入以及用户资料补全后的跳转规则,不再回跳扫码详情页
- 重构Welcome与AddProfile页面的参数传递逻辑,使用from=welcome替代老旧传参方式
......@@ -179,7 +179,6 @@ import BASE_URL from '@/utils/config'
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
// 获取接口信息
import { updateUserProfileAPI } from '@/api/user'
import { normalizeReturnUrl } from '@/utils/returnUrl'
import { buildUpdateUserProfilePayload } from '@/utils/userProfile'
// 导入主题颜色
import { THEME_COLORS } from '@/utils/config'
......@@ -204,7 +203,7 @@ const formData = reactive({
const registerSourceParams = reactive({
reg_source: '',
reg_stage_id: '',
return_url: '',
from: '',
})
/**
......@@ -401,10 +400,21 @@ const handleSave = async () => {
icon: 'success',
})
setTimeout(() => {
// 从扫码打卡链路进入补资料页时,保存成功后需要原路回到关卡详情继续扫码。
if (registerSourceParams.return_url) {
// Welcome 进入补资料页时,保存成功后要回 Welcome 继续完成家庭选择,
// 不能直接去首页,否则没有家庭的用户会被首页再打回 Welcome。
if (registerSourceParams.from === 'welcome') {
const params = new URLSearchParams()
if (registerSourceParams.reg_source) {
params.set('reg_source', registerSourceParams.reg_source)
}
if (registerSourceParams.reg_stage_id) {
params.set('reg_stage_id', registerSourceParams.reg_stage_id)
}
const query = params.toString()
Taro.redirectTo({
url: normalizeReturnUrl(registerSourceParams.return_url),
url: query ? `/pages/Welcome/index?${query}` : '/pages/Welcome/index',
})
return
}
......@@ -423,7 +433,7 @@ const handleSave = async () => {
useLoad(options => {
registerSourceParams.reg_source = options?.reg_source || ''
registerSourceParams.reg_stage_id = options?.reg_stage_id || ''
registerSourceParams.return_url = normalizeReturnUrl(options?.return_url || '')
registerSourceParams.from = options?.from || ''
})
</script>
......
......@@ -226,7 +226,6 @@ import { Tips, Photograph, Right, IconFont } from '@nutui/icons-vue-taro'
import BASE_URL from '@/utils/config'
// 接口信息
import { createFamilyAPI } from '@/api/family'
import { normalizeReturnUrl } from '@/utils/returnUrl'
// 区域信息
import { SHANGHAI_REGION } from '@/utils/config'
......@@ -251,7 +250,6 @@ const districtColumns = ref(SHANGHAI_REGION)
const familyAvatar = ref('')
const focusedIndex = ref(-1)
const inputRefs = ref([])
const returnUrl = ref('')
const isFormValid = computed(() => {
return (
......@@ -538,13 +536,7 @@ const handleCreateFamily = async () => {
showToast('创建成功', 'success')
setTimeout(() => {
if (returnUrl.value) {
Taro.redirectTo({
url: normalizeReturnUrl(returnUrl.value),
})
return
}
// 扫码准入链路已经不要求回原详情页,创建家庭成功后直接进入首页即可。
Taro.navigateTo({
url: '/pages/Dashboard/index',
})
......@@ -559,8 +551,4 @@ const handleCreateFamily = async () => {
showToast('网络错误,请重试', 'none')
}
}
Taro.useLoad(options => {
returnUrl.value = normalizeReturnUrl(options?.return_url || '')
})
</script>
......
......@@ -182,7 +182,6 @@ import Taro from '@tarojs/taro'
import { My, Check, IconFont } from '@nutui/icons-vue-taro'
// 获取接口信息
import { searchFamilyByPassphraseAPI, joinFamilyAPI } from '@/api/family'
import { normalizeReturnUrl } from '@/utils/returnUrl'
// 导入主题颜色
import { THEME_COLORS } from '@/utils/config'
// 默认头像
......@@ -208,7 +207,6 @@ const pageSize = ref(10)
const hasMoreData = ref(true)
const isLoadingMore = ref(false)
const totalFamilies = ref([])
const returnUrl = ref('')
const handleInputChange = (index, value) => {
// 允许输入多个字符,但只保留第一个有效字符(汉字、数字、大小写字母),兼容输入法
......@@ -396,13 +394,8 @@ const confirmJoinFamily = async () => {
})
setTimeout(() => {
if (returnUrl.value) {
Taro.redirectTo({
url: normalizeReturnUrl(returnUrl.value),
})
return
}
// 无论是单个家庭直加入,还是弹窗确认加入,
// 现在成功后都统一进入首页,不再做扫码详情回跳。
Taro.redirectTo({
url: '/pages/Dashboard/index',
})
......@@ -476,13 +469,7 @@ const handleJoinFamily = async () => {
})
setTimeout(() => {
if (returnUrl.value) {
Taro.redirectTo({
url: normalizeReturnUrl(returnUrl.value),
})
return
}
// 这里和弹窗确认加入保持同一落点,避免两条加入分支跳转语义不一致。
Taro.redirectTo({
url: '/pages/Dashboard/index',
})
......@@ -504,10 +491,6 @@ const handleJoinFamily = async () => {
}
}
Taro.useLoad(options => {
returnUrl.value = normalizeReturnUrl(options?.return_url || '')
})
// 加载更多家庭数据
const loadMoreFamilies = async () => {
if (isLoadingMore.value || !hasMoreData.value) {
......
......@@ -55,7 +55,7 @@ import { reactive, computed } from 'vue'
import Taro, { useLoad } from '@tarojs/taro'
import './index.less'
import RichTextRenderer from '@/components/RichTextRenderer.vue'
import { getCurrentPageFullPath, handleSharePageAuth } from '@/utils/authRedirect'
import { handleSharePageAuth } from '@/utils/authRedirect'
import { getMyFamiliesAPI } from '@/api/family'
import { getScanStageDetailAPI, submitScanCheckinAPI } from '@/api/map_activity'
import { getUserProfileAPI } from '@/api/user'
......@@ -74,7 +74,6 @@ const detail = reactive({
id: '',
regSource: '',
regStageId: '',
returnUrl: '',
openid: '',
entryMode: 'scan_before_submit',
entrySceneRaw: '',
......@@ -128,10 +127,10 @@ const normalizedRichTextContent = computed(() => {
const navigateToWelcome = () => {
// 扫码入口沿用首页广告位的判断路线:
// 先判断是否有家庭,没有则先去 Welcome,再由 Welcome 决定补资料/创建家庭/加入家庭。
// 现在这条链路不再要求“完成后回到当前详情页继续扫码”,而是完成家庭准入后回首页。
const params = new URLSearchParams({
reg_source: detail.regSource,
reg_stage_id: detail.regStageId,
return_url: detail.returnUrl,
})
Taro.redirectTo({
......@@ -427,8 +426,6 @@ const initPage = options => {
detail.regStageId = options.reg_stage_id || ''
detail.entrySceneRaw = sceneParams.rawScene || ''
detail.entryMode = resolveEntryMode(sceneParams, options)
// 当前页路径会透传给补资料页,提交成功后用于回跳续扫。
detail.returnUrl = `/${getCurrentPageFullPath()}`
detail.id = detailId
loadStageDetail()
......
......@@ -148,7 +148,6 @@ import BottomNav from '@/components/BottomNav.vue'
import AdOverlay from '@/components/AdOverlay.vue'
// 获取接口信息
import { getUserProfileAPI } from '@/api/user'
import { appendReturnUrlParam, normalizeReturnUrl } from '@/utils/returnUrl'
import { isUserProfileComplete } from '@/utils/userProfile'
// 导入主题颜色
import { THEME_COLORS } from '@/utils/config'
......@@ -160,7 +159,6 @@ const userAge = ref(null)
const userInfo = ref({})
const canCreateFamily = ref(true)
const hasProfile = ref(false)
const returnUrl = ref('')
const regSource = ref('')
const regStageId = ref('')
......@@ -243,10 +241,9 @@ useDidShow(async () => {
})
const handleNavigate = url => {
const nextUrl = appendReturnUrl(url)
if (!hasProfile.value) {
// 显示个人信息收集说明弹窗
// 扫码准入链路里,缺资料时要先去补资料页,
// 补完后再回 Welcome,让用户继续选择“创建家庭”或“加入家庭”。
pendingNavigateUrl.value = buildAddProfileUrl()
showPrivacyDialog.value = true
return
......@@ -260,7 +257,7 @@ const handleNavigate = url => {
}
}
navigateTo(nextUrl)
navigateTo(url)
}
// Dialog事件处理方法
......@@ -284,22 +281,18 @@ const onAgeConfirm = () => {
useLoad(options => {
// 处理分享页面的授权逻辑
handleSharePageAuth(options)
returnUrl.value = normalizeReturnUrl(options?.return_url || '')
regSource.value = options?.reg_source || ''
regStageId.value = options?.reg_stage_id || ''
})
const appendReturnUrl = url => {
return appendReturnUrlParam(url, returnUrl.value)
}
const buildAddProfileUrl = () => {
if (!returnUrl.value && !regSource.value && !regStageId.value) {
if (!regSource.value && !regStageId.value) {
return '/pages/AddProfile/index'
}
// 从扫码链路进入 Welcome 时,补资料完成后应该先回 Welcome,
// 继续完成创建/加入家庭,最后再由家庭流程回到打卡详情页。
// from=welcome 只表达一件事:
// AddProfile 保存成功后先回 Welcome,不直接去首页,
// 因为用户还没完成“创建家庭 / 加入家庭”这个关键分支。
const params = new URLSearchParams()
if (regSource.value) {
params.set('reg_source', regSource.value)
......@@ -307,28 +300,11 @@ const buildAddProfileUrl = () => {
if (regStageId.value) {
params.set('reg_stage_id', regStageId.value)
}
params.set('return_url', buildWelcomeReturnUrl())
params.set('from', 'welcome')
return `/pages/AddProfile/index?${params.toString()}`
}
const buildWelcomeReturnUrl = () => {
const params = new URLSearchParams()
if (regSource.value) {
params.set('reg_source', regSource.value)
}
if (regStageId.value) {
params.set('reg_stage_id', regStageId.value)
}
if (returnUrl.value) {
params.set('return_url', returnUrl.value)
}
const query = params.toString()
return query ? `/pages/Welcome/index?${query}` : '/pages/Welcome/index'
}
/**
* 定义分享给朋友的内容
* @returns {Object} 分享配置对象
......