ZhaoJing 1 year ago
parent
commit
175e81bb47

+ 26 - 21
src/pages/jsd/wdkc/zbkc/live.vue

@@ -19,7 +19,7 @@
     class="mt-10px shadow-default bg-white-grey pt-25px pl-35px pr-35px pb-35px rounded-10px"
   >
     <div class="flex justify-between">
-      <div class="w-full relative">
+      <div class="w-800px relative">
         <div class="flex justify-between items-center">
           <h3 class="nav-title flex-1">
             <span>第{{ numberToChinese(chapter_info.order_num) }}课时:</span>
@@ -70,28 +70,24 @@
         </div>
         <div class="mt-20px" id="player-con"></div>
         <ChatBlock :id="tzk_id" />
-      </div>
-      <!--            <div class="w-300px mt-46px right-box pt-30px relative">-->
-      <!--                <el-button v-if="chapter_info.tzk_zjr_user_id === user.user_id" type="primary" color="#1259a1" size="large" class="w-100px live-btn" @click="launchLive">启动直播工具-->
-      <!--                </el-button>-->
-      <!--                <div class="right-nav ml-20px">-->
-      <!--                    <span>相关文档</span>-->
-      <!--                    <i></i>-->
-      <!--                </div>-->
-      <!--                <ul class="mt-25px right-chapter-list">-->
-      <!--                    <li v-for="item in chapterList" :class="item.tmz_id === tmz_id?'selected':''"-->
-      <!--                        @click="changeChapter(item)">-->
-      <!--                        {{ item.tmz_zjmc }}-->
-      <!--                    </li>-->
-      <!--                </ul>-->
-      <!--            </div>-->
-    </div>
+      	</div>
+            <div class="w-300px mt-46px right-box pt-30px relative">
+                 <el-button v-if="chapter_info.tzk_zjr_user_id === user.user_id" type="primary" color="#1259a1" size="large" class="w-100px live-btn" @click="launchLive">启动直播工具
+                </el-button>
+                <div class="right-nav ml-20px">
+                    <span>相关文档</span>
+                    <i></i>
+                </div>
+            	<homeworkBlock :id="tzk_id" :dxa="chapter_info.tzk_dxa_file" :homework="chapter_info.tzk_ksce_file" :file="chapter_info.tzk_files_json" :user_id="chapter_info.tzk_zjr_user_id" @filePre="filePre"></homeworkBlock>
+            </div>
+   		 </div>
   </div>
-  <el-dialog v-model="dialogVisible" title="资源预览" width="80%">
-    <iframe
+  <el-dialog v-model="dialogVisible" :title="title" width="80%">
+    <!-- <iframe
       style="width: 100%; height: 700px; overflow-y: auto"
-      :src="previewUrl"
-    ></iframe>
+      :src="chapter_info.kscs_preview"
+    ></iframe> -->
+	<filePreview style="width: 100%; height: 700px; overflow-y: auto" :url="previewUrl"></filePreview>
     <template #footer>
       <div class="text-center">
         <el-button size="large" type="primary" @click="dialogVisible = false"
@@ -104,8 +100,10 @@
 
 <script setup>
 import { user } from "@/store/index";
+import filePreview from '@/components/FilePreview/index.vue'
 import { ElMessageBox } from "element-plus";
 import ChatBlock from "../../../zbkc/chat.vue";
