ソースを参照

直播自动化任务添加 定时发送红包和抽奖

yuhongqi 1 週間 前
コミット
c90297969f

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

@@ -125,3 +125,12 @@ export function startLive(data) {
     params: data
   })
 }
+
+// 复制录播直播间
+export function copyLive(data) {
+  return request({
+    url: '/live/live/copyLive',
+    method: 'get',
+    params: data
+  })
+}

+ 9 - 0
src/api/live/liveLotteryConf.js

@@ -51,3 +51,12 @@ export function exportLiveLotteryConf(query) {
     params: query
   })
 }
+
+// 查询直播抽奖配置列表  未开启
+export function listLiveLotteryConfOn(query) {
+  return request({
+    url: '/live/liveLotteryConf/listOn',
+    method: 'get',
+    params: query
+  })
+}

+ 11 - 0
src/api/live/liveRedConf.js

@@ -51,3 +51,14 @@ export function exportLiveRedConf(query) {
     params: query
   })
 }
+
+
+// 查询直播红包 未使用的红包
+export function listLiveRedConfOn(query) {
+  return request({
+    url: '/live/liveRedConf/listOn',
+    method: 'get',
+    params: query
+  })
+}
+

+ 47 - 37
src/views/live/live/index.vue

@@ -140,43 +140,43 @@
             @click="handleManage(scope.row)"
             v-hasPermi="['live:console:list']"
           >进入直播间</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-setting"
-            @click="handleAudit(scope.row)"
-            v-hasPermi="['live:config:list']"
-          >审核</el-button>
-          <el-button
-            v-if="scope.row.status != 2"
-            size="mini"
-            type="text"
-            icon="el-icon-monitor"
-            @click="handleStart(scope.row)"
-            v-hasPermi="['live:config:list']"
-          >去直播</el-button>
-          <el-button
-            v-if="scope.row.status == 2"
-            size="mini"
-            type="text"
-            icon="el-icon-monitor"
-            @click="handleEnded(scope.row)"
-            v-hasPermi="['live:config:list']"
-          >结束</el-button>
-          <el-button
-            v-if="scope.row.status == 2 && scope.row.liveType == 1"
-            size="mini"
-            type="text"
-            icon="el-icon-set-up"
-            @click="showLivingUrl(scope.row)"
-            v-hasPermi="['live:live:remove']"
-          >推流码</el-button>
-          <el-dropdown-item
-            v-if="scope.row.liveCodeUrl != null"
-            @click.native="handleCheckCode(scope.row)"
-          >
-            <i class="el-icon-service"></i> 查看二维码
-          </el-dropdown-item>
+          <el-dropdown trigger="hover">
+            <el-button size="mini" type="text" icon="el-icon-more">
+              更多
+            </el-button>
+            <el-dropdown-menu slot="dropdown">
+              <el-dropdown-item
+                v-if="scope.row.status == 2 && scope.row.liveType == 1"
+                @click.native="showLivingUrl(scope.row)"
+              >
+                <i class="el-icon-switch-button"></i> 推流码
+              </el-dropdown-item>
+              <!-- 去直播按钮 -->
+              <el-dropdown-item
+                v-if="scope.row.status != 2"
+                @click.native="handleStart(scope.row)"
+              >
+                <i class="el-icon-monitor"></i> 去直播
+              </el-dropdown-item>
+              <el-dropdown-item
+                v-if="scope.row.status == 2"
+                @click.native="handleEnded(scope.row)"
+              >
+                <i class="el-icon-service"></i> 结束
+              </el-dropdown-item>
+              <el-dropdown-item
+                @click.native="handleCopy(scope.row)"
+              >
+                <i class="el-icon-service"></i> 复制直播间
+              </el-dropdown-item>
+              <el-dropdown-item
+                @click.native="handleAudit(scope.row)"
+              >
+                <i class="el-icon-service"></i> 审核
+              </el-dropdown-item>
+
+            </el-dropdown-menu>
+          </el-dropdown>
 <!--          <el-button-->
 <!--            v-if="scope.row.status == 2"-->
 <!--            size="mini"-->
@@ -353,6 +353,7 @@ import {
   handleShelfOrUn,
   handleDeleteSelected,
   finishLive, startLive,
+  copyLive,
 } from "@/api/live/live";
 import Editor from '@/components/Editor/wang';
 import user from '@/store/modules/user';
@@ -808,6 +809,15 @@ export default {
         finishLive({"liveId":row.liveId}).then(response=>{this.getList()})
       }).catch(() => {});
     },
+    handleCopy(row){
+      this.$confirm('是否确认复制直播间?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        copyLive({"liveId":row.liveId}).then(response=>{this.getList()})
+      }).catch(() => {});
+    },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;

