|
|
@@ -9,7 +9,13 @@ import chat from "@/assets/images/profile.jpg";
|
|
|
import cebian from "@/assets/images/cebian.png";
|
|
|
import send from "@/assets/images/send.png";
|
|
|
import sendFile from "@/assets/images/send-file.png";
|
|
|
-import store from '@/store'
|
|
|
+import store from "@/store";
|
|
|
+import { msgFriend } from "@/api/chat/msg";
|
|
|
+//websocket连接====
|
|
|
+import useWebsoctStore from '@/store/modules/websocket'
|
|
|
+const websoctStore = useWebsoctStore()
|
|
|
+
|
|
|
+//====
|
|
|
const height = ref(document.documentElement.clientHeight - 74 + "px;");
|
|
|
const searchText = ref(""); //搜
|
|
|
const SearchChat = () => {}; //搜索的点击事件
|
|
|
@@ -28,11 +34,32 @@ const personList = reactive({
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
+// const personList =reactive({data: []})
|
|
|
+//获取好友列表
|
|
|
+function getMsgList() {
|
|
|
+ msgFriend().then((res) => {
|
|
|
+ // personList.data=res.rows
|
|
|
+ })
|
|
|
+}
|
|
|
+const chatRecords= reactive( [
|
|
|
+ { sender: 'friend', content: 'Hello' },
|
|
|
+ { sender: 'me', content: 'Hi' },
|
|
|
+ { sender: 'me', content: 'How are you?' },
|
|
|
+ { sender: 'friend', content: 'I am fine, thanks!' },
|
|
|
+ ])
|
|
|
//点击左侧聊天列表
|
|
|
const clickPersonIndex = ref("");
|
|
|
const clickPerson = (index) => {
|
|
|
clickPersonIndex.value = index;
|
|
|
};
|
|
|
+onMounted(() => {
|
|
|
+ try {
|
|
|
+ getMsgList();
|
|
|
+ websoctStore.connect()
|
|
|
+ } catch (e) {
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -78,7 +105,32 @@ const clickPerson = (index) => {
|
|
|
<el-header height="64px" class="right-header flex-buju"
|
|
|
>Header</el-header
|
|
|
>
|
|
|
- <el-main class="right-container">Main</el-main>
|
|
|
+ <!-- 聊天 -->
|
|
|
+ <el-main class="right-container">
|
|
|
+ <div
|
|
|
+ class="message-container"
|
|
|
+ v-for="(record,index) in chatRecords"
|
|
|
+ :class="{
|
|
|
+ 'message-left': record.sender !== 'me',
|
|
|
+ 'message-right': record.sender === 'me',
|
|
|
+ }"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <span v-if="record.sender == 'me'">{{ record.content }}</span>
|
|
|
+ <img :src="chat" class="head-sculpture"/>
|
|
|
+ <span v-if="record.sender !== 'me'">{{ record.content }}</span>
|
|
|
+ </div>
|
|
|
+ <!-- <div class="chat-message">
|
|
|
+ <div class="chat-item" :class="{'chat-item-out':item.sender=='out'}" v-for="(item,index) in chatRecords" :key="index">
|
|
|
+ <div class="chat-item-content">
|
|
|
+ <div :class="{'triangle':item.sender == 'me','triangle_tow': item.sender !== 'me'}"></div>
|
|
|
+ <div :class="{'fill':item.sender == 'me','fill_tow': item.sender !== 'me'}"></div>
|
|
|
+ {{ item.content }}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div> -->
|
|
|
+ </el-main>
|
|
|
<!-- 底部 -->
|
|
|
<el-footer height="72px" class="right-footer">
|
|
|
<img :src="sendFile" class="send-info-file" />
|
|
|
@@ -99,125 +151,38 @@ const clickPerson = (index) => {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@import "@/assets/styles/my-common.scss";
|
|
|
-.main {
|
|
|
- overflow: hidden;
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- .left-main,
|
|
|
- .right-main {
|
|
|
- background: #fff;
|
|
|
- border-radius: 4px;
|
|
|
- }
|
|
|
- //左侧板块
|
|
|
- .left-main {
|
|
|
- width: 312px;
|
|
|
- margin-right: 8px;
|
|
|
- .left-top {
|
|
|
- display: flex;
|
|
|
- justify-content: space-around;
|
|
|
- align-items: center;
|
|
|
- height: 48px;
|
|
|
- background: #ebeff6;
|
|
|
- border-top-right-radius: 4px;
|
|
|
- border-top-left-radius: 4px;
|
|
|
- }
|
|
|
- }
|
|
|
- //右侧板块
|
|
|
- .right-main {
|
|
|
- width: 100%;
|
|
|
- flex-grow: 1;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- .right-header {
|
|
|
- background-color: #ebeff6;
|
|
|
- border-top-right-radius: 4px;
|
|
|
- border-top-left-radius: 4px;
|
|
|
- }
|
|
|
- .right-container {
|
|
|
- flex: 1;
|
|
|
- border-bottom: 1px solid #c1cce3;
|
|
|
- }
|
|
|
- .right-footer {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- :deep .el-input__wrapper {
|
|
|
- background: #F5F7F9 !important;
|
|
|
- border-radius: 16px;
|
|
|
- }
|
|
|
- .w-50{
|
|
|
- margin: 0 16px;
|
|
|
- flex:1;
|
|
|
- }
|
|
|
- .send-info {
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- border-radius: 16px;
|
|
|
- }
|
|
|
- .send-info-file{
|
|
|
- width: 28px;
|
|
|
- height: 28px;
|
|
|
- }
|
|
|
- :deep .el-input {
|
|
|
- width: 80%;
|
|
|
- height: 40px;
|
|
|
- border-radius: 16px;
|
|
|
- --el-input-border-color: #c9d2e6;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-//搜索
|
|
|
-.search {
|
|
|
- .w-50,
|
|
|
- :deep .el-input {
|
|
|
- width: 80%;
|
|
|
- height: 32px;
|
|
|
- border-radius: 4px;
|
|
|
- --el-input-border-color: #c9d2e6;
|
|
|
- }
|
|
|
-}
|
|
|
-//左侧聊天列表展示
|
|
|
-.left-container {
|
|
|
- height: 80px;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- border-bottom: 1px solid #c1cce3;
|
|
|
- position: relative;
|
|
|
- .head-sculpture {
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- border-radius: 20px;
|
|
|
- margin: 0 8px 0 12px;
|
|
|
- vertical-align: middle;
|
|
|
- }
|
|
|
+// .chat-item-out{
|
|
|
+// justify-content: flex-end;
|
|
|
+// .chat-item-content{
|
|
|
+// margin-right: 10px;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// .chat-message{
|
|
|
|
|
|
- & > div:last-child {
|
|
|
- vertical-align: middle;
|
|
|
- margin-right: 10px;
|
|
|
- display: flex;
|
|
|
- height: 40px;
|
|
|
- justify-content: space-between;
|
|
|
- flex-direction: column;
|
|
|
- .person-name {
|
|
|
- font-family: "Inter-Medium";
|
|
|
- color: #000;
|
|
|
- font-size: 16px;
|
|
|
- }
|
|
|
- .person-cont {
|
|
|
- color: #505870;
|
|
|
- font-size: 14px;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-//点击时列表的背景色
|
|
|
-.activ-left-container {
|
|
|
- background: #f5f7f9;
|
|
|
-}
|
|
|
-.cebian {
|
|
|
- height: 100%;
|
|
|
- width: 4px;
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
-}
|
|
|
+// }
|
|
|
+// .chat-item-content{
|
|
|
+// position: relative;
|
|
|
+// padding:10px 6px;
|
|
|
+// margin-top: 10px;
|
|
|
+// margin-left: 10px;
|
|
|
+// border-radius: 5px;
|
|
|
+// word-break: break-all;
|
|
|
+// background: skyblue;
|
|
|
+// color: white;
|
|
|
+// }
|
|
|
+// .chat-item{
|
|
|
+// display: flex;
|
|
|
+// }
|
|
|
+// .triangle,.triangle_tow{
|
|
|
+// position: absolute;
|
|
|
+// top: 15px;
|
|
|
+// border-width: 10px;
|
|
|
+// border-style: solid;
|
|
|
+// }
|
|
|
+// .fill_tow{
|
|
|
+// position: relative;
|
|
|
+// top: 15px;
|
|
|
+// border-width: 10px;
|
|
|
+// border-style:solid ;
|
|
|
+// }
|
|
|
</style>
|