mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-09-20 20:02:02 +08:00
feat(distribution): 增强分销入口检查与用户反馈
- 引入自助招募入口检查逻辑,确保用户在访问前获得明确的状态反馈。 - 在分销相关页面中添加分销功能关闭和线上招募关闭的提示信息。 - 优化页面逻辑,确保在不同状态下用户体验的一致性与流畅性。
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
|
||||
import { distribution } from '@/api/distribution'
|
||||
import { distribution, getRecruitPage } from '@/api/distribution'
|
||||
|
||||
export const DISTRIBUTION_STATUS = {
|
||||
PASS: 'PASS',
|
||||
@@ -24,6 +24,17 @@ export const DISTRIBUTION_APPLY_MESSAGE = '您的信息正在审核'
|
||||
|
||||
export const DISTRIBUTION_NOT_MEMBER_MESSAGE = '您还不是分销员'
|
||||
|
||||
/** 线上自助招募入口关闭(22009) */
|
||||
export const DISTRIBUTION_ONLINE_ENTRY_CLOSED_MESSAGE = '暂未开放线上招募'
|
||||
|
||||
/** 邀请 token 无效或已失效(22010) */
|
||||
export const DISTRIBUTION_RECRUIT_INVITE_INVALID_MESSAGE = '邀请无效或已失效'
|
||||
|
||||
/** 分销总闸关闭时的前端展示文案(接口码 22000) */
|
||||
export const DISTRIBUTION_CLOSE_MESSAGE = '分销功能暂未开启'
|
||||
|
||||
const DISTRIBUTION_CLOSE_CODE = 22000
|
||||
|
||||
const JOIN_PATH = '/pages/mine/distribution/join'
|
||||
const MINE_TAB = '/pages/tabbar/user/my'
|
||||
const TOAST_DURATION = 2000
|
||||
@@ -61,6 +72,42 @@ function goRecruitJoin() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭判断与后端一致:onlineEntryVisible !== true(含 false / null / 缺字段)。
|
||||
*/
|
||||
export function isOnlineEntryVisible(page) {
|
||||
return !!(page && page.onlineEntryVisible === true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析招募页响应,决定自助入口是否可进。
|
||||
* 22000 不算 fail-open;其它非 success 或网络失败为 fail-open。
|
||||
* @returns {'open'|'entry_closed'|'distribution_closed'|'fail_open'}
|
||||
*/
|
||||
export function resolveRecruitPageGate(res) {
|
||||
const data = res && res.data ? res.data : res
|
||||
if (!data) {
|
||||
return 'fail_open'
|
||||
}
|
||||
if (data.code == DISTRIBUTION_CLOSE_CODE) {
|
||||
return 'distribution_closed'
|
||||
}
|
||||
if (data.success) {
|
||||
return isOnlineEntryVisible(data.result) ? 'open' : 'entry_closed'
|
||||
}
|
||||
return 'fail_open'
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉招募页判断自助入口。仅成功且入口关闭时拦截;22000 走总闸;失败 fail-open。
|
||||
* @returns {Promise<'open'|'entry_closed'|'distribution_closed'|'fail_open'>}
|
||||
*/
|
||||
export function checkSelfRecruitEntry() {
|
||||
return getRecruitPage()
|
||||
.then((res) => resolveRecruitPageGate(res))
|
||||
.catch((err) => resolveRecruitPageGate(err && err.data ? err : null))
|
||||
}
|
||||
|
||||
/**
|
||||
* 能力页非 PASS 提示并退出。RETREAT 用统一清退文案;APPLY / REFUSE 与入口一致。
|
||||
*/
|
||||
@@ -72,7 +119,19 @@ export function leaveInactiveDistributor(member) {
|
||||
return
|
||||
}
|
||||
if (status === DISTRIBUTION_STATUS.REFUSE) {
|
||||
goRecruitJoin()
|
||||
checkSelfRecruitEntry().then((gate) => {
|
||||
if (gate === 'distribution_closed') {
|
||||
showStatusToast(DISTRIBUTION_CLOSE_MESSAGE)
|
||||
leaveCapabilityPage()
|
||||
return
|
||||
}
|
||||
if (gate === 'entry_closed') {
|
||||
showStatusToast(DISTRIBUTION_ONLINE_ENTRY_CLOSED_MESSAGE)
|
||||
leaveCapabilityPage()
|
||||
return
|
||||
}
|
||||
goRecruitJoin()
|
||||
})
|
||||
return
|
||||
}
|
||||
if (status === DISTRIBUTION_STATUS.APPLY) {
|
||||
|
||||
Reference in New Issue
Block a user