fix:客服和绑定手机号问题修复
This commit is contained in:
46
src/utils/api-flow-token.ts
Normal file
46
src/utils/api-flow-token.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/** 判断是否为接口返回的 opaque 令牌(非中文提示文案) */
|
||||
function isOpaqueToken(value: string): boolean {
|
||||
if (!value) return false
|
||||
if (/[\u4e00-\u9fa5,。!?;:]/.test(value)) return false
|
||||
return value.length >= 8
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 request 解包结果或完整 ApiResponse 中提取流程令牌。
|
||||
* 部分 RuoYi 接口在 data 为空时把 changeToken / resetToken 放在 msg。
|
||||
*/
|
||||
export function extractFlowToken(data: unknown): string {
|
||||
if (typeof data === 'string') {
|
||||
const text = data.trim()
|
||||
return isOpaqueToken(text) ? text : ''
|
||||
}
|
||||
if (!data || typeof data !== 'object') return ''
|
||||
|
||||
const record = data as Record<string, unknown>
|
||||
|
||||
for (const key of ['changeToken', 'resetToken', 'token']) {
|
||||
const direct = record[key]
|
||||
if (direct != null && String(direct).trim()) {
|
||||
return String(direct).trim()
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof record.data === 'string' && record.data.trim()) {
|
||||
return record.data.trim()
|
||||
}
|
||||
|
||||
if (record.data && typeof record.data === 'object') {
|
||||
const nested = record.data as Record<string, unknown>
|
||||
for (const key of ['changeToken', 'resetToken', 'token']) {
|
||||
const v = nested[key]
|
||||
if (v != null && String(v).trim()) return String(v).trim()
|
||||
}
|
||||
}
|
||||
|
||||
const msg = typeof record.msg === 'string' ? record.msg.trim() : ''
|
||||
if (msg && (record.data === null || record.data === undefined) && isOpaqueToken(msg)) {
|
||||
return msg
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
@@ -27,8 +27,9 @@ import tabMine from '@/static/tab-mine-active.png'
|
||||
import tabMineActive from '@/static/tab-mine.png'
|
||||
import iconChevronLeft from '@/static/chevron.left.png'
|
||||
import iconSupportMic from '@/static/组 134.png'
|
||||
import iconSupportTag from '@/static/图标 13.png'
|
||||
import iconSupportPhoto from '@/static/图片.png'
|
||||
import iconSupportSend from '@/static/图标 14.png'
|
||||
import iconSupportQueue from '@/static/组 98@2x.png'
|
||||
import iconMineNotify from '@/static/组 14919@2x.png'
|
||||
import iconMineOrder from '@/static/订单@2x.png'
|
||||
import iconMineCoupon from '@/static/优惠券@2x.png'
|
||||
@@ -87,10 +88,12 @@ export const staticAssets = {
|
||||
iconChevronLeft,
|
||||
/** 组 134.png — 在线客服页麦克风 */
|
||||
iconSupportMic,
|
||||
/** 图标 13.png — 在线客服页输入框旁标签 */
|
||||
iconSupportTag,
|
||||
/** 图片.png — 在线客服页发送图片 */
|
||||
iconSupportPhoto,
|
||||
/** 图标 14.png — 在线客服页发送 */
|
||||
iconSupportSend,
|
||||
/** 组 98@2x.png — 在线客服排队卡片标题图标 */
|
||||
iconSupportQueue,
|
||||
/** 组 14919@2x.png — 我的页消息通知 */
|
||||
iconMineNotify,
|
||||
/** 订单@2x.png — 我的页我的订单 */
|
||||
|
||||
Reference in New Issue
Block a user