+import homeworkBlock from "../../../zbkc/homework.vue";
 import { useRoute, useRouter } from "vue-router";
 import {
   chapter_detail,
@@ -310,6 +308,13 @@ function showDetail(url) {
 function launchLive() {
   window.open(chapter_info.push_rtmp_address, "_blank");
 }
+
+let title = $ref('资源预览')
+function filePre(item) {
+	console.log(item, 111111);
+	dialogVisible = true;
+	previewUrl = getFullUrl(item);
+}
 </script>
 
 <style lang="scss" scoped>

+ 7 - 2
src/pages/zbkc/chat.vue

@@ -27,9 +27,9 @@ ws.addEventListener('message', (e) => {
       }
 
       if (data.type === 'login') {
-        console.log(data.client_name, '1111');
+        // console.log(data.client_name, '1111');
         const [id, name, banned] = data.client_name.split('|');
-        console.log(noSayId);
+        // console.log(noSayId);
         login_data = {
           id, name, banned
         }
@@ -37,6 +37,8 @@ ws.addEventListener('message', (e) => {
       if (data.type === 'say') {
         const [id, name, banned] = data.from_client_name.split('|')
         const contentMiYao = data.content.split(",")[1];
+        const fileType = data.content.split("|")[1];
+        const fileContent = data.content.split("|")[0];
         if (contentMiYao) {
           const contentMiYaoId = contentMiYao.split(":")[1];
           const contentMiDesc = contentMiYao.split(":")[0];
@@ -53,6 +55,9 @@ ws.addEventListener('message', (e) => {
             data.content = content
           }
         }
+        if (fileType) {
+          return
+        }
         msgList.value.push({
           id,
           name,

+ 3 - 7
src/pages/zbkc/detailIsLive.vue

@@ -57,17 +57,12 @@
                 <div class="mt-20px" id="player-con"></div>
                 <ChatBlock :id="tzk_id" />
             </div>
-            <div v-if="user.user_role_id == 75" class="w-300px mt-46px right-box pt-30px">
+            <div v-if="user.user_role_id <75" class="w-300px mt-46px right-box pt-30px">
                 <div class="right-nav ml-20px">
                     <span>相关章节</span>
                     <i></i>
                 </div>
-                <ul class="mt-25px right-chapter-list">
-                    <li v-for="item in chapterList" :key="item.tzk_id" :class="item.tzk_id === tzk_id ? 'selected' : ''"
-                        @click="changeChapter(item)">
-                        {{ item.tzk_ksmc }}
-                    </li>
-                </ul>
+                <homeworkBlock :id="tzk_id" :dxa="chapter_info.tzk_dxa_file" :homework="chapter_info.tzk_ksce_file" :file="chapter_info.tzk_files_json" @filePre="filePre"></homeworkBlock> 
             </div>
         </div>
     </div>
@@ -76,6 +71,7 @@
 <script setup>
 import { ElMessageBox } from "element-plus";
 import ChatBlock from "./chat.vue";
+import homeworkBlock from "./homework.vue";
 import { useRoute, useRouter } from "vue-router";
 import { user } from '../../store/index';
 import {

+ 284 - 0
src/pages/zbkc/homework.vue

@@ -0,0 +1,284 @@
+<script setup>
+import { user } from '~/store/index';
+import downLoadFile1 from '@/utils/download'
+const props = defineProps({
+    id: String,
+    homework: String,
+    file: String,
+    dxa: String,
+    user_id: String,
+})
+const chatBox = ref()
+const ws = new WebSocket("wss://socket.txhlwxx.com")
+const emits = defineEmits(['filePre', 'edit', 'download', 'enter'])
+// let userList = ref(undefined)
+const msgList = ref([])
+
+let visiable = $ref(false);
+let title = $ref('')
+let filecontent = $ref('');
+let ban_id = $ref([]);
+let isBanned = $ref(false)
+let ban_me = $ref(false);
+let login_data = $ref({});
+let login_id = $ref([]);
+ws.addEventListener('message', (e) => {
+    if (e.data) {
+        try {
+            const data = JSON.parse(e.data)
+            // console.log(data,'data');
+            if (data.type !== 'ping') {
+                // console.log('ws message :>> ', data);
+            }
+
+            if (data.type === 'login') {
+                const [id, name, banned] = data.client_name.split('|');
+                // console.log(noSayId);
+                login_data = {
+                    id, name, banned
+                }
+            }
+            if (data.type === 'say') {
+                const [id, name,] = data.from_client_name.split('|')
+                const fileType = data.content.split("|")[1];
+                const fileContent = data.content.split("|")[0];
+                console.log(fileContent, visiable);
+                console.log(fileType, 123);
+                if (fileType) {
+                    visiable = true;
+                    filecontent = fileContent
+                    console.log(filecontent, 'kankan');
+                    switch (fileType) {
+                        case 'home':
+                            title = '作业';
+                            break
+                        case 'file':
+                            title = '文件';
+                            break
+                        case 'dxa':
+                            title = '课时导学案';
+                            break
+                    }
+                }
+
+                // msgList.value.push({
+                //     id,
+                //     name,
+                //     time: data.time,
+                //     content: data.content,
+                //     // bannedN: false,
+                // })
+
+                // msgList.value.forEach((el, index, array) => {
+                //     el.bannedN = false;
+                //     if (noSayId.includes(el.id)) {
+                //         el.bannedN = true;
+                //     }
+                // })
+                nextTick(() => {
+                    chatBox.value.scrollTo({
+                        top: (chatItemBox.value.getBoundingClientRect()).height,
+                        left: 0,
+                        behavior: "smooth"
+                    })
+                })
+
+            }
+            if (data.type === 'file') {
+                console.log(data);
+                console.log(1111111111);
+            }
+
+        } catch (error) {
+            console.error(error);
+        }
+    }
+
+})
+
+ws.addEventListener('error', (err) => {
+    console.error('ws error :>> ', err);
+})
+
+ws.addEventListener('open', (e) => {
+    ws.send(JSON.stringify({
+        "type": "login",
+        // "client_id": user.user_id,
+        "client_name": user.value.user_id + '|' + user.value.user_realname,
+        "room_id": 'zbkc' + props.id
+    }))
+})
+
+const msg = ref('')
+
+const chatItemBox = ref()
+
+function handleSendClick(item, name) {
+    ws.send(JSON.stringify({
+        type: "say",
+        to_client_id: 'all',
+        to_client_name: '所有人',
+        content: item + '|' + name,
+    }))
+    msg.value = ''
+
+}
+
+let noSayId = [];
+
+
+function filePre(item) {
+    emits('filePre', item)
+}
+
+function download(item) {
+    // window.open(getFullUrl(item), '_blank');
+    const ext = item.split(';')[2].split('.').at(-1).toLowerCase()
+    downLoadFile1(getFullUrl(item.split(';')[2]), `${item.split(';')[0]}.${ext}`)
+}
+</script>
+
+<template>
+    <div class="w-300px h-400px flex flex-col shadow chat">
+        <div class="h-100 overflow-hidden overflow-y-auto flex-auto home_scroll" ref="chatBox">
+            <ul ref="chatItemBox">
+                <li v-if="props?.dxa" class="chat_li flex justify-between items-center px-15px">
+                    <el-tooltip class="box-item" effect="dark" :content="props?.dxa.split(';')[0]" placement="top-start">
+                        <p class="w-129px truncate text-14px py-4px">
+                            {{ props?.dxa.split(';')[0] }}
+                        </p>
+                    </el-tooltip>
+                    <button class="button" @click="filePre(props?.dxa.split(';')[2])">查看</button>
+                    <button class="button" @click="handleSendClick(props?.dxa.split(';')[2], 'dxa')">下发</button>
+                </li>
+                <li v-if="props?.homework" class="chat_li flex justify-between items-center px-15px">
+                    <el-tooltip class="box-item" effect="dark" :content="props?.homework.split(';')[0]"
+                        placement="top-start">
+                        <p class="w-129px truncate text-14px py-4px">
+                            {{ props?.homework.split(';')[0] }}
+                        </p>
+                    </el-tooltip>
+                    <button class="button" @click="filePre(props?.homework.split(';')[2])">查看</button>
+                    <button class="button" @click="handleSendClick(props?.homework.split(';')[2], 'home')">下发</button>
+                </li>
+                <li v-if="props?.file" class="chat_li flex justify-between items-center px-15px">
+                    <el-tooltip class="box-item" effect="dark" :content="props?.file.split(';')[0]" placement="top-start">
+                        <p class="w-129px truncate text-14px py-4px">
+                            {{ props?.file.split(';')[0] }}
+                        </p>
+                    </el-tooltip>
+                    <button class="button" @click="filePre(props?.file.split(';')[2])">查看</button>
+                    <button class="button" @click="handleSendClick(props?.file.split(';')[2], 'file')">下发</button>
+                </li>
+                <!-- <li v-show="item.content" v-for="item in msgList"
+                    class="mb-5px px-10px py-5px chat_li rounded-10px relative" :key="item.id">
+                    <div class="flex flex-col flex-auto">
+                        <div class="flex justify-between items-center">
+                            <span class="text-14px mb-5px font-bold">{{ item.name }}</span>
+                            <div v-if="user.user_role_id === '75'" class="">
+                                <img v-if="!item.bannedN" @click="banText(item)" :src="text" alt="">
+                                <img v-else :src="notext" @click="JCText(item)" alt="">
+                            </div>
+                        </div>
+                        <div class="mb-3 rounded-md min-h-20px box-content">
+                            <p class="word_wrap text-16px" v-html="item.content"></p>
+                        </div>
+                    </div>
+                </li> -->
+            </ul>
+        </div>
+        <el-dialog v-model="visiable" :title="title">
+            <div class="chat_li flex justify-between items-center pl-15px pr-65px">
+                <el-tooltip class="box-item" effect="dark" :content="props?.file.split(';')[0]" placement="top-start">
+                    <p class="min-w-100px truncate text-14px py-4px">
+                        {{ props?.file.split(';')[0] }}
+                    </p>
+                </el-tooltip>
+                <div>
+                    <button class="button" @click="filePre(props?.file.split(';')[2])">查看</button>
+                    <button class="button" @click="download(props?.file)">下载</button>
+                </div>
+
+            </div>
+        </el-dialog>
+        <!-- <div v-if="user.user_role_id >= '3'" class="flex flex-none p-3">
+            <el-input class="input" v-model="msg"></el-input>
+            <el-button rounded type="primary" @click="handleSendClick" class="ml-4 button">发送</el-button>
+        </div> -->
+    </div>
+</template>
+
+<style lang="scss" scoped>
+$color: #1259A1;
+
+.chat_li {
+    // background-color: rgba($color: #000000, $alpha: .4);
+    height: 40px;
+}
+
+.button {
+    border: 1px solid $color;
+    border-radius: 15px;
+    width: 60px;
+    height: 30px;
+    margin-right: 5px;
+    // padding: 3px 18px;
+    color: $color;
+    font-size: 12px;
+}
+
+// :deep(.box-content){
+.word_wrap {
+    word-wrap: break-word;
+    word-break: break-all;
+}
+
+// }
+::v-deep .input {
+    width: 380px;
+    height: 40px;
+    border-radius: 10px;
+    background-color: rgba($color: #fff, $alpha: 0.3) !important;
+
+    .el-input__wrapper {
+        width: 380px;
+        height: 40px;
+        border-radius: 10px;
+        background-color: rgba($color: #fff, $alpha: 0.7) !important;
+    }
+}
+
+::v-deep .el-button {
+    width: 111px !important;
+    height: 32px;
+    opacity: 0.7;
+    background: linear-gradient(90deg, #2586e9 1%, #57c6d8 100%);
+    border-radius: 38px;
+    padding: 5px 40px;
+
+    span {
+        font-size: 14px;
+    }
+}
+
+.home_scroll::-webkit-scrollbar {
+    width: 2px;
+}
+
+.home_scroll::-webkit-scrollbar-thumb {
+    border-radius: 10px;
+    background: $color;
+    box-shadow: inset 0 0 5px rgba(0, 122, 204);
+}
+
+.home_scroll::-webkit-scrollbar-track {
+    border-radius: 10px;
+    background: #ededed;
+    box-shadow: inset 0 0 5px rgba(0, 0, 0, .1);
+}
+
+.home_scroll {
+    scrollbar-width: 2px;
+    scrollbar-color: $color #fff;
+}
+</style>

+ 15 - 0
src/utils/download.ts

@@ -0,0 +1,15 @@
+import { saveAs } from 'file-saver'
+
+export default function downLoadFile1(url: string, name: string) {
+  console.log(url, name)
+  const oReq = new XMLHttpRequest()
+  oReq.open('GET', url, true)
+  oReq.responseType = 'blob'
+  oReq.onload = function () {
+    const file = new Blob([oReq.response], {
+      type: 'blob',
+    })
+    saveAs.saveAs(file, name)
+  }
+  oReq.send()
+}