|
|
@@ -161,6 +161,16 @@
|
|
|
v-hasPermi="['live:liveLotteryConf:edit']"
|
|
|
style="margin-left: 10px"
|
|
|
>查看中奖</el-button>
|
|
|
+ <!-- 自动化抽奖按钮 -->
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.lotteryStatus+'' === '0'"
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-time"
|
|
|
+ @click="handleAutoLottery(scope.row)"
|
|
|
+ v-hasPermi="['live:liveLotteryConf:edit']"
|
|
|
+ style="margin-left: 10px"
|
|
|
+ >自动化抽奖</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -185,11 +195,23 @@
|
|
|
<el-option v-for="(item,index) in requireOptions" :key="item.dictValue+index" :label="item.dictLabel" :value="item.dictValue" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
-<!-- <el-form-item label="方式配置" prop="requireConf">-->
|
|
|
-<!-- <el-input v-model="form.requireConf" placeholder="请输入参与抽奖方式" />-->
|
|
|
-<!-- <span style="margin-bottom:10px;font-size: 10px; font-family: Arial,serif">当参与方式选择为“送礼参与”或“下单参与”时,此处填写商品ID及数量</span>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
- <el-form-item label="持续时间" prop="duration" style="margin-top: 50px;">
|
|
|
+ <!-- 评论关键词配置(仅当选择评论参与时显示) -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="form.require+'' === '4'"
|
|
|
+ label="评论关键词"
|
|
|
+ prop="requireConf"
|
|
|
+ style="margin-top: 20px;"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="form.requireConf"
|
|
|
+ placeholder="请输入评论关键词,例如:666、抽奖、我要中奖"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ <span style="display: block; margin-top: 5px; font-size: 12px; color: #909399;">
|
|
|
+ 💡 提示:用户发送包含该关键词的评论即可参与抽奖
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持续时间" prop="duration" :style="form.require+'' === '4' ? '' : 'margin-top: 50px;'">
|
|
|
<el-input v-model="form.duration" placeholder="请输入持续时间 单位:分" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="抽奖标题" prop="desc">
|
|
|
@@ -356,11 +378,50 @@
|
|
|
<el-button type="primary" @click="recordShow = false">关 闭</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <!-- 自动化抽奖设置对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="设置自动化抽奖"
|
|
|
+ :visible.sync="autoLotteryDialogVisible"
|
|
|
+ width="500px"
|
|
|
+ append-to-body
|
|
|
+ >
|
|
|
+ <el-form ref="autoLotteryForm" :model="autoLotteryForm" :rules="autoLotteryRules" label-width="130px">
|
|
|
+ <el-form-item label="抽奖ID" prop="lotteryId">
|
|
|
+ <el-input v-model="autoLotteryForm.lotteryId" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持续时间" prop="duration">
|
|
|
+ <el-input v-model="autoLotteryForm.duration" disabled>
|
|
|
+ <template slot="append">分钟</template>
|
|
|
+ </el-input>
|
|
|
+ <span style="display: block; margin-top: 5px; font-size: 12px; color: #909399;">
|
|
|
+ 💡 提示:抽奖将持续 {{ autoLotteryForm.duration }} 分钟后自动结算
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="自动开始时间" prop="autoStartTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="autoLotteryForm.autoStartTime"
|
|
|
+ type="datetime"
|
|
|
+ placeholder="请选择抽奖自动开始时间"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ style="width: 100%"
|
|
|
+ :picker-options="startTimePickerOptions"
|
|
|
+ />
|
|
|
+ <span v-if="calculatedEndTime" style="display: block; margin-top: 5px; font-size: 12px; color: #67C23A;">
|
|
|
+ ⏰ 预计结束时间:{{ calculatedEndTime }}
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="autoLotteryDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submitAutoLottery" :loading="autoLotterySubmitting">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listLiveLotteryConf, getLiveLotteryConf, delLiveLotteryConf, addLiveLotteryConf, updateLiveLotteryConf, exportLiveLotteryConf } from "@/api/live/liveLotteryConf";
|
|
|
+import { listLiveLotteryConf, getLiveLotteryConf, delLiveLotteryConf, addLiveLotteryConf, updateLiveLotteryConf, exportLiveLotteryConf, setAutoLottery } from "@/api/live/liveLotteryConf";
|
|
|
import LiveLotteryProductConf from '@/views/live/liveLotteryProductConf/index.vue'
|
|
|
import {
|
|
|
listStoreProduct,
|
|
|
@@ -372,10 +433,49 @@ import {info} from '@/api/live/liveUserLotteryRecord'
|
|
|
export default {
|
|
|
name: "LiveLotteryConf",
|
|
|
components: { LiveLotteryProductConf },
|
|
|
+ computed: {
|
|
|
+ // 计算预计结束时间
|
|
|
+ calculatedEndTime() {
|
|
|
+ if (this.autoLotteryForm.autoStartTime && this.autoLotteryForm.duration) {
|
|
|
+ const startTime = new Date(this.autoLotteryForm.autoStartTime);
|
|
|
+ const durationMinutes = parseInt(this.autoLotteryForm.duration);
|
|
|
+ const endTime = new Date(startTime.getTime() + durationMinutes * 60 * 1000);
|
|
|
+
|
|
|
+ const year = endTime.getFullYear();
|
|
|
+ const month = String(endTime.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(endTime.getDate()).padStart(2, '0');
|
|
|
+ const hours = String(endTime.getHours()).padStart(2, '0');
|
|
|
+ const minutes = String(endTime.getMinutes()).padStart(2, '0');
|
|
|
+ const seconds = String(endTime.getSeconds()).padStart(2, '0');
|
|
|
+
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
recordList:[],
|
|
|
recordShow: false,
|
|
|
+ // 自动化抽奖对话框
|
|
|
+ autoLotteryDialogVisible: false,
|
|
|
+ autoLotterySubmitting: false,
|
|
|
+ autoLotteryForm: {
|
|
|
+ lotteryId: '',
|
|
|
+ duration: 0,
|
|
|
+ autoStartTime: ''
|
|
|
+ },
|
|
|
+ autoLotteryRules: {
|
|
|
+ autoStartTime: [
|
|
|
+ { required: true, message: '请选择自动开始时间', trigger: 'change' },
|
|
|
+ { validator: this.validateStartTime, trigger: 'change' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ startTimePickerOptions: {
|
|
|
+ disabledDate: (time) => {
|
|
|
+ return time.getTime() < Date.now() - 8.64e7; // 禁止选择今天之前的日期
|
|
|
+ }
|
|
|
+ },
|
|
|
//字典
|
|
|
requireOptions: [],
|
|
|
// 抽奖状态
|
|
|
@@ -589,9 +689,14 @@ export default {
|
|
|
return this.selectDictLabel(this.lotteryStatusOptions, row.lotteryStatus);
|
|
|
},
|
|
|
validRequireConf(rule, value, callback) {
|
|
|
- if(this.form.require+"" === "2" || this.form.require+"" === "3"){
|
|
|
- if(!value){
|
|
|
- callback(new Error());
|
|
|
+ // 当参与方式为"送礼参与"(2)、"下单参与"(3)或"评论参与"(4)时,requireConf不能为空
|
|
|
+ if(this.form.require+"" === "2" || this.form.require+"" === "3" || this.form.require+"" === "4"){
|
|
|
+ if(!value || value.trim() === ""){
|
|
|
+ if(this.form.require+"" === "4") {
|
|
|
+ callback(new Error('请输入评论关键词'));
|
|
|
+ } else {
|
|
|
+ callback(new Error('当参与方式选择为送礼参与或下单参与时,对应的配置不能为空'));
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -870,6 +975,73 @@ export default {
|
|
|
this.download(response.msg);
|
|
|
this.exportLoading = false;
|
|
|
}).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 自动化抽奖按钮操作 */
|
|
|
+ handleAutoLottery(row) {
|
|
|
+ // 重置表单
|
|
|
+ this.autoLotteryForm = {
|
|
|
+ lotteryId: row.lotteryId,
|
|
|
+ duration: row.duration || 0,
|
|
|
+ autoStartTime: ''
|
|
|
+ };
|
|
|
+ // 清空验证
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.autoLotteryForm) {
|
|
|
+ this.$refs.autoLotteryForm.clearValidate();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.autoLotteryDialogVisible = true;
|
|
|
+ },
|
|
|
+ /** 验证自动开始时间 */
|
|
|
+ validateStartTime(rule, value, callback) {
|
|
|
+ if (!value) {
|
|
|
+ callback(new Error('请选择自动开始时间'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const startTime = new Date(value).getTime();
|
|
|
+ const now = Date.now();
|
|
|
+ if (startTime < now) {
|
|
|
+ callback(new Error('自动开始时间不能早于当前时间'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 提交自动化抽奖设置 */
|
|
|
+ submitAutoLottery() {
|
|
|
+ this.$refs.autoLotteryForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.autoLotterySubmitting = true;
|
|
|
+
|
|
|
+ const { lotteryId, autoStartTime } = this.autoLotteryForm;
|
|
|
+
|
|
|
+ // 前端计算结束时间 = 开始时间 + 持续时间(分钟)
|
|
|
+ const autoSettlementTime = this.calculatedEndTime;
|
|
|
+
|
|
|
+ console.log('自动化抽奖设置请求参数:', { lotteryId, autoStartTime, autoSettlementTime });
|
|
|
+
|
|
|
+ // 调用接口
|
|
|
+ setAutoLottery(lotteryId, autoStartTime, autoSettlementTime)
|
|
|
+ .then(response => {
|
|
|
+ console.log('自动化抽奖设置返回数据:', response);
|
|
|
+
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('自动化抽奖设置成功');
|
|
|
+ this.autoLotteryDialogVisible = false;
|
|
|
+ this.getList(); // 刷新列表
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '设置失败');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('自动化抽奖设置失败:', error);
|
|
|
+ this.$message.error('设置失败,请稍后重试');
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.autoLotterySubmitting = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|