From 0e810bdd0fda4c09364a8cd8f4f405f7f967b06d Mon Sep 17 00:00:00 2001 From: linju Date: Thu, 21 Nov 2024 21:06:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20share-msg=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=A7=BB=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/uni-im-msg/popup-control.vue | 15 +- .../share-msg/share-msg.vue | 303 ++++++++++++------ 2 files changed, 202 insertions(+), 116 deletions(-) rename components/uni-im-share-msg/uni-im-share-msg.vue => pages/share-msg/share-msg.vue (59%) diff --git a/components/uni-im-msg/popup-control.vue b/components/uni-im-msg/popup-control.vue index 87f9a77..6c00941 100644 --- a/components/uni-im-msg/popup-control.vue +++ b/components/uni-im-msg/popup-control.vue @@ -60,16 +60,7 @@ this.$emit('chooseMore',[this.controlData.msg]) }, share(e){ - // 仅支持web pc端 - if(!this.isWidescreen){ - uni.showToast({ - title:'仅支持web pc端', - icon:'none' - }) - return - } this.$emit('share',[this.controlData.msg]) - }, initControlList(msg){ this.controlList = [ @@ -96,12 +87,12 @@ { title:'转发', action:()=>this.share(), - canDisplay:this.isWidescreen && msg._id != undefined, + canDisplay: msg._id != undefined, }, { title:'多选', action:()=>this.chooseMore(), - canDisplay:this.isWidescreen && msg._id != undefined, + canDisplay: msg._id != undefined, } ] @@ -109,7 +100,7 @@ this.controlList.push({ title:'进入会话', action:()=> this.$emit('intoTopic', msg._id), - canDisplay:true, + canDisplay: this.isWidescreen }) } diff --git a/components/uni-im-share-msg/uni-im-share-msg.vue b/pages/share-msg/share-msg.vue similarity index 59% rename from components/uni-im-share-msg/uni-im-share-msg.vue rename to pages/share-msg/share-msg.vue index f82c246..b0add5a 100644 --- a/components/uni-im-share-msg/uni-im-share-msg.vue +++ b/pages/share-msg/share-msg.vue @@ -5,6 +5,15 @@ @click="close" > + + + 返回 + 选择会话 + + 发送({{checkedList.length}}) + 发送 + + - + 转发给: @@ -97,6 +106,7 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js'; export default { name: 'UniImShareMsg', + emits: ['close'], props: { noMsgList: { // 不显示转发的消息列表 type: Boolean, @@ -114,13 +124,54 @@ export default { checkedList: [], isOpen: false, msgList: [], - merge: false + merge: false, + canSend: false + } + }, + computed: { + ...uniIm.mapState(['isWidescreen']) + }, + watch: { + checkedList: { + handler(val) { + this.canSend = val.length > 0; + // #ifdef APP + const titleNView = { + "autoBackButton": false, + "buttons": [{ + "text": "取消", + "fontSize": 16, + "float": "left", + "onclick": this.close + },{ + "text": "发送", + "fontSize": 16, + "float": "right", + "onclick": this.canSend ? this.send : null + }] + } + const rightButton = titleNView.buttons[1]; + rightButton.width = "100px" + rightButton.text = `发送(${val.length})` + rightButton.color = this.canSend ? '#149d42' : '#CCC' + const currentWebview = this.$scope.$getAppWebview(); + currentWebview.setStyle({titleNView}); + // #endif + }, + immediate: true, + deep: true } }, - computed: {}, + onLoad() { + const eventChannel = this.getOpenerEventChannel(); + eventChannel.on('shareMsg', ([msgList,merge]) => { + console.log('shareMsg',msgList,merge) + this.open(msgList, merge); + }); + }, methods: { open(msgList, merge) { - // console.info('msgList', msgList); + console.info('msgList', msgList); this.isOpen = true; this.merge = merge; @@ -142,6 +193,9 @@ export default { this.isOpen = false; this.checkedList = []; this.inputText = ''; + if(!this.isWidescreen){ + uni.navigateBack(); + } }, createMsg(msg, conversation) { @@ -151,6 +205,8 @@ export default { this.$refs['view-msg'].open(this.msgList); }, async send() { + console.info('send', this.checkedList); + console.info('this.msgList', this.msgList); if (!this.merge && this.inputText.length != 0) { this.msgList.push({ "body": this.inputText, @@ -235,7 +291,8 @@ export default { } - \ No newline at end of file -- GitLab