You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
6.2 KiB

2 months ago
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<!--#include file="/widget/head.html"-->
<script type="text/javascript" src="../js/template-web.js"></script>
</head>
<body class="layui-layout-body" layadmin-themealias="default">
<div id="wrapper">
<!--#include file="/widget/nav.html"-->
<div id="page-wrapper" class="layui-body layadmin-tabsbody-item layui-show layui-fluid layui-row layui-col-space15">
<div class="layui-card" id="card-page-wrapper">
<div class="row">
<div class="container" style="margin-left: 1px">
<div class="col-md-1">
<button type="button" class="layui-btn pull-right" id="add">查询记录</button>
</div>
<div class="col-md-1">
<button type="button" class="layui-btn pull-right" id="outFile">导出聊天</button>
</div>
<div class="col-md-1">
<button type="button" class="layui-btn pull-right" id="reload">重新加载</button>
</div>
</div>
</div>
<div class="row table-responsive" id="form" style="width:90%">
<table class="table table-striped table-bordered table-hover inline" id="hero_table">
</table>
<div id="test1"></div>
</div>
</div>
</div>
<label style="color:blue;">关闭</label>
</div>
<script id="btn" type="text/template">
</script>
<!--#include file="/widget/tail.html"-->
<script type="text/javascript">
ServerIp="http://127.0.0.1:8088"
var m_limit = 0;
$("#add").click(function () {
opennotice();
});
$("#outFile").click(function(){
downflie();
})
function opennotice() {
Select_data(0, 20, 1);
}
var herotable;
var exchange_data;
function ini_page(data) {
layui.laypage.render({
elem: 'test1',
count: data.count,
limits: [10, 20, 30, 40, 50, 80, 100],
limit: 20,
layout: ["count", "prev", "page", "next", "limit", "skip"],
jump: function (obj, first) {
if (!first) {
Select_data(obj.curr, obj.limit, 0);
}
}
});
}
function inihero_table(data, limit) {
m_limit = limit;
console.info(data);
herotable = layui.table.render({
elem: '#hero_table',
page: false,
data: data,
width: 1300,
height: 1100,
autoSort: true,
limit: limit,
cols: [[
{ field: 'id', title: 'id', sort: true, width: 120 },
{ field: 'name', title: 'name', sort: true, width: 180 },
{ field: 'code', title: '编号', sort: true, width: 100 },
{ field: 'ip', title: 'IP', sort: true, width: 200 },
{ field: 'branch', title: 'branch', sort: true, width: 100 },
{ field: 'game_port', title: 'game_port', sort: true, width: 180 },
{ field: 'version_port', title: 'version_port', sort: true, width: 180 },
{ field: 'g_gate_port', title: 'g_gate_port', sort: true, width: 180 },
{ field: 'c_gate_port', title: 'c_gate_port', sort: true, width: 180 },
{ field: 'gm_port', title: 'gm_port', sort: true, width: 180 },
]]
});
}
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
}
function Select_data(page, limit, first) {
var channel = $("#channel").select().val();
$.ajax({
type: "GET",
url: ServerIp + "/server/list",
dataType: "json",
beforeSend: function () {
layer.load(1, { shade: [0.8, '#393D49'] });
},
complete: function () {
layer.closeAll('loading');
},
success: function (d) {
debugger;
console.dir(d);
exchange_data =d.data; //JSON.parse(d.data);
inihero_table(exchange_data, limit);
if (first === 1) {
ini_page(d);
}
}
});
}
$(function () {
initPage('聊天记录');
Select_data(0, 20, 1);
});
function downflie() {
var data = {};
data.token = cookie.get("token");
$.ajax({
type: "get",
url: Page.SvrIp + "/api/download_chat",
data: data,
dataType: "json",
success: function (d) {
if (d.ret == 0) {
// download_txt("chat_list.csv", d.data);
download_csv("chat_list.csv", d.data)
}
},
error: function () {
alert("保存失败");
}
});
}
function download_csv(filename, texturl) {
var data = getDecode(texturl);
debugger;
console.dir(data);
data = "\ufeff" + data;
let blob = new Blob([data], { type: 'text/csv,charset=UTF-8' });
let url = URL.createObjectURL(blob);
let a = document.createElement("a");
a.download = filename + ".csv";
a.href = url;
a.click();
}
function getDecode(str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
</script>
<script src="../js/coupon.js"></script>
</body>
</html>