biliob/Web/html/ui/createConfig.html

253 lines
9.9 KiB
HTML

<head>
<link rel="stylesheet" href="/layui/css/layui.css">
<style>
.layui-form-label {
width: 120px !important;
}
</style>
</head>
<body>
<input id="value" value="" type="hidden" />
<form class="layui-form layui-form-pane" action="" lay-filter="form-filter">
<div class="layui-form-item">
<label class="layui-form-label">直播房间地址</label>
<div class="layui-input-inline" style="width: 60%;">
<input type="text" id="url" name="url" autocomplete="off" placeholder="https://live.bilibili.com/xxxxx"
lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">录制弹幕</label>
<div class="layui-input-block">
<input type="checkbox" name="recordDanmu" lay-skin="switch" lay-filter="switchTest" title="启用|禁用">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">录制视频</label>
<div class="layui-input-block">
<input type="checkbox" name="recordLive" lay-skin="switch" lay-filter="switchTest" title="启用|禁用">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">录制视频时<br>同步录制弹幕</label>
<div class="layui-input-block"><br>
<input type="checkbox" name="syncDanmuForLive" lay-skin="switch" lay-filter="switchSync" title="启用|禁用">
<i class="layui-icon layui-icon-help layui-text-em " onclick="timeTips2(this)"></i>
<br>
<br>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">录制日期</label>
<div class="layui-input-block">
<input type="checkbox" name="week_1" title="周一" lay-skin="tag">
<input type="checkbox" name="week_2" title="周二" lay-skin="tag">
<input type="checkbox" name="week_3" title="周三" lay-skin="tag">
<input type="checkbox" name="week_4" title="周四" lay-skin="tag">
<input type="checkbox" name="week_5" title="周五" lay-skin="tag">
<input type="checkbox" name="week_6" title="周六" lay-skin="tag">
<input type="checkbox" name="week_7" title="周日" lay-skin="tag">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">弹幕录制时间</label>
<div class="layui-input-inline">
<input type="text" name="recordDanmuDate" id="recordDanmuDate" value="00:00:00 - 23:59:59"
lay-verify="required" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid layui-text-em" onclick="timeTips(false,this)"><i
class="layui-icon layui-icon-help"></i> </div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">视频录制时间</label>
<div class="layui-input-inline">
<input type="text" name="recordLiveDate" id="recordLiveDate" value="00:00:00 - 23:59:59"
lay-verify="required" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid layui-text-em" onclick="timeTips(true,this)"><i
class="layui-icon layui-icon-help"></i> </div>
</div>
<div class="layui-inline">
<label class="layui-form-label">录制绑定用户</label>
<div id="selects" class="layui-input-inline">
</div>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="submit-form">确认</button>
<button id="btn_reset" type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
</body>
<script id="selectUser" type="text/html">
<select id="recordUid" name="recordUid" lay-search>
<option value="">不登陆</option>
{{# layui.each(d.data, function(index, item){ }}
<option value="{{= item.uid}}">[{{=item.uid}}]{{= item.uname}}</option>
{{# }); }}
</select>
</script>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/httpUtils.js"></script>
<script src="/js/CommonConfig.js"></script>
<script>
function timeTips(isLive, that) {
if (isLive) {
layer.tips('是从开始到结束时间范围内,主播开播会启动录制,超过结束范围不会中断正在录制的任务', that);
} else {
layer.tips('仅在当前时间范围内录制,如遇到正在直播,则延迟到下播时停止录制', that);
}
}
function timeTips2(that) {
layer.tips('启用后,录制视频时会同步录制弹幕,下播后会同步停止录制.同时上面录制弹幕按钮将失效', that);
}
var roomId = getParam("roomId");
var editArray = getParam("array")
layui.use(['form', 'laytpl', 'laydate'], function () {
var form = layui.form;
var layer = layui.layer;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var windowsIndex;
form.render();
// 提交事件
form.on('submit(submit-form)', function (data) {
var field = data.field; // 获取表单字段值
windowsIndex = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
// 显示填写结果,仅作演示用
// 此处可执行 Ajax 等操作
// …
var weeks = [
]
for (let i = 1; i <= 7; i++) {
if (field[`week_${i}`] === 'on') {
weeks.push(i.toString());
}
}
field.weeks = weeks;
console.log(field)
if (editArray === null) {
var loadIndex = showLoadingDialog();
addRoomConfig(field)
.then(json => {
layer.close(loadIndex)
layer.msg(json.message, function () {
if (json.status == 100) {
close()
}
})
})
} else {
var array = []
editArray.split(',').forEach(element => {
array.push(element)
});
var loadIndex = showLoadingDialog();
setArrayRoomConfig(array, field)
.then(json => {
layer.close(loadIndex)
layer.msg(json.message, function () {
if (json.status == 100) {
close()
}
})
})
}
return false; // 阻止默认 form 跳转
});
function close() {
parent.layer.close(windowsIndex);
}
laydate.render({
elem: '#recordDanmuDate',
type: 'time',
range: true
});
laydate.render({
elem: '#recordLiveDate',
type: 'time',
range: true
});
form.on('switch(switchSync)', function (data) {
if (form.val('form-filter').syncDanmuForLive === 'on') {
$("[name='recordDanmu']").prop("disabled", true);
} else {
$("[name='recordDanmu']").prop("disabled", false);
}
form.render();
});
function init() {
getUserInfo();
if (roomId !== null) {
$('#btn_reset').get(0).disabled = true;
editRoom()
}
if (editArray !== null) {
editArrayRoom()
}
}
function getUserInfo() {
getBiliAllUser()
.then(data => {
var view = $("#selects").get(0);
laytpl($('#selectUser').get(0).innerHTML).render(data, function (html) {
view.innerHTML = html
form.render('select');
});
});
}
function editRoom() {
getRoomConfig(roomId)
.then(data => {
if (data.status === 100) {
var json = data.data;
var result = {
'url': 'https://live.bilibili.com/' + json.live_room_id,
'recordLive': json.recordLive,
'recordDanmu': json.recordDanmu,
'recordDanmuDate': json.recordDanmuDate,
'recordLiveDate': json.recordLiveDate,
'syncDanmuForLive': json.syncDanmuForLive,
};
for (let i = 0; i < json.weeks.length; i++) {
result[`week_${json.weeks[i]}`] = true;
}
form.val('form-filter', result);
if (json.syncDanmuForLive) {
$("[name='recordDanmu']").prop("disabled", true);
} else {
$("[name='recordDanmu']").prop("disabled", false);
}
$('#url').get(0).disabled = true;
}
})
}
function editArrayRoom() {
$('#btn_reset').get(0).disabled = true;
$('#url').get(0).disabled = true;
var result = {
'url': editArray
};
form.val('form-filter', result);
}
init();
});
</script>