This commit is contained in:
2022-01-28 11:41:13 +08:00
11 changed files with 961 additions and 859 deletions

View File

@@ -56,7 +56,7 @@
{{item}}
</view>
</view>
</view>
</view>
</block>
</view>
<!-- 未登录 -->
@@ -74,7 +74,9 @@
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
import im from '@/utils/im/index.js'
import userAuth from '@/public/userAuth'
import { getImToken } from '@/apis/interfaces/im.js'
import {
getImToken
} from '@/apis/interfaces/im.js'
export default {
data() {
return {
@@ -99,13 +101,20 @@
}
}
},
onLoad() {
if (this.isShown) {
uni.$on('onReceiveMessage', (msg) => {
console.log(msg);
this.getConversationList()
})
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
}
},
onShow() {
if (this.$store.state.token !== '') {
getImToken().then(res => {
im.connect(res.token, res.userInfo, () => {
this.getConversationList()
})
})
this.getConversationList()
}
this.isShown = true
},
@@ -127,16 +136,6 @@
}
}
},
watch: {
'$store.getters.newMessage': function(n, o) {
if (this.isShown) {
this.getConversationList()
}
},
'$store.getters.connection': function(n, o) {
this.connection = n
}
},
methods: {
hidePop() {
this.showPop = false
@@ -202,9 +201,6 @@
// 进入聊天的详情页面,清理未读消息数量
toDetail(item) {
this.hidePop()
// uni.navigateTo({
// url: '/pages/im/private/call?targetId=' + item.targetId + '&mediaType=1'
// })
uni.navigateTo({
url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item
.conversationType
@@ -229,10 +225,8 @@
scanQrCode() {
uni.scanCode({
success: (res) => {
// "result": "ADDFRIEND|10010",
if (res.scanType == 'QR_CODE') {
res.result.substr(0, 10) == 'ADDFRIEND|'
// 跳转到添加好友页面
uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + res.result.substr(10)
})