Commit a058d446 by Liu

feat:工单busiId参数改为userid

parent 3b632092
...@@ -132,23 +132,23 @@ export const TacticsChat: React.FC = () => { ...@@ -132,23 +132,23 @@ export const TacticsChat: React.FC = () => {
const getConversationExtra = useCallback(() => { const getConversationExtra = useCallback(() => {
if (orderMeta) { if (orderMeta) {
console.log('orderMeta', orderMeta) console.log('orderMeta', orderMeta)
// 从 localStorage 读取 userName // 从 localStorage 读取 userId
const userNameFromStorage = safeLocalStorageGetItem('__USER_NAME__') const userIdFromStorage = safeLocalStorageGetItem('__USER_NAME__')
let userName = '' let userId = ''
if (userNameFromStorage) { if (userIdFromStorage) {
try { try {
// useLocalStorageState 会将值序列化为 JSON,需要解析 // useLocalStorageState 会将值序列化为 JSON,需要解析
const parsed = JSON.parse(userNameFromStorage) const parsed = JSON.parse(userIdFromStorage)
userName = parsed || userNameFromStorage userId = parsed || userIdFromStorage
} }
catch { catch {
// 如果不是 JSON 格式,直接使用原始值 // 如果不是 JSON 格式,直接使用原始值
userName = userNameFromStorage userId = userIdFromStorage
} }
} }
return { return {
busiType: '02', busiType: '02',
busiId: userName, busiId: userId,
workOrderIds: orderMeta.workOrderIds, workOrderIds: orderMeta.workOrderIds,
} as Partial<any> } as Partial<any>
} }
...@@ -446,21 +446,21 @@ export const TacticsChat: React.FC = () => { ...@@ -446,21 +446,21 @@ export const TacticsChat: React.FC = () => {
// from=tactics 场景下补充业务识别参数 // from=tactics 场景下补充业务识别参数
if (orderMeta && shouldIncludeOrderMeta) { if (orderMeta && shouldIncludeOrderMeta) {
requestBody.busiType ??= '02' requestBody.busiType ??= '02'
// 从 localStorage 读取 userName // 从 localStorage 读取 userId
const userNameFromStorage = safeLocalStorageGetItem('__USER_NAME__') const userIdFromStorage = safeLocalStorageGetItem('__USER_NAME__')
let userName = '' let userId = ''
if (userNameFromStorage) { if (userIdFromStorage) {
try { try {
// useLocalStorageState 会将值序列化为 JSON,需要解析 // useLocalStorageState 会将值序列化为 JSON,需要解析
const parsed = JSON.parse(userNameFromStorage) const parsed = JSON.parse(userIdFromStorage)
userName = parsed || userNameFromStorage userId = parsed || userIdFromStorage
} }
catch { catch {
// 如果不是 JSON 格式,直接使用原始值 // 如果不是 JSON 格式,直接使用原始值
userName = userNameFromStorage userId = userIdFromStorage
} }
} }
requestBody.busiId = userName requestBody.busiId = userId
} }
else if (userMeta?.place === 'user') { else if (userMeta?.place === 'user') {
requestBody.busiType ??= '02' requestBody.busiType ??= '02'
......
...@@ -75,23 +75,23 @@ export const TacticsHome: React.FC = () => { ...@@ -75,23 +75,23 @@ export const TacticsHome: React.FC = () => {
// 仅用于创建会话的额外参数(对应 create_conversation) // 仅用于创建会话的额外参数(对应 create_conversation)
const getConversationExtra = useCallback(() => { const getConversationExtra = useCallback(() => {
if (orderMeta) { if (orderMeta) {
// 从 localStorage 读取 userName // 从 localStorage 读取 userId
const userNameFromStorage = safeLocalStorageGetItem('__USER_NAME__') const userIdFromStorage = safeLocalStorageGetItem('__USER_NAME__')
let userName = '' let userId = ''
if (userNameFromStorage) { if (userIdFromStorage) {
try { try {
// useLocalStorageState 会将值序列化为 JSON,需要解析 // useLocalStorageState 会将值序列化为 JSON,需要解析
const parsed = JSON.parse(userNameFromStorage) const parsed = JSON.parse(userIdFromStorage)
userName = parsed || userNameFromStorage userId = parsed || userIdFromStorage
} }
catch { catch {
// 如果不是 JSON 格式,直接使用原始值 // 如果不是 JSON 格式,直接使用原始值
userName = userNameFromStorage userId = userIdFromStorage
} }
} }
return { return {
busiType: '02', busiType: '02',
busiId: userName, busiId: userId,
workOrderIds: orderMeta.workOrderIds, workOrderIds: orderMeta.workOrderIds,
} as Partial<any> } as Partial<any>
} }
......
...@@ -295,17 +295,17 @@ export const Home: React.FC = () => { ...@@ -295,17 +295,17 @@ export const Home: React.FC = () => {
console.error('降级存储也失败:', storageError) console.error('降级存储也失败:', storageError)
} }
} }
if (res.data.userName) { if (res.data.userId) {
try { try {
setUserName(res.data.userName) setUserName(res.data.userId)
} }
catch { catch {
// userName 存储失败时使用降级方案 // userId 存储失败时使用降级方案
try { try {
safeLocalStorageSetItem('__USER_NAME__', JSON.stringify(res.data.userName)) safeLocalStorageSetItem('__USER_NAME__', JSON.stringify(res.data.userId))
} }
catch (storageError) { catch (storageError) {
console.error('userName 降级存储失败:', storageError) console.error('userId 降级存储失败:', storageError)
} }
} }
} }
...@@ -407,17 +407,17 @@ export const Home: React.FC = () => { ...@@ -407,17 +407,17 @@ export const Home: React.FC = () => {
console.error('降级存储也失败:', storageError) console.error('降级存储也失败:', storageError)
} }
} }
if (res.data.userName) { if (res.data.userId) {
try { try {
setUserName(res.data.userName) setUserName(res.data.userId)
} }
catch { catch {
// userName 存储失败时使用降级方案 // userId 存储失败时使用降级方案
try { try {
safeLocalStorageSetItem('__USER_NAME__', JSON.stringify(res.data.userName)) safeLocalStorageSetItem('__USER_NAME__', JSON.stringify(res.data.userId))
} }
catch (storageError) { catch (storageError) {
console.error('userName 降级存储失败:', storageError) console.error('userId 降级存储失败:', storageError)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment