From ca9b43a5971e344a2b08c89e97ed464ecd450989 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Thu, 13 Aug 2020 16:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pageD/privateChat/privateChat.vue | 30 ++++++++++++++++++++++++++++++ static/imservice.js | 3 +++ 2 files changed, 33 insertions(+) diff --git a/pageD/privateChat/privateChat.vue b/pageD/privateChat/privateChat.vue index 4509e4a..aa55234 100644 --- a/pageD/privateChat/privateChat.vue +++ b/pageD/privateChat/privateChat.vue @@ -68,6 +68,7 @@
+ @@ -191,6 +192,13 @@ }) }, sendMessage() {//发送消息 + if(!this.imService.status){ + this.$refs.uToast.show({ + title: '连接聊天中,请稍候', + type: 'warning' + }) + return + } if (this.content.trim() != '') { this.imService.sendPrivateTextMessage(this.friend.uuid, this.content); let that = this @@ -209,6 +217,13 @@ this.imService.loadPrivateHistoryMessage(this.friend.uuid, lastMessageTimeStamp); }, onRecordStart () { + if(!this.imService.status){ + this.$refs.uToast.show({ + title: '连接聊天中,请稍候', + type: 'warning' + }) + return + } try{ recorderManager.start(); }catch(e){ @@ -231,6 +246,13 @@ } }, sendVideo () {//发送文件 + if(!this.imService.status){ + this.$refs.uToast.show({ + title: '连接聊天中,请稍候', + type: 'warning' + }) + return + } uni.chooseVideo({ success : (res) => { console.log(res) @@ -239,6 +261,13 @@ }) }, sendImage() { + if(!this.imService.status){ + this.$refs.uToast.show({ + title: '连接聊天中,请稍候', + type: 'warning' + }) + return + } uni.chooseImage({ count :1, success :(res) => { @@ -248,6 +277,7 @@ }) }, showImageFullScreen (e) { + var imagesUrl = [e.currentTarget.dataset.url]; uni.previewImage({ urls: imagesUrl diff --git a/static/imservice.js b/static/imservice.js index 098524d..57453ef 100644 --- a/static/imservice.js +++ b/static/imservice.js @@ -37,6 +37,7 @@ function IMService() { host:'hangzhou.goeasy.io',//qos=1 appkey:'BC-453aa755c4ea48148abefc55a86df283' }); + this.status = false //当前“我” this.currentUser = null; //我的好友 @@ -236,10 +237,12 @@ IMService.prototype.connectIM = function () { IMService.prototype.initialIMListeners = function () { this.im.on(GoEasyIM.EVENT.CONNECTED, () => { console.log('连接成功.') + this.status = true }); this.im.on(GoEasyIM.EVENT.DISCONNECTED, () => { console.log('连接断开.') + this.status = false }); //监听好友上下线 -- 2.45.2