|
@@ -1,7 +1,14 @@
|
|
|
<script setup lang="ts">
|
|
|
-import UserStatus from '@/components/UserStatus/index.vue'
|
|
|
+import { UserStatus } from '@/components/Im/UserStatus'
|
|
|
+import { messageType } from '@/constant/im'
|
|
|
+/* 组件 */
|
|
|
import MessageList from './components/messageList/index.vue'
|
|
|
import InputBox from './components/inputBox/index.vue'
|
|
|
+
|
|
|
+const { push, currentRoute } = useRouter() // 路由
|
|
|
+const { query } = useRoute() // 查询参数
|
|
|
+
|
|
|
+const { CHAT_TYPE } = messageType
|
|
|
/* header 操作 */
|
|
|
const drawer = ref(false) //抽屉显隐
|
|
|
const handleDrawer = () => {
|
|
@@ -19,7 +26,7 @@ const delTheFriend = () => {
|
|
|
// 当前聊天对象信息
|
|
|
const nowPickInfo = ref({
|
|
|
id: '1',
|
|
|
- chatType: 1,
|
|
|
+ chatType: CHAT_TYPE.SINGLE,
|
|
|
userInfo: {
|
|
|
nickname: '好友1',
|
|
|
userStatus: '1'
|
|
@@ -41,6 +48,24 @@ const messageData = computed(() => [
|
|
|
type: 'text'
|
|
|
}
|
|
|
])
|
|
|
+//监听路由改变获取对应的getIdInfo
|
|
|
+const stopWatchRoute = watch(
|
|
|
+ () => query,
|
|
|
+ (routeVal) => {
|
|
|
+ console.log('>>>>>>>>监听到路由参数变化', routeVal)
|
|
|
+ if (routeVal) {
|
|
|
+ // nowPickInfo.value = { ...routeVal }
|
|
|
+ // loginState.value && getIdInfo(routeVal)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+)
|
|
|
+//离开该路由销毁route监听
|
|
|
+onBeforeRouteLeave(() => {
|
|
|
+ stopWatchRoute()
|
|
|
+})
|
|
|
/* 消息相关 */
|
|
|
const loadingHistoryMsg = ref(false) //是否正在加载中
|
|
|
const isMoreHistoryMsg = ref(true) //加载文案展示为加载更多还是已无更多。
|
|
@@ -64,46 +89,15 @@ const messageQuote = (msg) => inputBox.value.handleQuoteMessage(msg)
|
|
|
<template>
|
|
|
<el-container class="app_container">
|
|
|
<el-header class="chat_message_header">
|
|
|
- <template v-if="nowPickInfo.chatType === 1">
|
|
|
+ <template v-if="nowPickInfo.chatType === CHAT_TYPE.SINGLE">
|
|
|
<div v-if="nowPickInfo.userInfo" class="chat_user_box">
|
|
|
<span class="chat_user_name"> {{ nowPickInfo.userInfo.nickname || nowPickInfo.id }}</span>
|
|
|
<UserStatus :userStatus="nowPickInfo.userInfo.userStatus" />
|
|
|
</div>
|
|
|
<div v-else> {{ nowPickInfo.id }}<span style="font-size: 10px">(非好友)</span> </div>
|
|
|
</template>
|
|
|
- <template v-if="nowPickInfo.chatType === 2">
|
|
|
- <div v-if="nowPickInfo.groupDetail" class="chat_user_box">
|
|
|
- <span class="chat_user_name">
|
|
|
- {{ groupDetail.name || '' }}
|
|
|
- {{ `(${groupDetail?.affiliations_count || ''})` }}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <div v-else class="chat_user_box">
|
|
|
- <span class="chat_user_name">
|
|
|
- {{ groupDetail.name || nowPickInfo.id }}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <!-- 群组展示抽屉 -->
|
|
|
- <span
|
|
|
- class="more"
|
|
|
- v-if="nowPickInfo.groupDetail && nowPickInfo.chatType === 2"
|
|
|
- @click="handleDrawer"
|
|
|
- >
|
|
|
- <svg
|
|
|
- width="18"
|
|
|
- height="4"
|
|
|
- viewBox="0 0 18 4"
|
|
|
- fill="none"
|
|
|
- xmlns="http://www.w3.org/2000/svg"
|
|
|
- >
|
|
|
- <circle cx="2" cy="2" r="2" fill="#333333" />
|
|
|
- <circle cx="9" cy="2" r="2" fill="#333333" />
|
|
|
- <circle cx="16" cy="2" r="2" fill="#333333" />
|
|
|
- </svg>
|
|
|
- </span>
|
|
|
<!-- 单人展示删除拉黑 -->
|
|
|
- <span class="more" v-if="nowPickInfo.chatType === 1">
|
|
|
+ <span class="more" v-if="nowPickInfo.chatType === CHAT_TYPE.SINGLE">
|
|
|
<el-dropdown placement="bottom-end" trigger="click">
|
|
|
<svg
|
|
|
width="18"
|
|
@@ -149,31 +143,16 @@ const messageQuote = (msg) => inputBox.value.handleQuoteMessage(msg)
|
|
|
<MessageList
|
|
|
:nowPickInfo="nowPickInfo"
|
|
|
:messageData="messageData"
|
|
|
- @scrollMessageList="scrollMessageList"
|
|
|
- @reEditMessage="reEditMessage"
|
|
|
- @messageQuote="messageQuote"
|
|
|
+ @scroll-message-list="scrollMessageList"
|
|
|
+ @re-edit-message="reEditMessage"
|
|
|
+ @message-quote="messageQuote"
|
|
|
/>
|
|
|
</div>
|
|
|
</el-scrollbar>
|
|
|
</el-main>
|
|
|
- <el-footer class="chat_message_inputbar">
|
|
|
+ <el-footer class="chat_message_input_bar">
|
|
|
<InputBox ref="inputBox" :nowPickInfo="nowPickInfo" />
|
|
|
</el-footer>
|
|
|
- <el-drawer
|
|
|
- v-if="nowPickInfo.chatType === 2"
|
|
|
- v-model="drawer"
|
|
|
- :show-close="false"
|
|
|
- :close-on-click-modal="true"
|
|
|
- direction="rtl"
|
|
|
- :modal="true"
|
|
|
- size="280px"
|
|
|
- >
|
|
|
- <GroupsDetails
|
|
|
- :nowGroupId="nowPickInfo.id"
|
|
|
- :groupDetail="groupDetail"
|
|
|
- @handleDrawer="handleDrawer"
|
|
|
- />
|
|
|
- </el-drawer>
|
|
|
</el-container>
|
|
|
</template>
|
|
|
|