1060 lines
50 KiB
Vue
1060 lines
50 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<section class="content-header">
|
||
<h1 id="itemTitle">游戏信息管理</h1>
|
||
</section>
|
||
<section class="content">
|
||
<div id="table"></div>
|
||
<div id="toolbar">
|
||
<button id="addBtn" class="btn btn-default">
|
||
<i class="glyphicon glyphicon-plus"></i>增加
|
||
</button>
|
||
游戏名: <input type="text" id='gameName' placeholder=''>
|
||
<button id="btnSearch" class="btn btn-sm btn-primary" data-id=" + word + ">查询</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</section>
|
||
<div class="modal fade" id="actModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||
aria-hidden="true">x</span></button>
|
||
<h4 class="modal-title" id="addModalLabel">游戏信息</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="actForm">
|
||
<input type="hidden" name="id" id="actId" value="0">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="gameId" class="col-sm-3 control-label">游戏ID:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="gameId" id="gameId"
|
||
style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gameName" class="col-sm-3 control-label">游戏名:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="gameName" id="name"
|
||
style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gameChannel" class="col-sm-3 control-label">游戏厂商:</label>
|
||
<div class="col-sm-9">
|
||
<!--<input type="text" class="form-control validate[required]" name="gameChannel"-->
|
||
<!--id="gameChannel"-->
|
||
<!--style="width:400px">-->
|
||
<select name="gameChannel" id="gameChannel" class="form-control validate[required]"
|
||
style="width:300px">
|
||
<option value="">-- 请选择 --</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gameIcon" class="col-sm-3 control-label">游戏图标:</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="gameImgUrl" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="uploadGameFile" name="uploadGameFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="uploadGameBtn">上传</button>
|
||
<input type="hidden" class="form-control validate[required]" name="gameIcon"
|
||
id="gameIcon" style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gamePicture" class="col-sm-3 control-label">游戏图标(IM/多人房):</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="gamePicUrl" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="uploadPicFile" name="uploadPicFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="uploadPicBtn">上传</button>
|
||
<input type="hidden" class="form-control validate[required]" name="gamePicture"
|
||
id="gamePicture" style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="tagIcon" class="col-sm-3 control-label">标签图标:</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="tagImgUrl" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="uploadTagFile" name="uploadTagFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="uploadTagBtn">上传</button>
|
||
<input type="hidden" class="form-control validate[required]" name="tagIcon" id="tagIcon"
|
||
style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="priority" class="col-sm-3 control-label">优先级:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="priority" id="priority"
|
||
style="width:400px">
|
||
</div>
|
||
</div>
|
||
<form class="form-horizontal">
|
||
<div class="form-group">
|
||
<label for="addStartDate" class="col-sm-3 control-label">生效时间:</label>
|
||
<div class="col-sm-8">
|
||
<input id="addStartDate" type="text" name="startTime"
|
||
class="form-control validate[required]">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="addEndDate" class="col-sm-3 control-label">失效时间:</label>
|
||
<div class="col-sm-8">
|
||
<input id="addEndDate" type="text" name="endTime"
|
||
class="form-control validate[required]">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<div class="form-group">
|
||
<label for="status" class="col-sm-3 control-label">激活设置:</label>
|
||
<select name="status" id="status" class="col-sm-2">
|
||
<option value="1">上架中</option>
|
||
<option value="2">未上架</option>
|
||
<option value="3">下架</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="type" class="col-sm-3 control-label">游戏类型:</label>
|
||
<select name="type" id="type" class="col-sm-2">
|
||
<option value="1">1v1游戏</option>
|
||
<option value="2">多人游戏</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="type" class="col-sm-3 control-label">展示平台:</label>
|
||
<select name="platform" id="platform" class="col-sm-2">
|
||
<option value="all">所有平台</option>
|
||
<option value="ios">只展示ios</option>
|
||
<option value="android">只展示安卓</option>
|
||
<option value="none">都不展示</option>
|
||
</select>
|
||
</div>
|
||
<!--<div class="form-group">
|
||
<label for="appKey" class="col-sm-3 control-label">appKey:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="appKey" id="appKey"
|
||
style="width:400px">
|
||
</div>
|
||
</div>-->
|
||
<div class="form-group">
|
||
<label for="groupId" class="col-sm-3 control-label">组id:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="groupId" id="groupId"
|
||
placeholder="设置该游戏由哪个线程扫描" style="width:400px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="groupName" class="col-sm-3 control-label">组名:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="groupName"
|
||
id="groupName" placeholder="设置该游戏由哪个线程扫描的说明" style="width:400px">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" id="save">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||
aria-hidden="true">x</span></button>
|
||
<h4 class="modal-title" id="editModalLabel">游戏信息编辑</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="editForm">
|
||
<input type="hidden" name="gameId" id="egameId" value="0">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="gameName" class="col-sm-3 control-label">游戏名:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="gameName" id="ename"
|
||
style="width:200px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gameChannel" class="col-sm-3 control-label">游戏厂商:</label>
|
||
<!--<div class="col-sm-9">-->
|
||
<!--<input type="text" class="form-control validate[required]" name="gameChannel"-->
|
||
<!--id="egameChannel"-->
|
||
<!--style="width:200px">-->
|
||
<!--</div>-->
|
||
<div class="col-sm-9">
|
||
<select name="gameChannel" id="egameChannel" class="form-control validate[required]"
|
||
style="width:300px">
|
||
<option value="">-- 请选择 --</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gameIcon" class="col-sm-3 control-label">游戏图标:</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="eGameImgUrl" style="width:90px;height:90px;" alt="">
|
||
<input type="file" id="addGameUploadFile" name="uploadGameFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="addGameUploadBtn">上传</button>
|
||
<input type="hidden" id="egameIcon" name="gameIcon"
|
||
class="form-control validate[required]" />
|
||
<!--input type="text" class="form-control validate[required]" name="gameIcon" id="egameIcon"
|
||
style="width:400px">-->
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="gamePicture" class="col-sm-3 control-label">游戏图标(IM/多人房):</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="eGamePicUrl" style="width:90px;height:90px;" alt="">
|
||
<input type="file" id="addPicUploadFile" name="uploadPicFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="addPicUploadBtn">上传</button>
|
||
<input type="hidden" id="egamePic" name="gamePicture"
|
||
class="form-control validate[required]" />
|
||
<!--input type="text" class="form-control validate[required]" name="gameIcon" id="egameIcon"
|
||
style="width:400px">-->
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="tagIcon" class="col-sm-3 control-label">标签图标:</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="eTagImgUrl" style="width:90px;height:50px;" alt="">
|
||
<input type="file" id="addTagUploadFile" name="uploadTagFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="addTagUploadBtn">上传</button>
|
||
<input type="hidden" id="etagIcon" name="tagIcon"
|
||
class="form-control validate[required]" />
|
||
<!--<input type="text" class="form-control validate[required]" name="tagIcon" id="etagIcon"
|
||
style="width:400px">-->
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="priority" class="col-sm-3 control-label">优先级:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="priority"
|
||
id="epriority" style="width:200px" placeholder="数值越大排在越前面">
|
||
</div>
|
||
</div>
|
||
<form class="form-horizontal">
|
||
<div class="form-group">
|
||
<label for="addStartDate" class="col-sm-3 control-label">生效时间:</label>
|
||
<div class="col-sm-8">
|
||
<input id="eaddStartDate" type="text" name="startTime"
|
||
class="form-control validate[required]">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="addEndDate" class="col-sm-3 control-label">失效时间:</label>
|
||
<div class="col-sm-8">
|
||
<input id="eaddEndDate" type="text" name="endTime"
|
||
class="form-control validate[required]">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<div class="form-group">
|
||
<label for="status" class="col-sm-3 control-label">激活设置:</label>
|
||
<select name="status" id="estatus" class="col-sm-2">
|
||
<option value="1">上架中</option>
|
||
<option value="2">未上架</option>
|
||
<option value="3">下架</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="type" class="col-sm-3 control-label">游戏类型:</label>
|
||
<select name="type" id="etype" class="col-sm-2">
|
||
<option value="1">1v1游戏</option>
|
||
<option value="2">多人游戏</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="type" class="col-sm-3 control-label">展示平台:</label>
|
||
<select name="platform" id="eplatform" class="col-sm-2">
|
||
<option value="all">所有平台</option>
|
||
<option value="ios">只展示ios</option>
|
||
<option value="android">只展示安卓</option>
|
||
<option value="none">都不展示</option>
|
||
</select>
|
||
</div>
|
||
<!--<div class="form-group">-->
|
||
<!--<label for="appKey" class="col-sm-3 control-label">appKey:</label>-->
|
||
<!--<div class="col-sm-9">-->
|
||
<!--<input type="text" class="form-control validate[required]" name="appKey" id="eappKey"-->
|
||
<!--style="width:400px">-->
|
||
<!--</div>-->
|
||
<!--</div>-->
|
||
<div class="form-group">
|
||
<label for="groupId" class="col-sm-3 control-label">组id:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="groupId" id="egroupId"
|
||
placeholder="设置该游戏由哪个线程扫描" style="width:200px">
|
||
</div>
|
||
</div>
|
||
<!--<div class="form-group">
|
||
<label for="groupName" class="col-sm-3 control-label">组名:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="groupName"
|
||
id="egroupName"
|
||
placeholder="设置该游戏由哪个线程扫描的说明" style="width:400px">
|
||
</div>
|
||
-->
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" id="edit">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal fade" id="sureModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||
<button type="button" class="btn btn-primary" id="sure">确定</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div id="imgMask"><img src="" alt=""></div>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
|
||
var picker1 = $("#endDate").datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
|
||
var picker2 = $('#addStartDate').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
|
||
var picker3 = $('#addEndDate').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
picker3.on('changeDate', function () {
|
||
var date = $('#addEndDate').datetimepicker('getDate');
|
||
console.log(date);
|
||
picker2.datetimepicker('setEndDate', date);
|
||
});
|
||
picker2.on('changeDate', function () {
|
||
var date = $('#addStartDate').datetimepicker('getDate');
|
||
picker3.datetimepicker('setStartDate', date);
|
||
});
|
||
|
||
picker3 = $("#eendDate").datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
|
||
var picker4 = $('#eaddStartDate').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
|
||
var picker5 = $('#eaddEndDate').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
picker5.on('changeDate', function () {
|
||
var date = $('#eaddEndDate').datetimepicker('getDate');
|
||
console.log(date);
|
||
picker4.datetimepicker('setEndDate', date);
|
||
});
|
||
picker4.on('changeDate', function () {
|
||
var date = $('#eaddStartDate').datetimepicker('getDate');
|
||
picker5.datetimepicker('setStartDate', date);
|
||
});
|
||
|
||
export default {
|
||
name: "GameInfoView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
$(function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
initTable();
|
||
// 查询刷新
|
||
$('#btnSearch').on('click', function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
initTable();
|
||
});
|
||
|
||
|
||
initChannelSelect();
|
||
|
||
$('#addBtn').on('click', function () {
|
||
cleanModal($("#actForm"));
|
||
$("#actForm")[0].reset();
|
||
$('#actModal').modal('show');
|
||
});
|
||
$('#table').on('click', '.opt-edit', function () {
|
||
cleanModal($("#editForm"));
|
||
var gameId = $(this).attr("data-id");
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/gameinfo/getByGameId",
|
||
data: { "gameId": gameId },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json) {
|
||
var date = json.endTime ? new Date(json.endTime).format("yyyy-MM-dd hh:mm:ss") : '';
|
||
var startDate = new Date(json.startTime).format("yyyy-MM-dd hh:mm:ss");
|
||
$('#ename').val(json.gameName);
|
||
$('#egameId').val(json.gameId);
|
||
$('#egameChannel').val(json.gameChannel);
|
||
$('#eGameImgUrl').attr('src', json.gameIcon);
|
||
$('#eGamePicUrl').attr('src', json.gamePicture);
|
||
$('#egameIcon').val(json.gameIcon);
|
||
$('#egamePic').val(json.gamePicture);
|
||
$('#eTagImgUrl').attr('src', json.tagIcon);
|
||
$('#etagIcon').val(json.tagIcon);
|
||
$('#epriority').val(json.priority);
|
||
$("#estatus").val(json.status);
|
||
$('#etype').val(json.type);
|
||
$('#eplatform').val(json.platform);
|
||
$('#egroupId').val(json.groupId);
|
||
$('#eappKey').val(json.appKey);
|
||
$('#eaddEndDate').val(date);
|
||
$('#eaddStartDate').val(startDate);
|
||
$("#editModal").modal('show');
|
||
picker1.datetimepicker('setStartDate', startDate);
|
||
} else {
|
||
$("#tipMsg").text("获取信息出错");
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
$('#save').on('click', function () {
|
||
if ($('#actForm').validationEngine('validate')) {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameinfo/add",
|
||
data: $('#actForm').serialize(),
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.success == 'true') {
|
||
$("#actModal").modal('hide');
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("保存失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
$('#edit').on('click', function () {
|
||
if ($('#editForm').validationEngine('validate')) {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameinfo/update",
|
||
data: $('#editForm').serialize(),
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
console.log(json);
|
||
if (json.success == 'true') {
|
||
$("#editModal").modal('hide');
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("修改失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
$("#table").on("click", '.opt-del', function () {
|
||
var id = $(this).attr("data-id");
|
||
if (id == 'undefined') {
|
||
$("#tipMsg").text("id参数有误");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (confirm("你确认删除吗?")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '/admin/gameinfo/delete',
|
||
data: { 'gameId': id },
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.success == 'true') {
|
||
$("#tipMsg").text("删除成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("删除失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
$('#table').on('mouseenter', 'img', function (e) {
|
||
console.log($(this), e.clientX);
|
||
var src = $(this).attr('src');
|
||
$('#imgMask img').attr('src', src);
|
||
$('#imgMask').show();
|
||
$('#imgMask').css({
|
||
top: e.clientY + 20,
|
||
left: e.clientX + 20
|
||
})
|
||
})
|
||
$('#table').on('mouseleave', 'img', function (e) {
|
||
console.log('移出');
|
||
$('#imgMask').hide();
|
||
})
|
||
|
||
}); $(function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
initTable();
|
||
// 查询刷新
|
||
$('#btnSearch').on('click', function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
initTable();
|
||
});
|
||
|
||
|
||
initChannelSelect();
|
||
|
||
$('#addBtn').on('click', function () {
|
||
cleanModal($("#actForm"));
|
||
$("#actForm")[0].reset();
|
||
$('#actModal').modal('show');
|
||
});
|
||
$('#table').on('click', '.opt-edit', function () {
|
||
cleanModal($("#editForm"));
|
||
var gameId = $(this).attr("data-id");
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/gameinfo/getByGameId",
|
||
data: { "gameId": gameId },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json) {
|
||
var date = json.endTime ? new Date(json.endTime).format("yyyy-MM-dd hh:mm:ss") : '';
|
||
var startDate = new Date(json.startTime).format("yyyy-MM-dd hh:mm:ss");
|
||
$('#ename').val(json.gameName);
|
||
$('#egameId').val(json.gameId);
|
||
$('#egameChannel').val(json.gameChannel);
|
||
$('#eGameImgUrl').attr('src', json.gameIcon);
|
||
$('#eGamePicUrl').attr('src', json.gamePicture);
|
||
$('#egameIcon').val(json.gameIcon);
|
||
$('#egamePic').val(json.gamePicture);
|
||
$('#eTagImgUrl').attr('src', json.tagIcon);
|
||
$('#etagIcon').val(json.tagIcon);
|
||
$('#epriority').val(json.priority);
|
||
$("#estatus").val(json.status);
|
||
$('#etype').val(json.type);
|
||
$('#eplatform').val(json.platform);
|
||
$('#egroupId').val(json.groupId);
|
||
$('#eappKey').val(json.appKey);
|
||
$('#eaddEndDate').val(date);
|
||
$('#eaddStartDate').val(startDate);
|
||
$("#editModal").modal('show');
|
||
picker1.datetimepicker('setStartDate', startDate);
|
||
} else {
|
||
$("#tipMsg").text("获取信息出错");
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
$('#save').on('click', function () {
|
||
if ($('#actForm').validationEngine('validate')) {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameinfo/add",
|
||
data: $('#actForm').serialize(),
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.success == 'true') {
|
||
$("#actModal").modal('hide');
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("保存失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
$('#edit').on('click', function () {
|
||
if ($('#editForm').validationEngine('validate')) {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameinfo/update",
|
||
data: $('#editForm').serialize(),
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
console.log(json);
|
||
if (json.success == 'true') {
|
||
$("#editModal").modal('hide');
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("修改失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
$("#table").on("click", '.opt-del', function () {
|
||
var id = $(this).attr("data-id");
|
||
if (id == 'undefined') {
|
||
$("#tipMsg").text("id参数有误");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (confirm("你确认删除吗?")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '/admin/gameinfo/delete',
|
||
data: { 'gameId': id },
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.success == 'true') {
|
||
$("#tipMsg").text("删除成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("删除失败,错误码:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
$('#table').on('mouseenter', 'img', function (e) {
|
||
console.log($(this), e.clientX);
|
||
var src = $(this).attr('src');
|
||
$('#imgMask img').attr('src', src);
|
||
$('#imgMask').show();
|
||
$('#imgMask').css({
|
||
top: e.clientY + 20,
|
||
left: e.clientX + 20
|
||
})
|
||
})
|
||
$('#table').on('mouseleave', 'img', function (e) {
|
||
console.log('移出');
|
||
$('#imgMask').hide();
|
||
})
|
||
|
||
$('#addGameUploadBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimg',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#egameIcon').val(json.path);
|
||
$('#eGameImgUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#editForm').ajaxSubmit(options);
|
||
});
|
||
$('#addPicUploadBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimgforpicture',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#egamePic').val(json.path);
|
||
$('#eGamePicUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#editForm').ajaxSubmit(options);
|
||
});
|
||
|
||
$('#addTagUploadBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimgfortag',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#etagIcon').val(json.path);
|
||
$('#eTagImgUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#editForm').ajaxSubmit(options);
|
||
});
|
||
|
||
$('#uploadGameBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimg',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#gameIcon').val(json.path);
|
||
$('#gameImgUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#actForm').ajaxSubmit(options);
|
||
});
|
||
$('#uploadPicBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimgforpicture',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#gamePicture').val(json.path);
|
||
$('#gamePicUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#actForm').ajaxSubmit(options);
|
||
});
|
||
|
||
$('#uploadTagBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/gameinfo/headimgfortag',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#tagIcon').val(json.path);
|
||
$('#tagImgUrl').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#actForm').ajaxSubmit(options);
|
||
});
|
||
|
||
});
|
||
}
|
||
},
|
||
|
||
};
|
||
|
||
function cleanModal(obj) {
|
||
$('#actForm').find('input[type=text],input[type=hidden],input[type=file]').each(function () {
|
||
$(this).val('');
|
||
})
|
||
$('#actForm').find('img').attr('src', '');
|
||
//清空输入框
|
||
obj.find('input:text').val('');
|
||
//清空隐藏域
|
||
obj.find('input:hidden').val('');
|
||
//清空单选按钮
|
||
obj.find('input:radio').attr("checked", false);
|
||
//清空文本域
|
||
obj.find('textarea').val('');
|
||
//清空图片
|
||
obj.find('img').attr("src", "");
|
||
//清空已上传
|
||
obj.find('span').html("");
|
||
}
|
||
|
||
/**
|
||
* 初始化厂商下拉表数据
|
||
*/
|
||
function initChannelSelect() {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: "/admin/gamechannel/getChannelIdList",
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
|
||
$('#gameChannel').html("");
|
||
|
||
var $select = $('#gameChannel');
|
||
$.each(data, function (i, item) {
|
||
var $option = $('<option value="' + item + '">' + item + '</option>');
|
||
$select.append($option);
|
||
});
|
||
|
||
$('#egameChannel').html("");
|
||
|
||
$select = $('#egameChannel');
|
||
$.each(data, function (i, item) {
|
||
var $option = $('<option value="' + item + '">' + item + '</option>');
|
||
$select.append($option);
|
||
});
|
||
|
||
}
|
||
})
|
||
}
|
||
|
||
function initTable() {
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'tmp1', title: '游戏Id', align: 'center', checkbox: true, width: '5%' },
|
||
{ field: 'gameId', title: '游戏Id', align: 'center', valign: 'middle', width: '10%' },
|
||
{ field: 'gameName', title: '游戏名', align: 'center', valign: 'middle', width: '10%' },
|
||
{ field: 'gameChannel', title: '游戏厂商渠道', align: 'center', valign: 'middle', width: '10%' },
|
||
|
||
{
|
||
field: 'gameIcon',
|
||
title: '游戏图标',
|
||
align: 'center',
|
||
width: '10%',
|
||
formatter: function (val, row, index) {
|
||
return "<img src='" + val + "' width='60' height='50'>";
|
||
}
|
||
},
|
||
{
|
||
field: 'gamePicture',
|
||
title: '游戏图标(IM/多人房)',
|
||
align: 'center',
|
||
width: '10%',
|
||
formatter: function (val, row, index) {
|
||
return "<img src='" + val + "' width='60' height='50'>";
|
||
}
|
||
},
|
||
{
|
||
field: 'tagIcon',
|
||
title: '标签图标',
|
||
align: 'center',
|
||
width: '10%',
|
||
formatter: function (val, row, index) {
|
||
return "<img src='" + val + "' width='60' height='30'>";
|
||
}
|
||
},
|
||
{
|
||
field: 'startTime',
|
||
title: '生效时间',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'endTime',
|
||
title: '失效时间',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||
} else {
|
||
return '-';
|
||
}
|
||
|
||
}
|
||
},
|
||
{ field: 'priority', title: '优先级', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'status',
|
||
title: '状态',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
console.log(val);
|
||
switch (val) {
|
||
case 1:
|
||
return '上架中';
|
||
|
||
case 2:
|
||
return '未上架';
|
||
|
||
case 3:
|
||
return '下架';
|
||
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'type',
|
||
title: '类型',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
console.log(val);
|
||
switch (val) {
|
||
case 1:
|
||
return '1v1';
|
||
|
||
case 2:
|
||
return '多人游戏';
|
||
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'platform', title: '展示平台', align: 'center', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
console.log(val);
|
||
switch (val) {
|
||
case 'all':
|
||
return '所有平台展示';
|
||
|
||
case 'none':
|
||
return '所有平台都不展示';
|
||
|
||
case 'ios':
|
||
return '只在IOS展示';
|
||
|
||
case 'android':
|
||
return '只在安卓展示';
|
||
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'createTime',
|
||
title: '创建时间',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'tmp',
|
||
title: '操作',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
var gameId = row.gameId;
|
||
return "<button class='btn btn-sm btn-success opt-edit' data-id =" + gameId + ">" +
|
||
"编辑</button>" + " " +
|
||
"<button class='btn btn-sm btn-danger opt-del' data-id=" + gameId + ">删除</button>";
|
||
|
||
}
|
||
}
|
||
],
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 20,
|
||
pagination: true,
|
||
pageList: [10, 20, 30, 50],
|
||
sidePagination: "server", //表示服务端请求
|
||
//设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
|
||
//设置为limit可以获取limit, offset, search, sort, order
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
pageSize: params.pageSize,
|
||
pageNumber: params.pageNumber,
|
||
gameName: $("#gameName").val()
|
||
};
|
||
// console.log(param);
|
||
return param;
|
||
},
|
||
uniqueId: 'gameId',
|
||
toolbar: '#toolbar',
|
||
url: '/admin/gameinfo/list',
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
console.log("load success");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
|
||
$('#table').on('mouseenter', 'img', function (e) {
|
||
var src = $(this).attr('src')
|
||
$('#imgMask img').attr('src', src);
|
||
$('#imgMask').show();
|
||
$('#imgMask').css({
|
||
top: e.clientY + 20,
|
||
left: e.clientX + 20
|
||
});
|
||
});
|
||
|
||
$('#table').on('mouseleave', 'img', function (e) {
|
||
$('#imgMask').hide();
|
||
});
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
#imgMask {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
width: 250px;
|
||
height: 250px;
|
||
padding: 4px;
|
||
background: #fff;
|
||
z-index: 999;
|
||
display: none;
|
||
}
|
||
|
||
#imgMask img {
|
||
width: 100%;
|
||
height: 100%;
|
||
vertical-align: top;
|
||
}
|
||
</style> |