Parcourir la source

销售直播代码 直播间

yuhongqi il y a 2 mois
Parent
commit
ca0f9ce936

+ 12 - 2
src/components/LiveVideoUpload/index.vue

@@ -147,17 +147,26 @@ export default {
       uploadKey: 0,
     };
   },
+  mounted() {
+    this.reset()
+  },
   watch: {
     localUploadType(newType) {
+
       this.$emit("update:uploadType", newType);
-      this.$emit("change");
     },
     uploadType(newType) {
       this.localUploadType = newType;
     },
   },
   methods: {
-
+// 提供重置方法供父组件调用
+    reset() {
+      this.txProgress = 0;
+      this.fileList = [];
+      this.$refs.upload.clearFiles();
+      // 重置其他状态...
+    },
     handleChange(file, fileList) {
       this.fileList = fileList;
       this.getVideoDuration(file.raw);
@@ -221,6 +230,7 @@ export default {
         console.log("组装URL========>",line_1);
         this.$emit("update:videoUrl", line_1);
         this.$emit("update:line_1", line_1);
+        this.$emit("change", line_1,line_1);
         // this.$emit("update:line_2", line_2);
         this.$message.success("线路一上传成功");
       } catch (error) {

+ 12 - 17
src/views/live/live/index.vue

@@ -222,6 +222,7 @@
           :videoUrl.sync="videoUrl"
           :fileName.sync="form.fileName"
           :line_2.sync="form.lineTwo"
+          :line_1.sync="form.lineOne"
           :thumbnail.sync="form.thumbnail"
           :uploadType.sync="form.uploadType"
           :isTranscode.sync="form.isTranscode"
@@ -236,12 +237,12 @@
                           v-model="form.startTime"
                           @change="timeChange"
                           type="datetime"
-                          format="yyyy-MM-dd HH:mm"
+                          format="yyyy-MM-dd HH:mm:ss"
                           value-format="yyyy-MM-dd HH:mm:ss"
                           :picker-options="{
                             timePickerOptions: {
-                              selectableRange: '00:00 - 23:59',
-                              format: 'HH:mm'
+                              selectableRange: '00:00:00 - 23:59:59',
+                              format: 'HH:mm:ss'
                             }
                           }"
                           placeholder="选择开始时间">
@@ -251,12 +252,12 @@
           <el-date-picker size="small"
                           v-model="form.finishTime"
                           type="datetime"
-                          format="yyyy-MM-dd HH:mm"
+                          format="yyyy-MM-dd HH:mm:ss"
                           value-format="yyyy-MM-dd HH:mm:ss"
                           :picker-options="{
                             timePickerOptions: {
-                              selectableRange: '00:00 - 23:59',
-                              format: 'HH:mm'
+                              selectableRange: '00:00:00 - 23:59:59',
+                              format: 'HH:mm:ss'
                             }
                           }"
                           placeholder="视屏播放结束">
@@ -361,7 +362,7 @@ export default {
       },
       // 表单参数
       form: {
-        uploadType: 2,
+        uploadType: 1,
         isTranscode:0,
         transcodeFileKey:null
       },
@@ -517,16 +518,9 @@ export default {
     handleVideoDuration(duration) {
       this.form.duration = duration;
     },
-    handleVideoChange(){
-      console.log(this.videoUrl)
-      if(this.form.uploadType==1){
-        this.videoUrl = this.form.lineOne;
-      }else if(this.form.uploadType==2){
-        this.videoUrl = this.form.lineTwo;
-        this.form.videoUrl = this.form.lineTwo;
-      }else if(this.form.uploadType==3){
-        this.videoUrl = this.form.lineThree;
-      }
+    handleVideoChange(videoUrl,lineOne){
+      this.videoUrl = videoUrl;
+      this.form.videoUrl = videoUrl;
       console.log(this.videoUrl)
     },
     changeDuration(e){
@@ -580,6 +574,7 @@ export default {
         liveType: 2,
         isShow: 1,
         isTranscode:0,
+        uploadType:1,
         transcodeFileKey:null
       };
       this.videoUrl = "";

+ 37 - 9
src/views/live/liveConfig/goods.vue

@@ -94,6 +94,12 @@
             style="color: #0066FF;"
             @click="handleGoodStock(scope.row)"
           >调整库存</el-button>
+          <el-button
+            type="text"
+            size="small"
+            style="color: #0066FF;"
+            @click="handleGoodSale(scope.row)"
+          >调整销量</el-button>
           <el-button
             type="text"
             size="small"
@@ -259,6 +265,23 @@ export default {
     }
     };
   },
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        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]
+      },
+      // 初始化时立即执行一次
+      immediate: true
+    }
+  },
   created() {
     if (this.$route.params.liveId) {
       this.liveId = this.$route.params.liveId;
@@ -279,16 +302,15 @@ export default {
           row.isShow = res.isShow
           if (res.msg == "目前仅支持单一物品展示") {
             this.$message.error(res.msg)
-          } else if(res.isShow){
-            if (this.socket == null) {
-              this.$message.error("请从直播间开启展示状态!");
-            } else {
-              const msg = {
-                cmd: 'goods',
-                data: {"liveId":this.liveId,"goodsId":goodsList[0]}
-              }
-              this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+          }
+          if (this.socket == null) {
+            this.$message.error("请从直播间开启展示状态!");
+          } else {
+            const msg = {
+              cmd: 'goods',
+              data: {"liveId":this.liveId,"goodsId":goodsList[0],"status":targetStatus ? 1 : 0}
             }
+            this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
           }
         }
       })
@@ -416,6 +438,12 @@ export default {
       this.stockForm.productId = row.productId;
       this.stockDialogVisible = true;
     },
+    handleGoodSale(row){
+      this.stockForm.goodsId = row.goodsId;
+      this.stockForm.stock = row.stock;
+      this.stockForm.productId = row.productId;
+      this.stockDialogVisible = true;
+    },
     // 添加确认修改库存方法
     confirmStockChange() {
       this.$refs.stockForm.validate((valid) => {

+ 24 - 1
src/views/live/liveConfig/liveLotteryConf.vue

@@ -451,6 +451,28 @@ export default {
       }
     };
   },
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        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();
+      },
+      // 初始化时立即执行一次
+      immediate: true
+    }
+  },
   created() {
     this.getDicts("sys_live_lottery_require").then(response => {
       this.requireOptions = response.data;
@@ -707,7 +729,8 @@ export default {
       const doLotteryParam = {
         lotteryId: row.lotteryId,
         lotteryStatus: status,
-        duration: row.duration
+        duration: row.duration,
+        status: status
       };
       updateLiveLotteryConf(doLotteryParam).then(response => {
         if(response.code === 200){

+ 25 - 2
src/views/live/liveConfig/liveRedConf.vue

@@ -262,9 +262,31 @@ export default {
           { required: true, message: "描述不能为空", trigger: "blur" }
         ],
       },
-      liveId: null,
+
     };
   },
+  watch: {
+    // 监听路由的 query 参数变化
+    '$route.query': {
+      handler(newQuery) {
+        if (this.$route.params.liveId) {
+          this.liveId = this.$route.params.liveId;
+        }else {
+          this.liveId = this.$route.query.liveId;
+        }
+        this.queryParams.liveId = this.liveId;
+        this.parentLiveId = this.liveId;
+        if(this.queryParams.liveId){
+          this.form.liveId = this.parentLiveId;
+          //设置查询条件直播间ID不可修改
+          this.canLiveId = true;
+        }
+        this.getList();
+      },
+      // 初始化时立即执行一次
+      immediate: true
+    }
+  },
   created() {
     this.getDicts("sys_live_red_status").then(response => {
       this.redStatusOptions = response.data;
@@ -329,6 +351,7 @@ export default {
         redId: row.redId,
         redStatus: status,
         totalLots: row.totalLots,
+        status: status,
         duration: row.duration
       };
       updateLiveRedConf(doRedParam).then(response => {
@@ -476,7 +499,7 @@ export default {
             cmd: 'red',
             data: {
               redId: row.redId,
-              redStatus: 2,
+              status: 2,
               totalLots: row.totalLots,
               duration: row.duration
             }

+ 32 - 11
src/views/live/liveConfig/task.vue

@@ -95,12 +95,9 @@
       <el-table-column label="任务类型" align="center" prop="taskType" :formatter="taskTypeFormatter" />
       <el-table-column label="触发类型" align="center" prop="triggerType" :formatter="triggerTypeFormatter" />
       <el-table-column label="触发时间" align="center" prop="triggerValue" :formatter="triggerValueFormatter" />
+      <el-table-column label="产品名称" align="center" prop="productName" :formatter="productNameFormatter" />
       <el-table-column label="状态" align="center" prop="status" :formatter="statusFormatter" />
-      <el-table-column label="创建时间" align="center" prop="createdTime" width="180">
-        <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
-        </template>
-      </el-table-column>
+      <el-table-column label="完成状态" align="center" prop="finishStatus" :formatter="finishStatusFormatter" />
       <el-table-column label="更新时间" align="center" prop="updatedTime" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
@@ -144,7 +141,7 @@
           <el-input v-model="form.taskName" placeholder="请输入任务名称" />
         </el-form-item>
         <el-form-item label="任务类型" prop="taskType">
-          <el-select v-model="form.taskType" placeholder="请选择任务类型" @change="updateTaskType()">
+          <el-select v-model="form.taskType" placeholder="请选择任务类型" @change="updateTaskType()" >
             <el-option v-for="i in taskTypeOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
           </el-select>
         </el-form-item>
@@ -165,10 +162,12 @@
         </el-form-item>
         <el-form-item label="触发时间" prop="content">
           <el-time-picker
+            default-value="2025-01-01 00:00:00"
             v-model="form.triggerValue"
             :picker-options="{
       selectableRange: '00:00:00 - 23:59:59'
     }"
+
             placeholder="任意时间点">
           </el-time-picker>
         </el-form-item>
@@ -208,7 +207,7 @@ export default {
     return {
       taskTypeOptions:[
         {
-          value: "1",
+          value: 1,
           label: "定时卡片推荐商品"
         },
         // {
@@ -331,7 +330,6 @@ export default {
     this.socket = this.$store.state.liveWs[this.liveId]
   },
   methods: {
-
     statusFormatter(row, column, value){
       if (!value) return '--'; // 空值处理
       switch ( value){
@@ -343,6 +341,17 @@ export default {
           return "--";
       }
     },
+    finishStatusFormatter(row, column, value){
+      if (!value) return '--'; // 空值处理
+      switch ( value){
+        case 0:
+          return "未执行";
+        case 1:
+          return "已执行";
+        default:
+          return "--";
+      }
+    },
     taskTypeFormatter(row, column, value){
       if (!value) return '--'; // 空值处理
       switch (value) {
@@ -365,6 +374,13 @@ export default {
           return "--";
       }
     },
+    productNameFormatter(row, column, value){
+      let content = JSON.parse(row.content)
+      if(content.productName) {
+        return content.productName
+      }
+      return "--";
+    },
     triggerValueFormatter(row, column, value) {
       if (!value) return '--'; // 空值处理
 
@@ -492,13 +508,18 @@ export default {
       this.title = "添加直播间自动化任务配置";
     },
     /** 修改按钮操作 */
-    handleUpdate(row) {
+    async handleUpdate(row) {
       this.reset();
+      if(row.taskType == 1){
+        await this.addGoodsList();
+      }
       const id = row.id || this.ids
       getTask(id).then(response => {
         this.form = response.data;
-        this.form.content = null;
-        this.form.taskType = null;
+        if (this.form.taskType == 1) {
+          let content = JSON.parse( response.data.content)
+          this.form.content = content.goodsId;
+        }
         this.open = true;
         this.title = "修改直播间自动化任务配置";
       });

+ 9 - 5
src/views/live/liveConsole/index.vue

@@ -406,6 +406,7 @@ export default {
           }
           if (res.data.liveType == 1) {
             this.livingUrl = res.data.flvHlsUrl
+            this.livingUrl = this.livingUrl.replace("flv","m3u8")
             this.$nextTick(() => {
               this.initPlayer()
             })
@@ -767,14 +768,17 @@ export default {
               this.$refs.manageRightRef.wrap.scrollTop = this.$refs.manageRightRef.wrap.scrollHeight - this.$refs.manageRightRef.wrap.clientHeight
             }, 200)
           })
-        }
-        else if (cmd === 'entry' || cmd === 'out') {
-          this.loadUserList()
+        } else if (cmd === 'entry' || cmd === 'out') {
           let user = data
           if(this.userList.length > 0){
             this.userList = this.userList.filter(u => u.userId !== user.userId)
           }
-          this.userList.push(user)
+          let online = 0
+          if (cmd === 'out') {
+            online = 1
+          }
+          let info = {"avatar":user.avatar, "nickName":user.nickName,"liveId":this.liveId, "msgStatus":user.msgStatus,"online": online,"userId":user.userId};
+          this.userList.push(info)
         } else if (cmd === 'live_start') {
           this.msgSuccess("直播开始了!");
         } else if (cmd === 'live_end') {
@@ -912,7 +916,7 @@ export default {
 
 /* 时间显示样式 */
 .time-display {
-  color: #333;
+  color: #ffffff;
   font-size: 14px;
 }
 </style>