|
@@ -39,8 +39,8 @@
|
|
|
<template v-for="(message, index) in currConversationChatList" :key="index">
|
|
|
<ChatMessage :message="message"></ChatMessage>
|
|
|
</template>
|
|
|
- <div v-if="false" class="text-[#979797] text-sm text-center mt-auto mb-10">
|
|
|
- {{ followStatus }}在对方关注或回复前,最多只能发送1条信息
|
|
|
+ <div v-if="chatErrorText" class="text-[#979797] text-sm text-center mt-auto mb-10">
|
|
|
+ {{chatErrorText}}
|
|
|
</div>
|
|
|
</van-list>
|
|
|
</van-pull-refresh>
|
|
@@ -177,7 +177,8 @@ const sendTextMessage = async (text) => {
|
|
|
id: getLocalId(),
|
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
|
headImageUrl: userInfo?.value.headImageUrl,
|
|
|
- showName: userInfo?.value.showName
|
|
|
+ showName: userInfo?.value.showName,
|
|
|
+ web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
|
}
|
|
|
}
|
|
|
const isLink = !!findHyperlinks(text)
|
|
@@ -185,7 +186,9 @@ const sendTextMessage = async (text) => {
|
|
|
// console.log(currConversationChatList.value, '1122')
|
|
|
currConversationChatList.value.push(msg)
|
|
|
await scrollToBottom()
|
|
|
- await chatsStore.sendSocketMessage(msg)
|
|
|
+ const backMessage = await chatsStore.sendSocketMessage(msg);
|
|
|
+ const {index, message} = chatsStore.updateBackMessage(currConversationChatList.value, backMessage);
|
|
|
+ currConversationChatList.value[index] = message
|
|
|
} catch (e) {
|
|
|
console.log(e, '2')
|
|
|
} finally {
|
|
@@ -220,13 +223,17 @@ const sendImageMessage = async (file) => {
|
|
|
id: getLocalId(),
|
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
|
headImageUrl: userInfo?.value.headImageUrl,
|
|
|
- showName: userInfo?.value.showName
|
|
|
+ showName: userInfo?.value.showName,
|
|
|
+ web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
|
}
|
|
|
}
|
|
|
closeToast()
|
|
|
currConversationChatList.value.push(msg)
|
|
|
await scrollToBottom()
|
|
|
await chatsStore.sendSocketMessage(msg)
|
|
|
+ const backMessage = await chatsStore.sendSocketMessage(msg);
|
|
|
+ const {index, message} = chatsStore.updateBackMessage(currConversationChatList.value, backMessage);
|
|
|
+ currConversationChatList.value[index] = message
|
|
|
} catch (e) {
|
|
|
console.error(e, '??')
|
|
|
} finally {
|
|
@@ -253,6 +260,41 @@ const handleSendMessage = async ({ type, messageContent }) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 加载更多
|
|
|
+const moreLoading = ref(false)
|
|
|
+const moreDisabled = ref(false)
|
|
|
+
|
|
|
+const loadMore = async () => {
|
|
|
+ // console.warn('loadMore')
|
|
|
+ try {
|
|
|
+ moreLoading.value = true
|
|
|
+ if (currConversationChatList.value.length) {
|
|
|
+ if (totalCount.value === currConversationChatList.value.length) {
|
|
|
+ console.warn('已经加载了全部')
|
|
|
+ // 已经加载了全部
|
|
|
+ moreDisabled.value = true
|
|
|
+ } else {
|
|
|
+ await getChatList('more')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ await getChatList('init')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ // console.log(e, 'error')
|
|
|
+ } finally {
|
|
|
+ moreLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const onClickRight = () => {
|
|
|
+ navigateTo({
|
|
|
+ path: '/chat/set-single',
|
|
|
+ query: {
|
|
|
+ toUserId: route.query.getUserId,
|
|
|
+ groupId: groupId.value
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
// async
|
|
|
const scrollToBottom = async () => {
|
|
|
// 操作向上加载不滚动 TODO 判断用户是否有向上滑的操作更准确
|
|
@@ -289,41 +331,9 @@ const getFollowStatus = async () => {
|
|
|
followStatus.value = status
|
|
|
}
|
|
|
|
|
|
-// 加载更多
|
|
|
-const moreLoading = ref(false)
|
|
|
-const moreDisabled = ref(false)
|
|
|
-
|
|
|
-const loadMore = async () => {
|
|
|
- // console.warn('loadMore')
|
|
|
- try {
|
|
|
- moreLoading.value = true
|
|
|
- if (currConversationChatList.value.length) {
|
|
|
- if (totalCount.value === currConversationChatList.value.length) {
|
|
|
- console.warn('已经加载了全部')
|
|
|
- // 已经加载了全部
|
|
|
- moreDisabled.value = true
|
|
|
- } else {
|
|
|
- await getChatList('more')
|
|
|
- }
|
|
|
- } else {
|
|
|
- await getChatList('init')
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- // console.log(e, 'error')
|
|
|
- } finally {
|
|
|
- moreLoading.value = false
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-const onClickRight = () => {
|
|
|
- navigateTo({
|
|
|
- path: '/chat/set-single',
|
|
|
- query: {
|
|
|
- toUserId: route.query.getUserId,
|
|
|
- groupId: groupId.value
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
+const chatErrorText = computed(() => {
|
|
|
+ return chatsStore.getChatErrorText(currConversationChatList.value)
|
|
|
+})
|
|
|
|
|
|
// 本地生成一个唯一消息id
|
|
|
function getLocalId() {
|
|
@@ -343,14 +353,12 @@ onMounted(() => {
|
|
|
await scrollToBottom()
|
|
|
}
|
|
|
if (!isOtherUserMessage) {
|
|
|
- await getChatList('init')
|
|
|
+ // 这里就不做处理,因为本地发送后就立马更新了currConversationChatList
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
|
|
|
-watchEffect(() => {})
|
|
|
-
|
|
|
// 会话好友的信息
|
|
|
const getAnnouncement = () => {
|
|
|
return new Promise((resolve) => {
|