+ 155 - 39
src/views/live/liveConfig/task.vue

@@ -49,7 +49,7 @@
           icon="el-icon-plus"
           size="mini"
           @click="handleAdd"
-          v-hasPermi="['shop:task:add']"
+          v-hasPermi="['live:task:add']"
         >新增</el-button>
       </el-col>
       <el-col :span="1.5">
@@ -60,7 +60,7 @@
           size="mini"
           :disabled="single"
           @click="handleUpdate"
-          v-hasPermi="['shop:task:edit']"
+          v-hasPermi="['live:task:edit']"
         >修改</el-button>
       </el-col>
       <el-col :span="1.5">
@@ -71,7 +71,7 @@
           size="mini"
           :disabled="multiple"
           @click="handleDelete"
-          v-hasPermi="['shop:task:remove']"
+          v-hasPermi="['live:task:remove']"
         >删除</el-button>
       </el-col>
       <el-col :span="1.5">
@@ -82,7 +82,7 @@
           size="mini"
           :loading="exportLoading"
           @click="handleExport"
-          v-hasPermi="['shop:task:export']"
+          v-hasPermi="['live:task:export']"
         >导出</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@@ -95,6 +95,7 @@
       <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">
@@ -113,14 +114,14 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
-            v-hasPermi="['shop:task:edit']"
+            v-hasPermi="['live:task:edit']"
           >修改</el-button>
           <el-button
             size="mini"
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
-            v-hasPermi="['shop:task:remove']"
+            v-hasPermi="['live:task:remove']"
           >删除</el-button>
         </template>
       </el-table-column>
@@ -163,6 +164,36 @@
             </div>
           </el-select>
         </el-form-item>
+        <el-form-item label="红包选择" prop="content" v-if="form.taskType == 2">
+          <el-select v-model="form.content" placeholder="请选择红包" ref="selectRef" >
+            <el-option v-for="i in redOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            <!-- 加载载中状态 -->
+            <div v-if="isLoading" class="loading-indicator">
+              <i class="el-icon-loading"></i>
+              <span>加载中...</span>
+            </div>
+
+            <!-- 没有更多数据 -->
+            <div v-if="!hasMore && !isLoading" class="no-more">
+              没有更多数据了
+            </div>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="抽奖选择" prop="content" v-if="form.taskType == 4">
+          <el-select v-model="form.content" placeholder="请选择抽奖" ref="selectRef" >
+            <el-option v-for="i in lotteryOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            <!-- 加载载中状态 -->
+            <div v-if="isLoading" class="loading-indicator">
+              <i class="el-icon-loading"></i>
+              <span>加载中...</span>
+            </div>
+
+            <!-- 没有更多数据 -->
+            <div v-if="!hasMore && !isLoading" class="no-more">
+              没有更多数据了
+            </div>
+          </el-select>
+        </el-form-item>
         <el-form-item label="触发时间" prop="content">
           <el-time-picker
             default-value="2025-01-01 00:00:00"
@@ -202,6 +233,8 @@
 <script>
 import { listTask, getTask, delTask, addTask, updateTask, exportTask } from "@/api/live/task";
 import {listLiveGoods} from "@/api/live/liveGoods";
+import {listLiveRedConfOn} from "@/api/live/liveRedConf";
+import {listLiveLotteryConfOn} from "@/api/live/liveLotteryConf";
 
 export default {
   name: "Task",
@@ -212,25 +245,15 @@ export default {
           value: 1,
           label: "定时卡片推荐商品"
         },
-        // {
-        //   value: "1",
-        //   label: "请选择字典生成"
-        // },
-        // {
-        //   value: "1",
-        //   label: "请选择字典生成"
-        // }
+        {
+          value: 2,
+          label: "定时红包发送"
+        },
+        {
+          value: 4,
+          label: "定时抽奖"
+        },
       ],
-      // triggerTypeOptions:[
-      //   {
-      //     value: "1",
-      //     label: "请选择字典生成"
-      //   },
-      //   {
-      //     value: "1",
-      //     label: "请选择字典生成"
-      //   }
-      // ],
       statusOptions:[{
         value: "0",
         label: "禁用"
@@ -240,6 +263,13 @@ export default {
           label: "启用"
         }
       ],
+      haveData:{
+        goods:false,
+        red:false,
+        lottery:false
+      },
+      redOptions:[],
+      lotteryOptions:[],
       productOptions:[],
       // 遮罩层
       loading: true,
@@ -306,7 +336,7 @@ export default {
         ]
       },
       liveId: null,
