|
|
|
@ -1,45 +1,54 @@ |
|
|
|
<template> |
|
|
|
<el-container class="r-chat-box"> |
|
|
|
<el-header height="60px"> |
|
|
|
{{title}} |
|
|
|
<span>{{title}}</span> |
|
|
|
<span class="btn-side el-icon-more" @click="showSide=!showSide"></span> |
|
|
|
</el-header> |
|
|
|
<el-main class="im-chat-main" id="chatScrollBox"> |
|
|
|
<div class="im-chat-box"> |
|
|
|
<ul> |
|
|
|
<li v-for="msgInfo in chat.messages" :key="msgInfo.id"> |
|
|
|
<message-item :mine="msgInfo.sendId == mine.id" :headImage="headImage(msgInfo)" :showName="showName(msgInfo)" |
|
|
|
:msgInfo="msgInfo"> |
|
|
|
</message-item> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</el-main> |
|
|
|
<el-footer height="25%" class="im-chat-footer"> |
|
|
|
<div class="chat-tool-bar"> |
|
|
|
<div class="el-icon-service"></div> |
|
|
|
<div> |
|
|
|
<file-upload action="/api/image/upload" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg', 'image/gif']" |
|
|
|
@before="handleImageBefore" @success="handleImageSuccess" @fail="handleImageFail"> |
|
|
|
<i class="el-icon-picture-outline"></i> |
|
|
|
</file-upload> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<file-upload action="/api/file/upload" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess" |
|
|
|
@fail="handleFileFail"> |
|
|
|
<i class="el-icon-wallet"></i> |
|
|
|
</file-upload> |
|
|
|
</div> |
|
|
|
<div class="el-icon-chat-dot-round"></div> |
|
|
|
</div> |
|
|
|
<textarea v-model="sendText" ref="sendBox" class="send-text-area" @keydown.enter="sendTextMessage()"></textarea> |
|
|
|
<div class="im-chat-send"> |
|
|
|
<el-button type="primary" @click="sendTextMessage()">发送</el-button> |
|
|
|
</div> |
|
|
|
</el-footer> |
|
|
|
<el-container> |
|
|
|
<el-container class="content-box"> |
|
|
|
<el-main class="im-chat-main" id="chatScrollBox"> |
|
|
|
<div class="im-chat-box"> |
|
|
|
<ul> |
|
|
|
<li v-for="msgInfo in chat.messages" :key="msgInfo.id"> |
|
|
|
<message-item :mine="msgInfo.sendId == mine.id" :headImage="headImage(msgInfo)" :showName="showName(msgInfo)" |
|
|
|
:msgInfo="msgInfo"> |
|
|
|
</message-item> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</el-main> |
|
|
|
<el-footer height="25%" class="im-chat-footer"> |
|
|
|
<div class="chat-tool-bar"> |
|
|
|
<div class="el-icon-service"></div> |
|
|
|
<div> |
|
|
|
<file-upload action="/api/image/upload" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg', 'image/gif']" |
|
|
|
@before="handleImageBefore" @success="handleImageSuccess" @fail="handleImageFail"> |
|
|
|
<i class="el-icon-picture-outline"></i> |
|
|
|
</file-upload> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<file-upload action="/api/file/upload" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess" |
|
|
|
@fail="handleFileFail"> |
|
|
|
<i class="el-icon-wallet"></i> |
|
|
|
</file-upload> |
|
|
|
</div> |
|
|
|
<div class="el-icon-chat-dot-round"></div> |
|
|
|
</div> |
|
|
|
<textarea v-model="sendText" ref="sendBox" class="send-text-area" @keydown.enter="sendTextMessage()"></textarea> |
|
|
|
<div class="im-chat-send"> |
|
|
|
<el-button type="primary" @click="sendTextMessage()">发送</el-button> |
|
|
|
</div> |
|
|
|
</el-footer> |
|
|
|
</el-container> |
|
|
|
<el-aside class="chat-group-side-box" width="20%" v-show="showSide"> |
|
|
|
<chat-group-side :group="group" :groupMembers="groupMembers" @reload="loadGroup(group.id)"></chat-group-side> |
|
|
|
</el-aside> |
|
|
|
</el-container> |
|
|
|
</el-container> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import ChatGroupSide from "./ChatGroupSide.vue"; |
|
|
|
import MessageItem from "./MessageItem.vue"; |
|
|
|
import FileUpload from "../common/FileUpload.vue"; |
|
|
|
|
|
|
|
@ -47,7 +56,8 @@ |
|
|
|
name: "chatPrivate", |
|
|
|
components: { |
|
|
|
MessageItem, |
|
|
|
FileUpload |
|
|
|
FileUpload, |
|
|
|
ChatGroupSide |
|
|
|
}, |
|
|
|
props: { |
|
|
|
chat: { |
|
|
|
@ -57,6 +67,7 @@ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
sendText: "", |
|
|
|
showSide: false, |
|
|
|
group: {}, |
|
|
|
groupMembers: [] |
|
|
|
} |
|
|
|
@ -174,8 +185,11 @@ |
|
|
|
// 借助file对象保存对方id |
|
|
|
file.targetId = this.chat.targetId; |
|
|
|
}, |
|
|
|
handleCloseSide() { |
|
|
|
this.showSide = false; |
|
|
|
}, |
|
|
|
sendTextMessage() { |
|
|
|
|
|
|
|
|
|
|
|
if (!this.sendText.trim()) { |
|
|
|
this.$message.error("不能发送空白信息"); |
|
|
|
return |
|
|
|
@ -214,7 +228,7 @@ |
|
|
|
method: 'get' |
|
|
|
}).then((group) => { |
|
|
|
this.group = group; |
|
|
|
this.$store.commit("updateChatFromGroup",group); |
|
|
|
this.$store.commit("updateChatFromGroup", group); |
|
|
|
}); |
|
|
|
|
|
|
|
this.$http({ |
|
|
|
@ -244,8 +258,8 @@ |
|
|
|
mine() { |
|
|
|
return this.$store.state.userStore.userInfo; |
|
|
|
}, |
|
|
|
title(){ |
|
|
|
let size = this.groupMembers.filter(m=>!m.quit).length; |
|
|
|
title() { |
|
|
|
let size = this.groupMembers.filter(m => !m.quit).length; |
|
|
|
return `${this.chat.showName}(${size})`; |
|
|
|
} |
|
|
|
|
|
|
|
@ -259,4 +273,15 @@ |
|
|
|
</script> |
|
|
|
|
|
|
|
<style> |
|
|
|
.btn-side { |
|
|
|
position: absolute; |
|
|
|
right: 20px; |
|
|
|
line-height: 60px; |
|
|
|
font-size: 22px; |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
&:hover { |
|
|
|
font-size: 30px; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
|