聊天记录
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
console.log('App Show')
|
console.log('App Show')
|
||||||
|
|
||||||
appInit(500).then((res) => {
|
appInit(500).then((res) => {
|
||||||
|
// getAddressList
|
||||||
console.log("获取到token,创建长链接")
|
console.log("获取到token,创建长链接")
|
||||||
this.$store.dispatch('getAddressList');
|
this.$store.dispatch('getAddressList');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -540,6 +540,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO 需要请求接口获取真实的消息时间
|
//TODO 需要请求接口获取真实的消息时间
|
||||||
|
/*
|
||||||
chatWindowData.push(msgOffline)
|
chatWindowData.push(msgOffline)
|
||||||
store.dispatch('updateChatById', {
|
store.dispatch('updateChatById', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -549,6 +550,11 @@ export default {
|
|||||||
userId: userId,
|
userId: userId,
|
||||||
data: msgList
|
data: msgList
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
store.dispatch('tabBarpull')
|
store.dispatch('tabBarpull')
|
||||||
store.dispatch('updateChatDataState', userId);
|
store.dispatch('updateChatDataState', userId);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -139,9 +139,7 @@ export default {
|
|||||||
// console.warn(res)
|
// console.warn(res)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
sdk.getUserConversationList(0).then(res => {
|
store.dispatch('queryConversationList')
|
||||||
console.warn(res)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -138,6 +138,70 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
queryConversationList(context){
|
||||||
|
const userId = uni.getStorageSync("userId")
|
||||||
|
console.log("==================开始 获取会话列表")
|
||||||
|
_im.queryConversationList().then((res) => {
|
||||||
|
console.log("==================已经获取到会话列表")
|
||||||
|
console.log(res)
|
||||||
|
if(res.code==200){
|
||||||
|
var retdata = publicFc.getKeyObjectStorage(userId + '_' +
|
||||||
|
'chatlistData')
|
||||||
|
var _newConversationList=[]
|
||||||
|
res.data.map((item)=>{
|
||||||
|
console.log(item)
|
||||||
|
var _userId=item.ownerId==item.fromId?item.toId:item.fromId
|
||||||
|
|
||||||
|
console.log("会话对方id:",_userId)
|
||||||
|
|
||||||
|
_im.getSingleUserInfo(_userId).then((userInfo) => {
|
||||||
|
var detail = userInfo.data
|
||||||
|
console.log("会话对方nickName:",detail.nickName)
|
||||||
|
|
||||||
|
item.messageBody = JSON.parse(item.messageBody)
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (item.messageBody.msgType == "CALL_video") {
|
||||||
|
item.messageBody.content = "【视频通话】"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.messageBody.msgType == "CALL_voice") {
|
||||||
|
item.messageBody.content = "【语音通话】"
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
context.dispatch('updateChatListInfoById', {
|
||||||
|
userId: _userId,
|
||||||
|
data: {
|
||||||
|
content: item.messageBody.content,
|
||||||
|
userId: _userId,
|
||||||
|
personId: _userId,
|
||||||
|
nickName: detail.nickName,
|
||||||
|
portrait: detail.photo,
|
||||||
|
time: dayjs(item.createTime).format(
|
||||||
|
"YYYY/MM/DD HH:mm:ss"),
|
||||||
|
num: item.num,
|
||||||
|
windowType: 'SINGLE',
|
||||||
|
disturb: 'N', //是否静默消息
|
||||||
|
top: 'N', //是否置顶
|
||||||
|
userType: 'SINGLE'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
context.dispatch('tabBarpull')
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
updateChartHistoryFromServerLimit5(context, data) {
|
updateChartHistoryFromServerLimit5(context, data) {
|
||||||
const _userId = uni.getStorageSync("userId")
|
const _userId = uni.getStorageSync("userId")
|
||||||
const _userInfo = uni.getStorageSync("userInfo")
|
const _userInfo = uni.getStorageSync("userInfo")
|
||||||
@@ -160,7 +224,7 @@ const store = new Vuex.Store({
|
|||||||
list: []
|
list: []
|
||||||
}
|
}
|
||||||
var _serverMsgList = []
|
var _serverMsgList = []
|
||||||
_im.getChatMessageHistoryList(data.userId, 1, 5).then((res) => {
|
_im.getChatMessageHistoryList(data.userId, 1, 3).then((res) => {
|
||||||
res.data.map((item) => {
|
res.data.map((item) => {
|
||||||
item.messageBody = JSON.parse(item.messageBody)
|
item.messageBody = JSON.parse(item.messageBody)
|
||||||
var obj = {
|
var obj = {
|
||||||
@@ -212,44 +276,6 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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.time).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
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -307,38 +333,6 @@ const store = new Vuex.Store({
|
|||||||
|
|
||||||
context.dispatch('getchatDatalist');
|
context.dispatch('getchatDatalist');
|
||||||
|
|
||||||
const _obj = _serverMsgList[_serverMsgList.length - 1]
|
|
||||||
|
|
||||||
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.time).format(
|
|
||||||
"YYYY/MM/DD HH:mm:ss"),
|
|
||||||
num: 0,
|
|
||||||
windowType: 'SINGLE',
|
|
||||||
disturb: 'N', //是否静默消息
|
|
||||||
top: 'N', //是否置顶
|
|
||||||
userType: 'SINGLE'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -577,6 +571,8 @@ const store = new Vuex.Store({
|
|||||||
if (res.data.code == 200) {
|
if (res.data.code == 200) {
|
||||||
var records = res.data.result.records
|
var records = res.data.result.records
|
||||||
context.state.addressList = records
|
context.state.addressList = records
|
||||||
|
localForage.setItem("addressList", records)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@@ -285,7 +285,7 @@
|
|||||||
this.isMobile = true
|
this.isMobile = true
|
||||||
}
|
}
|
||||||
// TODO PC开发
|
// TODO PC开发
|
||||||
this.isMobile = true
|
// this.isMobile = true
|
||||||
|
|
||||||
if (this.chatListInfo && this.chatListInfo.nickName) {
|
if (this.chatListInfo && this.chatListInfo.nickName) {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
@@ -363,6 +363,20 @@
|
|||||||
console.log("########### 此时需要发送已读回执 ###########")
|
console.log("########### 此时需要发送已读回执 ###########")
|
||||||
this.$store.dispatch('sendP2PMessageReciveAck', message)
|
this.$store.dispatch('sendP2PMessageReciveAck', message)
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.dispatch('updateChartHistoryFromServerLimit5', {
|
||||||
|
userId: this.talkTo.userId,
|
||||||
|
data: ""
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.dispatch('updateChartHistoryFromServerLimit5', {
|
||||||
|
userId: this.talkTo.userId,
|
||||||
|
data: ""
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
}, 1500)
|
||||||
|
|
||||||
},
|
},
|
||||||
addMsg(e) {
|
addMsg(e) {
|
||||||
this.msg += e;
|
this.msg += e;
|
||||||
|
|||||||
@@ -61,6 +61,10 @@
|
|||||||
console.log("首页获取到url参数")
|
console.log("首页获取到url参数")
|
||||||
console.log(options)
|
console.log(options)
|
||||||
console.log(location.href)
|
console.log(location.href)
|
||||||
|
|
||||||
|
// // 监听接收聊天信息
|
||||||
|
uni.$on('onP2PMessage', this.onMessage)
|
||||||
|
|
||||||
if (options.imUserSign) {
|
if (options.imUserSign) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "数据加载中...",
|
title: "数据加载中...",
|
||||||
@@ -185,6 +189,7 @@
|
|||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
var i=0
|
var i=0
|
||||||
|
this.$store.dispatch('queryConversationList');
|
||||||
this.$store.dispatch('tabBarpull');
|
this.$store.dispatch('tabBarpull');
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
i=i+1;
|
i=i+1;
|
||||||
@@ -204,6 +209,11 @@
|
|||||||
console.log('beforeUnmount');
|
console.log('beforeUnmount');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onMessage(){
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.dispatch('queryConversationList')
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
longpressItem(e, i, v) {
|
longpressItem(e, i, v) {
|
||||||
// console.log(e,i,v)
|
// console.log(e,i,v)
|
||||||
this.longTapItemKey = i;
|
this.longTapItemKey = i;
|
||||||
|
|||||||
Reference in New Issue
Block a user