2024-04-24 20:54:13 +08:00
|
|
|
<script setup lang="ts">
|
2024-04-28 22:02:38 +08:00
|
|
|
import { UserStatus } from '@/components/Im/UserStatus'
|
|
|
|
import { messageType } from '@/constant/im'
|
|
|
|
/* 组件 */
|
2024-04-27 23:10:03 +08:00
|
|
|
import MessageList from './components/messageList/index.vue'
|
|
|
|
import InputBox from './components/inputBox/index.vue'
|
2024-04-28 22:02:38 +08:00
|
|
|
|
|
|
|
const { push, currentRoute } = useRouter() // 路由
|
|
|
|
const { query } = useRoute() // 查询参数
|
|
|
|
|
|
|
|
const { CHAT_TYPE } = messageType
|
2024-04-27 23:10:03 +08:00
|
|
|
/* header 操作 */
|
|
|
|
const drawer = ref(false) //抽屉显隐
|
|
|
|
const handleDrawer = () => {
|
|
|
|
drawer.value = !drawer.value
|
|
|
|
}
|
|
|
|
//删除好友
|
|
|
|
const delTheFriend = () => {
|
|
|
|
console.log(nowPickInfo.value)
|
|
|
|
if (nowPickInfo.value?.id) {
|
|
|
|
const targetId = nowPickInfo.value.id
|
|
|
|
// EaseChatClient.deleteContact(targetId)
|
|
|
|
// ElMessage({ type: 'success', center: true, message: '好友已删除~' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 当前聊天对象信息
|
|
|
|
const nowPickInfo = ref({
|
|
|
|
id: '1',
|
2024-04-28 22:02:38 +08:00
|
|
|
chatType: CHAT_TYPE.SINGLE,
|
2024-04-27 23:10:03 +08:00
|
|
|
userInfo: {
|
|
|
|
nickname: '好友1',
|
|
|
|
userStatus: '1'
|
|
|
|
},
|
|
|
|
groupDetail: {
|
|
|
|
name: '',
|
|
|
|
affiliations_count: '',
|
|
|
|
custom: ''
|
|
|
|
}
|
|
|
|
})
|
2024-04-24 20:54:13 +08:00
|
|
|
|
2024-04-27 23:10:03 +08:00
|
|
|
//获取群组详情
|
|
|
|
const groupDetail = computed(() => {
|
|
|
|
return nowPickInfo.value.groupDetail
|
|
|
|
})
|
|
|
|
//获取其id对应的消息内容
|
|
|
|
const messageData = computed(() => [
|
|
|
|
{
|
|
|
|
type: 'text'
|
|
|
|
}
|
|
|
|
])
|
2024-04-28 22:02:38 +08:00
|
|
|
//监听路由改变获取对应的getIdInfo
|
|
|
|
const stopWatchRoute = watch(
|
|
|
|
() => query,
|
|
|
|
(routeVal) => {
|
|
|
|
console.log('>>>>>>>>监听到路由参数变化', routeVal)
|
|
|
|
if (routeVal) {
|
|
|
|
// nowPickInfo.value = { ...routeVal }
|
|
|
|
// loginState.value && getIdInfo(routeVal)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
immediate: true
|
|
|
|
}
|
|
|
|
)
|
|
|
|
//离开该路由销毁route监听
|
|
|
|
onBeforeRouteLeave(() => {
|
|
|
|
stopWatchRoute()
|
|
|
|
})
|
2024-04-27 23:10:03 +08:00
|
|
|
/* 消息相关 */
|
|
|
|
const loadingHistoryMsg = ref(false) //是否正在加载中
|
|
|
|
const isMoreHistoryMsg = ref(true) //加载文案展示为加载更多还是已无更多。
|
|
|
|
const notScrollBottom = ref(false) //是否滚动置底
|
|
|
|
//获取历史记录
|
|
|
|
const fechHistoryMessage = (loadType) => {
|
|
|
|
console.log(loadType)
|
|
|
|
console.log('加载更多')
|
|
|
|
}
|
|
|
|
//控制消息滚动
|
|
|
|
const scrollMessageList = (direction) => {
|
|
|
|
console.log(direction)
|
|
|
|
}
|
|
|
|
//消息重新编辑
|
|
|
|
const inputBox = ref(null)
|
|
|
|
const reEditMessage = (msg) => (inputBox.value.textContent = msg)
|
|
|
|
//消息引用
|
|
|
|
const messageQuote = (msg) => inputBox.value.handleQuoteMessage(msg)
|
2024-04-24 20:54:13 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-27 23:10:03 +08:00
|
|
|
<el-container class="app_container">
|
|
|
|
<el-header class="chat_message_header">
|
2024-04-28 22:02:38 +08:00
|
|
|
<template v-if="nowPickInfo.chatType === CHAT_TYPE.SINGLE">
|
2024-04-27 23:10:03 +08:00
|
|
|
<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>
|
|
|
|
<!-- 单人展示删除拉黑 -->
|
2024-04-28 22:02:38 +08:00
|
|
|
<span class="more" v-if="nowPickInfo.chatType === CHAT_TYPE.SINGLE">
|
2024-04-27 23:10:03 +08:00
|
|
|
<el-dropdown placement="bottom-end" trigger="click">
|
|
|
|
<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>
|
|
|
|
<template #dropdown>
|
|
|
|
<el-dropdown-menu>
|
|
|
|
<el-dropdown-item @click="delTheFriend"> 删除好友 </el-dropdown-item>
|
|
|
|
<!-- <el-dropdown-item @click="addFriendToBlackList">
|
|
|
|
加入黑名单
|
|
|
|
</el-dropdown-item> -->
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</template>
|
|
|
|
</el-dropdown>
|
|
|
|
</span>
|
|
|
|
</el-header>
|
|
|
|
<el-main class="chat_message_main">
|
|
|
|
<el-scrollbar class="main_container" ref="messageContainer">
|
|
|
|
<div class="innerRef">
|
|
|
|
<div v-show="isMoreHistoryMsg" class="chat_message_tips">
|
|
|
|
<div
|
|
|
|
v-show="messageData?.length && messageData[0].type !== 'inform'"
|
|
|
|
class="load_more_msg"
|
|
|
|
>
|
|
|
|
<el-link
|
|
|
|
v-show="!loadingHistoryMsg"
|
|
|
|
:disabled="!isMoreHistoryMsg"
|
|
|
|
:underline="false"
|
|
|
|
@click="fechHistoryMessage('loadFirst')"
|
|
|
|
>
|
|
|
|
加载更多
|
|
|
|
</el-link>
|
|
|
|
<el-link v-show="loadingHistoryMsg" disabled>消息加载中...</el-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<MessageList
|
|
|
|
:nowPickInfo="nowPickInfo"
|
|
|
|
:messageData="messageData"
|
2024-04-28 22:02:38 +08:00
|
|
|
@scroll-message-list="scrollMessageList"
|
|
|
|
@re-edit-message="reEditMessage"
|
|
|
|
@message-quote="messageQuote"
|
2024-04-27 23:10:03 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</el-scrollbar>
|
|
|
|
</el-main>
|
2024-04-28 22:02:38 +08:00
|
|
|
<el-footer class="chat_message_input_bar">
|
2024-04-27 23:10:03 +08:00
|
|
|
<InputBox ref="inputBox" :nowPickInfo="nowPickInfo" />
|
|
|
|
</el-footer>
|
|
|
|
</el-container>
|
2024-04-24 20:54:13 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2024-04-27 23:10:03 +08:00
|
|
|
@import './index.scss';
|
2024-04-24 20:54:13 +08:00
|
|
|
</style>
|