|
@@ -1,5 +1,12 @@
|
|
|
<template>
|
|
|
<div class="w-full">
|
|
|
+ <audio
|
|
|
+ class="fixed top-0 left-0"
|
|
|
+ ref="audioRef"
|
|
|
+ :src="audioTips"
|
|
|
+ style="opacity: 0; z-index: -1"
|
|
|
+ ></audio>
|
|
|
+
|
|
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
|
|
<van-sticky :offset-top="50">
|
|
|
<div
|
|
@@ -32,7 +39,11 @@
|
|
|
@click="onChatPage('/profile/system-message', {})"
|
|
|
class="w-full relative h-82 flex justify-start items-center px-16"
|
|
|
>
|
|
|
- <van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
|
|
|
+ <van-badge
|
|
|
+ v-if="chatList[0]?.unreadMessageCount"
|
|
|
+ v-bind="messageNumber(chatList[0]?.unreadMessageCount)"
|
|
|
+ max="99"
|
|
|
+ >
|
|
|
<div
|
|
|
class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
@@ -48,27 +59,35 @@
|
|
|
v-else
|
|
|
class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
|
- <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
|
|
|
+ <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/remind.svg" alt="" />
|
|
|
</div>
|
|
|
|
|
|
<div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
|
|
|
- <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">系统消息</h1>
|
|
|
+ <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">
|
|
|
+ {{ chatList[0]?.groupName }}
|
|
|
+ </h1>
|
|
|
<p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">
|
|
|
- 你吃饭了么wwwwwdasdasdasdwwwwwwwwwwwwwwwwwwwwwwwssssssssssssssssssssssssssssss
|
|
|
+ {{ messageContentParse(chatList[0]?.lastMessage?.messageContent) }}
|
|
|
</p>
|
|
|
</div>
|
|
|
|
|
|
<div class="w-35 h-48 shrink-0">
|
|
|
- <p class="text-black/[0.6] text-sm text-end">02:06</p>
|
|
|
+ <p class="text-black/[0.6] text-sm text-end">
|
|
|
+ {{ createTimeSplit(chatList[0]?.lastMessage?.createTime) }}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
- @click="onChatPage('/', {})"
|
|
|
+ @click="navigateTo('/follow?listType=fans')"
|
|
|
class="w-full relative h-82 flex justify-start items-center px-16"
|
|
|
>
|
|
|
- <van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
|
|
|
+ <van-badge
|
|
|
+ v-if="chatList[1]?.unreadMessageCount"
|
|
|
+ v-bind="messageNumber(chatList[1]?.unreadMessageCount)"
|
|
|
+ max="99"
|
|
|
+ >
|
|
|
<div
|
|
|
class="w-48 h-48 bg-[#FF9300] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
@@ -78,20 +97,25 @@
|
|
|
|
|
|
<div
|
|
|
v-else
|
|
|
+ @click="navigateTo('/follow?listType=fans')"
|
|
|
class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
|
<img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
|
|
|
</div>
|
|
|
|
|
|
<div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
|
|
|
- <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">新增粉丝</h1>
|
|
|
+ <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">
|
|
|
+ {{ chatList[1]?.groupName }}
|
|
|
+ </h1>
|
|
|
<p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">
|
|
|
- 你吃饭了么wwwwwdasdasdasdwwwwwwwwwwwwwwwwwwwwwwwssssssssssssssssssssssssssssss
|
|
|
+ {{ messageContentParse(chatList[1]?.lastMessage?.messageContent) }}
|
|
|
</p>
|
|
|
</div>
|
|
|
|
|
|
<div class="w-35 h-48 shrink-0">
|
|
|
- <p class="text-black/[0.6] text-sm text-end">02:06</p>
|
|
|
+ <p class="text-black/[0.6] text-sm text-end">
|
|
|
+ {{ createTimeSplit(chatList[1]?.lastMessage?.createTime) }}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
|
|
|
</div>
|
|
@@ -101,47 +125,84 @@
|
|
|
>
|
|
|
<van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
|
|
|
<div
|
|
|
- class="w-48 h-48 bg-[#FF9300] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
+ class="w-48 h-48 bg-[#FF476A] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
|
- <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
|
|
|
+ <img
|
|
|
+ class="w-24 h-24 shrink-0 object-cover"
|
|
|
+ src="~/assets/img/chat/weixin-shake.svg"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
</div>
|
|
|
</van-badge>
|
|
|
|
|
|
<div
|
|
|
v-else
|
|
|
- class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
+ class="w-48 h-48 bg-[#FF476A] rounded-full overflow-hidden flex justify-center items-center"
|
|
|
>
|
|
|
- <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
|
|
|
+ <img
|
|
|
+ class="w-24 h-24 shrink-0 object-cover"
|
|
|
+ src="~/assets/img/chat/weixin-shake.svg"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
</div>
|
|
|
|
|
|
<div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
|
|
|
- <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">互动消息</h1>
|
|
|
- <p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">收藏了你的游记</p>
|
|
|
+ <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">
|
|
|
+ {{ chatList[2]?.groupName }}
|
|
|
+ </h1>
|
|
|
+ <p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">
|
|
|
+ {{ messageContentParse(chatList[2]?.lastMessage?.messageContent) }}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
|
|
|
<div class="w-35 h-48 shrink-0">
|
|
|
- <p class="text-black/[0.6] text-sm text-end">02:06</p>
|
|
|
+ <p class="text-black/[0.6] text-sm text-end">
|
|
|
+ {{ createTimeSplit(chatList[2]?.lastMessage?.createTime) }}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
|
|
|
</div>
|
|
|
|
|
|
- <!-- 置顶绘画列表 -->
|
|
|
-
|
|
|
- <div v-if="activeNames" class="w-full">
|
|
|
- <template v-for="(item, index) in pinnedList" :key="index">
|
|
|
- <ProfileNewsGroupChat
|
|
|
- :item-data="{ title: item }"
|
|
|
- @on-chat-page="
|
|
|
- onChatPage('/chat/group', { userId: userInfo.userId, groupId: '1877363770339758081' })
|
|
|
- "
|
|
|
- @on-no-bother="noBother(item)"
|
|
|
- @on-conv-delete="convDelete()"
|
|
|
- />
|
|
|
+ <!-- 置顶绘画列表 "-->
|
|
|
+ <div v-if="isTopList?.length && activeNames" class="w-full">
|
|
|
+ <template v-for="(item, index) in isTopList" :key="item?.id">
|
|
|
+ <template v-if="index > 2">
|
|
|
+ <!-- 单聊会话 -->
|
|
|
+ <ProfileNewsGroupChat
|
|
|
+ v-if="item?.noticeType == 2"
|
|
|
+ :item-data="{
|
|
|
+ ...item,
|
|
|
+ updateTime: createTimeSplit(item?.lastMessage?.updateTime)
|
|
|
+ }"
|
|
|
+ @on-chat-page="
|
|
|
+ onChatPage('/chat/group', { userId: user.userId, groupId: item?.groupId })
|
|
|
+ "
|
|
|
+ @on-no-bother="noBother(item)"
|
|
|
+ @on-is-top="onIsTop(item)"
|
|
|
+ @on-conv-delete="onIsShow(item)"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 群聊会话 -->
|
|
|
+ <ProfileNewsSingleChat
|
|
|
+ v-if="item?.noticeType == 1"
|
|
|
+ :item-data="{
|
|
|
+ ...item,
|
|
|
+ updateTime: createTimeSplit(item?.lastMessage?.updateTime)
|
|
|
+ }"
|
|
|
+ @on-chat-page="
|
|
|
+ onChatPage('/chat/single', { userId: userInfo.userId, groupId: item?.groupId })
|
|
|
+ "
|
|
|
+ @on-no-bother="noBother(item)"
|
|
|
+ @on-is-top="onIsTop(item)"
|
|
|
+ @on-conv-delete="onIsShow(item)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template v-else></template>
|
|
|
</template>
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
- v-if="pinnedList.length >= 6"
|
|
|
+ v-if="isTopList.length >= 6"
|
|
|
@click="activeNames = !activeNames"
|
|
|
class="flex justify-between border items-center h-20 w-full p-16 box-border"
|
|
|
>
|
|
@@ -151,22 +212,36 @@
|
|
|
</div>
|
|
|
<div class="w-16 h-16 shrink-0">
|
|
|
<van-icon name="arrow" size="16" />
|
|
|
- <!-- <img class="w-full h-full object-cover" src="" alt="" /> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <ProfileNewsGroupChat
|
|
|
- @on-chat-page="
|
|
|
- onChatPage('/chat/group', { userId: userInfo.userId, groupId: '1877349481146540033' })
|
|
|
- "
|
|
|
- @on-no-bother="noBother()"
|
|
|
- @on-conv-delete="convDelete()"
|
|
|
- />
|
|
|
- <ProfileNewsSingleChat
|
|
|
- @on-chat-page="onChatPage('/chat/single', { userId: userInfo.userId, singleId: '2' })"
|
|
|
- @on-no-bother="noBother()"
|
|
|
- @on-conv-delete="convDelete()"
|
|
|
- />
|
|
|
+ <!-- 不置顶的会话列表 -->
|
|
|
+ <template v-for="(item, index) in pinnedList" :key="item?.id">
|
|
|
+ <ProfileNewsGroupChat
|
|
|
+ v-if="item?.noticeType == 2"
|
|
|
+ :item-data="{
|
|
|
+ ...item,
|
|
|
+ updateTime: createTimeSplit(item?.lastMessage?.updateTime)
|
|
|
+ }"
|
|
|
+ @on-chat-page="onChatPage('/chat/group', { userId: user.userId, groupId: item?.groupId })"
|
|
|
+ @on-no-bother="noBother(item)"
|
|
|
+ @on-is-top="onIsTop(item)"
|
|
|
+ @on-conv-delete="onIsShow(item)"
|
|
|
+ />
|
|
|
+ <ProfileNewsSingleChat
|
|
|
+ v-if="item?.noticeType == 1"
|
|
|
+ :item-data="{
|
|
|
+ ...item,
|
|
|
+ updateTime: createTimeSplit(item?.lastMessage?.updateTime)
|
|
|
+ }"
|
|
|
+ @on-chat-page="
|
|
|
+ onChatPage('/chat/single', { userId: user.userId, groupId: item?.groupId })
|
|
|
+ "
|
|
|
+ @on-no-bother="noBother(item)"
|
|
|
+ @on-is-top="onIsTop(item)"
|
|
|
+ @on-conv-delete="onIsShow(item)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
</van-pull-refresh>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -176,6 +251,8 @@ import comments from '~/assets/img/chat/comments-white.svg'
|
|
|
import plaza from '~/assets/img/chat/guangchang.svg'
|
|
|
import userAdd from '~/assets/img/chat/user-add.svg'
|
|
|
|
|
|
+import { messageContentParse } from '~/utils/detalTime.js'
|
|
|
+
|
|
|
const actionsList = [
|
|
|
{ text: '创建群聊', icon: comments },
|
|
|
{ text: '群聊广场', icon: plaza },
|
|
@@ -184,58 +261,19 @@ const actionsList = [
|
|
|
]
|
|
|
const userInfoStore = useUserInfoStore()
|
|
|
const { userInfo } = storeToRefs(userInfoStore)
|
|
|
-const uploadUrl = `${import.meta.env.VITE_APP_BASE_URL}/website/tourMessage/upload`
|
|
|
+// const uploadUrl = `${import.meta.env.VITE_APP_BASE_URL}/website/tourMessage/upload`
|
|
|
const chatStore = useChatStore()
|
|
|
-const { ws, curConversiton, receive, receiveGetter, connectSta, onNewMessage } =
|
|
|
+const { messages, user, connectSta, chatList, curConversiton, onNewMessage } =
|
|
|
storeToRefs(chatStore)
|
|
|
-const user = computed(() => chatStore.user)
|
|
|
-
|
|
|
-// 消息接收者的用户id
|
|
|
-const getUserId = computed(() => curConversiton.value.toUserId)
|
|
|
-
|
|
|
-// 消息发送者:当前登录用户的加密id
|
|
|
-const sendUserId = computed(() => user.value.pass)
|
|
|
-
|
|
|
-// 会话id
|
|
|
-const groupId = computed(() => curConversiton.value.groupId)
|
|
|
-
|
|
|
-// 用户在群聊中艾特的人
|
|
|
-const specialUserId = ref('')
|
|
|
-
|
|
|
-// 用户输入的文本消息
|
|
|
-const messageContent = ref('')
|
|
|
-
|
|
|
-// 聊天类型 1单聊 2群聊 3系统消息 4关注信息
|
|
|
-const noticeType = computed(() => curConversiton.value.noticeType)
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- userInfoStore.getUserInfo()
|
|
|
-})
|
|
|
-
|
|
|
-useSeoMeta({
|
|
|
- title: '我的消息'
|
|
|
-})
|
|
|
-
|
|
|
-// 获取连接状态
|
|
|
-const isConnected = computed(() => chatStore.isConnected)
|
|
|
-
|
|
|
-// 连接 WebSocket
|
|
|
-// const connectSocket = () => {
|
|
|
-// chatStore.connect(`?userId=${userInfo.value.userId}`)
|
|
|
-// }
|
|
|
+// const user = computed(() => chatStore.user)
|
|
|
|
|
|
-// 发送测试消息
|
|
|
-// const sendTestMessage = () => {
|
|
|
-// chatStore.sendMessage({ message: 'Hello WebSocket!' })
|
|
|
-// }
|
|
|
+// // 聊天类型 1单聊 2群聊 3系统消息 4关注信息
|
|
|
+// const noticeType = computed(() => curConversiton.value.noticeType)
|
|
|
|
|
|
-// 断开 WebSocket
|
|
|
-// const disconnectSocket = () => {
|
|
|
-// chatStore.disconnect()
|
|
|
-// }
|
|
|
+const wsConnect = computed(() => connectSta.value)
|
|
|
|
|
|
-// 消息历史
|
|
|
-// const messages = computed(() => chatStore.wsService.value?.messages || [])
|
|
|
+const audioRef = ref(null)
|
|
|
|
|
|
const finished = ref(false)
|
|
|
|
|
@@ -248,7 +286,9 @@ const showPopover = ref(false)
|
|
|
const messagesNumber = ref(10)
|
|
|
|
|
|
// 置顶列表
|
|
|
-const pinnedList = ref([1, 2, 3, 4, 5, 6, 7])
|
|
|
+const isTopList = ref([])
|
|
|
+const pinnedList = ref([])
|
|
|
+const pinnedSystemList = ref([]) //三个固定的消息
|
|
|
|
|
|
// 个置顶聊天
|
|
|
const collapse_text = '折叠置顶聊天'
|
|
@@ -259,40 +299,122 @@ const collapseTitle = ref(collapse_text)
|
|
|
|
|
|
// 刷新
|
|
|
const refreshing = ref(false)
|
|
|
+
|
|
|
+// 建立链接
|
|
|
+async function getUserInfo() {
|
|
|
+ const { data } = await request('/website/tourism/user/view')
|
|
|
+ chatStore.user = data
|
|
|
+ user.value = data
|
|
|
+ console.log(data, 'createConnection')
|
|
|
+
|
|
|
+ await chatStore.createConnection(data.pass)
|
|
|
+ chatStore.reqChatList()
|
|
|
+
|
|
|
+ console.log('用户信息:', chatStore.user)
|
|
|
+
|
|
|
+ // console.log('会话列表:', chatStore.chatList.value)
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getUserInfo()
|
|
|
+ if (wsConnect == 0) {
|
|
|
+ showToast('聊天网络连接中...')
|
|
|
+ } else if (wsConnect == 1) {
|
|
|
+ showToast(' 聊天正在连接中...')
|
|
|
+ } else if (wsConnect == 3) {
|
|
|
+ showToast(' 聊天连接已断开,请刷新页面重新连接,或稍后重试!')
|
|
|
+ } else if (wsConnect == 2) {
|
|
|
+ }
|
|
|
+
|
|
|
+ // chatStore.reqChatList()
|
|
|
+})
|
|
|
+
|
|
|
+useSeoMeta({
|
|
|
+ title: '我的消息'
|
|
|
+})
|
|
|
+
|
|
|
+watch(
|
|
|
+ chatList.value,
|
|
|
+ (newList, oldList) => {
|
|
|
+ // pinnedSystemList.value = newList.filter((el) => el.noticeType == 3)
|
|
|
+ pinnedList.value = newList.filter((el) => el.isTop != 1)
|
|
|
+ isTopList.value = newList.filter((el) => el.isTop == 1)
|
|
|
+
|
|
|
+ console.log(pinnedList.value, 'pinnedList')
|
|
|
+ console.log(isTopList.value, 'isTopList')
|
|
|
+ // console.log(newList, 'newList')
|
|
|
+ console.log(oldList, 'oldList')
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+)
|
|
|
+
|
|
|
+// 时间的转换
|
|
|
+const createTimeSplit = (timer) => {
|
|
|
+ if (timer) {
|
|
|
+ return timer.split(' ')[1]
|
|
|
+ }
|
|
|
+}
|
|
|
// 下拉刷新
|
|
|
const onRefresh = () => {
|
|
|
refreshing.value = true
|
|
|
- // getVisaOrderList()
|
|
|
+ chatStore.reqChatList()
|
|
|
}
|
|
|
|
|
|
// 打扰和免打扰得
|
|
|
const noBother = (parmas) => {
|
|
|
- if (parmas?.bother == false) {
|
|
|
- parmas.bother = true
|
|
|
- } else {
|
|
|
- parmas.bother = false
|
|
|
- }
|
|
|
+ handleBoolean({ groupId: parmas.groupId, isNotDisturb: parmas.isNotDisturb })
|
|
|
}
|
|
|
|
|
|
-// 会话的删除
|
|
|
-const convDelete = (parmas) => {}
|
|
|
+// 是否置顶
|
|
|
+const onIsTop = (parmas) => {
|
|
|
+ handleBoolean({ groupId: parmas.groupId, isTop: parmas.isTop })
|
|
|
+}
|
|
|
+
|
|
|
+// 是否显示会话
|
|
|
+const onIsShow = (parmas) => {
|
|
|
+ handleBoolean({ groupId: parmas.groupId, isShow: parmas.isShow })
|
|
|
+}
|
|
|
+
|
|
|
+// 是否免打扰和 是否置顶 公共
|
|
|
+const handleBoolean = async (body) => {
|
|
|
+ try {
|
|
|
+ let { data } = await request('/website/tourMember/updateSingleTourMember', {
|
|
|
+ method: 'post',
|
|
|
+ body
|
|
|
+ })
|
|
|
+ if (data) {
|
|
|
+ chatStore.reqChatList()
|
|
|
+ }
|
|
|
+ } catch (error) {}
|
|
|
+}
|
|
|
|
|
|
// 消息数量通知的展示 需要动态的展示
|
|
|
const messageNumber = (content) => {
|
|
|
let messageNumberObj = {}
|
|
|
- if (content <= 1) {
|
|
|
+
|
|
|
+ if (content != null || content != undefined || content != '') {
|
|
|
+ if (content <= 1) {
|
|
|
+ messageNumberObj = {
|
|
|
+ offset: [-5, 4],
|
|
|
+ dot: true,
|
|
|
+ content
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (content > 1) {
|
|
|
+ messageNumberObj = {
|
|
|
+ offset: [-10, 7],
|
|
|
+ content
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ content = 0
|
|
|
messageNumberObj = {
|
|
|
offset: [-5, 4],
|
|
|
dot: true,
|
|
|
content
|
|
|
}
|
|
|
}
|
|
|
- if (content > 1) {
|
|
|
- messageNumberObj = {
|
|
|
- offset: [-10, 7],
|
|
|
- content
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
return messageNumberObj
|
|
|
}
|
|
|
|
|
@@ -311,18 +433,6 @@ const onSelect = (action) => {
|
|
|
if (action.text == '加入群聊') onChatPage('/scan', {})
|
|
|
if (action.text == '添加用户') onChatPage('/chat/user-add', {})
|
|
|
}
|
|
|
-
|
|
|
-async function getList() {
|
|
|
- try {
|
|
|
- let {
|
|
|
- data: { dataList }
|
|
|
- } = await request('/website/tourism/fans/getTourMemberList')
|
|
|
- } catch (error) {}
|
|
|
-}
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- getList()
|
|
|
-})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|