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.
 
 
 
 
 
 

302 lines
10 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>U2</title>
<!--#include file="/widget/head.html"-->
</head>
<body class="layui-layout-body" layadmin-themealias="default" layadmin-themealias="default">
<div class="">
<div id="page-wrapper">
<div class="row" style="margin-top: 20px;margin-left: 130px">
<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>
</div>
<div class="row table-responsive" id="form" style="width:100%;margin-left: 130px">
<table class="table table-striped table-bordered table-hover " id="hero_table">
</table>
<div id="test1"></div>
</div>
</div>
</div>
<script type="text/javascript">
//const ServerIp = "http://127.0.0.1:8088"
const ServerIp = "http://43.138.62.206:8088"
var m_limit = 0;
$("#add").click(function () {
opennotice('');
});
var dataList;
function Delete(id) {
console.dir(id);
layer.msg('确定要删除?', {
time: 200000, //20s后自动关闭
btn: ['删除', '再想想'],
yes: function (index, layero) {
DeleteServer(id)
layer.msg('删除');
},
btn2: function (index, layero) {
layer.msg('再想想');
},
});
}
function opennotice(url) {
layer.open({
type: 1,
area: [700 + 'px', 600 + 'px'],
fix: false, //不固定
maxmin: true,
shade: 0.4,
title: '新增',
content: '<form class="layui-form" action="#">\n' +
' <div class="layui-form-item">\n' +
' <div class="layui-inline">\n' +
' <label class="layui-form-label">IP</label>\n' +
' <div class="layui-input-inline layui-input-wrap">\n' +
' <input type="text" id="IP" name="IP" value="" lay-verify="required|ip" lay-reqtext="请填IP地址" lay-affix="clear" class="layui-input demo-phone">\n' +
' </div>\n' +
' </div>\n' +
' </div>\n' +
' <div class="layui-form-item">\n' +
' <label class="layui-form-label">排序</label>\n' +
' <div class="layui-input-inline layui-input-wrap">\n' +
' <input type="text" id="order" name="order" value="" lay-verify="required" lay-affix="number" value="0" class="layui-input">\n' +
' </div>\n' +
' </div>\n' +
' <div class="layui-form-item">\n' +
' <label class="layui-form-label">名称</label>\n' +
' <div class="layui-input-inline layui-input-wrap">\n' +
' <input type="text" id="name" name="name" value="" lay-verify="required" lay-affix="clear" class="layui-input">\n' +
' </div>\n' +
' </div>\n' +
' <div class="layui-form-item">\n' +
' <label class="layui-form-label">分支</label>\n' +
' <div class="layui-input-inline layui-input-wrap">\n' +
' <input type="text" id="branch" name="branch" value="trunk" lay-verify="required" lay-affix="clear" class="layui-input">\n' +
' </div>\n' +
' </div>\n' +
' <div class="layui-form-item">\n' +
' <div class="layui-inline">\n' +
' <label class="layui-form-label">游戏端口</label>\n' +
' <div class="layui-input-inline" style="width: 100px;">\n' +
' <input type="number" id="game_port" name="game_port" placeholder="" autocomplete="off" class="layui-input" value="9710" min="0" step="1" lay-affix="number">\n' +
' </div>\n' +
' </div>\n' +
' </div>\n' +
' <div class="layui-form-item">\n' +
' <div class="layui-input-block">\n' +
' <button type="button" onclick="Submit()" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>\n' +
' <button type="reset" class="layui-btn layui-btn-primary">重置</button>\n' +
' </div>\n' +
' </div>\n' +
'</form>\n' +
' '
});
}
var herotable;
var exchange_data;
function Submit() {
debugger
let ip = $("#IP").val();
let name = $("#name").val();
let branch = $("#branch").val();
let game_port = Number($("#game_port").val());
let version_port = 8610;
let g_gate_port = 9711;
let c_gate_port = 9810;
let gm_port = 56318;
let order = $("#order").val();
let code =0;
let data = {
ip: ip,
name: name,
branch:branch,
code :code,
game_port: game_port,
version_port: version_port,
g_gate_port: g_gate_port,
c_gate_port: c_gate_port,
gm_port: gm_port,
order:order
}
let json = JSON.stringify(data);
$.ajax({
type: "POST",
url: ServerIp + "/server/create",
data:json ,
dataType: "json",
beforeSend: function () {
layer.load(1, {shade: [0.8, '#393D49']});
},
complete: function () {
layer.closeAll();
},
success: function (d) {
layer.closeAll();
Select_data(0, 20, 1);
}
});
}
function ini_page() {
layui.laypage.render({
elem: 'test1',
count: 20,
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,
autoSort: true,
limit: limit,
cols: [[
{
field: 'id',
title: '删除',
width: 120,
templet: '<div><button class="layui-btn layui-btn-xs" name="btDetailBtn" onclick="Delete({{= d.id }})">删除</button>' +
'<button class="layui-btn layui-btn-xs" name="btDetailBtn" onclick="goGm({{= d.id }})">GM</button></div>'
},
{field: 'id', title: 'id', sort: true, width: 120},
{field: 'name', title: 'name', sort: true, width: 180},
{field: 'order', title: 'order', sort: true, width: 80},
{field: 'ip', title: 'IP', sort: true, width: 200},
{field: 'code', title: '编号', sort: true, width: 100},
{field: 'game_port', title: 'game_port', sort: true, width: 100},
{field: 'version_port', title: 'version_port', sort: true, width: 100},
{field: 'g_gate_port', title: 'g_gate_port', sort: true, width: 100},
{field: 'c_gate_port', title: 'c_gate_port', sort: true, width: 100},
{field: 'gm_port', title: 'gm_port', sort: true, width: 100},
{field: 'branch', title: 'branch', sort: true, width: 100},
]]
});
}
function goGm(id){
for (const dataListKey in dataList) {
let data=dataList[dataListKey];
console.dir(data.id);
if(data.id==id){
let url="http://"+data.ip+":"+data.gm_port+"/pages/login.html"
window.open(url, '_blank');
break;
}
}
}
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
}
function Select_data(page, limit, first) {
$.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);
dataList=d;
inihero_table(dataList, limit);
if (first === 1) {
ini_page();
}
}
});
}
function DeleteServer(id) {
$.ajax({
type: "POST",
url: ServerIp + "/server/delete?id=" + id,
data: {id: id},
dataType: "json",
beforeSend: function () {
layer.load(1, {shade: [0.8, '#393D49']});
},
complete: function () {
layer.closeAll('loading');
},
success: function (d) {
layer.closeAll('loading');
Select_data(0, 20, 1);
}
});
}
$(function () {
Select_data(0, 20, 1);
});
</script>
<!--#include file="/widget/login-tail.html"-->
<script src="../bower_components/crypto-js/crypto-js.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
</head>
<body>
<style>
.demo-login-container {
width: 320px;
margin: 21px auto 0;
}
.demo-login-other .layui-icon {
position: relative;
display: inline-block;
margin: 0 2px;
top: 2px;
font-size: 26px;
}
</style>
</body>
</html>
<script type="text/javascript" src="../js/template-web.js"></script>
<script type="text/javascript" src="../js/notice/xm-select.js"></script>