|
@@ -61,15 +61,7 @@ const sendCont = reactive({
|
|
|
});
|
|
|
const searchText = ref(""); //搜
|
|
|
const searchData = ref([]);
|
|
|
-const SearchChat = () => {
|
|
|
- if (searchText.value) {
|
|
|
- searchData.value = personList.data.filter((i) => {
|
|
|
- return i.toName == searchText.value;
|
|
|
- });
|
|
|
- } else {
|
|
|
- searchData.value = personList.data;
|
|
|
- }
|
|
|
-}; //搜索的点击事件
|
|
|
+
|
|
|
//聊天列表数据模拟
|
|
|
const personList = reactive({ data: [] });
|
|
|
//获取好友列表
|
|
@@ -79,7 +71,15 @@ const getMsgList = async () => {
|
|
|
// .filter(
|
|
|
// (item) => item.toId !== useUserStore().uid
|
|
|
// );
|
|
|
+
|
|
|
searchData.value = personList.data;
|
|
|
+ //圆点======
|
|
|
+ searchData.value.map((i) => {
|
|
|
+ if(i.fromId==websoctStore.messOne?.fromId){i.showCircel=true}else{
|
|
|
+ i.showCircel=false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //圆点======
|
|
|
sendCont.data.toId =
|
|
|
personList.data[0]?.toId == userIds.uid
|
|
|
? personList.data[0].fromId
|
|
@@ -103,7 +103,6 @@ const msgRecordEvent = async (toIdValue) => {
|
|
|
resMsgData.rows.map((i) => (i.isForward = false));
|
|
|
chatRecords.data = resMsgData.rows.reverse();
|
|
|
const nowtime = parseTime(new Date().getTime(), "{y}-{m}-{d}");
|
|
|
- console.log("firstnowtime", nowtime);
|
|
|
chatRecords.data.map((i) => {
|
|
|
if (nowtime == i.createTime.substr(0, 10))
|
|
|
i.createTime = i.createTime.substring(11);
|
|
@@ -134,6 +133,10 @@ const clickPerson = (index, item) => {
|
|
|
: item.toName;
|
|
|
noMes.value = false;
|
|
|
clickPersonIndex.value = index;
|
|
|
+ //点击某个人就不显示红点
|
|
|
+ searchData.value.map((i) => {
|
|
|
+ if(i.fromId==websoctStore.messOne?.fromId){i.showCircel=false}
|
|
|
+ });
|
|
|
msgRecordEvent(sendCont.data.toId);
|
|
|
};
|
|
|
//删除聊天
|
|
@@ -153,6 +156,7 @@ const delClick = (msgId) => {
|
|
|
const changeMsg = async (val) => {
|
|
|
const resInfo = await userInfo(val.id);
|
|
|
if (searchData.value.length > 0) {
|
|
|
+ //判断是否有相同的聊天人
|
|
|
const filerData = searchData.value.filter(
|
|
|
(vPerson) =>
|
|
|
(vPerson.toId && vPerson.toId == resInfo.userId) ||
|
|
@@ -174,6 +178,10 @@ const changeMsg = async (val) => {
|
|
|
|
|
|
//发送聊天
|
|
|
const msgSendClick = () => {
|
|
|
+ noMes.value = false;
|
|
|
+ if (messageText.value.trim() == "") {
|
|
|
+ return ElMessage({ message: "不能发送空白消息", type: "error" });
|
|
|
+ }
|
|
|
const message = {
|
|
|
content: messageText.value,
|
|
|
msgType: "2",
|
|
@@ -181,6 +189,12 @@ const msgSendClick = () => {
|
|
|
toId: sendCont.data.toId,
|
|
|
};
|
|
|
websoctStore.sendMessage(message);
|
|
|
+ //发送消息后滚动到最底部显示最新消息
|
|
|
+ const chatContainer = document.querySelector(".right-container");
|
|
|
+ // 计算滚动的目标位置
|
|
|
+ const targetScrollTop = chatContainer.scrollHeight;
|
|
|
+ // 设置滚动位置
|
|
|
+ chatContainer.scrollTop = targetScrollTop;
|
|
|
messageText.value = "";
|
|
|
};
|
|
|
//发送文件确认按钮
|
|
@@ -206,14 +220,14 @@ const sendFileClick = async () => {
|
|
|
const handleNewMessage = async () => {
|
|
|
if (websoctStore.newMessage) {
|
|
|
msgRecordEvent(sendCont.data.toId); //获取用户的聊天记录
|
|
|
- getMsgList()
|
|
|
+ getMsgList();
|
|
|
websoctStore.newMessage = false; // 重置新消息标记
|
|
|
}
|
|
|
};
|
|
|
watchEffect(() => {
|
|
|
if (websoctStore.messOne?.fromId) {
|
|
|
msgRecordEvent(websoctStore.messOne.fromId);
|
|
|
- getMsgList()
|
|
|
+ getMsgList();
|
|
|
}
|
|
|
});
|
|
|
// 滚动翻页========
|
|
@@ -237,7 +251,6 @@ const loadPreviousPage = async () => {
|
|
|
pageNum: currentPageNum,
|
|
|
pageSize: 10,
|
|
|
};
|
|
|
-
|
|
|
const resMsgData = await msgRecord(sendCont.data.toId, queryParams);
|
|
|
const previousPageData = resMsgData.rows.reverse();
|
|
|
chatRecords.data = [...previousPageData, ...chatRecords.data];
|
|
@@ -281,9 +294,18 @@ const forwardClick = async (indexs, docIds) => {
|
|
|
const forwardChangeMsg = async (val) => {};
|
|
|
//点击下载
|
|
|
const downClick = async (fileId) => {
|
|
|
- // location.href=await fileDownload(fileId)
|
|
|
location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
|
|
|
};
|
|
|
+//搜索的点击事件
|
|
|
+const SearchChat = () => {
|
|
|
+ if (searchText.value) {
|
|
|
+ searchData.value = personList.data.filter((i) => {
|
|
|
+ return i.toName == searchText.value;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ getMsgList();
|
|
|
+ }
|
|
|
+};
|
|
|
// 滚动翻页========
|
|
|
onMounted(() => {
|
|
|
getMsgList();
|
|
@@ -357,7 +379,10 @@ onMounted(() => {
|
|
|
{{ item.file?.fileName ? item.file?.fileName : item.content }}</span
|
|
|
>
|
|
|
</div>
|
|
|
- <!-- <span class="yuandian" v-if="showCircel==item.fromId&&$route.path=='/index'"></span> -->
|
|
|
+ <span
|
|
|
+ class="yuandian"
|
|
|
+ v-if="item.showCircel&& $route.path == '/index'"
|
|
|
+ ></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 右侧聊天 -->
|
|
@@ -491,7 +516,7 @@ onMounted(() => {
|
|
|
clearable
|
|
|
size="small"
|
|
|
placeholder="请输入聊天内容"
|
|
|
- maxlength="450"
|
|
|
+ maxlength="800"
|
|
|
@keydown.enter="msgSendClick"
|
|
|
/>
|
|
|
<!-- 发送按钮 -->
|