|
|
|
@ -1,58 +1,62 @@ |
|
|
|
<template> |
|
|
|
<div class="im-msg-item" :class="{'im-chat-mine':mine}"> |
|
|
|
<div class="head-image"> |
|
|
|
<head-image :url="headImage" :id="msgInfo.sendId"></head-image> |
|
|
|
</div> |
|
|
|
<div class="im-msg-content"> |
|
|
|
<div class="im-msg-top"> |
|
|
|
<span>{{showName}}</span> |
|
|
|
<chat-time :time="msgInfo.sendTime"></chat-time> |
|
|
|
<div class="im-msg-item"> |
|
|
|
<div class="im-msg-tip" v-show="msgInfo.type==10">{{msgInfo.content}}</div> |
|
|
|
<div class="im-msg-normal" v-show="msgInfo.type!=10" :class="{'im-chat-mine':mine}"> |
|
|
|
<div class="head-image"> |
|
|
|
<head-image :url="headImage" :id="msgInfo.sendId"></head-image> |
|
|
|
</div> |
|
|
|
<div class="im-msg-bottom"> |
|
|
|
<span class="im-msg-text" v-if="msgInfo.type==0" v-html="$emo.transform(msgInfo.content)"></span> |
|
|
|
<div class="im-msg-image" v-if="msgInfo.type==1"> |
|
|
|
<div class="img-load-box" v-loading="loading" |
|
|
|
element-loading-text="上传中.." |
|
|
|
element-loading-background="rgba(0, 0, 0, 0.4)"> |
|
|
|
<img class="send-image" |
|
|
|
:src="JSON.parse(msgInfo.content).thumbUrl" |
|
|
|
@click="showFullImageBox()"/> |
|
|
|
</div> |
|
|
|
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span> |
|
|
|
<div class="im-msg-content"> |
|
|
|
<div class="im-msg-top"> |
|
|
|
<span>{{showName}}</span> |
|
|
|
<chat-time :time="msgInfo.sendTime"></chat-time> |
|
|
|
</div> |
|
|
|
<div class="im-msg-file" v-if="msgInfo.type==2"> |
|
|
|
<div class="im-file-box" v-loading="loading"> |
|
|
|
<div class="im-file-info"> |
|
|
|
<el-link class="im-file-name" :underline="true" target="_blank" type="primary" :href="data.url">{{data.name}}</el-link> |
|
|
|
<div class="im-file-size">{{fileSize}}</div> |
|
|
|
<div class="im-msg-bottom" @contextmenu.prevent="showRightMenu($event)"> |
|
|
|
<span class="im-msg-text" v-if="msgInfo.type==0" v-html="$emo.transform(msgInfo.content)"></span> |
|
|
|
<div class="im-msg-image" v-if="msgInfo.type==1"> |
|
|
|
<div class="img-load-box" v-loading="loading" element-loading-text="上传中.." element-loading-background="rgba(0, 0, 0, 0.4)"> |
|
|
|
<img class="send-image" :src="JSON.parse(msgInfo.content).thumbUrl" @click="showFullImageBox()" /> |
|
|
|
</div> |
|
|
|
<div class="im-file-icon"> |
|
|
|
<span type="primary" class="el-icon-document"></span> |
|
|
|
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span> |
|
|
|
</div> |
|
|
|
<div class="im-msg-file" v-if="msgInfo.type==2"> |
|
|
|
<div class="im-file-box" v-loading="loading"> |
|
|
|
<div class="im-file-info"> |
|
|
|
<el-link class="im-file-name" :underline="true" target="_blank" type="primary" :href="data.url">{{data.name}}</el-link> |
|
|
|
<div class="im-file-size">{{fileSize}}</div> |
|
|
|
</div> |
|
|
|
<div class="im-file-icon"> |
|
|
|
<span type="primary" class="el-icon-document"></span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span> |
|
|
|
</div> |
|
|
|
<div class="im-msg-voice" v-if="msgInfo.type==3" @click="handlePlayVoice()"> |
|
|
|
<audio controls :src="JSON.parse(msgInfo.content).url"></audio> |
|
|
|
</div> |
|
|
|
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span> |
|
|
|
</div> |
|
|
|
<div class="im-msg-voice" v-if="msgInfo.type==3" @click="handlePlayVoice()"> |
|
|
|
<audio controls :src="JSON.parse(msgInfo.content).url"></audio> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
<right-menu v-show="rightMenu.show" :pos="rightMenu.pos" :items="menuItems" @close="rightMenu.show=false" |
|
|
|
@select="handleSelectMenu"></right-menu> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import ChatTime from "./ChatTime.vue"; |
|
|
|
import HeadImage from "../common/HeadImage.vue"; |
|
|
|
import RightMenu from '../common/RightMenu.vue'; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "messageItem", |
|
|
|
components: { |
|
|
|
ChatTime, |
|
|
|
HeadImage |
|
|
|
HeadImage, |
|
|
|
RightMenu |
|
|
|
}, |
|
|
|
props: { |
|
|
|
mine:{ |
|
|
|
type:Boolean, |
|
|
|
mine: { |
|
|
|
type: Boolean, |
|
|
|
required: true |
|
|
|
}, |
|
|
|
headImage: { |
|
|
|
@ -68,42 +72,59 @@ |
|
|
|
required: true |
|
|
|
} |
|
|
|
}, |
|
|
|
data(){ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
audioPlayState: 'STOP', |
|
|
|
rightMenu: { |
|
|
|
show: false, |
|
|
|
pos: { |
|
|
|
x: 0, |
|
|
|
y: 0 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
handleSendFail(){ |
|
|
|
methods: { |
|
|
|
handleSendFail() { |
|
|
|
this.$message.error("该文件已发送失败,目前不支持自动重新发送,建议手动重新发送") |
|
|
|
}, |
|
|
|
showFullImageBox(){ |
|
|
|
showFullImageBox() { |
|
|
|
let imageUrl = JSON.parse(this.msgInfo.content).originUrl; |
|
|
|
if(imageUrl){ |
|
|
|
this.$store.commit('showFullImageBox',imageUrl); |
|
|
|
if (imageUrl) { |
|
|
|
this.$store.commit('showFullImageBox', imageUrl); |
|
|
|
} |
|
|
|
}, |
|
|
|
handlePlayVoice(){ |
|
|
|
if(!this.audio){ |
|
|
|
handlePlayVoice() { |
|
|
|
if (!this.audio) { |
|
|
|
this.audio = new Audio(); |
|
|
|
} |
|
|
|
this.audio.src = JSON.parse(this.msgInfo.content).url; |
|
|
|
this.audio.play(); |
|
|
|
this.handlePlayVoice = 'RUNNING'; |
|
|
|
}, |
|
|
|
showRightMenu(e) { |
|
|
|
this.rightMenu.pos = { |
|
|
|
x: e.x, |
|
|
|
y: e.y |
|
|
|
}; |
|
|
|
this.rightMenu.show = "true"; |
|
|
|
}, |
|
|
|
handleSelectMenu(item) { |
|
|
|
this.$emit(item.key.toLowerCase(), this.msgInfo); |
|
|
|
} |
|
|
|
}, |
|
|
|
computed:{ |
|
|
|
loading(){ |
|
|
|
computed: { |
|
|
|
loading() { |
|
|
|
return this.msgInfo.loadStatus && this.msgInfo.loadStatus === "loading"; |
|
|
|
}, |
|
|
|
loadFail(){ |
|
|
|
loadFail() { |
|
|
|
return this.msgInfo.loadStatus && this.msgInfo.loadStatus === "fail"; |
|
|
|
}, |
|
|
|
data(){ |
|
|
|
data() { |
|
|
|
return JSON.parse(this.msgInfo.content) |
|
|
|
}, |
|
|
|
fileSize(){ |
|
|
|
fileSize() { |
|
|
|
let size = this.data.size; |
|
|
|
if (size > 1024 * 1024) { |
|
|
|
return Math.round(size / 1024 / 1024) + "M"; |
|
|
|
@ -113,6 +134,22 @@ |
|
|
|
} |
|
|
|
return size + "B"; |
|
|
|
}, |
|
|
|
menuItems() { |
|
|
|
let items = []; |
|
|
|
items.push({ |
|
|
|
key: 'DELETE', |
|
|
|
name: '删除', |
|
|
|
icon: 'el-icon-delete' |
|
|
|
}); |
|
|
|
if (this.msgInfo.selfSend && this.msgInfo.id > 0) { |
|
|
|
items.push({ |
|
|
|
key: 'RECALL', |
|
|
|
name: '撤回', |
|
|
|
icon: 'el-icon-refresh-left' |
|
|
|
}); |
|
|
|
} |
|
|
|
return items; |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
//console.log(this.msgInfo); |
|
|
|
@ -122,198 +159,207 @@ |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
.im-msg-item { |
|
|
|
position: relative; |
|
|
|
font-size: 0; |
|
|
|
margin-bottom: 10px; |
|
|
|
padding-left: 60px; |
|
|
|
min-height: 68px; |
|
|
|
|
|
|
|
.head-image { |
|
|
|
position: absolute; |
|
|
|
width: 40px; |
|
|
|
height: 40px; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-content { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
.im-msg-tip { |
|
|
|
line-height: 50px; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-top { |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
color: #333; |
|
|
|
font-size: 14px; |
|
|
|
line-height: 20px; |
|
|
|
.im-msg-normal { |
|
|
|
position: relative; |
|
|
|
font-size: 0; |
|
|
|
margin-bottom: 10px; |
|
|
|
padding-left: 60px; |
|
|
|
min-height: 68px; |
|
|
|
|
|
|
|
span { |
|
|
|
margin-right: 12px; |
|
|
|
} |
|
|
|
.head-image { |
|
|
|
position: absolute; |
|
|
|
width: 40px; |
|
|
|
height: 40px; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-bottom { |
|
|
|
text-align: left; |
|
|
|
.im-msg-content { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
|
|
|
|
.im-msg-text { |
|
|
|
position: relative; |
|
|
|
line-height: 22px; |
|
|
|
margin-top: 10px; |
|
|
|
padding: 10px; |
|
|
|
background-color: #eeeeee; |
|
|
|
border-radius: 3px; |
|
|
|
.im-msg-top { |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
color: #333; |
|
|
|
display: inline-block; |
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
&:after { |
|
|
|
content: ""; |
|
|
|
position: absolute; |
|
|
|
left: -10px; |
|
|
|
top: 13px; |
|
|
|
width: 0; |
|
|
|
height: 0; |
|
|
|
border-style: solid dashed dashed; |
|
|
|
border-color: #eeeeee transparent transparent; |
|
|
|
overflow: hidden; |
|
|
|
border-width: 10px; |
|
|
|
line-height: 20px; |
|
|
|
|
|
|
|
span { |
|
|
|
margin-right: 12px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-image{ |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
flex-direction: row; |
|
|
|
align-items: center; |
|
|
|
|
|
|
|
.send-image{ |
|
|
|
min-width: 300px; |
|
|
|
min-height: 200px; |
|
|
|
max-width: 600px; |
|
|
|
max-height: 400px; |
|
|
|
border: #dddddd solid 1px; |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
.im-msg-bottom { |
|
|
|
text-align: left; |
|
|
|
|
|
|
|
.im-msg-text { |
|
|
|
position: relative; |
|
|
|
line-height: 22px; |
|
|
|
margin-top: 10px; |
|
|
|
padding: 10px; |
|
|
|
background-color: #eeeeee; |
|
|
|
border-radius: 3px; |
|
|
|
color: #333; |
|
|
|
display: inline-block; |
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
&:after { |
|
|
|
content: ""; |
|
|
|
position: absolute; |
|
|
|
left: -10px; |
|
|
|
top: 13px; |
|
|
|
width: 0; |
|
|
|
height: 0; |
|
|
|
border-style: solid dashed dashed; |
|
|
|
border-color: #eeeeee transparent transparent; |
|
|
|
overflow: hidden; |
|
|
|
border-width: 10px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.send-fail{ |
|
|
|
color: #e60c0c; |
|
|
|
font-size: 30px; |
|
|
|
cursor: pointer; |
|
|
|
margin: 0 20px; |
|
|
|
|
|
|
|
.im-msg-image { |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
flex-direction: row; |
|
|
|
align-items: center; |
|
|
|
|
|
|
|
.send-image { |
|
|
|
min-width: 300px; |
|
|
|
min-height: 200px; |
|
|
|
max-width: 600px; |
|
|
|
max-height: 400px; |
|
|
|
border: #dddddd solid 1px; |
|
|
|
cursor: pointer; |
|
|
|
} |
|
|
|
|
|
|
|
.send-fail { |
|
|
|
color: #e60c0c; |
|
|
|
font-size: 30px; |
|
|
|
cursor: pointer; |
|
|
|
margin: 0 20px; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-file{ |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
flex-direction: row; |
|
|
|
align-items: center; |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
.im-file-box{ |
|
|
|
|
|
|
|
.im-msg-file { |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
flex-direction: row; |
|
|
|
align-items: center; |
|
|
|
width: 20%; |
|
|
|
min-height: 80px; |
|
|
|
border: #dddddd solid 1px; |
|
|
|
border-radius: 3px; |
|
|
|
background-color: #eeeeee; |
|
|
|
padding: 10px 15px; |
|
|
|
.im-file-info{ |
|
|
|
flex:1; |
|
|
|
height: 100%; |
|
|
|
text-align: left; |
|
|
|
font-size: 14px; |
|
|
|
.im-file-name { |
|
|
|
font-size: 16px; |
|
|
|
font-weight: 600; |
|
|
|
margin-bottom: 15px; |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
.im-file-box { |
|
|
|
display: flex; |
|
|
|
flex-wrap: nowrap; |
|
|
|
align-items: center; |
|
|
|
width: 20%; |
|
|
|
min-height: 80px; |
|
|
|
border: #dddddd solid 1px; |
|
|
|
border-radius: 3px; |
|
|
|
background-color: #eeeeee; |
|
|
|
padding: 10px 15px; |
|
|
|
|
|
|
|
.im-file-info { |
|
|
|
flex: 1; |
|
|
|
height: 100%; |
|
|
|
text-align: left; |
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
.im-file-name { |
|
|
|
font-size: 16px; |
|
|
|
font-weight: 600; |
|
|
|
margin-bottom: 15px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-file-icon { |
|
|
|
font-size: 50px; |
|
|
|
color: #d42e07; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-file-icon{ |
|
|
|
font-size: 50px; |
|
|
|
color: #d42e07; |
|
|
|
|
|
|
|
.send-fail { |
|
|
|
color: #e60c0c; |
|
|
|
font-size: 30px; |
|
|
|
cursor: pointer; |
|
|
|
margin: 0 20px; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.send-fail{ |
|
|
|
color: #e60c0c; |
|
|
|
font-size: 30px; |
|
|
|
|
|
|
|
.im-msg-voice { |
|
|
|
font-size: 14px; |
|
|
|
cursor: pointer; |
|
|
|
margin: 0 20px; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-voice { |
|
|
|
font-size: 14px; |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
audio { |
|
|
|
height: 45px; |
|
|
|
padding: 5px 0; |
|
|
|
|
|
|
|
audio { |
|
|
|
height: 45px; |
|
|
|
padding: 5px 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
&.im-chat-mine { |
|
|
|
text-align: right; |
|
|
|
padding-left: 0; |
|
|
|
padding-right: 60px; |
|
|
|
&.im-chat-mine { |
|
|
|
text-align: right; |
|
|
|
padding-left: 0; |
|
|
|
padding-right: 60px; |
|
|
|
|
|
|
|
.head-image { |
|
|
|
left: auto; |
|
|
|
right: 0; |
|
|
|
} |
|
|
|
.head-image { |
|
|
|
left: auto; |
|
|
|
right: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-content { |
|
|
|
.im-msg-content { |
|
|
|
|
|
|
|
.im-msg-top { |
|
|
|
flex-direction: row-reverse; |
|
|
|
.im-msg-top { |
|
|
|
flex-direction: row-reverse; |
|
|
|
|
|
|
|
span { |
|
|
|
margin-left: 12px; |
|
|
|
margin-right: 0; |
|
|
|
span { |
|
|
|
margin-left: 12px; |
|
|
|
margin-right: 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-bottom { |
|
|
|
text-align: right; |
|
|
|
.im-msg-bottom { |
|
|
|
text-align: right; |
|
|
|
|
|
|
|
.im-msg-text { |
|
|
|
margin-left: 10px; |
|
|
|
background-color: #5fb878; |
|
|
|
color: #fff; |
|
|
|
display: inline-block; |
|
|
|
vertical-align: top; |
|
|
|
font-size: 14px; |
|
|
|
.im-msg-text { |
|
|
|
margin-left: 10px; |
|
|
|
background-color: #5fb878; |
|
|
|
color: #fff; |
|
|
|
display: inline-block; |
|
|
|
vertical-align: top; |
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
&:after { |
|
|
|
left: auto; |
|
|
|
right: -10px; |
|
|
|
border-top-color: #5fb878; |
|
|
|
&:after { |
|
|
|
left: auto; |
|
|
|
right: -10px; |
|
|
|
border-top-color: #5fb878; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-image { |
|
|
|
flex-direction: row-reverse; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-file { |
|
|
|
flex-direction: row-reverse; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-image { |
|
|
|
flex-direction: row-reverse; |
|
|
|
} |
|
|
|
|
|
|
|
.im-msg-file { |
|
|
|
flex-direction: row-reverse; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.message-info { |
|
|
|
right: 60px !important; |
|
|
|
display: inline-block; |
|
|
|
.message-info { |
|
|
|
right: 60px !important; |
|
|
|
display: inline-block; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
|