From 8e036cc171aee438767772a5cef17396b57d72e7 Mon Sep 17 00:00:00 2001 From: commie Date: Sun, 23 Nov 2025 07:58:47 +0800 Subject: [PATCH] 3 --- api/login.js | 18 ++++++++---------- pages/common/searchUserOrGroup/index.vue | 9 +++++---- pages/common/userCard/index.vue | 9 +++------ store/modules/user.js | 15 ++++++--------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/api/login.js b/api/login.js index 675f71f..f6e111f 100644 --- a/api/login.js +++ b/api/login.js @@ -48,15 +48,14 @@ export const businessGetUserInfo = (userID) => } ); -export const businessSearchUserInfo = (keyword) => +export const businessSearchUserInfo = (keyword,searchtype) => uni.$u?.http.post( "/user/search", JSON.stringify({ keyword, - pagination: { - pageNumber: 1, - showNumber: 10, - }, + searchtype:(searchtype? searchtype : 'id'), + page: 1, + limit: 10 }), { header: { token: uni.getStorageSync("BusinessToken"), @@ -64,15 +63,14 @@ export const businessSearchUserInfo = (keyword) => } ); -export const businessSearchUser = (keyword) => +export const businessSearchUser = (keyword,searchtype) => uni.$u?.http.post( "/friend/search", JSON.stringify({ keyword, - pagination: { - pageNumber: 1, - showNumber: 99, - }, + searchtype:(searchtype? searchtype : 'id'), + page: 1, + limit: 99, }), { header: { token: uni.getStorageSync("BusinessToken"), diff --git a/pages/common/searchUserOrGroup/index.vue b/pages/common/searchUserOrGroup/index.vue index 90acd5a..437ec24 100644 --- a/pages/common/searchUserOrGroup/index.vue +++ b/pages/common/searchUserOrGroup/index.vue @@ -98,19 +98,20 @@ (item) => item.userID === value, ); if (!info) { - const {total,users} = await businessSearchUserInfo(value); - if (total > 0) { + const res = await businessSearchUserInfo(value,'kw'); + if (res.total > 0) { const {data} = await IMSDK.asyncApi( IMSDK.IMMethods.GetUsersInfo, IMSDK.uuid(), - [users[0].userID], + [res.data[0].id], ); const imData = data[0]; info = { ...imData, - ...users[0], + ...res.data[0], }; + console.log(info) } } if (info) { diff --git a/pages/common/userCard/index.vue b/pages/common/userCard/index.vue index 5c6b697..5459586 100644 --- a/pages/common/userCard/index.vue +++ b/pages/common/userCard/index.vue @@ -135,11 +135,8 @@ } this.isLoading = true try { - const { - total, - users - } = await businessSearchUserInfo(this.sourceID); - if (total > 0) { + const res = await businessSearchUserInfo(this.sourceID); + if (res.total > 0) { const { data } = await IMSDK.asyncApi( @@ -150,7 +147,7 @@ const imData = data[0]?.friendInfo ?? data[0]?.publicInfo ?? {}; info = { ...imData, - ...users[0], + ...res.data[0], }; console.log(info) } diff --git a/store/modules/user.js b/store/modules/user.js index 378a386..705e08d 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -54,11 +54,10 @@ const actions = { IMSDK.IMMethods.GetSelfUserInfo, uuidv4(), ); - const { - users - } = await businessGetUserInfo(data.userID); - console.log(users); - const businessData = users[0] ?? {}; + const res = await businessGetUserInfo(data.userID); + //console.log(res.data); + + const businessData = res.data[0] ?? {}; filterEmptyValue(businessData); commit("SET_SELF_INFO", { ...data, @@ -74,10 +73,8 @@ const actions = { state }) { try { - const { - users - } = await businessGetUserInfo(state.selfInfo.userID); - const businessData = users[0] ?? {}; + const res = await businessGetUserInfo(state.selfInfo.userID); + const businessData = res.data[0] ?? {}; filterEmptyValue(businessData); commit("SET_SELF_INFO", { ...state.selfInfo,