biliob/Web/html/ui/createConfig.html
2024-11-01 00:15:12 +08:00

189 lines
7.3 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">录制日期</label>
<div class="layui-input-block">
<input type="checkbox" checked name="week_1" title="周一" lay-skin="tag">
<input type="checkbox" checked name="week_2" title="周二" lay-skin="tag">
<input type="checkbox" checked name="week_3" title="周三" lay-skin="tag">
<input type="checkbox" checked name="week_4" title="周四" lay-skin="tag">
<input type="checkbox" checked name="week_5" title="周五" lay-skin="tag">
<input type="checkbox" checked name="week_6" title="周六" lay-skin="tag">
<input type="checkbox" checked 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(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(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(that) {
layer.tips('是从开始到结束时间范围内,主播开播会启动录制,超过结束范围不会中断正在录制的任务', that);
}
var roomId = getParam("roomId");
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)
addRoomConfig(field)
.then(json => {
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
});
function init() {
getUserInfo();
if (roomId !== null) {
$('#btn_reset').get(0).disabled = true;
editRoom()
}
}
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,
};
for (let i = 0; i < json.weeks.length; i++) {
result[`week_${json.weeks[i]}`] = true;
}
form.val('form-filter',result);
$('#url').get(0).disabled = true;
}
})
}
init();
});
</script>