作者 xuqiang

提交

... ... @@ -139,7 +139,9 @@
})
},
toRoom(item) {
this.$store.commit('updateConversationActive', item)
uni.setStorageSync('toRoomType','toUserItem')
uni.setStorageSync('toUserItem',JSON.stringify(item))
// this.$store.commit('updateConversationActive', item)
uni.navigateTo({
url: './room'
})
... ...
... ... @@ -229,17 +229,19 @@
watch:{
currentMessageList(newVal,oldVal){
this.msgList = newVal
this.screenMsg(newVal,oldVal)
if(this.isSDKReady){
this.screenMsg(newVal,oldVal)
}
},
},
onLoad(option) {
onLoad() {
this.showRoom = false
if(!this.isSDKReady){
uni.switchTab({
url:'/pages/index/index'
})
return
this.loginTim()
}else{
this.getTimInfo()
}
this.showRoom = false
//监听键盘高度变化
uni.onKeyboardHeightChange(res => {
console.log('键盘高度变化了',res.height)
... ... @@ -249,21 +251,6 @@
this.keyboardHeight = 20
}
})
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.toUserId = this.$store.state.toUserId
this.conversationActive = this.$store.state.conversationActive
this.TIM = this.$TIM
//获取聊天对象的用户信息
this.$request('/user/userInfo',{user_id:this.toUserId}).then((res)=>{
console.log('获取聊天对象的用户信息',res)
this.toUserInfo = res.data
uni.setNavigationBarTitle({
title:this.toUserInfo.nickname
})
this.getMsgList();
})
},
onShow(){
this.scrollTop = 9999999;
... ... @@ -282,6 +269,57 @@
}
},
methods:{
getTimInfo(){
if(uni.getStorageSync('toUserItem') && uni.getStorageSync('toRoomType') == 'toUserItem'){
this.$store.commit('updateConversationActive', JSON.parse(uni.getStorageSync('toUserItem')))
}
if(uni.getStorageSync('toUserId') && uni.getStorageSync('toRoomType') == 'toUserId'){
this.$store.commit('createConversationActive',uni.getStorageSync('toUserId'))
}
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
this.toUserId = this.$store.state.toUserId
this.conversationActive = this.$store.state.conversationActive
this.TIM = this.$TIM
//获取聊天对象的用户信息
this.$request('/user/userInfo',{user_id:this.toUserId}).then((res)=>{
console.log('获取聊天对象的用户信息',res)
this.toUserInfo = res.data
uni.setNavigationBarTitle({
title:this.toUserInfo.nickname
})
this.getMsgList();
})
},
loginTim(){
let userID = this.userinfo.id.toString()
let userSig = this.userinfo.user_sign
let userInfo = {
user: this.userinfo.nickname,
userId:this.userinfo.id,
img:this.userinfo.avatar,
userSig:this.userinfo.user_sign
}
//登录腾讯IM及时通讯
let promise = this.tim.login({
userID: userID,
userSig: userSig
});
promise.then((res) => {
console.warn('腾讯云即时通讯登录成功', res);
//登录成功后 更新登录状态
this.$store.commit("toggleIsLogin", true);
//自己平台的用户基础信息
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
//tim 返回的用户信息
uni.setStorageSync('userTIMInfo', JSON.stringify(res.data))
setTimeout(()=>{
this.getTimInfo()
},1000)
}).catch((err) => {
console.warn('腾讯云即时通讯登录报错', err);
});
},
//聊天的节点加上外层的div
nodesFliter(str){
let nodeStr = '<div style="align-items: center;word-wrap:break-word;">'+str+'</div>'
... ...
... ... @@ -861,7 +861,9 @@
},
//选择用户聊天
checkUserToRoom(id) {
this.$store.commit('createConversationActive',id)
uni.setStorageSync('toRoomType','toUserId')
uni.setStorageSync('toUserId',id)
// this.$store.commit('createConversationActive',id)
this.href('/pages/HM-chat/room')
},
//定位当前位置
... ...
... ... @@ -433,7 +433,9 @@
},
//选择用户聊天
checkUserToRoom(id) {
this.$store.commit('createConversationActive',id)
uni.setStorageSync('toRoomType','toUserId')
uni.setStorageSync('toUserId',id)
// this.$store.commit('createConversationActive',id)
this.$href('/pages/HM-chat/room')
},
//关注
... ...
... ... @@ -327,7 +327,9 @@
},
//选择用户聊天
checkUserToRoom(item) {
this.$store.commit('createConversationActive',item.id)
uni.setStorageSync('toRoomType','toUserId')
uni.setStorageSync('toUserId',item.id)
// this.$store.commit('createConversationActive',item.id)
this.href('/pages/HM-chat/room')
},
getLandList(){
... ...
... ... @@ -216,14 +216,18 @@
})
},
toRoom(item) {
this.$store.commit('updateConversationActive', item)
uni.setStorageSync('toRoomType','toUserItem')
uni.setStorageSync('toUserItem',JSON.stringify(item))
// this.$store.commit('updateConversationActive', item)
uni.navigateTo({
url: '/pages/HM-chat/room'
})
},
//选择用户聊天
checkUserToRoom(toUserInfo) {
this.$store.commit('createConversationActive', toUserInfo.userId)
uni.setStorageSync('toRoomType','toUserId')
uni.setStorageSync('toUserId',toUserInfo.userId)
// this.$store.commit('createConversationActive', toUserInfo.userId)
uni.navigateTo({
url: '/pages/HM-chat/room'
})
... ...