biliob/Web/html/ui/createConfig.html
2024-10-31 18:23:39 +08:00

175 lines
6.7 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" name="2" title="周一" lay-skin="tag">
<input type="checkbox" name="3" title="周二" lay-skin="tag">
<input type="checkbox" name="4" title="周三" lay-skin="tag">
<input type="checkbox" name="5" title="周四" lay-skin="tag">
<input type="checkbox" name="6" title="周五" lay-skin="tag">
<input type="checkbox" name="7" title="周六" lay-skin="tag">
<input type="checkbox" name="1" 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" 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" 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('填写[分钟][小时][星期],空格分割,例如预定每周6晚上8点之后才开始录制则填写:* 8 6', 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 等操作
// …
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;
form.val('form-filter', {
'url': 'https://live.bilibili.com/' + json.live_room_id,
'recordLive': json.recordLive,
'recordDanmu': json.recordDanmu,
'recordDanmuDate': json.recordDanmuDate,
'recordLiveDate': json.recordLiveDate
});
$('#url').get(0).disabled = true;
}
})
}
init();
});
</script>