From b4a5b975ef8e37f49afc4493e9959b8f238d4c3f Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Thu, 5 Jun 2025 15:37:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(im):=20=E5=AE=9E=E7=8E=B0=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=AB=AF=E8=81=8A=E5=A4=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增学生端获取好友关系绑定详情、聊天消息列表、发送聊天消息和好友关系列表的接口 - 修改聊天信息页面,支持学生端和员工端的不同接口调用 - 更新消息页面,增加学生端用户信息获取和联系人列表获取的逻辑 --- api/apiRoute.js | 30 ++++++++++++++++++++++++++++ pages/common/im_chat_info.vue | 37 +++++++++++++++++++++++++++++++---- pages/common/my_message.vue | 29 +++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 6 deletions(-) diff --git a/api/apiRoute.js b/api/apiRoute.js index 7c91198..4d2becd 100644 --- a/api/apiRoute.js +++ b/api/apiRoute.js @@ -433,6 +433,36 @@ export default { }) }, + //学生端-获取好友关系绑定详情 + xy_chatGetChatFriendsInfo(data = {}) { + let url = '/xy/chat/getChatFriendsInfo' + return http.get(url, data).then(res => { + return res; + }) + }, + //学生端-获取聊天消息列表 + xy_chatGetChatMessagesList(data = {}) { + let url = '/xy/chat/getChatMessagesList' + return http.get(url, data).then(res => { + return res; + }) + }, + //学生端-发送聊天消息 + xy_chatSendChatMessages(data = {}) { + let url = '/xy/chat/sendChatMessages' + return http.post(url, data).then(res => { + return res; + }) + }, + //学生端-好友关系列表 + xy_chatGetChatFriendsList(data = {}) { + let url = '/xy/chat/getChatFriendsList' + return http.get(url, data).then(res => { + return res; + }) + }, + + diff --git a/pages/common/im_chat_info.vue b/pages/common/im_chat_info.vue index a1de633..3d20bf8 100644 --- a/pages/common/im_chat_info.vue +++ b/pages/common/im_chat_info.vue @@ -200,7 +200,17 @@ export default { personnel_id: this.chatFriendsInfoParams.personnel_id,//员工资源ID customer_resources_id: this.chatFriendsInfoParams.customer_resources_id,//学生资源ID } - let res = await apiRoute.xs_chatGetChatFriendsInfo(params) + + let res + if( this.from_type == 'personnel'){ + //员工 + res = await apiRoute.xs_chatGetChatFriendsInfo(params) + }else{ + //学生 + res = await apiRoute.xy_chatGetChatFriendsInfo(params) + } + + if (res.code != 1){ uni.showToast({ title: res.msg, @@ -253,7 +263,17 @@ export default { this.tableList = [] } - let res = await apiRoute.xs_chatGetChatMessagesList(data)//获取消息列表 + + let res + if( this.from_type == 'personnel'){ + //员工 + res = await apiRoute.xs_chatGetChatMessagesList(data)//获取消息列表 + }else{ + //学生 + res = await apiRoute.xy_chatGetChatMessagesList(data)//获取消息列表 + } + + this.loading = false this.isReachedBottom = false; if (res.code != 1){ @@ -327,7 +347,16 @@ export default { }) return } - let res = await apiRoute.xs_chatSendChatMessages(data) + + let res + if( this.from_type == 'personnel'){ + //员工 + res = await apiRoute.xs_chatSendChatMessages(data) + }else{ + //学生 + res = await apiRoute.xy_chatSendChatMessages(data) + } + if (res.code != 1) { uni.showToast({ title: res.msg, @@ -370,7 +399,7 @@ export default { this.moreShow = false }, - //但文件上传回调 + //文件上传回调 uplodeImageRes(resData,extraData){ console.log('上传成功回调',resData,extraData) //判断是不是上传相册图片 diff --git a/pages/common/my_message.vue b/pages/common/my_message.vue index 7d14eb8..5ab28e7 100644 --- a/pages/common/my_message.vue +++ b/pages/common/my_message.vue @@ -103,11 +103,12 @@ export default { }else{ //获取学生用户详情 this.from_type = 'customer'//学生 + await this.getMemberInit() } this.getContactList() }, - //获取用户详情 + //获取员工用户详情 async getPersonnelUserInfo(){ let data = {} let res = await apiRoute.getPersonnelInfo(data); @@ -130,6 +131,20 @@ export default { this.filteredData.personnel_id = res.data.id }, + //获取学员用户信息 + async getMemberInit() { + let res = await apiRoute.xy_memberInfo({}) + if(res.code != 1){ + uni.showToast({ + title: res.msg, + icon: 'none' + }) + return + } + this.member_info = res.data + this.filteredData.customer_resources_id = res.data.id//学生资源的id + }, + //获取联系人列表 async getContactList(){ let params = {...this.filteredData} @@ -147,7 +162,17 @@ export default { this.contactList = [] } - let res = await apiRoute.xs_chatGetChatFriendsList(params) + let res + //1=教练,2=销售,3=学员 + if (['1', '2'].includes(String(this.userType))) { + //员工 + res = await apiRoute.xs_chatGetChatFriendsList(params) + }else{ + //学生 + res = await apiRoute.xy_chatGetChatFriendsList(params) + } + + this.loading = false this.isReachedBottom = false;