mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-09-20 11:52:02 +08:00
feat(distribution): 优化招募页面数据加载逻辑
- 引入 `savePendingRecruitToken` 方法,确保在用户登录时保存招募令牌。 - 重构数据加载流程,使用异步函数处理页面数据和进度信息,提升用户体验。 - 增强错误处理,确保在加载失败时不影响页面展示。
This commit is contained in:
@@ -185,7 +185,7 @@ import storage from '@/utils/storage.js'
|
|||||||
import config from '@/config/config'
|
import config from '@/config/config'
|
||||||
import { parseGoodsImageUrl, tipsToLogin } from '@/utils/filters.js'
|
import { parseGoodsImageUrl, tipsToLogin } from '@/utils/filters.js'
|
||||||
import { resolveRecruitDistributionIdFromScene } from '@/utils/distributionBind.js'
|
import { resolveRecruitDistributionIdFromScene } from '@/utils/distributionBind.js'
|
||||||
import { getRecruitPage, getRecruitProgress, getRecruitInviter, submitRecruitApplication } from '@/api/distribution'
|
import { getRecruitPage, getRecruitProgress, getRecruitInviter, submitRecruitApplication, savePendingRecruitToken } from '@/api/distribution'
|
||||||
import {
|
import {
|
||||||
DISTRIBUTION_APPLY_MESSAGE,
|
DISTRIBUTION_APPLY_MESSAGE,
|
||||||
DISTRIBUTION_CLOSE_MESSAGE,
|
DISTRIBUTION_CLOSE_MESSAGE,
|
||||||
@@ -386,28 +386,40 @@ function loadPageData() {
|
|||||||
submitApplicationStatus.value = ''
|
submitApplicationStatus.value = ''
|
||||||
formInfoCompleted.value = false
|
formInfoCompleted.value = false
|
||||||
Object.keys(fieldErrors).forEach((key) => delete fieldErrors[key])
|
Object.keys(fieldErrors).forEach((key) => delete fieldErrors[key])
|
||||||
const tasks: Promise<any>[] = [getRecruitPage()]
|
|
||||||
if (isUserLoggedIn.value) {
|
const load = async () => {
|
||||||
tasks.push(getRecruitProgress())
|
if (isUserLoggedIn.value) {
|
||||||
}
|
if (recruitToken.value) {
|
||||||
Promise.all(tasks)
|
try {
|
||||||
.then((results) => {
|
await savePendingRecruitToken(recruitToken.value)
|
||||||
const pageRes = results[0]
|
} catch (e) {
|
||||||
const pageData = pageRes.data || {}
|
// 上报失败不阻断加入页
|
||||||
if (pageData.code == 22000) {
|
}
|
||||||
isDistributionClosed.value = true
|
}
|
||||||
pageInfo.value = {}
|
try {
|
||||||
|
const progressRes = await getRecruitProgress()
|
||||||
|
progress.value = progressRes.data?.result || emptyProgress()
|
||||||
|
} catch (e) {
|
||||||
progress.value = emptyProgress()
|
progress.value = emptyProgress()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
const pageResult = pageData.result || {}
|
}
|
||||||
pageInfo.value = pageResult
|
const pageRes = await getRecruitPage()
|
||||||
if (results.length > 1) {
|
const pageData = pageRes.data || {}
|
||||||
progress.value = results[1].data?.result || emptyProgress()
|
if (pageData.code == 22000) {
|
||||||
} else {
|
isDistributionClosed.value = true
|
||||||
progress.value = hasConditionalJoin(pageResult.plan) ? emptyProgress() : { satisfied: true }
|
pageInfo.value = {}
|
||||||
}
|
progress.value = emptyProgress()
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
const pageResult = pageData.result || {}
|
||||||
|
pageInfo.value = pageResult
|
||||||
|
if (!isUserLoggedIn.value) {
|
||||||
|
progress.value = hasConditionalJoin(pageResult.plan) ? emptyProgress() : { satisfied: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.resolve(load())
|
||||||
|
.catch(() => {})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user