This commit is contained in:
2024-11-01 00:15:12 +08:00
parent 526cf7e25f
commit 45c38f56fd
24 changed files with 508 additions and 239 deletions

View File

@@ -10,17 +10,16 @@
<body>
<div id="header"></div>
<button id="btn" type="button" class="layui-btn" onclick="onButton()">默认按钮</button>
<div class="layui-row layui-col-space15">
<div id="card"></div>
</div>
</div><br>
<div id="page"></div>
</body>
<script id="liveCard" type="text/html">
{{# layui.each(d.data, function(index, item){ }}
<div class="layui-col-xs3">
<div class="layui-col-xs3 layui-col-sm3 layui-col-md3">
<div class="layui-bg-gray" style="padding: 16px;">
<div class="layui-row layui-col-space15">
<div class="layui-card">
@@ -34,7 +33,8 @@
</span>
</div>
<div class="layui-card-body">
<img src="#" onerror="showImage('{{= item.cover}}',this)" style="width: 100%; height: 100%;"/><br>
<img src="#" onerror="showTmpImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br>
<!-- <img src="#" onerror="showImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br> -->
{{= item.title}}<br>
直播录制状态:
{{# if(item.downloadVideo){ }}
@@ -64,20 +64,24 @@
<script>
headerModel = 0;
$('#header').load("/html/header.html");
function toLive(roomId){
console.log(roomId)
window.open("https://live.bilibili.com/"+roomId,'_blank')
}
function clickVideo(roomId, status) {
const title = "是否" + (status ? "停止" : "启动") + "录制视频?"
layer.confirm(title, { icon: 3 }, function () {
if (status) {
stopLiveVideo(roomId)
.then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload();
});
})
} else {
startLiveVideo(roomId)
.then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload();
});
})
@@ -93,15 +97,15 @@
if (status) {
stopLiveDanmu(roomId)
.then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload();
});
})
} else {
startLiveDanmu(roomId)
.then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload();
});
})
@@ -112,22 +116,55 @@
}
</script>
<script>
layui.use(['laytpl'], function () {
layui.use(['laytpl', 'laypage'], function () {
var laytpl = layui.laytpl;
var laypage = layui.laypage;
var pageIndex = 0;
var pageMax = 8;
var listCount=10;
var listMax=pageMax;
var initPage=true;
function initCard() {
getAllLive()
var loadIndex = layer.msg('加载中', {
icon: 16,
shade: 0.4
});
getAllLive(pageIndex, pageMax)
.then(data => {
console.log(data)
listCount=data.count;
if(initPage){
initPage=false;
initPageView();
}
var view = $("#card").get(0);
laytpl($('#liveCard').get(0).innerHTML).render(data, function (html) {
view.innerHTML = html
view.innerHTML = html;
layer.close(loadIndex)
});
})
}
function init() {
initCard()
}
function initPageView(){
laypage.render({
elem: 'page',
limit: 8,
curr: pageIndex + 1,
limits: [4, 8, 16, 24, 32, 40],
layout: ['prev', 'page', 'next', 'limit'],
count: listCount, // 数据总数
jump: function (obj, first) {
listMax=obj.limit
if (!first) {
pageIndex =obj.curr;
pageMax = obj.limit;
initCard()
}
}
});
}
init()
})
function onButton() {