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.
 
 
 
 
 
 

675 lines
23 KiB

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<!--#include file="/widget/head.html"-->
</head>
<body class="layui-layout-body" layadmin-themealias="default">
<div id="wrapper" class="layui-fluid">
<!--#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="layui-card-header">
<h2>玩家数据查询</h2>
</div>
<div class="layui-row layui-col-space10">
<div class="layui-form layui-col-md12">
<div class="col-md-1" style="width:50px;"><label
style="font-size: 15px;line-height: 35px;float: left">UID:</label></div>
<div class="form-group col-md-1"><input type="text" class=" layui-input" id="uid"
placeholder="Enter Uid"></div>
<div class="col-md-1" style="width:100px;">
<label style="font-size: 15px;line-height: 35px;float: left">DB名称:</label>
</div>
<form>
<div class="form-group col-md-2" style="width:200px;">
<select class="form-control" id="dbName" lay-search lay-filter="dbName">
<option value="AccountData">账号信息</option>
<option value="RoleBase">RoleBase数据</option>
<option value="RoleData">RoleData所有数据</option>
<option value="DropRateData">DropRateData所有数据</option>
<option value="TaskEXDataList">任务列表数据</option>
<option value="MailData">MailData数据</option>
<option value="WeeklyBattlePass">周BattlePass</option>
<option value="PandoraBag">背包数据</option>
</select>
</div>
<div class="col-md-1" style="width:100px;">
<label style="font-size: 15px;line-height: 35px;float: left">基础属性:</label>
</div>
<div class="form-group col-md-2">
<select class="form-control" id="fieldName" lay-search lay-filter="fieldNameSelect">
</select>
</div>
<div id="subPath">
</div>
</form>
<div class="form-group col-md-4">
<button type="button" class=" layui-btn " id="sele">查询</button>
<button type="button" class=" layui-btn" style="display:none;" id="unlockBp">解锁周BP</button>
<button type="button" class=" layui-btn" style="display:none;" id="mailDelDiv">删除邮件</button>
<button type="button" class=" layui-btn" style="display:none;" id="costItemDiv">更改道具
</button>
<button type="button" class=" layui-btn" style="display:none;" id="doneTask">完成任务</button>
<button type="button" class=" layui-btn" style="display:none;" id="dumpData">下载数据</button>
<button type="button" class=" layui-btn" style="display:none;" id="importData">导入数据</button>
</div>
</div>
</div>
<div class="layui-card-body">
<pre id='preId' class="layui-code" style="white-space: pre-line;"></pre>
<div id="dataTableDiv">
<table class="layui-table" id="dataTable"></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--#include file="/widget/tail.html"-->
<script type="text/javascript">
layui.use(['layer', 'jquery', 'form'], function () {
$ = layui.jquery;
layui.form.on('select(dbName)', function (data) {
clearSubPath();
var dbName = $("#dbName").select().val();
if (dbName == "RoleData") {
InitRoleSelect();
}else{
$("#fieldName").html("");
layui.form.render();
}
});
layui.form.on('select(fieldNameSelect)', function (data) {
clearSubPath();
});
layui.form.on('select(subFieldName)', function (data) {
var dataSize = $(data.elem).attr('data');
OnChangeSubPath(dataSize)
});
});
//--------------------把线上一个玩家得数据下载到本地,然后导入到本地来,不用全部导入线上所有数据,方便测试
//下载数据
$("#dumpData").click(function () {
var uid = $("#uid").val();
if (uid == null || uid == "") {
layer.alert('请输入uid先查询', {icon: 2});
return;
}
var data = {};
data.token = cookie.get("token");
data.Account = uid;
data.uid = uid;
data.AccountType = 0;
data.dbName = "Dump";
$.ajax({
type: "get",
url: Page.SvrIp + "/api/player_monitor",
data: data,
dataType: "json",
success: function (d) {
if (d.ret == 0) {
download_fdb(uid + ".fdb", d.data)
}
},
error: function () {
alert("保存失败");
}
});
});
//上传数据,
$("#importData").click(function () {
layer.open({
title: '上传fdb数据',
type: 1,
area: ['500px', '200px'],
btn: ['确认上传', '取消操作'],
content: ' <div class="form-group col-md-4"><button type="button" class="layui-btn" value="" onclick="uidtext.click();" >' +
'<i class="layui-icon layui-icon-upload" id="fileName">UID文本文件</i>' +
'</button><input type="file" id="uidtext" onchange="readtext();" style="display:none;"></div>',
btn1: function (index, layero) {
importData(index)
},
btn2: function (index, layero) {
layer.close(index)
return false;
}
});
});
function importData(index) {
if (reader == null) {
layer.msg("请选择所下载的fdb文件");
return false;
}
var context = reader.result;
var data = btoa(context)
var uid = $("#uid").val();
$.get(Page.SvrIp + "/api/import_role_data",
{
uid: uid,
token: cookie.get("token"),
data: data
}, function (d) {
if (d.ret == 0) {
layer.msg('导入完成', {icon: 1});
layer.close(index)
} else {
layer.msg('导入失败', {icon: 2});
}
});
}
var reader = null;
function readtext() {
var file = $("#uidtext")[0].files[0];
if (file) {
var index = file.name.lastIndexOf(".");//获取最后一个.的位置
var ext = file.name.substr(index + 1);//获取后缀
var pattern = /^(txt|fdb)$/;
$("#fileName").text(file.name);
if (!pattern.test(ext)) {
reader = null;
layer.msg("请选择所下载的fdb文件");
return false;
}
reader = new FileReader();
reader.readAsText(file);
reader.onload = function () {
}
}
}
//----------------------------------------------------------------
function download_fdb(filename, texturl) {
var data = getDecode(texturl);
data = "\ufeff" + data;
let blob = new Blob([data], {type: 'text/plain,charset=UTF-8'});
let url = URL.createObjectURL(blob);
let a = document.createElement("a");
a.download = filename;
a.href = url;
a.click();
}
function getDecode(str) {
return atob(str);
}
$("#sele").click(function () {
var uid = $("#uid").val();
if (uid == null || uid == "") {
layer.alert('请输入账号', {icon: 2});
return;
}
var dbName = $("#dbName").select().val();
var fieldName = $("#fieldName").select().val();
var loadIndex = layer.load(0);
let timeout = true;
var subFieldName = "";
if (dbName == "RoleData") {
for (let i = 1; i <= subPathListSize; i++) {
var t = $("#fieldName" + i).select().val();
if (t != "") {
subFieldName += t + ".";
}
}
}
setTimeout(() => {
layer.close(loadIndex)
if (timeout) {
layer.msg("request timeout");
}
}, 5000);
$.get(Page.SvrIp + "/api/player_monitor",
{
Account: uid,
uid: uid,
token: cookie.get("token"),
AccountType: 0,
dbName: dbName,
fieldName: fieldName,
subPath: subFieldName,
},
function (d) {
timeout = false;
layer.close(loadIndex)
$("#preId").val('');
console.dir('request info :')
console.dir(d)
CloseTable()
if (d.code == 0) {
if (d.type == 1) {
$("#preId").show();
document.getElementById('preId').innerHTML = d.data;
} else {
var data = JSON.stringify(d.data, null, 4);
document.getElementById('preId').innerHTML = data;
$("#preId").show();
if (d.type == 3) {//表格显示
$("#preId").hide();
ShoTable(d.data)
}
}
$("#dumpData").hide();
$("#importData").hide();
$("#costItemDiv").hide();
$("#mailDelDiv").hide();
$("#unlockBp").hide()
$("#doneTask").hide();
switch (dbName) {
case "PandoraBag":
packageIds = d.data
$("#costItemDiv").show();
break;
case "MailData":
$("#mailDelDiv").show();
break;
case "WeeklyBattlePass":
$("#unlockBp").show()
break;
case "TaskEXDataList":
$("#doneTask").show()
break;
case "RoleData":
if(d.isOnline==0){
//只有线下才可以用这个功能
$("#importData").show();
}
$("#dumpData").show();
if (d.tailFieldSize != undefined && d.tailFieldSize != subPathListSize) {
//若是父级和子集名字一样呢???这不就傻逼了
if (tailFiledName != d.tailFiledName && d.tailFiledName != undefined) {
tailFiledName = d.tailFiledName;
let subType = d.subType;
structFinish = !d.isStruct;
if (subType != undefined && subType != null && Array.isArray(subType)) {
subPathListSize++;
InitSubPath(subType);
}
}
}
break
default:
break;
}
} else {
layer.alert('输入错误,请检查', {icon: 2});
$("#dumpData").hide();
$("#importData").hide();
$("#preId").val('');
}
}
);
});
$(function () {
layui.form.render();
$(document).on('dblclick', 'pre', function () {
var $pre = $(this);
var text = $pre.text();
console.log(structFinish);
if (!structFinish) {
return;
}
var $textarea = $('<textarea class="layui-textarea"></textarea>').val(text);
$pre.replaceWith($textarea);
$textarea.focus();
$textarea.on('blur', function () {
saveChanges(text, $textarea);
});
});
})
function saveChanges(oldvalue, $textarea) {
var newText = $textarea.val();
var $newPre = $('<pre id="preId"></pre>').text(newText);
$textarea.replaceWith($newPre);
layui.form.render();
if (oldvalue === newText) {
return;
}
let path = GetUpdatePath("RoleData");
layui.layer.msg('确定要把 RoleData.'+path+'=>'+oldvalue+' 的值修改为'+newText+'?', {
time: 200000, //20s后自动关闭
btn: ['确定', '再想想'],
yes: function (index, layero) {
UpdateRoleData(newText)
layui.layer.msg('提交成功,请刷新');
},
btn2: function (index, layero) {
layui.layer.msg('暂不修改,请再想想');
},
});
}
function UpdateRoleData(newValue) {
var uid = $("#uid").val();
if (uid == null || uid == "") {
layer.alert('请输入账号', {icon: 2});
return;
}
var dbName = $("#dbName").select().val();
let timeout = true;
var subFieldName = GetUpdatePath(dbName);
if (subFieldName === "") {
return;
}
var loadIndex = layer.load(0);
setTimeout(() => {
layer.close(loadIndex)
if (timeout) {
layer.msg("request timeout");
layer.closeAll();
}
}, 5000);
$.get(Page.SvrIp + "/api/update_role_data",
{
Account: uid,
uid: uid,
token: cookie.get("token"),
subPath: subFieldName,
newValue: newValue,
},
function (d) {
timeout = false;
layer.close(loadIndex)
if (d.code == 0) {
layer.msg("修改成功");
} else {
layer.alert('输入错误,请检查', {icon: 2});
$("#preId").val('');
}
}
);
}
function GetUpdatePath(dbName){
var subFieldName = $("#fieldName").select().val();
if (subFieldName == '' || subFieldName == null) {
layer.alert('请选择需要修改的数据', {icon: 2});
return '';
}
subFieldName += ".";
if (dbName != "RoleData") {
layer.alert('请选择需要修改的数据', {icon: 2});
return '';
}
for (let i = 1; i <= subPathListSize; i++) {
var t = $("#fieldName" + i).select().val();
if (t != "") {
if (t.includes("[")) {
subFieldName = subFieldName.substring(0, subFieldName.length - 1) + t + ".";
} else {
subFieldName += t + ".";
}
}
}
return subFieldName;
}
function InitRoleSelect() {
$.get(Page.SvrIp + "/api/player_role_field", {}, function (d) {
$("#fieldName").html("");
if (d.data == undefined) {
return;
}
$("#fieldName").append('<option value="">请选择字段</option>');
for (var i = 0; i < d.data.length; i++) {
$("#fieldName").append('<option value="' + d.data[i] + '">' + d.data[i] + '</option>');
}
layui.form.render();
});
}
function clearSubPath() {
let obj = $("#subPath");
obj.html('');
subPathListSize = 0;
tailFiledName = "";
layui.form.render();
}
function OnChangeSubPath(changeSize) {
//大于这个的都要清理掉
subPathListSize = changeSize;
$('#subPath .form-group').each(function () {
var id = parseInt($(this).attr('id'), 10);
if (id > changeSize) {
$(this).remove();
}
});
layui.form.render();
}
function InitSubPath(subPath) {
let obj = $("#subPath");
let size = subPathListSize;
let op = '<option value="">请选择字段</option>';
for (const i in subPath) {
op += '<option value="' + subPath[i] + '">' + subPath[i] + '</option>';
}
let id = "fieldName" + size;
let html = '<div class="form-group col-md-2" id="' + size + '"><select class="form-control" data="' + size + '" id="' + id + '"' + ' lay-search lay-filter="subFieldName">' + op + '</select></div>';
obj.append(html);
layui.form.render();
}
function ShoTable(data) {
if (data.length == 0) {
return;
}
head = data[0];
var keys = Object.keys(head)
var fds = new Array();
for (i = 0; i < keys.length; i++) {
fds.push({field: keys[i], title: keys[i], width: 120, sort: true})
}
layui.use('table', function () {
var table = layui.table;
// 已知数据渲染
var inst = table.render({
id: "table",
elem: '#dataTable',
cols: [fds],
data: data,
skin: 'line', // 表格风格
even: true,
page: false, // 是否显示分页
limits: [5, 10, 15],
limit: 256 // 每页默认显示的数量
});
});
}
function CloseTable() {
$("#dataTableDiv").html('<table class="layui-table" id="dataTable"></table>')
}
$("#costItemDiv").click(function () {
var uid = $("#uid").val();
opennotice(uid)
});
$("#mailDelDiv").click(function () {
var uid = $("#uid").val();
deleteMail(uid)
});
$("#unlockBp").click(function () {
var uid = $("#uid").val();
unLockBattlePass(uid)
});
$("#doneTask").click(function () {
var uid = $("#uid").val();
doneTask(uid)
});
function unLockBattlePass(uid) {
layer.prompt({title: '解锁玩家:' + uid + "的周BP", formType: 0}, function (name, index) {
console.dir(name, index);
$.ajax({
type: "get",
url: Page.SvrIp + "/api/unlock_player_weekly_bp",
data: {uid: uid, ActID: name, token: cookie.get("token")},
dataType: "json",
success: function (d) {
if (d.code == 0) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
layer.msg('操作完成');
} else {
layer.msg(d.msg);
}
},
error: function (status) {
console.dir(status)
parent.layer.close(parent.layer.getFrameIndex(window.name));
// parent.location.reload();
}
});
});
}
function doneTask(uid) {
layer.prompt({title: '完成玩家:' + uid + "的任务", formType: 0}, function (name, index) {
console.dir(name, index);
if (name == "") {
layer.msg('输入任务ID');
return;
}
$.ajax({
type: "get",
url: Page.SvrIp + "/api/update_player_task",
data: {uid: uid, taskId: name, token: cookie.get("token")},
dataType: "json",
success: function (d) {
if (d.code == 0) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
layer.msg('操作完成');
} else {
layer.msg(d.msg);
}
},
error: function (status) {
console.dir(status)
parent.layer.close(parent.layer.getFrameIndex(window.name));
// parent.location.reload();
}
});
});
}
function deleteMail(uid) {
layer.prompt({title: '删除玩家:' + uid + "的邮件", formType: 0}, function (name, index) {
console.dir(name, index);
$.ajax({
type: "get",
url: Page.SvrIp + "/api/delete_player_mail",
data: {uid: uid, mailId: name, token: cookie.get("token")},
dataType: "json",
success: function (d) {
if (d.code == 0) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
layer.msg('操作完成');
}
},
error: function (status) {
console.dir(status)
parent.layer.close(parent.layer.getFrameIndex(window.name));
// parent.location.reload();
}
});
});
}
var packageIds
let subPathListSize = 0;
var tailFiledName = "";
var structFinish = false;
function opennotice(uid) {
let title = "扣除道具";
layer.open({
content: `/pages/EditBagCost.html?uid=${uid}`,
type: 2,
title: title,
area: ['550px', '350px'],
success: function (layero, index) {
// 获取弹窗中的iframe元素
var iframe = layero.find('iframe')[0];
// 向iframe传递数据
iframe.contentWindow.postMessage({data: uid}, '*');
}
});
}
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
}
$(function () {
//initPage('玩家数据查询');
});
</script>
<script src="../js/coupon.js"></script>
</body>
</html>