From 295cd5c92580a99cf6b1b4637be1566bf4628171 Mon Sep 17 00:00:00 2001 From: rowger Date: Wed, 27 Sep 2023 18:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../im/tcp/handler/NettyServerHandler.java | 8 +- im-uniapp/common/config.js | 4 +- im-uniapp/common/publicFc.js | 352 ++++++++++-------- im-uniapp/common/socketTask.js | 25 +- im-uniapp/manifest.json | 6 +- im-uniapp/store/index.js | 30 +- im-uniapp/wx/chatWindow/index.vue | 25 +- im-uniapp/wx/tabbar2/index.vue | 8 +- .../lim-ts-sdk/src/lim/core/ImClient.ts | 1 + 9 files changed, 269 insertions(+), 190 deletions(-) diff --git a/hs-im-server/im-tcp/src/main/java/com/lld/im/tcp/handler/NettyServerHandler.java b/hs-im-server/im-tcp/src/main/java/com/lld/im/tcp/handler/NettyServerHandler.java index 88959c2..0856960 100644 --- a/hs-im-server/im-tcp/src/main/java/com/lld/im/tcp/handler/NettyServerHandler.java +++ b/hs-im-server/im-tcp/src/main/java/com/lld/im/tcp/handler/NettyServerHandler.java @@ -61,9 +61,8 @@ public class NettyServerHandler extends SimpleChannelInboundHandler { @Override protected void channelRead0(ChannelHandlerContext ctx, Message msg) throws Exception { - logger.info("***********************收到消息:{}", msg); - logger.info("***********************收到消息:{}", msg); - logger.info("***********************收到消息:{}", msg); +// logger.info("***********************收到消息:{}", msg); +// logger.info("***********************收到消息:{}", msg); Integer command = msg.getMessageHeader().getCommand(); @@ -149,6 +148,9 @@ public class NettyServerHandler extends SimpleChannelInboundHandler { ctx.channel().attr(AttributeKey.valueOf(Constants.ReadTime)).set(System.currentTimeMillis()); }else if(command == MessageCommand.MSG_P2P.getCommand() || command == GroupEventCommand.MSG_GROUP.getCommand()){ + logger.info("***********************收到单聊或者群聊消息:{}", msg); + + try { String toId = ""; CheckSendMessageReq req = new CheckSendMessageReq(); diff --git a/im-uniapp/common/config.js b/im-uniapp/common/config.js index 3fb783e..6198b65 100644 --- a/im-uniapp/common/config.js +++ b/im-uniapp/common/config.js @@ -1,9 +1,9 @@ export default class config{ static getBaseApiUrl(){ - return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:8989' :'http://www.shudong.xyz/shudong_api/'; + return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:8989' :'http://192.168.1.117:8989'; } static getImApiUrl(){ - return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:28000/v1' :'http://www.shudong.xyz/shudong_api/'; + return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:28000/v1' :'http://192.168.1.117:28000/v1'; } static getImAppId(){ return 10000; diff --git a/im-uniapp/common/publicFc.js b/im-uniapp/common/publicFc.js index 9a04782..93f9ef7 100644 --- a/im-uniapp/common/publicFc.js +++ b/im-uniapp/common/publicFc.js @@ -186,7 +186,7 @@ export default { browser.show(url) }, //获取时间format - getNewDate(format, add0,datetime) { + getNewDate(format, add0, datetime) { //获取当前时间 function addZero(val) { //补零 @@ -197,10 +197,10 @@ export default { } } var date = new Date() - if(datetime){ - date=Date.parse(new Date(datetime)) + if (datetime) { + date = Date.parse(new Date(datetime)) } - + var year = date.getFullYear(), month = addZero(date.getMonth() + 1), strDate = addZero(date.getDate()), @@ -254,37 +254,39 @@ export default { } }, loadMore({ - url='xxx/list/', - queryParams={ - refreshing:false, - pageNum:1, - status: 'more',//more loading前 loading loading中 noMore 没有更多了 - pageSize:10 + url = 'xxx/list/', + queryParams = { + refreshing: false, + pageNum: 1, + status: 'more', //more loading前 loading loading中 noMore 没有更多了 + pageSize: 10 }, - status='0'//0无更多数据 1持续加载 2重新加载 3无数据+清空数据 - }){ + status = '0' //0无更多数据 1持续加载 2重新加载 3无数据+清空数据 + }) { return new Promise((resolve, reject) => { http.request({ - url:url+'&pageNum='+(queryParams.refreshing ? 1 : queryParams.pageNum) +'&pageSize=' +queryParams.pageSize, + url: url + '&pageNum=' + (queryParams.refreshing ? 1 : queryParams.pageNum) + + '&pageSize=' + queryParams.pageSize, success: res => { if (res.data.code == 200) { let list = []; let data = res.data.rows; - if (queryParams.refreshing&&res.data.rows == ''||queryParams.refreshing&&res.data.rows.length==0) { - queryParams.status='noMore' + if (queryParams.refreshing && res.data.rows == '' || queryParams + .refreshing && res.data.rows.length == 0) { + queryParams.status = 'noMore' resolve({ - queryParams:queryParams, - list:list, - status:'3' + queryParams: queryParams, + list: list, + status: '3' }) return } - if (res.data.rows == ''||res.data.rows.length==0) { - queryParams.status='noMore' + if (res.data.rows == '' || res.data.rows.length == 0) { + queryParams.status = 'noMore' resolve({ - queryParams:queryParams, - list:list, - status:'0' + queryParams: queryParams, + list: list, + status: '0' }) return } @@ -295,19 +297,19 @@ export default { if (queryParams.refreshing) { queryParams.refreshing = false; queryParams.pageNum = 2; - queryParams.status='more' + queryParams.status = 'more' resolve({ - queryParams:queryParams, - list:list, - status:'2' + queryParams: queryParams, + list: list, + status: '2' }) } else { queryParams.pageNum += 1; - queryParams.status='more' + queryParams.status = 'more' resolve({ - queryParams:queryParams, - list:list, - status:'1' + queryParams: queryParams, + list: list, + status: '1' }) } } else { @@ -325,55 +327,64 @@ export default { console.log(resbody) var pushType = resbody.pushType //推送类型 if (pushType == 'MSG') { + /* if(resbody.msgContent.msgType=='TRTC_VOICE_START'||resbody.msgContent.msgType=='TRTC_VIDEO_START'){ //音视频开始拦截 return - } - var userId=resbody.fromInfo.userId - var windowType='SINGLE' + } + */ + var userId = resbody.userId + var windowType = 'SINGLE' + /* if(resbody.groupInfo.userId){ userId=resbody.groupInfo.userId windowType='GROUP' - } + } + */ + const _userId = uni.getStorageSync("userId") + + debugger + this.pushInMsg({ type: resbody.msgContent.msgType == 'ALERT' ? 3 : 1, //显示类型 1左侧 2右侧 3中间 msgContent: resbody.msgContent.content, //msg内容 msgType: resbody.msgContent.msgType, //msgType信息类型 windowType: windowType, //聊天室类型 SINGLE GROUP time: resbody.createTime, //时间 - fromInfo:resbody.fromInfo,//来源信息 - groupInfo:resbody.groupInfo,//群信息 - userId: userId,//talktoId - personId:resbody.fromInfo.userId, - msgId:resbody.msgId,//消息Id - disturb:resbody.msgContent.disturb,//是否静默消息 - top:resbody.msgContent.top//是否置顶 + fromInfo: resbody.fromInfo, //来源信息 + groupInfo: resbody.groupInfo, //群信息 + userId: _userId, //talktoId + personId: resbody.fromInfo.userId, + msgId: resbody.msgId, //消息Id + disturb: resbody.msgContent.disturb, //是否静默消息 + top: resbody.msgContent.top //是否置顶 }) + return } - if (pushType == 'NOTICE') {//红点通知等 - if(resbody.msgContent.topicReply.count){ - store.commit('update_topicReply',resbody.msgContent.topicReply) + if (pushType == 'NOTICE') { //红点通知等 + if (resbody.msgContent.topicReply.count) { + store.commit('update_topicReply', resbody.msgContent.topicReply) } - if(resbody.msgContent.topicRed.portrait){ - store.commit('update_topicRed',resbody.msgContent.topicRed) + if (resbody.msgContent.topicRed.portrait) { + store.commit('update_topicRed', resbody.msgContent.topicRed) } - if(resbody.msgContent.friendApply.count){ - store.commit('update_friendApply',resbody.msgContent.friendApply) + if (resbody.msgContent.friendApply.count) { + store.commit('update_friendApply', resbody.msgContent.friendApply) } } - if (pushType == 'BIG') {//大消息 - var bigId=resbody.msgContent.content + if (pushType == 'BIG') { //大消息 + var bigId = resbody.msgContent.content http.request({ - url: '/chat/getBigMsg/'+bigId, + url: '/chat/getBigMsg/' + bigId, success: (res) => { if (res.data.code == 200) { - var resbody=res.data.data - var userId=resbody.fromInfo.userId - var windowType='SINGLE' - if(resbody.groupInfo.userId){ - userId=resbody.groupInfo.userId - windowType='GROUP' + var resbody = res.data.data + var userId = resbody.fromInfo.userId + var windowType = 'SINGLE' + if (resbody.groupInfo.userId) { + userId = resbody.groupInfo.userId + windowType = 'GROUP' } this.pushInMsg({ type: resbody.msgContent.msgType == 'ALERT' ? 3 : 1, //显示类型 1左侧 2右侧 3中间 @@ -381,13 +392,13 @@ export default { msgType: resbody.msgContent.msgType, //msgType信息类型 windowType: windowType, //聊天室类型 SINGLE GROUP time: resbody.createTime, //时间 - fromInfo:resbody.fromInfo,//来源信息 - groupInfo:resbody.groupInfo,//群信息 - userId: userId,//talktoId - personId:resbody.fromInfo.userId, - msgId:resbody.msgId,//消息Id - disturb:resbody.msgContent.disturb,//是否静默消息 - top:resbody.msgContent.top//是否置顶 + fromInfo: resbody.fromInfo, //来源信息 + groupInfo: resbody.groupInfo, //群信息 + userId: userId, //talktoId + personId: resbody.fromInfo.userId, + msgId: resbody.msgId, //消息Id + disturb: resbody.msgContent.disturb, //是否静默消息 + top: resbody.msgContent.top //是否置顶 }) } } @@ -397,18 +408,18 @@ export default { }, // 接收到的聊天推送 pushInMsg({ - msgId,//消息Id - msgContent,//内容 - msgType,//消息类型 - windowType,//聊天室类型 SINGLE GROUP - userId,//聊天对象ID - personId,//发送人ID - time,//时间 - type,//显示类型 1左侧 2右侧 3中间 - fromInfo,//来源 - groupInfo,//群信息 - disturb,//是否静默消息 - top//是否置顶 + msgId, //消息Id + msgContent, //内容 + msgType, //消息类型 + windowType, //聊天室类型 SINGLE GROUP + userId, //聊天对象ID + personId, //发送人ID + time, //时间 + type, //显示类型 1左侧 2右侧 3中间 + fromInfo, //来源 + groupInfo, //群信息 + disturb, //是否静默消息 + top //是否置顶 }) { var msgTypeLabel = ''; //消息类型 if (msgType == 'TEXT') { @@ -444,26 +455,37 @@ export default { if (msgType == 'TRTC_VIDEO_END') { msgTypeLabel = '[视频通话]' } - store.dispatch('createChatObj',{ - userId:userId, - windowType:windowType, - }).then(res=>{ - var localData=res.data + console.log(userId) + debugger + store.dispatch('createChatObj', { + userId: userId, + windowType: windowType, + }).then(res => { + debugger + var localData = res.data store.dispatch('getchatDatalist'); store.dispatch('getChatList'); var chatWindowData = store.state.chatDatalist[userId].list var chatListInfo = store.state.chatlist[userId] // 找到数组中对象属性值一样的对象并返回 - function arrfindobject({arr,object,key}){ - var result=arr.find(item =>{ - return item[key] == object[key] + function arrfindobject({ + arr, + object, + key + }) { + var result = arr.find(item => { + return item[key] == object[key] }); return result } - var same=arrfindobject({arr:chatWindowData,object:{ - msgId:msgId - },key:'msgId'}) - if(same){ + var same = arrfindobject({ + arr: chatWindowData, + object: { + msgId: msgId + }, + key: 'msgId' + }) + if (same) { return } //离线消息体 @@ -476,13 +498,13 @@ export default { content: msgContent, time: time, type: type, - msgId:msgId, + msgId: msgId, windowType: windowType } - + // 聊天记录体 var msgList = {} - if(windowType=='SINGLE'){ + if (windowType == 'SINGLE') { msgList = { userId: userId, personId: personId, @@ -490,14 +512,14 @@ export default { portrait: fromInfo.portrait, content: msgTypeLabel, time: time, - num: disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1), + num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1), windowType: windowType, - disturb:disturb,//是否静默消息 - top:top,//是否置顶 - userType:fromInfo.userType + disturb: disturb, //是否静默消息 + top: top, //是否置顶 + userType: fromInfo.userType } } - if(windowType=='GROUP'){ + if (windowType == 'GROUP') { msgList = { userId: userId, personId: personId, @@ -505,11 +527,11 @@ export default { portrait: groupInfo.portrait, content: msgTypeLabel, time: time, - num: disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1), + num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1), windowType: windowType, - disturb:disturb,//是否静默消息 - top:top,//是否置顶 - userType:'GROUP' + disturb: disturb, //是否静默消息 + top: top, //是否置顶 + userType: 'GROUP' } } chatWindowData.push(msgOffline) @@ -522,7 +544,7 @@ export default { data: msgList }) store.dispatch('tabBarpull') - store.dispatch('updateChatDataState',userId); + store.dispatch('updateChatDataState', userId); }); }, //发送消息 @@ -567,28 +589,28 @@ export default { msgTypeLabel = '[视频通话]' } var userInfo = store.state.userInfo; - store.dispatch('createChatObj',{ - userId:userId, - windowType:windowType, - }).then(res=>{ - var localData=res.data + store.dispatch('createChatObj', { + userId: userId, + windowType: windowType, + }).then(res => { + var localData = res.data store.dispatch('getchatDatalist'); store.dispatch('getChatList'); var chatWindowData = store.state.chatDatalist[userId].list var chatListInfo = store.state.chatlist[userId] - var time = this.getNewDate('format',true) + var time = this.getNewDate('format', true) //在线消息体 - var msgOnlie={} + var msgOnlie = {} //聊天记录 - var msgList={} - var url='' - if(windowType=='SINGLE'){ + var msgList = {} + var url = '' + if (windowType == 'SINGLE') { msgOnlie = { userId: userId, msgType: msgType, content: msgContent } - url='/chat/sendMsg' + url = '/chat/sendMsg' msgList = { userId: userId, personId: userInfo.userId, @@ -596,20 +618,20 @@ export default { portrait: localData.fromInfo.portrait, content: msgTypeLabel, time: time, - num: chatListInfo.disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0), + num: chatListInfo.disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0), windowType: windowType, - disturb:chatListInfo.disturb ? chatListInfo.disturb : 'N',//是否静默消息 - top:chatListInfo.top ? chatListInfo.top : 'N',//是否置顶 - userType:localData.fromInfo.userType + disturb: chatListInfo.disturb ? chatListInfo.disturb : 'N', //是否静默消息 + top: chatListInfo.top ? chatListInfo.top : 'N', //是否置顶 + userType: localData.fromInfo.userType } } - if(windowType=='GROUP'){ + if (windowType == 'GROUP') { msgOnlie = { groupId: userId, msgType: msgType, content: msgContent } - url='/group/sendMsg' + url = '/group/sendMsg' msgList = { userId: userId, personId: userInfo.userId, @@ -617,11 +639,11 @@ export default { portrait: localData.groupInfo.portrait, content: msgTypeLabel, time: time, - num: chatListInfo.disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0), + num: chatListInfo.disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0), windowType: windowType, - disturb:chatListInfo.disturb ? chatListInfo.disturb : 'N',//是否静默消息 - top:chatListInfo.top ? chatListInfo.top : 'N',//是否置顶 - userType:'GROUP' + disturb: chatListInfo.disturb ? chatListInfo.disturb : 'N', //是否静默消息 + top: chatListInfo.top ? chatListInfo.top : 'N', //是否置顶 + userType: 'GROUP' } } //离线消息体 自己的消息 @@ -634,7 +656,7 @@ export default { content: msgContent, time: time, type: 2, - msgId:'local', + msgId: 'local', windowType: windowType }; //离线/发送失败错误消息体 @@ -646,6 +668,40 @@ export default { type: 3 }; var msgSendType = 'wating'; + + //开始发送消息 + store.dispatch('sendMsg', { + userId: userId, + data: msgOnlie + }); + + // TODO + // 发送完成之后设置消息状态 + + // msgSendType = 'error'; + msgOffline.sendtype = msgSendType; + msgOffline.msgId = "1231" + msgNotSend.content = msgOnlie.content; + msgList.content = msgOnlie.content; + + chatWindowData.push(msgOffline); + if (msgSendType == 'error') { + chatWindowData.push(msgNotSend); + } + store.dispatch('updateChatById', { + userId: userId, + data: chatWindowData + }); + store.dispatch('updateChatListInfoById', { + userId: userId, + data: msgList + }); + store.dispatch('tabBarpull'); + store.dispatch('updateChatDataState', userId); + + + return false; + http.request({ url: url, method: 'POST', @@ -655,7 +711,7 @@ export default { if (res.data.data.status !== '0') { msgSendType = 'error'; msgOffline.sendtype = msgSendType; - msgOffline.msgId=res.data.data.msgId + msgOffline.msgId = res.data.data.msgId msgNotSend.content = res.data.data.statusLabel; msgList.content = res.data.data.statusLabel; } else { @@ -679,7 +735,7 @@ export default { data: msgList }); store.dispatch('tabBarpull'); - store.dispatch('updateChatDataState',userId); + store.dispatch('updateChatDataState', userId); }, fail: res => { msgSendType = 'error'; @@ -696,7 +752,7 @@ export default { data: msgList }); store.dispatch('tabBarpull'); - store.dispatch('updateChatDataState',userId); + store.dispatch('updateChatDataState', userId); } }); }); @@ -890,24 +946,24 @@ export default { } return sortlist }, - saoyisao(){//扫一扫 + saoyisao() { //扫一扫 // #ifdef APP-PLUS uni.scanCode({ - success: (res)=> { - var result=res.result - var data=res.result.split(':') - var type=data[0] - var value=data[1] - switch (type){ + success: (res) => { + var result = res.result + var data = res.result.split(':') + var type = data[0] + var value = data[1] + switch (type) { case 'group': - uni.navigateTo({ - url:'../../wx/groupInfo/scanCodeDetail?param='+result - }) + uni.navigateTo({ + url: '../../wx/groupInfo/scanCodeDetail?param=' + result + }) break; case 'user': - uni.navigateTo({ - url:'../../wx/personInfo/detail?param='+value+'&source=1' - }) + uni.navigateTo({ + url: '../../wx/personInfo/detail?param=' + value + '&source=1' + }) break; default: break; @@ -917,13 +973,13 @@ export default { // #endif // #ifndef APP-PLUS uni.showToast({ - title:'扫一扫', - icon:'none' + title: '扫一扫', + icon: 'none' }) // #endif }, // 设置原生titleNView导航文字 - setTitleNViewBtns(index,text){ + setTitleNViewBtns(index, text) { let pages = getCurrentPages(); let page = pages[pages.length - 1]; // #ifdef APP-PLUS @@ -938,7 +994,7 @@ export default { }); // #endif }, - debounce(func, wait = 1000, immediate = true){ + debounce(func, wait = 1000, immediate = true) { /** * @desc 函数防抖 * @param func 目标函数 @@ -957,7 +1013,7 @@ export default { timer = setTimeout(() => { timer = null; }, wait); - if (callNow){ + if (callNow) { func.apply(this, args); } } else { @@ -967,7 +1023,7 @@ export default { } } }, - throttle (func, wait = 1000, type = 1) { + throttle(func, wait = 1000, type = 1) { /** * @desc 函数节流 * @param func 函数 @@ -981,7 +1037,7 @@ export default { let args = arguments; if (type === 1) { let now = Date.now(); - + if (now - previous > wait) { func.apply(context, args); previous = now; @@ -996,4 +1052,4 @@ export default { } } } -} +} \ No newline at end of file diff --git a/im-uniapp/common/socketTask.js b/im-uniapp/common/socketTask.js index fe10bee..9a11a6a 100644 --- a/im-uniapp/common/socketTask.js +++ b/im-uniapp/common/socketTask.js @@ -1,7 +1,7 @@ import config from "@/common/config.js" let timer = null let retimer = null - +import store from '../store' import * as sdk from "@/common/imSdk/lim-sdk.js"; @@ -30,15 +30,35 @@ export default { }, onTestMessage: (e) => { console.log("onTestMessage :" + e); + store.dispatch('onP2PMessage',e) }, onP2PMessage: (e) => { console.log("onP2PMessage :" + e); e = JSON.parse(e) - e.pushType="TEXT" + e.data.pushType="MSG" + e.data.msgContent={ + msgType:"UNKOWN", + content:e.data.messageBody, + disturb:false, + top:false, + } + + e.data.windowType="SINGLE" + e.data.createTime=e.data.messageTime; + e.data.fromInfo={ + userId:e.data.fromId + }; + e.data.groupInfo={}; + e.data.msgId=e.data.messageId; + + debugger uni.$emit('onP2PMessage', e.data); + store.dispatch('onP2PMessage',e.data) }, onLogin: (uid) => { console.log("用户" + uid + "登陆sdk成功"); + + } }; @@ -54,6 +74,7 @@ export default { console.log(lim) + // 防止多次建立ws链接,貌似还没有生效,需要检查 if (this.socketTask != null) { return false } diff --git a/im-uniapp/manifest.json b/im-uniapp/manifest.json index 806dc57..7957eab 100644 --- a/im-uniapp/manifest.json +++ b/im-uniapp/manifest.json @@ -1,7 +1,7 @@ { - "name" : "微聊", - "appid" : "__UNI__CA19A2D", - "description" : "考拉Team微聊", + "name" : "IM", + "appid" : "__UNI__1A208D0", + "description" : "HS-IM", "versionName" : "1.2.1", "versionCode" : 121, "developer" : { diff --git a/im-uniapp/store/index.js b/im-uniapp/store/index.js index de29e4e..78257fa 100644 --- a/im-uniapp/store/index.js +++ b/im-uniapp/store/index.js @@ -9,9 +9,10 @@ const store = new Vuex.Store({ import * as sdk from "@/common/imSdk/lim-sdk.js"; - import lim from "@/common/imSdk/sdk-bridge.js"; +const _im=lim.lim.im + // #ifdef VUE3 import { createStore } from 'vuex' const store = createStore({ @@ -52,6 +53,21 @@ import { createStore } from 'vuex' } }, actions: { + onP2PMessage(context,data){ + console.log("========================store 收到信息") + console.log("========================store 收到信息") + console.log("========================store 收到信息") + console.error(data) + publicFc.getPush(data) + + }, + sendMsg(context,data){ + console.log("========================") + console.log("========================") + console.log("========================") + console.error(data) + _im.sendP2PMessage(_im.createP2PTextMessage(data.userId,data.data.content)) + }, updateChatDataState(context,data){ context.state.chatDataState++ context.state.chatDataUserId=data @@ -118,15 +134,19 @@ import { createStore } from 'vuex' context.commit('update_ChatList',data) }, updateChatListInfoById(context,data) {//修改聊天记录 + console.log("修改聊天记录 2") var getKey=data.userId var retdata=publicFc.getKeyObjectStorage(context.state.userInfo.userId+'_'+'chatlistData') retdata[getKey]=data.data uni.setStorageSync(context.state.userInfo.userId+'_'+'chatlistData', JSON.stringify(retdata)); }, createChatObj(context,data){ - + console.log("修改聊天记录 3") + console.log("context.state.userInfo.userId:",context.state.userInfo.userId) + console.log("data.userId:",data.userId) var userId=data.userId var windowType=data.windowType + debugger //初始化聊天记录 var data2=publicFc.getKeyObjectStorage(context.state.userInfo.userId+'_'+'chatlistData') if(!data2[userId]){ @@ -145,7 +165,7 @@ import { createStore } from 'vuex' // console.warn(res) // }) - lim.lim.im.getSingleUserInfo(userId).then((res)=>{ + _im.getSingleUserInfo(userId).then((res)=>{ console.log(res.data) console.log(res.data) console.log(res.data) @@ -155,7 +175,7 @@ import { createStore } from 'vuex' data1[userId]={ fromInfo:{ nickName: detail.nickName, - portrait: detail.portrait, + portrait: detail.photo, userId: detail.userId, userType:detail.userType }, @@ -169,7 +189,7 @@ import { createStore } from 'vuex' userId: detail.userId, personId: context.state.userInfo.userId, nickName: detail.nickName, - portrait: detail.portrait, + portrait: detail.photo, content: '', time: publicFc.getNewDate('format',true), num: 0, diff --git a/im-uniapp/wx/chatWindow/index.vue b/im-uniapp/wx/chatWindow/index.vue index cd67b62..bceaadc 100644 --- a/im-uniapp/wx/chatWindow/index.vue +++ b/im-uniapp/wx/chatWindow/index.vue @@ -174,7 +174,7 @@ onLoad(e) { // // 监听接收聊天信息 - uni.$on('onP2PMessage', this.onMessage) + // uni.$on('onP2PMessage', this.onMessage) this.talkTo = e; // 根据Id @@ -263,28 +263,7 @@ }, methods: { onMessage(message) { - console.log('[聊天页] 监听接收聊天信息', message); - if (message.fromId != this.talkTo.userId) { - return; - } - - console.log('[聊天页] 监听接收聊天信息', message); - - this.$fc.getPush(data); - - // var messageBody = message - - // let msg = { - // userId: message.fromId, - // avatar: "/static/images/userpic.png", - // data: messageBody.messageBody == '' ? '空消息' : messageBody.messageBody, - // nickname: message.fromId, - // type: "text", - // createTime: message.messageTime / 1000, - // isRemove: false - // } - // this.list.push(msg) - + }, addMsg(e) { this.msg += e; diff --git a/im-uniapp/wx/tabbar2/index.vue b/im-uniapp/wx/tabbar2/index.vue index e4e4f80..df06c8e 100644 --- a/im-uniapp/wx/tabbar2/index.vue +++ b/im-uniapp/wx/tabbar2/index.vue @@ -35,26 +35,26 @@ var list=[ { name:"测试18200702230", - avatar:"item.portrait", + avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png", userId:"18200702230", userType:"item.userType", chatNo:"item.chatNo" }, { name:"测试18200000000", - avatar:"item.portrait", + avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png", userId:"18200000000", userType:"item.userType", chatNo:"item.chatNo" },{ name:"测试18200000001", - avatar:"item.portrait", + avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png", userId:"18200000001", userType:"item.userType", chatNo:"item.chatNo" },{ name:"测试lld3", - avatar:"item.portrait", + avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png", userId:"lld3", userType:"item.userType", chatNo:"item.chatNo" diff --git a/lim-ts-sdk-master/lim-ts-sdk/src/lim/core/ImClient.ts b/lim-ts-sdk-master/lim-ts-sdk/src/lim/core/ImClient.ts index 668ff2e..d4be0d3 100644 --- a/lim-ts-sdk-master/lim-ts-sdk/src/lim/core/ImClient.ts +++ b/lim-ts-sdk-master/lim-ts-sdk/src/lim/core/ImClient.ts @@ -154,6 +154,7 @@ export class ImClient { let bodyLen = byteBuffer[1];//解析bodylen let unpack = bytebuf.vstring(null, bodyLen).unpack();//解析出字符串 let msgBody = unpack[2]; + console.log("sdk收到服务端数据 command:" + command) console.log("sdk收到服务端数据:" + msgBody) if (command === MessageCommand.MSG_P2P) {