-      goodsParams: {
+      listParams: {
         pageNum: 1,
         pageSize: 10,
         liveId: null
@@ -364,6 +394,8 @@ export default {
           return "定时推送卡片商品";
         case 2:
           return "定时发送红包";
+        case 4:
+          return "定时抽奖";
         default:
           return "--";
       }
@@ -379,6 +411,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 '--'; // 空值处理
 
@@ -406,21 +445,37 @@ export default {
       return `${hours}:${minutes}:${seconds}`;
     },
     async updateTaskType(){
-      if (this.form.taskType == 1) {
-        if (this.isLoading || !this.hasMore) return;
-        this.isLoading = true;
-        this.goodsParams.liveId = this.liveId;
-        try{
+      this.hasMore = true;
+      this.listParams = {
+        pageNum: 1,
+        pageSize: 10,
+        liveId: null
+      }
+      if (this.isLoading || !this.hasMore) return;
+      this.isLoading = true;
+      this.listParams.liveId = this.liveId;
+      if(this.listParams.liveId == null) {
+        this.$message.error("页面错误,请联系管理员");
+        return;
+      }
+
+      try{
+        if (this.form.taskType == 1) {
           await this.addGoodsList();
-        }catch ( err){
-          console.error('加载数据失败:', err);
-        }finally {
-          this.isLoading = false;
+        }else if (this.form.taskType == 2) {
+          await this.addRedList();
+        }else if (this.form.taskType == 4) {
+          await this.addLotteryList();
         }
+      }catch ( err){
+        console.error('加载数据失败:', err);
+      }finally {
+        this.isLoading = false;
       }
     },
     addGoodsList() {
-      listLiveGoods(this.goodsParams).then(res => {
+      if(this.haveData.goods) return
+      listLiveGoods(this.listParams).then(res => {
         if(res.rows.length > 0) {
           res.rows.forEach(item => {
             // 根据productName和goodsId组装成为label和value
@@ -429,13 +484,66 @@ export default {
               label: item.productName
             })
           })
-          this.goodsParams.pageNum++;
+          this.listParams.pageNum++;
           // 判断是否还有更多数据
           this.hasMore = this.productOptions.length < res.total;
-          if(this.hasMore) {
+          if (this.hasMore) {
             this.addGoodsList();
+          } else {
+            this.haveData.goods = true;
+          }
+        } else {
+          this.hasMore = false;
+          this.haveData.goods = true;
+        }
+      });
+    },
+    addRedList() {
+      if(this.haveData.red) return
+      listLiveRedConfOn(this.listParams).then(res => {
+        if(res.rows.length > 0) {
+          res.rows.forEach(item => {
+            // 根据productName和goodsId组装成为label和value
+            this.redOptions.push({
+              value: item.redId,
+              label: item.desc
+            })
+          })
+          this.listParams.pageNum++;
+          // 判断是否还有更多数据
+          this.hasMore = this.redOptions.length < res.total;
+          if (this.hasMore) {
+            this.addRedList();
+          } else {
+            this.haveData.red = true
+          }
+        } else {
+          this.haveData.red = true
+          this.hasMore = false;
+        }
+      });
+    },
+    addLotteryList() {
+      if(this.haveData.lottery) return
+      listLiveLotteryConfOn(this.listParams).then(res => {
+        if(res.rows.length > 0) {
+          res.rows.forEach(item => {
+            // 根据productName和goodsId组装成为label和value
+            this.lotteryOptions.push({
+              value: item.lotteryId,
+              label: item.desc
+            })
+          })
+          this.listParams.pageNum++;
+          // 判断是否还有更多数据
+          this.hasMore = this.lotteryOptions.length < res.total;
+          if (this.hasMore) {
+            this.addRedList();
+          } else {
+            this.haveData.lottery = true
           }
         } else {
+          this.haveData.lottery = true
           this.hasMore = false;
         }
       });
@@ -474,7 +582,7 @@ export default {
         createdTime: null,
         updatedTime: null
       };
-      this.goodsParams={
+      this.listParams={
           pageNum: 1,
           pageSize: 10,
           liveId: this.liveId
@@ -510,13 +618,21 @@ export default {
       this.reset();
       if(row.taskType == 1){
         await this.addGoodsList();
+      }else if(row.taskType == 2){
+        await this.addRedList();
+      }else if(row.taskType == 4){
+        await this.addLotteryList();
       }
       const id = row.id || this.ids
       getTask(id).then(response => {
         this.form = response.data;
+        let content = JSON.parse( response.data.content)
         if (this.form.taskType == 1) {
-          let content = JSON.parse( response.data.content)
           this.form.content = content.goodsId;
+        }else if (this.form.taskType == 2) {
+          this.form.content = content.desc;
+        }else if (this.form.taskType == 4) {
+          this.form.content = content.desc;
         }
         this.open = true;
         this.title = "修改直播间自动化任务配置";