plugins-huansi-im-ui
v1.0.7
Published
IM 通讯 插件
Downloads
4
Readme
IM 服务插件 plugins-huansi-im-ui
简介
基于vue 2.6.11。功能,聊天、通讯录、发送即消息等。需要配合接口服务运行。
安装插件
# 使用npm
npm i plugins-huansi-im-ui --save
安装依赖
//需要安装依赖包 package.json
"mqtt": "^4.3.7",
使用插件
//引入 外抛方法
import {handleSend, registerIM} from "plugins-huansi-im-ui";
methods: {
//初始化IM通讯
registerI() {
let IM_TOKEN = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjFCQzIzNkNFNUZDRkY2ODBGQjdFRTcwNjNGQzAxQUY3IiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2NDQ1NjEwNTAsImV4cCI6MTY0NDU2NDY1MCwiaXNzIjoiaHR0cHM6Ly90ZXN0LWhhbmd6aG91Lm9hdXRoLnNhYXMuaHVhbnNpLm5ldCIsImF1ZCI6WyJVc2VyUmlnaHQiLCJodHRwczovL3Rlc3QtaGFuZ3pob3Uub2F1dGguc2Fhcy5odWFuc2kubmV0L3Jlc291cmNlcyJdLCJjbGllbnRfaWQiOiJ3ZWItY29tbW9uLWxvY2FsaG9zdCBjbGllbnQiLCJzdWIiOiIxNDgxODE5OTU5Njk0ODA3MDQxIiwiYXV0aF90aW1lIjoxNjQ0NTYxMDQ5LCJpZHAiOiJsb2NhbCIsInByZWZlcnJlZF91c2VybmFtZSI6IjE4NjE2OTM4ODI0IiwibmFtZSI6Indtd3giLCJ0ZW5hbnRfaWQiOiIxNDc2Nzg3Njg2MTY4NzI3NTUyIiwidGVuYW50X2NvZGUiOiJjc3p3aHp3aGR0ZCIsImlzX2FkbWluIjpmYWxzZSwic2lkIjoiNzE4NjVGQzBFRUZERDUzRjkyNzdGQzk4REUyQTc4M0QiLCJpYXQiOjE2NDQ1NjEwNTAsInNjb3BlIjpbIm9wZW5pZCIsInByb2ZpbGUiLCJVc2VyUmlnaHQiXSwiYW1yIjpbInB3ZCJdfQ.iM6_o1U7boJ_odOyw6LJ_qdQp4vbyTsxtZo6Zk53X6dO3ShqjR9z2nOke5q4RYjPUWrMcxCONtHKAQfgc7MzJmSTPAVt313e6U4fBakIGsW003DNyQ3gf8VxjCN8KqsRsPGpS6bcqFNpjWp2FBq3vBbbS8wRfQamWPa_PdB279_Uhdz_Ra6o-Q7BtAYGv8xSntUfVbi9veo8mfPsilPGodjkIxL4SY_-WKQim3aKucbqGEQ0qw_yc96C6vVqHI9IaMblB3iMHmnkS7lorE_y1gIaO1hyIctxwmapFP1QT-hc_WDvQpzhxXfN6shvxHMyLwK3zGU3yDK2vF7BcXKd3g'
let IM_API_URL = 'http://im-service.test.huansi.net'
let IM_BROKER_URL = 'ws://ws.dev.huansi.net/mqtt'
registerIM(IM_TOKEN, IM_API_URL, IM_BROKER_URL, this.returnMessage)
},
//回调 消息接收
returnMessage(message) {
// debugger;
console.log('---handle message:' + JSON.stringify(message))
},
//发送消息
sendMessage() {
let toContactId = '1' //接收消息的联系人ID
let message = {
type: 'text',
content: '消息测试-1',
}
handleSend(toContactId, message, this.next)
},
//回调 发送消息返回状态
next(status) {
if (status) {
console.log('---send message wrong:' + status)
} else {
console.log('---send message success:' + status)
}
}
}