提交 0e810bdd 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 share-msg支持移动端

上级 5dd51d24
...@@ -60,16 +60,7 @@ ...@@ -60,16 +60,7 @@
this.$emit('chooseMore',[this.controlData.msg]) this.$emit('chooseMore',[this.controlData.msg])
}, },
share(e){ share(e){
// 仅支持web pc端
if(!this.isWidescreen){
uni.showToast({
title:'仅支持web pc端',
icon:'none'
})
return
}
this.$emit('share',[this.controlData.msg]) this.$emit('share',[this.controlData.msg])
}, },
initControlList(msg){ initControlList(msg){
this.controlList = [ this.controlList = [
...@@ -96,12 +87,12 @@ ...@@ -96,12 +87,12 @@
{ {
title:'转发', title:'转发',
action:()=>this.share(), action:()=>this.share(),
canDisplay:this.isWidescreen && msg._id != undefined, canDisplay: msg._id != undefined,
}, },
{ {
title:'多选', title:'多选',
action:()=>this.chooseMore(), action:()=>this.chooseMore(),
canDisplay:this.isWidescreen && msg._id != undefined, canDisplay: msg._id != undefined,
} }
] ]
...@@ -109,7 +100,7 @@ ...@@ -109,7 +100,7 @@
this.controlList.push({ this.controlList.push({
title:'进入会话', title:'进入会话',
action:()=> this.$emit('intoTopic', msg._id), action:()=> this.$emit('intoTopic', msg._id),
canDisplay:true, canDisplay: this.isWidescreen
}) })
} }
......
...@@ -5,6 +5,15 @@ ...@@ -5,6 +5,15 @@
@click="close" @click="close"
> >
<view class="share-msg-content" @click.stop> <view class="share-msg-content" @click.stop>
<!-- #ifndef APP -->
<view class="navbar" v-if="!isWidescreen">
<text class="btn cancel" @click="close">返回</text>
<text class="title">选择会话</text>
<text class="btn" @click="send" v-if="canSend">发送({{checkedList.length}})</text>
<text class="btn disabled" v-else>发送</text>
</view>
<!-- #endif -->
<view class="conversation-list-box"> <view class="conversation-list-box">
<uni-search-bar <uni-search-bar
id="search-bar" id="search-bar"
...@@ -22,7 +31,7 @@ ...@@ -22,7 +31,7 @@
:show-unread-count="false" :show-unread-count="false"
/> />
</view> </view>
<view class="conversation-detail-box"> <view class="conversation-detail-box" v-if="isWidescreen">
<text class="title"> <text class="title">
转发给: 转发给:
</text> </text>
...@@ -97,6 +106,7 @@ ...@@ -97,6 +106,7 @@
import uniIm from '@/uni_modules/uni-im/sdk/index.js'; import uniIm from '@/uni_modules/uni-im/sdk/index.js';
export default { export default {
name: 'UniImShareMsg', name: 'UniImShareMsg',
emits: ['close'],
props: { props: {
noMsgList: { // 不显示转发的消息列表 noMsgList: { // 不显示转发的消息列表
type: Boolean, type: Boolean,
...@@ -114,13 +124,54 @@ export default { ...@@ -114,13 +124,54 @@ export default {
checkedList: [], checkedList: [],
isOpen: false, isOpen: false,
msgList: [], 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: { methods: {
open(msgList, merge) { open(msgList, merge) {
// console.info('msgList', msgList); console.info('msgList', msgList);
this.isOpen = true; this.isOpen = true;
this.merge = merge; this.merge = merge;
...@@ -142,6 +193,9 @@ export default { ...@@ -142,6 +193,9 @@ export default {
this.isOpen = false; this.isOpen = false;
this.checkedList = []; this.checkedList = [];
this.inputText = ''; this.inputText = '';
if(!this.isWidescreen){
uni.navigateBack();
}
}, },
createMsg(msg, conversation) { createMsg(msg, conversation) {
...@@ -151,6 +205,8 @@ export default { ...@@ -151,6 +205,8 @@ export default {
this.$refs['view-msg'].open(this.msgList); this.$refs['view-msg'].open(this.msgList);
}, },
async send() { async send() {
console.info('send', this.checkedList);
console.info('this.msgList', this.msgList);
if (!this.merge && this.inputText.length != 0) { if (!this.merge && this.inputText.length != 0) {
this.msgList.push({ this.msgList.push({
"body": this.inputText, "body": this.inputText,
...@@ -235,7 +291,8 @@ export default { ...@@ -235,7 +291,8 @@ export default {
} }
</script> </script>
<style> <style lang="scss">
@import "@/uni_modules/uni-im/common/baseStyle.scss";
/* #ifdef H5*/ /* #ifdef H5*/
.share-msg-root, .share-msg-root,
.share-msg-root * { .share-msg-root * {
...@@ -246,11 +303,13 @@ export default { ...@@ -246,11 +303,13 @@ export default {
/* #endif */ /* #endif */
.share-msg-root { .share-msg-root {
width: 750rpx;
/* #ifndef APP */
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
z-index: 999; z-index: 999;
width: 750rpx; /* #endif */
/* #ifdef H5 */ /* #ifdef H5 */
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
...@@ -259,103 +318,139 @@ export default { ...@@ -259,103 +318,139 @@ export default {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-color: rgb(0, 0, 0, 0.3); background-color: rgb(0, 0, 0, 0.3);
} .share-msg-content {
.navbar {
.share-msg-content { flex-direction: row;
background-color: #fff; justify-content: space-between;
width: 750px; align-items: center;
height: 70vh; padding: 10px;
flex-direction: row; border-bottom: 1px solid #eee;
border-radius: 15px; .title {
position: relative; font-size: 14px;
} color: #333;
}
.conversation-list-box { .btn {
width: 300px; font-size: 12px;
height: 100%; color: #FFF;
border-right: 1px solid #eee; background-color: #149d42;
} padding: 4px 8px;
border-radius: 6px;
.conversation-list-box ::v-deep .conversation-list .refresh-box { &.disabled {
background-color: #fff; background-color: #EEE;
} color: #CCC;
}
.conversation-detail-box { &.cancel {
flex: 1; border: none;
} background-color: #FFF;
color: #666;
.conversation-detail-box .title { }
font-size: 18px; }
color: #333; }
margin: 15px; background-color: #fff;
} width: 750rpx;
height: 100%;
.selected-conversation-list { /* #ifdef H5 */
height: 0; @media screen and (min-device-width:960px){
flex: 1; width: 750px;
} height: 70vh;
border-radius: 15px;
.scroll-content { flex-direction: row;
flex-direction: row; }
flex-wrap: wrap; /* #endif */
margin: 0 5px 35px 5px; position: relative;
} }
.selected-conversation-item { .conversation-list-box {
flex-direction: row; /* #ifdef H5 */
padding: 3px; @media screen and (min-device-width:960px){
justify-content: center; width: 300px;
align-items: center; }
border-radius: 5px; /* #endif */
background-color: rgba(250, 250, 250, 1); height: 100%;
margin: 3px; border-right: 1px solid #eee;
} }
.selected-conversation-item .avatar { .conversation-list-box ::v-deep .conversation-list .refresh-box {
width: 35px; background-color: #fff;
height: 35px; }
border-radius: 50%;
} .conversation-detail-box {
flex: 1;
.selected-conversation-item .title { }
font-size: 12px;
color: #333; .conversation-detail-box .title {
text-align: center; font-size: 18px;
margin: 0 5px; color: #333;
} margin: 15px;
}
.close-icon {
cursor: pointer; .selected-conversation-list {
} height: 0;
flex: 1;
.msg {} }
.input-box { .scroll-content {
padding: 15px 10px; flex-direction: row;
border: 1px solid #EEE; flex-wrap: wrap;
border-width: 1px 0; margin: 0 5px 35px 5px;
} }
.textarea { .selected-conversation-item {
width: 100%; flex-direction: row;
border-radius: 5px; padding: 3px;
font-size: 14px; justify-content: center;
outline: none; align-items: center;
} border-radius: 5px;
background-color: rgba(250, 250, 250, 1);
.action-btns { margin: 3px;
flex-direction: row; }
justify-content: flex-end;
padding: 10px; .selected-conversation-item .avatar {
} width: 35px;
height: 35px;
.action-btns .btn { border-radius: 50%;
margin: 0 10px; }
width: 100px;
} .selected-conversation-item .title {
font-size: 12px;
.action-btns .btn.cancel { color: #333;
color: #999; text-align: center;
border-color: #999; margin: 0 5px;
}
.close-icon {
cursor: pointer;
}
.msg {}
.input-box {
padding: 15px 10px;
border: 1px solid #EEE;
border-width: 1px 0;
}
.textarea {
width: 100%;
border-radius: 5px;
font-size: 14px;
outline: none;
}
.action-btns {
flex-direction: row;
justify-content: flex-end;
padding: 10px;
}
.action-btns .btn {
margin: 0 10px;
width: 100px;
}
.action-btns .btn.cancel {
color: #999;
border-color: #999;
}
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册