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

748 lines
27 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>游戏登陆列表|----软件管理平台</title>
<link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/module.css">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
</head>
<style>
html {
min-width:100%;
height: 1000px;
}
body {
padding: 0px;
}
.trunk-search .form-group {
margin-left: 10px;
}
.normal_table input {
position: relative;
padding: 5px;
border: 1px solid #E5E5E5;
border-radius: 4px;
height: 25px;
}
.normal_table td {
padding: 5px;
text-align: center;
}
.normal_table td select {
width: 100%;
}
.normal_table td button {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.normal_table td button.delete-row {
background-color: rgb(249,104,104);
}
.btn-row {
position: relative;
font-size: 11px;
margin-top: 28px;
text-align: center;
}
.btn-row button {
width: 70px;
height: 35px;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
display: inline-block;
padding: 0px;
}
.btn-row button.close-btn {
background: #E5E5E5;
color: #535875;
}
.form-group .static-input {
line-height: 32px;
display: inline-block;
}
.trunk-search button {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
display: inline-block;
}
.info-row {
margin-top: 10px;
}
.info-row button {
width: auto;
height: 25px;
display: block;
background: #E5E5E5;
color: #535875;
border: none;
border-radius: 3px;
cursor: pointer;
display: inline-block;
margin-left: 10px;
padding: 0px 10px;
}
.info-row button.bind-btn {
background: #409eff;
color: #fff;
}
.form-group {
float: left;
}
.form-group input {
padding: 5px;
border: 1px solid #E5E5E5;
border-radius: 4px;
height: 24px;
}
.clearfix:after {
content: "\20";
display: block;
height: 0;
clear: both;
}
.clearfix {
*zoom: 1;
}
.select2-container--open {
z-index: 1001;
}
</style>
<body>
<div id="main" class="main" style="min-height: 342px;">
<div class="page-search normal_list promoteCoin-record-search" style="padding: 20px;">
<div class="trunk-content article">
<div class="trunk-search clearfix" style="margin-bottom: 10px;">
<form method="post" class="clearfix">
<div class="clearfix">
<div class="form-group">
<select id="game-select" name="" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择游戏</option>
<?php foreach($games as $game):?>
<option value="<?=$game['id']?>" <?php if($role && $role['game_id'] == $game['id']):?>selected<?php endif;?>>
<?=$game['game_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group">
<select id="server-select" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择区服</option>
<?php foreach($servers as $server):?>
<option value="<?=$server['id']?>" <?php if($role && $server['server_id'] == $role['server_id']):?>selected<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group">
<input id="test_account" type="text" name="account" class="txt normal_txt" placeholder="请输入测试资源账号" value="{$role.user_account}" <?php if($role):?>disabled<?php endif;?>>
</div>
<div class="form-group">
<select id="role-select" name="role_id" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="">请选择角色</option>
<?php if($role):?>
<option value="<?=$role['role_id']?>" selected><?=$role['role_name']?></option>
<?php endif;?>
</select>
</div>
</div>
<?php if($role):?>
<div class="info-row">
<?php if($bindingRole):?>
<button type="button">绑定角色: <?= $bindingRole['role_name']?></button>
<?php else:?>
<button id="bind-btn" class="bind-btn" type="button">绑定玩家角色</button>
<?php endif;?>
<div class="" style="display:inline-block; margin-left: 10px;">
当前可用额度:<span id="quota" data-quota="<?=$quota?>"><?=$quota?></span> 待审核额度:<span id="verify-quota">0</span>
</div>
</div>
<?php endif;?>
<div class="clearfix" style="margin-top: 10px;">
<input id="hasItf" type="hidden" value="<?=$hasItf?>" name="has_itf">
<?php if ($hasItf):?>
<div class="form-group fl">
<select id="resource-type-select" name="resource_type_id" style="width:150px" class="select_gallery">
<option value="">请选择资源类型</option>
</select>
</div>
<div class="form-group fl">
<select id="resource-select" name="resource_id" style="width:150px" class="select_gallery">
<option value="">请选择资源内容</option>
</select>
</div>
<div class="form-group fl">
<input id="remark-input" type="text" name="remark" class="txt normal_txt" placeholder="请输入备注" value="">
</div>
<div class="form-group fl">
<p id="resource-amount" class="static-input">资源价值: --</p>
</div>
<div class="form-group fl">
<p class="static-input">资源数量: 1</p>
<!-- <input id="num-input" type="text" name="num" class="txt normal_txt" id="uid" placeholder="请输入资源数量" value=""> -->
</div>
<?php else:?>
<div class="form-group fl">
<input id="remark-input" type="text" name="remark" class="txt normal_txt" placeholder="请输入资源备注" value="">
</div>
<div class="form-group fl">
<input id="remark-amount" type="text" name="amount" class="txt normal_txt" placeholder="请输入资源价值" value="">
</div>
<?php endif;?>
<div class="form-group fl">
<button id="add-row" class="add-row" type="button">增加</button>
</div>
</div>
</form>
</div>
<div class="trunk-list list_normal data_list" style="margin-top: 20px">
<div class="table-wrapper" style="height: 315px;">
<?php if($hasItf):?>
<table id="resource-table" class="table normal_table ">
<thead>
<tr class="table-header">
<th width="150">资源类型</th>
<th width="150">资源内容</th>
<th>资源价值</th>
<th>资源数量</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<?php else:?>
<table id="resource-table" class="table normal_table ">
<thead>
<tr class="table-header">
<th>资源备注</th>
<th>资源价值</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<?php endif;?>
</div>
<div class="btn-row clearfix">
<button id="submit-btn" class="submit-btn" type="button">提交</button>
<button id="close-btn" class="close-btn" type="button">关闭</button>
</div>
</div>
</div>
</div>
<div id="bind-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label>玩家账号</label>
<div class="form-item" style="width: 250px">
<input id="bind_account" name="account" type="text" class="form-input" style="width: 100%;">
</div>
</div>
<div class="form-group">
<label>玩家角色</label>
<div class="form-item" style="width: 250px">
<select id="bind-role-select" name="role_id" style="width:270px" class="select_gallery">
<option value="">请选择</option>
</select>
</div>
</div>
<div class="form-group">
<label></label>
<a id="submit-bind" href="javascript:;" class="add-submit btn">确定</a>
</div>
</form>
</div>
</div>
<script type="text/javascript">
$(".select_gallery").select2()
var globalGameId = $('#game-select').val()
var hasItf = $('#hasItf').val()
if (globalGameId > 0) {
initTable(globalGameId)
}
$('#game-select').on({
change: function () {
var gameId = $(this).val()
globalGameId = gameId
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var servers = result.data.servers
var html = "<option value='0'>请选择区服</option>";
for (var i in servers){
html += "<option value='"+servers[i].id+"'>"+servers[i].server_name+"</option>"
}
$("#server-select").html(html);
$("#server-select").select2();
} else {
}
}
})
initTable(gameId)
}
})
var resourceTypes = new Array()
var rowCount = 0
function initTable(gameId) {
var table = $('#resource-table');
table.find('.normal-row').remove()
if (hasItf != 1) {
return;
}
$.ajax({
url: "{:U('getResourceTypes')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
rowCount = 0
resourceTypes = result.data.resourceTypes
var selector = $('#resource-type-select')
var html = getResourceTypesHtml()
selector.html(html)
selector.select2();
var resourceSelector = $('#resource-select')
resourceSelector.html(getResourcesHtml([]))
resourceSelector.select2();
$('#resource-amount').html('资源价值:--')
$('#resource-table tbody').html('')
} else {
}
}
})
}
function getResourceTypesHtml() {
var html = "<option value=''>请选择资源类型</option>";
for (var i in resourceTypes) {
html += "<option value='"+resourceTypes[i].id+"'>"+resourceTypes[i].name+"</option>"
}
return html
}
$('#resource-type-select').change(function () {
var that = this
var typeId = $(this).val()
$.ajax({
url: "{:U('getResources')}",
type: "post",
data: { game_id: globalGameId, type_id: typeId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var resources = result.data.resources
var html = getResourcesHtml(resources)
var rowSelect = $('#resource-select')
rowSelect.html(html);
rowSelect.select2();
} else {
}
}
})
})
function getResourcesHtml(resources) {
var html = "<option value=''>请选择资源内容</option>";
for (var i in resources){
html += "<option value='"+resources[i].ref_id+"' data-amount="+resources[i].amount+">"+resources[i].name+"</option>"
}
return html
}
$('#resource-select').change(function () {
var amount = $(this).find('option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
$('#resource-amount').html('资源价值:' + amount)
})
$('#add-row').click(function () {
if (rowCount >= 5) {
return layer.msg('最多同时只能添加5条')
}
var hasItf = $('#hasItf').val()
if (hasItf == 1) {
addRowItf()
} else {
addRow()
}
})
function isFloat(num){
if(!num) {
return false
}
var strPreg = /^\d+(\.\d+)?$/;
if(!strPreg.test(num)) {
return false
}
try{
if(parseFloat(num) != num) {
return false
}
} catch(ex) {
return false
}
return true
}
function isNumber(num){
if(!num) {
return false
}
var strPreg = /^\d+$/
if(!strPreg.test(num)) {
return false
}
return true
}
function addRow() {
var remark = $('#remark-input').val()
var amount = $('#remark-amount').val()
if (remark == '') {
return layer.msg('请输入资源备注')
}
if (amount == '') {
return layer.msg('请输入资源价值')
}
if (!isNumber(amount)) {
return layer.msg('资源价值只能为正整数')
}
var html = '<tr class="normal-row" >' +
'<td style="width:420px" class="remark"><input name="remark" type="text" style="width:400px" value="' + remark + '"></td>' +
'<td class="amount"><input name="amount" type="text" value="' + amount + '"></td>' +
'<td><button class="delete-row" type="button" class="danger-btn">删除</button></td>' +
'</tr>';
$('#resource-table tbody').append(html)
rowCount ++
$(".select_gallery").select2()
statQuota()
}
function addRowItf() {
var resourceTypeId = $('#resource-type-select').val()
var resourceId = $('#resource-select').val()
var resourceTypeName = $('#resource-type-select option:selected').html()
var resourceName = $('#resource-select option:selected').html()
var amount = $('#resource-select option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
// var num = $('#num-input').val()
var num = 1
var remark = $('#remark-input').val()
if (resourceTypeId == '') {
return layer.msg('请选择资源类型')
}
if (resourceId == '') {
return layer.msg('请选择资源内容')
}
if (num == '') {
return layer.msg('请输入资源数量')
}
if (!isNumber(num)) {
return layer.msg('资源数量只能为正整数')
}
var html = '<tr class="normal-row" data-resource-id="' + resourceId + '" data-resource-type-id="' + resourceTypeId + '" >' +
'<td>' + resourceTypeName + '</td>' +
'<td>' + resourceName + '</td>' +
'<td class="amount">' + amount + '</td>' +
'<td class="num"><input name="num" type="text" value="' + num + '" readonly></td>' +
'<td class="remark"><input name="remark" type="text" value="' + remark + '"></td>' +
'<td><button class="delete-row" type="button" class="danger-btn">删除</button></td>' +
'</tr>';
$('#resource-table tbody').append(html)
rowCount ++
$(".select_gallery").select2()
statQuota()
}
$('#resource-table').on('click', '.delete-row', function () {
var tr = $(this).parents('tr').eq(0)
rowCount --
tr.remove()
statQuota()
})
$('#resource-table').on('blur', 'input[name=num]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
statQuota()
}
})
$('#resource-table').on('blur', 'input[name=amount]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
statQuota()
}
})
function statQuota() {
var quota = $('#quota').attr('data-quota')
var hasItf = $('#hasItf').val()
var verifyQuota = 0
if (hasItf == 1) {
$('#resource-table').find('.normal-row').each(function (index, ele) {
verifyQuota += $(ele).find('.amount').html() * $(ele).find('.num').children('input').val()
})
} else {
$('#resource-table').find('.normal-row').each(function (index, ele) {
verifyQuota += parseInt($(ele).find('.amount').children('input').val())
})
}
$('#verify-quota').html(verifyQuota)
$('#quota').html(quota-verifyQuota)
}
$('#test_account').on({
blur: function() {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var serverId = $('#server-select').val()
if (serverId == 0) {
return layer.msg('请选择区服')
}
var userAccount = $('#test_account').val()
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
}
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) {
if (roles.length == 0) {
return layer.msg('当前账号在该区服未创建角色')
}
if (!isTestingAccount) {
return layer.msg('此账号非测试账号')
}
var html = "<option value=''>请选择角色</option>";
for (var i in roles){
html += "<option value='"+roles[i].role_id+"'>"+roles[i].role_name+"</option>"
}
$("#role-select").html(html);
$("#role-select").select2();
})
}
})
function getUserRoles(userAccount, gameId, serverId, callback) {
$.ajax({
url: "{:U('getUserRoles')}",
type: "post",
data: { user_account: userAccount, game_id: gameId, server_id: serverId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var roles = result.data.roles
var isTestingAccount = result.data.is_testing_account
callback(roles, isTestingAccount)
} else {
layer.msg(result.message)
}
}
})
}
$('#bind_account').on({
blur: function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var serverId = $('#server-select').val()
if (serverId == 0) {
return layer.msg('请选择区服')
}
var userAccount = $('#bind_account').val()
if (userAccount == '') {
return layer.msg('请输入玩家账号')
}
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) {
if (roles.length == 0) {
return layer.msg('玩家账号在该区服未创建角色')
}
if (isTestingAccount) {
return layer.msg('此账号为测试账号,无法绑定')
}
var html = "<option value=''>请选择角色</option>";
for (var i in roles){
html += "<option value='"+roles[i].role_id+"'>"+roles[i].role_name+"</option>"
}
$("#bind-role-select").html(html);
$("#bind-role-select").select2();
})
}
})
function getRecords() {
var records = []
var hasItf = $('#hasItf').val()
if (hasItf == 1) {
$('#resource-table tbody tr').each(function (index, tr) {
var num = $(tr).find('input[name=num]').val()
var remark = $(tr).find('input[name=remark]').val()
var resourceId = $(tr).attr('data-resource-id')
var resourceTypeId = $(tr).attr('data-resource-type-id')
records.push({
resource_id: resourceId,
resource_type_id: resourceTypeId,
num: num,
remark: remark,
})
})
} else {
$('#resource-table tbody tr').each(function (index, tr) {
var amount = $(tr).find('input[name=amount]').val()
var remark = $(tr).find('input[name=remark]').val()
records.push({
amount: amount,
remark: remark,
})
})
}
return records
}
$('#bind-btn').click(function () {
var box = $('#bind-box')
layer.open({
title: '绑定玩家角色',
type: 1,
content: box,
area: ['500px', '250px'],
zIndex: 250,
scrollbar: false
})
});
$('#submit-bind').click(function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var roleId = $('#role-select').val()
if (roleId == 0) {
return layer.msg('请选择测试账号角色')
}
var bindRoleId = $('#bind-role-select').val()
if (bindRoleId == 0) {
return layer.msg('请选择玩家角色')
}
$.ajax({
url: "{:U('bindRole')}",
type: "post",
data: { game_id: gameId, bind_role_id: bindRoleId, testing_role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
} else {
layer.msg(result.message)
}
}
})
})
$('#submit-btn').on({
click: function () {
var records = getRecords()
if (records.length == 0) {
return layer.msg('至少添加一项资源申请')
}
for (var i in records) {
if (records[i].num == '') {
return layer.msg('请输入资源数量')
}
}
var gameId = $('#game-select').val()
var serverId = $('#server-select').val()
var userAccount = $('#test_account').val()
var roleId = $('#role-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
if (serverId == 0) {
return layer.msg('请选择区服')
}
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
}
if (roleId == 0) {
return layer.msg('请选择角色')
}
$.ajax({
url: "{:U('doApply')}",
type: "post",
data: { records: records, game_id: gameId, server_id: serverId, user_account: userAccount, role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
parent.window.location.href = "{:U('batches')}"
})
} else {
layer.msg(result.message)
}
}
})
}
})
$('#close-btn').on({
click: function () {
var index = parent.layer.getFrameIndex(window.name)
parent.layer.close(index)
}
})
</script>
</body>
</html>