|
@@ -2,23 +2,28 @@
|
|
|
import type { type_dyaw_xlfw_zxhd, type_dyaw_xlfw_zxhd_log } from '~/types';
|
|
|
import { Search } from '@element-plus/icons-vue'
|
|
|
import user from '~/store/user';
|
|
|
-import { createSocket } from '~/utils/ws';
|
|
|
+import { createSocket, socketSend } from '~/utils/ws';
|
|
|
+import type { TSocketRes } from '~/utils/ws';
|
|
|
|
|
|
let dyaw_xlfw_zxhd = $ref<type_dyaw_xlfw_zxhd | undefined>()
|
|
|
-const dyaw_xlfw_zxhd_list: type_dyaw_xlfw_zxhd[] = (await request({
|
|
|
- url: '/dyaw/xlfw_zxhd/index',
|
|
|
- data: {
|
|
|
- dxz_tea_user_id: user.user_id
|
|
|
- }
|
|
|
-})).data.page_data
|
|
|
-console.log('dyaw_xlfw_zxhd_list :>> ', dyaw_xlfw_zxhd_list);
|
|
|
+let dyaw_xlfw_zxhd_list = $ref<type_dyaw_xlfw_zxhd[] | undefined>()
|
|
|
+
|
|
|
+
|
|
|
+let timer: NodeJS.Timeout;
|
|
|
+(async function loop() {
|
|
|
+ dyaw_xlfw_zxhd_list = (await request({
|
|
|
+ url: '/dyaw/xlfw_zxhd/index',
|
|
|
+ data: {
|
|
|
+ dxz_tea_user_id: user.user_id
|
|
|
+ }
|
|
|
+ })).data.page_data
|
|
|
+ timer = setTimeout(async () => {
|
|
|
+ await loop();
|
|
|
+ }, 60 * 1000);
|
|
|
+})();
|
|
|
|
|
|
const searchValue = $ref('')
|
|
|
|
|
|
-const ChatAudioRef = $ref<typeof import('~/components/chat-audio/index.vue')['default']>()
|
|
|
-function handleClickEnd() {
|
|
|
- ChatAudioRef && ChatAudioRef.open()
|
|
|
-}
|
|
|
let infoList = $ref<Array<type_dyaw_xlfw_zxhd_log>>([])
|
|
|
let inputValue = $ref('')
|
|
|
let TinyRef = $ref<typeof import('~/components/tinymce-area/index.vue')['default']>()
|
|
@@ -47,13 +52,24 @@ async function handleClickSend() {
|
|
|
data: {
|
|
|
dyaw_xlfw_zxhd_log: reqDate
|
|
|
}
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === '1') {
|
|
|
+ socketSend(ws!, {
|
|
|
+ create_user_id: user.user_id,
|
|
|
+ create_dateline: Date.now().toString().slice(0, 10),
|
|
|
+ ...reqDate
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// const ws = createSocket()
|
|
|
+let ws = $ref<WebSocket>()
|
|
|
+
|
|
|
|
|
|
function handleClickStuCard(stu: type_dyaw_xlfw_zxhd) {
|
|
|
dyaw_xlfw_zxhd = stu
|
|
|
+ stu.dxz_unread_msg_num = "0"
|
|
|
+ ws?.close()
|
|
|
request({
|
|
|
url: '/dyaw/xlfw_zxhd_log/index',
|
|
|
data: {
|
|
@@ -63,10 +79,43 @@ function handleClickStuCard(stu: type_dyaw_xlfw_zxhd) {
|
|
|
}).then(res => {
|
|
|
if (res.code === '1') {
|
|
|
infoList = res.data.page_data.reverse()
|
|
|
+ ws = createSocket(
|
|
|
+ { teacher: user.user_id, student: stu.dxz_stu_user_id },
|
|
|
+ {
|
|
|
+ message(socketRes: TSocketRes<type_dyaw_xlfw_zxhd_log>) {
|
|
|
+ if (socketRes.from_client_name.endsWith('student')) {
|
|
|
+ infoList.push(socketRes.content)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+const scrollbarRef = $ref<HTMLElement>()
|
|
|
+function scrollToBottom() {
|
|
|
+ if (!scrollbarRef) return;
|
|
|
+ const scrollHeight = scrollbarRef!.scrollHeight;
|
|
|
+ scrollbarRef!.scrollTo(0, scrollHeight);
|
|
|
+}
|
|
|
+watch(
|
|
|
+ () => (infoList),
|
|
|
+ () => {
|
|
|
+ nextTick(() => {
|
|
|
+ scrollToBottom()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true,
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearInterval(timer)
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -82,10 +131,11 @@ function handleClickStuCard(stu: type_dyaw_xlfw_zxhd) {
|
|
|
<div class="w-680px h-full divide-y flex flex-col">
|
|
|
<template v-if="dyaw_xlfw_zxhd">
|
|
|
<div class="bg-pink-300 flex justify-between h-48px items-center px-18px">
|
|
|
- <span class="text-lg px-1 tracking-wider">王晓宇 当阳中学 六年级(1)班</span>
|
|
|
+ <span class="text-lg px-1 tracking-wider">{{ dyaw_xlfw_zxhd.dxz_stu_user_realname }}
|
|
|
+ {{ dyaw_xlfw_zxhd.dxz_stu_school_name }} {{ dyaw_xlfw_zxhd.dxz_class_name }}</span>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class="bg-hex-fff8fb h-410px p-6 scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
|
|
|
+ <div ref="scrollbarRef"
|
|
|
+ class="bg-hex-fff8fb space-y-2 h-410px p-6 scrollbar scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-200 scrollbar-track-transparent">
|
|
|
<info-item v-for="item in infoList" :left="item.create_user_id === user.user_id" :d="item"></info-item>
|
|
|
</div>
|
|
|
<div class="bg-white h-180px p-5px flex flex-col justify-between">
|
|
@@ -113,7 +163,6 @@ function handleClickStuCard(stu: type_dyaw_xlfw_zxhd) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <!-- <chat-audio ref="ChatAudioRef"></chat-audio> -->
|
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|