biliob/Web/html/body/user.html

235 lines
7.9 KiB
HTML
Raw Normal View History

2024-10-29 18:29:56 +08:00
<!DOCTYPE html>
<html lang="zh-CN">
2024-11-01 18:21:57 +08:00
2024-10-29 18:29:56 +08:00
<head>
2024-11-01 18:21:57 +08:00
<meta charset="utf-8">
2024-11-08 18:12:02 +08:00
<title>用户中心</title>
2024-11-01 18:21:57 +08:00
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/layui/css/layui.css">
2024-10-29 18:29:56 +08:00
</head>
2024-11-01 18:21:57 +08:00
<body class="layui-bg-gray">
<div id="header"></div>
2024-11-08 18:12:02 +08:00
<table class="layui-hide" id="roomList" lay-filter="roomTable"></table>
2024-11-01 18:21:57 +08:00
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
2024-11-08 18:12:02 +08:00
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" onclick="createRoom()">添加新账号</button>
</div>
</script>
<script type="text/html" id="toolDemo">
<div class="layui-clear-space">
2024-11-21 18:29:19 +08:00
<a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
2024-11-27 17:39:02 +08:00
<!-- <a class="layui-btn layui-btn-xs" lay-event="input">导入关注</a> -->
<a class="layui-btn layui-btn-xs" lay-event="more">
导入
<i class="layui-icon layui-icon-down"></i>
</a>
2024-11-08 18:12:02 +08:00
</div>
</script>
2024-11-01 18:21:57 +08:00
<script>
headerModel = 4;
2024-10-29 18:29:56 +08:00
$('#header').load("/html/header.html");
2024-11-08 18:12:02 +08:00
function createUser() {
2024-11-18 18:27:49 +08:00
layer.open({
type: 2,
title: "添加新房间",
area: ['600px', '500px'],
content: '/html/ui/createConfig.html?roomId='
2024-11-08 18:12:02 +08:00
2024-11-18 18:27:49 +08:00
});
2024-11-08 18:12:02 +08:00
}
2024-11-21 18:29:19 +08:00
function refresh(data) {
var loadIndex = showLoadingDialog();
2024-11-21 18:29:19 +08:00
refreshCookie(data)
.then(data => {
console.log(data)
layer.close(loadIndex)
2024-11-21 18:29:19 +08:00
layer.msg(data.message)
})
2024-11-08 18:12:02 +08:00
}
2024-11-18 18:27:49 +08:00
function createRoom() {
login()
.then(data => {
if (data.status === 300) {
layer.open({
type: 1, // page 层类型
area: ['320px', '400px'],
title: '打开B站客户端扫码登陆',
shade: 0.6, // 遮罩透明度
shadeClose: false, // 点击遮罩区域,关闭弹层
maxmin: true, // 允许全屏最小化
anim: 1, // 0-6 的动画形式,-1 不开启
2024-11-21 18:29:19 +08:00
content: '<div style="padding: 32px;text-align: center;" id="qrdiv"><span id="loginTip">登陆后刷新</span></div>',
2024-11-18 18:27:49 +08:00
success: function (layero, index, that) {
new QRCode(document.getElementById("qrdiv"), data.data.qrcode);
2024-11-21 18:29:19 +08:00
reloadLogin(document.getElementById("loginTip"))
2024-11-18 18:27:49 +08:00
}
});
} else if (data.status === 301) {
setTimeout(() => {
createRoom()
}, 100);
}
})
}
2024-11-21 18:29:19 +08:00
function reloadLogin(tips) {
setTimeout(() => {
login()
.then(data => {
tips.innerHTML = data.message;
if (data.code !== 302) {
reloadLogin(tips)
}
})
}, 1000);
}
2024-11-01 18:21:57 +08:00
</script>
2024-11-18 18:27:49 +08:00
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script src="/js/qrcode.min.js"></script>
2024-11-01 18:21:57 +08:00
<script>
// loadHeader($('#header').get(0))
layui.use(function () {
var dropdown = layui.dropdown;
var layer = layui.layer;
2024-11-08 18:12:02 +08:00
var table = layui.table;
2024-11-18 18:27:49 +08:00
2024-11-08 18:12:02 +08:00
table.render({
2024-11-18 18:27:49 +08:00
elem: '#roomList',
url: '/user/list',
toolbar: '#toolbarDemo',
totalRow: true, // 开启合计行
page: true,
response: {
statusCode: 100 // 重新规定成功的状态码为 200table 组件默认为 0
},
parseData: function (res) {
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"data": res.data, //解析数据列表
"count": res.count
};
},
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'uid', title: 'UID', width: 150, sort: true, fixed: 'left', templet: '<div><a href="https://space.bilibili.com/{{= d.uid}}" target="_blank">{{= d.uid}}</a>' },
{ field: 'uname', title: '用户名', width: 150, fixed: 'left' },
{ field: 'face', title: '头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.face }}\',this);" style="width: 30px;height: 30px;"></div>' },
2024-11-21 18:29:19 +08:00
{ field: 'status', title: '状态', width: 150, templet: '<div> {{= d.status}} <button class="layui-btn layui-btn-xs" onclick="refresh(\'{{= d.uid }}\')">刷新cookie</button>' },
2024-11-18 18:27:49 +08:00
{ field: 'sql_time', title: '添加时间', width: 190 },
2024-11-21 18:29:19 +08:00
{ fixed: "right", title: "操作", width: 180, align: "center", toolbar: "#toolDemo" }
2024-11-18 18:27:49 +08:00
]],
done: function () {
2024-11-21 18:29:19 +08:00
onDone();
2024-11-18 18:27:49 +08:00
},
error: function (res, msg) {
console.log(res, msg)
}
});
2024-11-08 18:12:02 +08:00
2024-11-21 18:29:19 +08:00
function onDone() {
table.on('tool(roomTable)', function (obj) {
var id = obj.config.id;
var data = obj.data;
var checkStatus = table.checkStatus(id);
var othis = lay(this);
switch (obj.event) {
2024-11-27 17:39:02 +08:00
case 'more':
dropdown.render({
elem: this, // 触发事件的 DOM 对象
show: true, // 外部事件触发即显示
data: [{
title: '关注列表',
id: 'follow'
}, {
title: '正在开播',
id: 'live'
}],
click: function (menudata) {
if (menudata.id === 'follow') {
onClickInput(data.uid)
} else if (menudata.id === 'live') {
onClickFollow(data.uid)
}
},
align: 'right', // 右对齐弹出
style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' // 设置额外样式
})
2024-11-21 18:29:19 +08:00
break;
};
});
}
function onClickInput(uid) {
layer.open({
type: 2, // page 层类型
area: ['650px', '400px'],
title: '选择主播',
shade: 0.6, // 遮罩透明度
shadeClose: false, // 点击遮罩区域,关闭弹层
maxmin: true, // 允许全屏最小化
anim: 1, // 0-6 的动画形式,-1 不开启
// btn: ['确定', '取消'],
content: '/html/ui/userFollow.html?uid=' + uid,
yes: function (index, layero) {
var iframeWin = window[layero.find('iframe')[0]['name']];
var anchorRoomId = iframeWin.$('#anchorRoomId')[0].value;
if (!hasString(anchorRoomId)) {
layer.msg("请选择")
return
}
let url = new URL(window.location.href);
url.searchParams.set('roomId', anchorRoomId);
window.location.href = url.toString();
}
});
}
2024-11-27 17:39:02 +08:00
function onClickFollow(uid) {
layer.open({
type: 2, // page 层类型
area: ['650px', '400px'],
title: '选择主播',
shade: 0.6, // 遮罩透明度
shadeClose: false, // 点击遮罩区域,关闭弹层
maxmin: true, // 允许全屏最小化
anim: 1, // 0-6 的动画形式,-1 不开启
// btn: ['确定', '取消'],
content: '/html/ui/userFollowLive.html?uid=' + uid,
yes: function (index, layero) {
var iframeWin = window[layero.find('iframe')[0]['name']];
var anchorRoomId = iframeWin.$('#anchorRoomId')[0].value;
if (!hasString(anchorRoomId)) {
layer.msg("请选择")
return
}
let url = new URL(window.location.href);
url.searchParams.set('roomId', anchorRoomId);
window.location.href = url.toString();
}
});
}
2024-11-01 18:21:57 +08:00
});
2024-11-27 17:39:02 +08:00
2024-11-01 18:21:57 +08:00
</script>
<style>
</style>
</body>
2024-10-30 18:27:37 +08:00
2024-10-29 18:29:56 +08:00
</html>