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.
307 lines
12 KiB
307 lines
12 KiB
<!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>
|
|
<style>
|
|
.col-md-4, .col-md-1 {
|
|
display: inline !important;
|
|
float: left;
|
|
}
|
|
|
|
.inline {
|
|
display: inline !important;
|
|
}
|
|
|
|
.layui-table-cell {
|
|
text-align: center;
|
|
height: auto;
|
|
}
|
|
</style>
|
|
</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="row">
|
|
<div class="container" style="margin-left: 30px">
|
|
<div class="col-md-2" style="width:450px;font-size:18px;">
|
|
状态
|
|
<label> <input type="radio" name="State" checked="checked" onchange="FilterData()" value="0" /> 全部 </label>
|
|
<label> <input type="radio" name="State" onchange="FilterData()" value="2" /> 未生效 </label>
|
|
<label> <input type="radio" name="State" onchange="FilterData()" value="1" /> 生效中 </label>
|
|
<label> <input type="radio" name="State" onchange="FilterData()" value="3" /> 已失效 </label>
|
|
</div>
|
|
<div class="col-md-2" style="width:420px;font-size:18px;">
|
|
是否开启
|
|
<label> <input type="radio" name="Status" checked="checked" onchange="FilterData()" value="0" /> 全部 </label>
|
|
<label> <input type="radio" name="Status" onchange="FilterData()" value="1" /> 开启 </label>
|
|
<label> <input type="radio" name="Status" onchange="FilterData()" value="2" /> 关闭 </label>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="button" class="layui-btn " id="add">添加</button>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="button" class="layui-btn " id="batchadd">批量添加</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>
|
|
<label style="color:blue;">关闭</label>
|
|
</div>
|
|
<script id="btn" type="text/template">
|
|
|
|
|
|
|
|
<div style="width:80px;">
|
|
<!-- {{if Type==0}}
|
|
<input type="button" class="layui-btn layui-btn-xs" value="编辑" onclick="opennotice({{Id}})" />
|
|
{{else}}
|
|
<input type="button" class="layui-btn layui-btn-xs" value="编辑" onclick="openbatchnotice({{Id}})" />
|
|
{{/if}}
|
|
<br /> -->
|
|
{{if Status==2}}
|
|
<input type="button" class="layui-btn layui-btn-xs" style="background-color:red;" value="开启" onclick="delnotice({{Id}},'{{ExchangeCode}}',1)" />
|
|
{{else}}
|
|
<input type="button" class="layui-btn layui-btn-xs" style="background-color:green;" value="禁用" onclick="delnotice({{Id}},'{{ExchangeCode}}',2)" />
|
|
{{/if}}
|
|
</div>
|
|
</script>
|
|
<!--#include file="/widget/tail.html"-->
|
|
<script type="text/javascript">
|
|
|
|
var m_limit = 0;
|
|
function FilterData() {
|
|
console.info(exchange_data);
|
|
var State = Number($('input[name="State"]:checked').val());
|
|
var Status = Number($('input[name="Status"]:checked').val());
|
|
|
|
var _exchange_data = exchange_data.concat();
|
|
|
|
if (State == 0 && Status == 0) {
|
|
_exchange_data = _exchange_data.filter(f => 1 == 1);
|
|
}
|
|
else {
|
|
if (State != 0) {
|
|
_exchange_data = _exchange_data.filter(f => f.State == State);
|
|
}
|
|
if (Status != 0) {
|
|
_exchange_data = _exchange_data.filter(f => f.Status == Status);
|
|
}
|
|
}
|
|
console.info(_exchange_data);
|
|
inihero_table(_exchange_data, m_limit);
|
|
|
|
}
|
|
|
|
function delnotice(id, text, status) {
|
|
var dotext = status == 2 ? "关闭" : "启用";
|
|
if (confirm("确定" + dotext + "《" + text + "》兑换码吗?")) {
|
|
$.get(Page.SvrIp + "/api/DoDisable_exchange", {
|
|
token: cookie.get("token"),
|
|
Id: id,
|
|
Status: status
|
|
}, function (data) {
|
|
if (data.ret == 0) {
|
|
alert(dotext + "成功!");
|
|
location.reload();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
$("#add").click(function () {
|
|
opennotice(0);
|
|
});
|
|
$("#batchadd").click(function () {
|
|
openbatchnotice(0);
|
|
});
|
|
function opennotice(id) {
|
|
var title = "";
|
|
if (id == 0) {
|
|
title = "添加";
|
|
} else {
|
|
title = "编辑";
|
|
}
|
|
layer.open({
|
|
content: `/pages/EditExchange.html?id=${id}`,
|
|
type: 2,
|
|
title: title,
|
|
area: ['850px', '770px']
|
|
});
|
|
}
|
|
|
|
function openbatchnotice(id) {
|
|
var title = "";
|
|
if (id == 0) {
|
|
title = "批量" + "添加" + "礼包码";
|
|
} else {
|
|
title = "批量" + "编辑" + "礼包码";
|
|
}
|
|
layer.open({
|
|
content: `/pages/BatchAddExchange.html?id=${id}`,
|
|
type: 2,
|
|
title: title,
|
|
area: ['850px', '870px']
|
|
});
|
|
}
|
|
|
|
|
|
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: 1500,
|
|
height: 1200,
|
|
autoSort: true,
|
|
limit: limit,
|
|
cols: [[
|
|
{ field: 'Id', title: 'Id', sort: true, width: 80 },
|
|
{
|
|
field: '*', title: '生成<br/>方式', sort: true, width: 80, templet: function (d) {
|
|
return d.Type === 0 ? "单条" : "批量";
|
|
}
|
|
}
|
|
, {
|
|
field: 'BeginTime', title: '开始时间', sort: true, width: 160, templet: function (d) {
|
|
return d.BeginTime == 0 ? "不限制" : Page.formatDate(d.BeginTime);
|
|
}
|
|
}
|
|
, {
|
|
field: 'EndTime', title: '结束时间', sort: true, width: 160, templet: function (d) {
|
|
return d.EndTime == 0 ? "不限制" : Page.formatDate(d.EndTime);
|
|
}
|
|
}
|
|
, {
|
|
field: 'Content', title: '奖励内容', sort: true, width: 240, templet: function (d) {
|
|
var text = "";
|
|
|
|
if (d.Type == 0) {
|
|
for (var i in d.Content.AddGoods) {
|
|
var _d = d.Content.AddGoods[i];
|
|
|
|
text += `ID :${_d.ID} 类型 :${_d.Type} 数量 :${_d.Count} <br/>`;
|
|
}
|
|
} else {
|
|
for (var x in d.Content.Groups) {
|
|
var _x = d.Content.Groups[x];
|
|
text += `<b>组${(Number(x) + 1)} </b >`;
|
|
for (var i in _x.AddGoods) {
|
|
var _d = _x.AddGoods[i];
|
|
text += `ID :${_d.ID} 类型 :${_d.Type} 数量 :${_d.Count} <br/>`;
|
|
}
|
|
}
|
|
|
|
}
|
|
return text;
|
|
}
|
|
}
|
|
, { field: 'ExchangeCode', title: '兑换码', sort: true, width: 150 }
|
|
, {
|
|
field: 'Status', title: '启用', sort: true, width: 80, templet: function (d) {
|
|
if (d.Status == 1) {
|
|
return "<label style=\"color: green;\">开启</label>";
|
|
} else if (d.Status == 2) {
|
|
return "<label style=\"color: red;\">关闭</label> ";
|
|
}
|
|
else {
|
|
return "<label >未知</label>";
|
|
}
|
|
}
|
|
}
|
|
, {
|
|
field: 'State', title: '状态', sort: true, width: 80, templet: function (d) {
|
|
switch (d.State) {
|
|
case 2: return "<label style=\"color: blue;\">未生效</label>";
|
|
case 1: return "<label style=\"color: green;\">生效中</label>";
|
|
case 3: return "<label style=\"color: red;\">已失效</label>";
|
|
default: return "<label >未知</label>";
|
|
}
|
|
}
|
|
}
|
|
, { field: 'ExchangeNum', title: '已兑换<br/>数量', sort: true, width: 80 }
|
|
//, { field: 'Mainline', title: '主线关卡', sort: true, width: 120 }
|
|
, { field: 'MaxExchangeNum', title: '最大兑换<br/>数量', sort: true, width: 120 }
|
|
, {
|
|
field: '*', title: '编辑', width: 120, templet: function (d) {
|
|
return template("btn", d);
|
|
}
|
|
}
|
|
|
|
]]
|
|
});
|
|
|
|
}
|
|
|
|
function getLocalTime(nS) {
|
|
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
|
|
}
|
|
function Select_data(page, limit, first) {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: Page.SvrIp + "/api/select_exchange",
|
|
data: {
|
|
token: cookie.get("token"),
|
|
page: page,
|
|
limit: limit
|
|
},
|
|
dataType: "json",
|
|
beforeSend: function () {
|
|
layer.load(1, { shade: [0.8, '#393D49'] });
|
|
},
|
|
complete: function () {
|
|
layer.closeAll('loading');
|
|
},
|
|
success: function (d) {
|
|
exchange_data = JSON.parse(d.data);
|
|
inihero_table(exchange_data, limit);
|
|
if (first === 1) {
|
|
ini_page(d);
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
$(function () {
|
|
initPage('礼包信息');
|
|
|
|
Select_data(1, 20, 1);
|
|
});
|
|
|
|
</script>
|
|
<script src="../js/coupon.js"></script>
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|