修改消息拉取记录
This commit is contained in:
@@ -92,6 +92,8 @@ export default {
|
|||||||
isForce: "0",
|
isForce: "0",
|
||||||
hasVideo: "1",
|
hasVideo: "1",
|
||||||
callSessionId: "",
|
callSessionId: "",
|
||||||
|
callStatus: "watting",//房间状态
|
||||||
|
callRoomInfoRequetTimes:0,//房间拉取次数
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -434,7 +436,10 @@ export default {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
this.generateVideoRoomStream(res.data.data)
|
this.generateVideoRoomStream(res.data.data)
|
||||||
|
}else {
|
||||||
|
this.generateVideoRoomStream([])
|
||||||
}
|
}
|
||||||
|
//TODO 增加网络异常时候的处理
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
leaveRoom() {
|
leaveRoom() {
|
||||||
@@ -527,6 +532,14 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
generateVideoRoomStream(videoList) {
|
generateVideoRoomStream(videoList) {
|
||||||
|
this.callRoomInfoRequetTimes=this.callRoomInfoRequetTimes+1;
|
||||||
|
if(this.callRoomInfoRequetTimes>5){
|
||||||
|
if(videoList.length==0){
|
||||||
|
// 拉取5次房间列表之后,如果房间里面视频流的数量为0,则关掉房间
|
||||||
|
this.videoDownAction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let hasUpdate = false;
|
let hasUpdate = false;
|
||||||
if (this.oldVideoStreamList == null) {
|
if (this.oldVideoStreamList == null) {
|
||||||
this.oldVideoStreamList = videoList;
|
this.oldVideoStreamList = videoList;
|
||||||
|
|||||||
@@ -693,10 +693,23 @@ export default {
|
|||||||
if (msgSendType == 'error') {
|
if (msgSendType == 'error') {
|
||||||
chatWindowData.push(msgNotSend);
|
chatWindowData.push(msgNotSend);
|
||||||
}
|
}
|
||||||
|
// TODO 内网环境下特殊配置,消息返送出去之后不直接存储
|
||||||
|
/*
|
||||||
store.dispatch('updateChatById', {
|
store.dispatch('updateChatById', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
data: chatWindowData
|
data: chatWindowData
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
setTimeout(() => {
|
||||||
|
store.dispatch('updateChartHistoryFromServerLimit5', {
|
||||||
|
userId: userId,
|
||||||
|
data: {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
|
||||||
store.dispatch('updateChatListInfoById', {
|
store.dispatch('updateChatListInfoById', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
data: msgList
|
data: msgList
|
||||||
|
|||||||
@@ -138,13 +138,126 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
updateChartHistoryFromServerLimit5(context, data) {
|
||||||
updateChartHistoryFromServer(context, data) {
|
|
||||||
const _userId = uni.getStorageSync("userId")
|
const _userId = uni.getStorageSync("userId")
|
||||||
const _userInfo = uni.getStorageSync("userInfo")
|
const _userInfo = uni.getStorageSync("userInfo")
|
||||||
var retdata = publicFc.getKeyObjectStorage(_userId + '_' + 'chatData')
|
var retdata = publicFc.getKeyObjectStorage(_userId + '_' + 'chatData')
|
||||||
|
|
||||||
var currentUserMsgList = retdata[data.userId].list
|
var currentUserMsgList = retdata[data.userId].list
|
||||||
|
console.warn(currentUserMsgList)
|
||||||
|
// if
|
||||||
|
|
||||||
|
_im.getSingleUserInfo(data.userId).then((res) => {
|
||||||
|
var detail = res.data
|
||||||
|
let _msgList = {
|
||||||
|
fromInfo: {
|
||||||
|
nickName: detail.nickName,
|
||||||
|
portrait: detail.photo,
|
||||||
|
userId: detail.userId,
|
||||||
|
userType: detail.userType
|
||||||
|
},
|
||||||
|
groupInfo: {},
|
||||||
|
list: []
|
||||||
|
}
|
||||||
|
var _serverMsgList = []
|
||||||
|
_im.getChatMessageHistoryList(data.userId, 1, 5).then((res) => {
|
||||||
|
res.data.map((item) => {
|
||||||
|
item.messageBody = JSON.parse(item.messageBody)
|
||||||
|
var obj = {
|
||||||
|
content: item.messageBody.content,
|
||||||
|
messageKey: item.messageKey,
|
||||||
|
msgType: item.messageBody.msgType,
|
||||||
|
nickName: _userId == item.fromId ? "我" :
|
||||||
|
detail.nickName,
|
||||||
|
portrait: _userId == item.fromId ? _userInfo
|
||||||
|
.photo : detail.photo,
|
||||||
|
personId: item.fromId,
|
||||||
|
sendtype: "waiting",
|
||||||
|
time: item.createTime,
|
||||||
|
type: _userId == item.fromId ? 2 : 1,
|
||||||
|
userId: item.fromId,
|
||||||
|
windowType: "SINGLE"
|
||||||
|
}
|
||||||
|
|
||||||
|
var _arr = currentUserMsgList.filter(obj => obj
|
||||||
|
.messageKey === item.messageKey)
|
||||||
|
if (_arr.length == 0) {
|
||||||
|
_serverMsgList.push(obj)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const reversedServerMsgList = _serverMsgList.reverse();
|
||||||
|
|
||||||
|
console.log("新的未收消息数组")
|
||||||
|
console.log(reversedServerMsgList)
|
||||||
|
|
||||||
|
let newCurrentUserMsgList = currentUserMsgList.concat(
|
||||||
|
reversedServerMsgList)
|
||||||
|
|
||||||
|
_serverMsgList = currentUserMsgList.sort(sortBy('time'))
|
||||||
|
|
||||||
|
_msgList.list = newCurrentUserMsgList;
|
||||||
|
|
||||||
|
retdata[data.userId] = _msgList
|
||||||
|
|
||||||
|
uni.setStorageSync(_userId + '_' + 'chatData', JSON.stringify(
|
||||||
|
retdata));
|
||||||
|
|
||||||
|
context.dispatch('getchatDatalist');
|
||||||
|
|
||||||
|
if (reversedServerMsgList.length > 0) {
|
||||||
|
uni.$emit('PageScroll', {
|
||||||
|
msg: '页面更新'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const _obj = newCurrentUserMsgList[newCurrentUserMsgList
|
||||||
|
.length - 1]
|
||||||
|
|
||||||
|
try {
|
||||||
|
var _content = JSON.parse(_obj.content)
|
||||||
|
|
||||||
|
if (_obj.msgType == "CALL_video") {
|
||||||
|
_obj.content = "【视频通话】"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_obj.msgType == "CALL_voice") {
|
||||||
|
_obj.content = "【语音通话】"
|
||||||
|
}
|
||||||
|
//判断头像是谁的
|
||||||
|
|
||||||
|
context.dispatch('updateChatListInfoById', {
|
||||||
|
userId: data.userId,
|
||||||
|
data: {
|
||||||
|
content: _obj.content,
|
||||||
|
userId: data.userId,
|
||||||
|
personId: _userId,
|
||||||
|
nickName: detail.nickName,
|
||||||
|
portrait: _userId == _obj.fromId ? _userInfo
|
||||||
|
.photo : detail.photo,
|
||||||
|
time: dayjs(_obj.createTime).format(
|
||||||
|
"YYYY/MM/DD HH:mm:ss"),
|
||||||
|
num: 0,
|
||||||
|
windowType: 'SINGLE',
|
||||||
|
disturb: 'N', //是否静默消息
|
||||||
|
top: 'N', //是否置顶
|
||||||
|
userType: 'SINGLE'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateChartHistoryFromServer(context, data) {
|
||||||
|
const _userId = uni.getStorageSync("userId")
|
||||||
|
const _userInfo = uni.getStorageSync("userInfo")
|
||||||
|
var retdata = publicFc.getKeyObjectStorage(_userId + '_' + 'chatData')
|
||||||
|
|
||||||
// if
|
// if
|
||||||
|
|
||||||
_im.getSingleUserInfo(data.userId).then((res) => {
|
_im.getSingleUserInfo(data.userId).then((res) => {
|
||||||
@@ -167,8 +280,10 @@ const store = new Vuex.Store({
|
|||||||
content: item.messageBody.content,
|
content: item.messageBody.content,
|
||||||
messageKey: item.messageKey,
|
messageKey: item.messageKey,
|
||||||
msgType: item.messageBody.msgType,
|
msgType: item.messageBody.msgType,
|
||||||
nickName:_userId==item.fromId?"我":detail.nickName,
|
nickName: _userId == item.fromId ? "我" :
|
||||||
portrait:_userId==item.fromId?_userInfo.photo:detail.photo,
|
detail.nickName,
|
||||||
|
portrait: _userId == item.fromId ? _userInfo
|
||||||
|
.photo : detail.photo,
|
||||||
personId: item.fromId,
|
personId: item.fromId,
|
||||||
sendtype: "waiting",
|
sendtype: "waiting",
|
||||||
time: item.createTime,
|
time: item.createTime,
|
||||||
@@ -176,15 +291,12 @@ const store = new Vuex.Store({
|
|||||||
userId: item.fromId,
|
userId: item.fromId,
|
||||||
windowType: "SINGLE"
|
windowType: "SINGLE"
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(obj.msgType=="CALL_video"){
|
|
||||||
obj.content=JSON.parse(item.messageBody.content)
|
|
||||||
obj.content=JSON.parse(obj.content)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
_serverMsgList.push(obj)
|
_serverMsgList.push(obj)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
_serverMsgList = _serverMsgList.sort(sortBy('time'))
|
_serverMsgList = _serverMsgList.sort(sortBy('time'))
|
||||||
|
|
||||||
_msgList.list = _serverMsgList;
|
_msgList.list = _serverMsgList;
|
||||||
@@ -215,8 +327,10 @@ const store = new Vuex.Store({
|
|||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
personId: _userId,
|
personId: _userId,
|
||||||
nickName: detail.nickName,
|
nickName: detail.nickName,
|
||||||
portrait:_userId==_obj.fromId?_userInfo.photo:detail.photo,
|
portrait: _userId == _obj.fromId ? _userInfo
|
||||||
time: dayjs(_obj.createTime).format("YYYY/MM/DD HH:mm:ss"),
|
.photo : detail.photo,
|
||||||
|
time: dayjs(_obj.createTime).format(
|
||||||
|
"YYYY/MM/DD HH:mm:ss"),
|
||||||
num: 0,
|
num: 0,
|
||||||
windowType: 'SINGLE',
|
windowType: 'SINGLE',
|
||||||
disturb: 'N', //是否静默消息
|
disturb: 'N', //是否静默消息
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<view class="chatNavBar">
|
<view class="chatNavBar">
|
||||||
<uni-nav-bar :leftIcon="isMobile==true?'left':''"
|
<uni-nav-bar :leftIcon="isMobile==true?'left':''" @clickLeft="clickLeftHandler">
|
||||||
@clickLeft="clickLeftHandler">
|
<view class="navBarTitle">{{title}}</view>
|
||||||
<view class="navBarTitle">{{title}}</view></uni-nav-bar>
|
</uni-nav-bar>
|
||||||
</view>
|
</view>
|
||||||
<watermark></watermark>
|
<watermark></watermark>
|
||||||
<uni-popup ref="popup" type="center">
|
<uni-popup ref="popup" type="center">
|
||||||
@@ -199,6 +199,10 @@
|
|||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
|
|
||||||
|
uni.$on('PageScroll', ()=>{
|
||||||
|
this.scrolltoBottom()
|
||||||
|
})
|
||||||
|
|
||||||
// // 监听接收聊天信息
|
// // 监听接收聊天信息
|
||||||
uni.$on('onP2PMessage', this.onMessage)
|
uni.$on('onP2PMessage', this.onMessage)
|
||||||
|
|
||||||
@@ -280,6 +284,8 @@
|
|||||||
if (hd_gps_location != null) {
|
if (hd_gps_location != null) {
|
||||||
this.isMobile = true
|
this.isMobile = true
|
||||||
}
|
}
|
||||||
|
// TODO PC开发
|
||||||
|
this.isMobile = true
|
||||||
|
|
||||||
if (this.chatListInfo && this.chatListInfo.nickName) {
|
if (this.chatListInfo && this.chatListInfo.nickName) {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
@@ -356,6 +362,7 @@
|
|||||||
//如果当前消息发送人和当前窗口的聊天对象一致,则发送已读回执
|
//如果当前消息发送人和当前窗口的聊天对象一致,则发送已读回执
|
||||||
console.log("########### 此时需要发送已读回执 ###########")
|
console.log("########### 此时需要发送已读回执 ###########")
|
||||||
this.$store.dispatch('sendP2PMessageReciveAck', message)
|
this.$store.dispatch('sendP2PMessageReciveAck', message)
|
||||||
|
|
||||||
},
|
},
|
||||||
addMsg(e) {
|
addMsg(e) {
|
||||||
this.msg += e;
|
this.msg += e;
|
||||||
@@ -888,6 +895,11 @@
|
|||||||
console.log("==============sdk:")
|
console.log("==============sdk:")
|
||||||
console.log(this.talkTo.userId)
|
console.log(this.talkTo.userId)
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.scrolltoBottom();
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
// this.imsdk.lim.im.sendP2PMessage(this.imsdk.lim.im.createP2PTextMessage(this.talkTo.userId, e))
|
// this.imsdk.lim.im.sendP2PMessage(this.imsdk.lim.im.createP2PTextMessage(this.talkTo.userId, e))
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
@@ -957,7 +969,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
.navBarTitle {
|
.navBarTitle {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -967,6 +978,7 @@
|
|||||||
font-size: 16px !important;
|
font-size: 16px !important;
|
||||||
font-weight: bold !important;
|
font-weight: bold !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chatNavBar {
|
.chatNavBar {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user