188 lines
6.0 KiB
HTML
188 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>用户中心</title>
|
||
<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">
|
||
</head>
|
||
|
||
<body class="layui-bg-gray">
|
||
<div id="header"></div>
|
||
<table class="layui-hide" id="roomList" lay-filter="roomTable"></table>
|
||
|
||
<script src="/js/jquery-3.2.1.js"></script>
|
||
<script src="/js/CommonConfig.js"></script>
|
||
<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">
|
||
<a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
|
||
<a class="layui-btn layui-btn-xs" lay-event="input">导入关注</a>
|
||
</div>
|
||
</script>
|
||
<script>
|
||
headerModel = 4;
|
||
$('#header').load("/html/header.html");
|
||
|
||
function createUser() {
|
||
layer.open({
|
||
type: 2,
|
||
title: "添加新房间",
|
||
area: ['600px', '500px'],
|
||
content: '/html/ui/createConfig.html?roomId='
|
||
|
||
});
|
||
}
|
||
function refresh(data) {
|
||
var loadIndex = showLoadingDialog();
|
||
refreshCookie(data)
|
||
.then(data => {
|
||
console.log(data)
|
||
layer.close(loadIndex)
|
||
layer.msg(data.message)
|
||
})
|
||
}
|
||
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 不开启
|
||
content: '<div style="padding: 32px;text-align: center;" id="qrdiv"><span id="loginTip">登陆后刷新</span></div>',
|
||
success: function (layero, index, that) {
|
||
new QRCode(document.getElementById("qrdiv"), data.data.qrcode);
|
||
reloadLogin(document.getElementById("loginTip"))
|
||
}
|
||
});
|
||
} else if (data.status === 301) {
|
||
setTimeout(() => {
|
||
createRoom()
|
||
}, 100);
|
||
}
|
||
})
|
||
|
||
}
|
||
function reloadLogin(tips) {
|
||
setTimeout(() => {
|
||
login()
|
||
.then(data => {
|
||
tips.innerHTML = data.message;
|
||
if (data.code !== 302) {
|
||
reloadLogin(tips)
|
||
}
|
||
})
|
||
}, 1000);
|
||
}
|
||
</script>
|
||
<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>
|
||
<script>
|
||
|
||
|
||
// loadHeader($('#header').get(0))
|
||
layui.use(function () {
|
||
var dropdown = layui.dropdown;
|
||
var layer = layui.layer;
|
||
var table = layui.table;
|
||
|
||
table.render({
|
||
elem: '#roomList',
|
||
url: '/user/list',
|
||
toolbar: '#toolbarDemo',
|
||
|
||
totalRow: true, // 开启合计行
|
||
page: true,
|
||
response: {
|
||
statusCode: 100 // 重新规定成功的状态码为 200,table 组件默认为 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>' },
|
||
{ field: 'status', title: '状态', width: 150, templet: '<div> {{= d.status}} <button class="layui-btn layui-btn-xs" onclick="refresh(\'{{= d.uid }}\')">刷新cookie</button>' },
|
||
{ field: 'sql_time', title: '添加时间', width: 190 },
|
||
{ fixed: "right", title: "操作", width: 180, align: "center", toolbar: "#toolDemo" }
|
||
]],
|
||
done: function () {
|
||
onDone();
|
||
},
|
||
error: function (res, msg) {
|
||
console.log(res, msg)
|
||
}
|
||
});
|
||
|
||
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) {
|
||
case 'input':
|
||
onClickInput(data.uid)
|
||
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();
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
});
|
||
|
||
</script>
|
||
|
||
<style>
|
||
|
||
</style>
|
||
|
||
</body>
|
||
|
||
</html> |