|
|
@@ -8,7 +8,6 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
// import Stomp from "stompjs"; |
|
|
|
import {SzyxPush} from "@/index"; |
|
|
|
import {MsgType} from "@/src/szyx-push-sdk"; |
|
|
|
// import SzyxPush from "@szyx/szyx-push-web" |
|
|
|
|
|
|
@@ -25,23 +24,23 @@ export default { |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
SzyxPush.register('xuqm').then(() => { |
|
|
|
this.$SzyxPush.register('xuqm').then(() => { |
|
|
|
console.log('>>>>>', 'IM连接成功') |
|
|
|
}).catch(error => { |
|
|
|
console.log('>>>>>', 'im连接失败', error) |
|
|
|
}) |
|
|
|
this.callId = SzyxPush.onMessage((type, msg) => { |
|
|
|
this.callId = this.$SzyxPush.onMessage((type, msg) => { |
|
|
|
console.log('新消息送达', msg) |
|
|
|
if (type === MsgType.text) |
|
|
|
this.msg = msg.message.text |
|
|
|
}) |
|
|
|
}, |
|
|
|
beforeUnmount() { |
|
|
|
SzyxPush.unMessage(this.callId) |
|
|
|
this.$SzyxPush.unMessage(this.callId) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
sendMsg() { |
|
|
|
SzyxPush.sendTextMsg('xuqinmin', '你好!','sas').then((res) => { |
|
|
|
this.$SzyxPush.sendTextMsg('xuqinmin', '你好!','sas').then((res) => { |
|
|
|
console.log('>>>>>', '发送消息成功', res) |
|
|
|
}).catch(error => { |
|
|
|
console.log('>>>>>', '发送消息失败', error) |
|
|
|