yuhongqi 1 день назад
Родитель
Сommit
3879840395

+ 1 - 1
src/api/live/liveGoods.js

@@ -63,7 +63,7 @@ export function exportLiveGoods(query) {
 // 直播商品
 export function listStoreProduct(data) {
   return request({
-    url: '/store/storeProduct/list',
+    url: '/live/liveGoods/liveList',
     method: 'get',
     params: data
   })

+ 4 - 4
src/api/live/liveQuestionLive.js

@@ -54,18 +54,18 @@ export function getConfig(id) {
 }
 
 // 新增直播观看奖励设置
-export function addConfig(data) {
+export function addConfig(data,liveId) {
   return request({
-    url: '/live/config',
+    url: '/live/config' + '?liveId=' + liveId,
     method: 'post',
     data: data
   })
 }
 
 // 修改直播观看奖励设置
-export function updateConfig(data) {
+export function updateConfig(data,liveId) {
   return request({
-    url: '/live/config',
+    url: '/live/config' + '?liveId=' + liveId,
     method: 'put',
     data: data
   })

+ 24 - 25
src/components/Editor/wang.vue

@@ -1,23 +1,23 @@
-<template>  
+<template>
     <div>
       <div  ref='editor1' class="myedit"></div>
-    </div> 
-</template>  
-  
-<script>  
-  import E from 'wangeditor'  
-  export default {  
-    name: 'editoritem',  
-    data() {  
+    </div>
+</template>
+
+<script>
+  import E from 'wangeditor'
+  export default {
+    name: 'editoritem',
+    data() {
       return {
         index:0,
         uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadWang",
         editor: null
-      }  
+      }
     },
     created() {
-       
-      
+
+
     },
     beforeDestroy() {
       // 销毁编辑器
@@ -25,7 +25,7 @@
         this.editor.destroy()
         this.editor = null
       }
-      
+
     },
     methods:{
       initEditor(){
@@ -36,7 +36,7 @@
             this.editor.config.uploadImgServer = this.uploadUrl;
 
 
-            
+
              this.editor.config.uploadImgMaxLength = 5
             this.editor.config.uploadImgMaxSize = 2 * 1024 * 1024 // 2M
             this.editor.config.uploadImgAccept = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']
@@ -69,7 +69,6 @@
               'redo',
           ]
           this.editor.config.onchange = function (newHtml) {
-            console.log(newHtml)
             that.$emit("on-text-change", newHtml);
           }
           this.editor.config.pasteFilterStyle = false
@@ -79,7 +78,7 @@
                 // 上传图片之前
                 before: function(xhr) {
                     //console.log(xhr)
-                    
+
                 },
                 // 图片上传并返回了结果,图片插入已成功
                 success: function(xhr) {
@@ -112,8 +111,8 @@
                           }
                           console.log(url);
                       }
-                      
-                     
+
+
                       // result 必须是一个 JSON 格式字符串!!!否则报错
                 }
             }
@@ -131,13 +130,13 @@
         else{
           this.editor.txt.html(text);
         }
-        
+
       },
      }
-   
-  }  
-</script>  
-  
+
+  }
+</script>
+
 <style scoped>
 .toolbar {
   border: 1px solid #ccc;
@@ -152,5 +151,5 @@
 .w-e-text-container{
   z-index: 1 !important;
 }
- 
-</style>
+
+</style>

+ 0 - 1
src/components/LiveVideoUpload/index.vue

@@ -218,7 +218,6 @@ export default {
         } else {
           line_1 = `${process.env.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
         }
-        line_1 = line_1.replace(/\.mp4$/, '.m3u8');
 
         let urlPathWithoutFirstSlash = data.urlPath.substring(1);
         this.$emit("update:fileKey", urlPathWithoutFirstSlash);

+ 49 - 4
src/components/VideoUpload/index.vue

@@ -48,7 +48,8 @@
       </div>
     </el-form-item>
     <el-form-item label="视频播放">
-      <video v-if="videoUrl" ref="myvideo" :src="videoUrl" id="video" width="100%" height="300px" controls></video>
+      <video v-if="videoUrl.endsWith('mp4')" ref="myvideo" :src="videoUrl" id="video" width="100%" height="300px" controls></video>
+      <video v-if="videoUrl.endsWith('m3u8')" ref="myM3u8Video" :src="videoUrl" id="meu8Video" width="100%" height="300px" controls type="application/x-mpegURL"></video>
       <div v-if="fileName">视频文件名: {{ fileName }}</div>
       <div v-if="fileKey">文件Key: {{ fileKey }}</div>
       <div v-if="fileSize">文件大小(MB): {{ (fileSize / (1024 * 1024)).toFixed(2) }} MB</div>
@@ -122,8 +123,9 @@
 <script>
 import { uploadObject } from "@/utils/cos.js";
 import Pagination from "@/components/Pagination";
-// import { listVideoResource } from '@/api/course/videoResource';
-import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo } from "@/api/live/liveVideo";
+import { listLiveVideo } from "@/api/live/liveVideo";
+import Hls from 'hls.js';
+import {isEmpty} from "@/components/LemonUI/utils/validate";
 
 export default {
   components: {
@@ -181,6 +183,9 @@ export default {
       default: true,
     }
   },
+  destroyed() {
+    this.hls?.destroy();
+  },
   data() {
     return {
       videoName:'',
@@ -228,8 +233,21 @@ export default {
   },
   mounted() {
     this.reset();
+    if (this.videoUrl.endsWith(".m3u8")) {
+      this.$nextTick(() => {
+        this.initPlayer()
+      })
+    }
   },
   watch: {
+    videoUrl(newVal,oldVal){
+      console.log("触发数据改变")
+      if (this.videoUrl.endsWith(".m3u8")) {
+        this.$nextTick(() => {
+          this.initPlayer()
+        })
+      }
+    },
     uploadType(newType) {
       this.localUploadType = newType;
     },
@@ -320,6 +338,29 @@ export default {
         this.$message.error("线路一上传失败");
       }
     },
+    initPlayer() {
+      this.hls?.destroy();
+      if (Hls.isSupported()) {
+        const videoElement = this.$refs.myM3u8Video
+        if (!videoElement) {
+          console.error('找不到 video 元素')
+          return
+        }
+        this.hls = new Hls();
+        this.hls.attachMedia(videoElement);
+        this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
+          this.hls.loadSource(this.videoUrl);
+          this.hls.on(Hls.Events.STREAM_LOADED, (event, data) => {
+            videoElement.play();
+          });
+        });
+        this.hls.on(Hls.Events.ERROR, (event, data) => {
+          console.error('HLS 错误:', data);
+        });
+      } else {
+        console.error('浏览器不支持 HLS')
+      }
+    },
     //上传华为云Obs
     async uploadVideoToHwObs() {
       try {
@@ -404,7 +445,11 @@ export default {
       this.$emit("update:videoUrl", this.selectedVideo.videoUrl);
       this.$emit("change", this.selectedVideo.videoUrl,this.selectedVideo.lineOne);
 
-
+      if (this.videoUrl.endsWith(".m3u8")) {
+        this.$nextTick(() => {
+          this.initPlayer()
+        })
+      }
       this.libraryOpen = false;
     },
     /** 取消视频选择 */

+ 14 - 0
src/utils/util.js

@@ -32,3 +32,17 @@ export function randomString(len) {
     }
     return pwd
 }
+
+function isEmpty(str) {
+  // 检查是否为 null 或 undefined
+  if (str == null) return true;
+
+  // 检查是否为字符串类型
+  if (typeof str !== 'string') {
+    // 如果不是字符串,尝试转换为字符串再判断
+    return String(str).trim() === '';
+  }
+
+  // 字符串类型直接去除空格后判断
+  return str.trim() === '';
+}

+ 2 - 2
src/views/live/liveConfig/goods.vue

@@ -267,7 +267,7 @@ export default {
       queryGoodParams: {
         pageNum: 1,
         pageSize: 10,
-        productName: null,
+        keywords: null,
       },
       goodsLiveList: [],
       goodsLiveTotal: 0,
@@ -444,7 +444,7 @@ export default {
     },
     handleGoodsSearch(){
       this.queryGoodParams.pageNum = 1
-      this.queryGoodParams.productName = this.searchTitle
+      this.queryGoodParams.keywords = this.searchTitle
       this.getStoreProductLists()
     },
     handleGoodsChange(goods) {

+ 3 - 1
src/views/live/liveConfig/preview.vue

@@ -147,9 +147,11 @@ export default {
   methods: {
     submitForm() {
       this.open = false;
+      var line_1 = this.videoUrl;
+      line_1 = line_1.replace(/\.mp4$/, '.m3u8');
       const doParam = {
         liveId: this.liveId,
-        videoUrl: this.videoUrl,
+        videoUrl: line_1,
         videoType: 3,
         duration: this.form.duration,
         fileSize: this.form.fileSize,

+ 2 - 2
src/views/live/liveConfig/watchReward.vue

@@ -283,13 +283,13 @@ export default {
           if (this.watchRewardForm.id == null) {
             // 调用保存观看奖励接口
             // 实现保存逻辑
-            addConfig(this.watchRewardForm).then(res => {
+            addConfig(this.watchRewardForm,this.liveId).then(res => {
               if (res.code == 200) {
                 this.msgSuccess("修改成功");
               }
             })
           } else {
-            updateConfig(this.watchRewardForm).then(response => {
+            updateConfig(this.watchRewardForm,this.liveId).then(response => {
               this.msgSuccess("修改成功");
             });
           }

+ 4 - 0
src/views/live/liveVideo/index.vue

@@ -165,6 +165,9 @@ export default {
       this.loading = true;
       listLiveVideo(this.queryParams).then(response => {
         this.liveVideoList = response.rows;
+        this.liveVideoList.forEach(item => {
+          item.videoUrl = item.videoUrl.replace(".m3u8", ".mp4");
+        });
         this.total = response.total;
         this.loading = false;
       });
@@ -240,6 +243,7 @@ export default {
             this.msgError("请上传视频");
             return;
           }
+          this.form.videoUrl.replace(/\.mp4$/, '.m3u8');
           addLiveVideo(this.form).then(response => {
             this.msgSuccess("新增成功");
             this.open = false;