...
|
...
|
@@ -212,6 +212,7 @@ |
|
|
},
|
|
|
computed:{
|
|
|
...mapState({
|
|
|
userinfo: state => state.userinfo,
|
|
|
isLogin: state => state.isLogin,
|
|
|
currentMessageList:state=>state.currentMessageList,
|
|
|
})
|
...
|
...
|
@@ -225,10 +226,7 @@ |
|
|
},
|
|
|
onLoad(option) {
|
|
|
if(!this.isLogin){
|
|
|
uni.setStorageSync("token",'')
|
|
|
uni.reLaunch({
|
|
|
url:"/pages/index/login"
|
|
|
})
|
|
|
this.loginTim()
|
|
|
}else{
|
|
|
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
|
|
|
console.log('this.userInfo11111111111111111111',this.userInfo)
|
...
|
...
|
@@ -249,19 +247,13 @@ |
|
|
},
|
|
|
onShow(){
|
|
|
if(!this.isLogin){
|
|
|
uni.setStorageSync("token",'')
|
|
|
uni.reLaunch({
|
|
|
url:"/pages/index/login"
|
|
|
})
|
|
|
this.loginTim()
|
|
|
}
|
|
|
this.scrollTop = 9999999;
|
|
|
},
|
|
|
onUnload(){
|
|
|
if(!this.isLogin){
|
|
|
uni.setStorageSync("token",'')
|
|
|
uni.reLaunch({
|
|
|
url:"/pages/index/login"
|
|
|
})
|
|
|
this.loginTim()
|
|
|
}else{
|
|
|
//退出页面 将所有的会话内的消息设置为已读
|
|
|
let promise = this.tim.setMessageRead({conversationID: this.conversationActive.conversationID});
|
...
|
...
|
@@ -275,6 +267,34 @@ |
|
|
}
|
|
|
},
|
|
|
methods:{
|
|
|
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) => {
|
|
|
//登录成功后 更新登录状态
|
|
|
this.$store.commit("toggleIsLogin", true);
|
|
|
//自己平台的用户基础信息
|
|
|
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
|
|
|
//tim 返回的用户信息
|
|
|
uni.setStorageSync('userTIMInfo', JSON.stringify(res.data))
|
|
|
uni.reLaunch({
|
|
|
url:"/pages/index/index"
|
|
|
})
|
|
|
}).catch((err) => {
|
|
|
// 登录失败的相关信息
|
|
|
});
|
|
|
},
|
|
|
//聊天的节点加上外层的div
|
|
|
nodesFliter(str){
|
|
|
let nodeStr = '<div style="align-items: center;word-wrap:break-word;">'+str+'</div>'
|
...
|
...
|
|