yuhongqi 1 месяц назад
Родитель
Сommit
2b7241192c

+ 8 - 0
src/api/live/live.js

@@ -124,3 +124,11 @@ export function startLive(data) {
     params: data
   })
 }
+// 生成直播间小程序二维码
+export function generateCode(data) {
+  return request({
+    url: '/live/live/getWxaCodeUnLimit',
+    method: 'get',
+    params: data
+  })
+}

+ 1 - 3
src/views/live/live/index.vue

@@ -202,7 +202,6 @@
         alt="直播二维码"
         class="qrcode-img"
         @error="handleImgError"
-      @click="handleImgZoom"
       >
     </div>
     </el-dialog>
@@ -736,9 +735,8 @@ export default {
         type: "warning"
       }).then(() => {
         generateCode({"liveId":row.liveId}).then(response=>{
-          if(res.code == 200){
+          if(response.code == 200){
             row.liveCodeUrl = response.data.liveCodeUrl
-            this.getList()
           }
         })
       }).catch(() => {});

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

@@ -332,20 +332,20 @@ export default {
         }
         this.goodsParams.liveId = this.liveId
         this.getLiveGoodsList();
-        this.socket = this.$store.state.liveWs[this.liveId]
+        // this.socket = this.$store.state.liveWs[this.liveId]
       },
       // 初始化时立即执行一次
       immediate: true
     }
   },
   created() {
-    if (this.$route.params.liveId) {
-      this.liveId = this.$route.params.liveId;
-    }else {
-      this.liveId = this.$route.query.liveId;
-    }
-    this.goodsParams.liveId = this.liveId
-    this.getLiveGoodsList();
+    // if (this.$route.params.liveId) {
+    //   this.liveId = this.$route.params.liveId;
+    // }else {
+    //   this.liveId = this.$route.query.liveId;
+    // }
+    // this.goodsParams.liveId = this.liveId
+    // this.getLiveGoodsList();
     this.socket = this.$store.state.liveWs[this.liveId]
   },
   methods: {

+ 13 - 4
src/views/live/liveConfig/idCard.vue

@@ -23,11 +23,20 @@ export default {
       liveId: null,
     };
   },
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        this.liveId = this.$route.params.liveId
+        getLive(this.liveId).then(res => {
+          this.idCardUrl = res.data.idCardUrl;
+        })
+      },
+      // 初始化时立即执行一次
+      immediate: true
+    }
+  },
   created() {
-    this.liveId = this.$route.params.liveId
-    getLive(this.liveId).then(res => {
-      this.idCardUrl = res.data.idCardUrl;
-    })
   },
   methods: {
     submit(){

+ 34 - 22
src/views/live/liveConfig/liveLotteryConf.vue

@@ -235,12 +235,11 @@
 <!--                <el-input v-model="prize.productId" placeholder="请输入商品ID" />-->
                 <el-select
                   v-model="prize.productId"
-                  filterable
+                  :filterable="true"
                   clearable
                   remote
                 reserve-keyword
                 placeholder="请输入关键字搜索"
-                :remote-method="fetchProducts"
                 :loading="loadingProducts"
                 size="small"
                 style="width: 180px"
@@ -468,6 +467,7 @@ export default {
           this.canLiveId = true;
         }
         this.getList();
+        this.getProducts();
       },
       // 初始化时立即执行一次
       immediate: true
@@ -481,19 +481,19 @@ export default {
     this.getDicts("sys_live_lottery_status").then(response => {
       this.lotteryStatusOptions = response.data;
     });
-    if (this.$route.params.liveId) {
-      this.liveId = this.$route.params.liveId;
-    }else {
-      this.liveId = this.$route.query.liveId;
-    }
-    this.parentLiveId = this.liveId;
-    this.queryParams.liveId = this.parentLiveId;
-    if(this.queryParams.liveId){
-      this.form.liveId = this.parentLiveId;
-      //设置查询条件直播间ID不可修改
-      this.canLiveId = true;
-    }
-    this.getList();
+    // if (this.$route.params.liveId) {
+    //   this.liveId = this.$route.params.liveId;
+    // }else {
+    //   this.liveId = this.$route.query.liveId;
+    // }
+    // this.parentLiveId = this.liveId;
+    // this.queryParams.liveId = this.parentLiveId;
+    // if(this.queryParams.liveId){
+    //   this.form.liveId = this.parentLiveId;
+    //   //设置查询条件直播间ID不可修改
+    //   this.canLiveId = true;
+    // }
+    // this.getList();
   },
   mounted() {
     this.$watch(
@@ -504,14 +504,9 @@ export default {
     );
   },
   methods: {
-    async fetchProducts(query) {
-      if (!query) {
-        this.productOptions = [];
-        return;
-      }
+    getProducts(){
       const queryParam = {
-        liveId : this.liveId,
-        keywords: query
+          liveId : this.liveId
       }
       this.loadingProducts = true;
       try {
@@ -525,6 +520,23 @@ export default {
         this.loadingProducts = false;
       }
     },
+    // async fetchProducts(query) {
+    //   const queryParam = {
+    //     liveId : this.liveId,
+    //     keywords: query
+    //   }
+    //   this.loadingProducts = true;
+    //   try {
+    //     listLiveGoods(queryParam).then(response => {
+    //       this.productOptions = response.rows;
+    //     })
+    //   } catch (err) {
+    //     console.error('查询商品失败:', err);
+    //     this.productOptions = [];
+    //   } finally {
+    //     this.loadingProducts = false;
+    //   }
+    // },
     // 获取默认奖品配置
     getDefaultPrize() {
       return {

+ 13 - 13
src/views/live/liveConfig/liveRedConf.vue

@@ -294,19 +294,19 @@ export default {
     this.getDicts("sys_live_red_type").then(response => {
       this.redTypeOptions = response.data;
     });
-    if (this.$route.params.liveId) {
-      this.liveId = this.$route.params.liveId;
-    }else {
-      this.liveId = this.$route.query.liveId;
-    }
-    this.parentLiveId = this.liveId;
-    this.queryParams.liveId = this.parentLiveId;
-    if(this.queryParams.liveId){
-      this.form.liveId = this.parentLiveId;
-      //设置查询条件直播间ID不可修改
-      this.canLiveId = true;
-    }
-    this.getList();
+    // if (this.$route.params.liveId) {
+    //   this.liveId = this.$route.params.liveId;
+    // }else {
+    //   this.liveId = this.$route.query.liveId;
+    // }
+    // this.parentLiveId = this.liveId;
+    // this.queryParams.liveId = this.parentLiveId;
+    // if(this.queryParams.liveId){
+    //   this.form.liveId = this.parentLiveId;
+    //   //设置查询条件直播间ID不可修改
+    //   this.canLiveId = true;
+    // }
+    // this.getList();
   },
   computed: {
 

+ 29 - 10
src/views/live/liveConfig/liveReplay.vue

@@ -184,17 +184,36 @@ export default {
 
     };
   },
-  created() {
-    if (this.$route.params.liveId) {
-      this.liveId = this.$route.params.liveId;
-    }else {
-      this.liveId = this.$route.query.liveId;
-    }
-    if(this.liveId == null) {
-      this.$message.error("页面错误,请联系管理员");
-      return;
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        if (this.$route.params.liveId) {
+          this.liveId = this.$route.params.liveId;
+        }else {
+          this.liveId = this.$route.query.liveId;
+        }
+        if(this.liveId == null) {
+          this.$message.error("页面错误,请联系管理员");
+          return;
+        }
+        this.getLive();
+      },
+      // 初始化时立即执行一次
+      immediate: true
     }
-    this.getLive();
+  },
+  created() {
+    // if (this.$route.params.liveId) {
+    //   this.liveId = this.$route.params.liveId;
+    // }else {
+    //   this.liveId = this.$route.query.liveId;
+    // }
+    // if(this.liveId == null) {
+    //   this.$message.error("页面错误,请联系管理员");
+    //   return;
+    // }
+    // this.getLive();
   },
   methods: {
     getLiveVideo() {

+ 22 - 12
src/views/live/liveConfig/task.vue

@@ -314,19 +314,29 @@ export default {
       hasMore: true, // 是否还有更多数据
     };
   },
-  created() {
-    if (this.$route.params.liveId) {
-      this.liveId = this.$route.params.liveId;
-    }else {
-      this.liveId = this.$route.query.liveId;
-    }
-    if(this.liveId == null) {
-      this.$message.error("页面错误,请联系管理员");
-      return;
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        if (this.$route.params.liveId) {
+          this.liveId = this.$route.params.liveId;
+        }else {
+          this.liveId = this.$route.query.liveId;
+        }
+        if(this.liveId == null) {
+          this.$message.error("页面错误,请联系管理员");
+          return;
+        }
+        this.liveAbled = true
+        this.queryParams.liveId = this.liveId;
+        this.getList();
+      },
+      // 初始化时立即执行一次
+      immediate: true
     }
-    this.liveAbled = true
-    this.queryParams.liveId = this.liveId;
-    this.getList();
+  },
+  created() {
+
     this.socket = this.$store.state.liveWs[this.liveId]
   },
   methods: {

+ 26 - 0
src/views/live/liveConsole/index.vue

@@ -75,9 +75,17 @@
             controls
             ref="livingPlayer"
             autoplay
+            @click.prevent
+            @contextmenu.prevent
+            class="custom-video"
             width="100%"
             style="display: block; background: #000; height: 45vh;"
           ></video>
+
+          <!-- 时间显示(可选) -->
+          <div ref="liveElapsedTime" class="time-display">
+            已播放:<span id="liveElapsedTime">00:00:00</span>
+          </div>
         </div>
         <div style="border-radius: 5px; overflow: hidden;" v-else-if="liveType == 2">
           <video
@@ -426,6 +434,8 @@ export default {
               this.$nextTick(() => {
                 this.initPlayer()
               })
+              this.startTime = new Date(res.data.startTime).getTime()
+              this.processInterval = setInterval(this.updateLiveProgress, 1000);
             } else {
               this.liveType = 2
               this.videoUrl = res.data.videoUrl;
@@ -503,6 +513,22 @@ export default {
       // 更新进度条宽度
       progressBar.style.width = `${progressPercent}%`;
 
+      // 格式化总流逝时间为“时:分:秒”并显示
+      elapsedTimeEl.textContent = this.formatTime(elapsedTime);
+    },
+    updateLiveProgress() {
+      const elapsedTimeEl = this.$refs.liveElapsedTime;
+
+      const currentTime = new Date().getTime();
+      const elapsedTime = currentTime - this.startTime; // 总流逝时间(毫秒)
+      console.log(this.startTime)
+
+      if (elapsedTime < 0) {
+        elapsedTimeEl.textContent = '00:00:00';
+        return;
+      }
+
+
       // 格式化总流逝时间为“时:分:秒”并显示
       elapsedTimeEl.textContent = this.formatTime(elapsedTime);
     },