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.
419 lines
18 KiB
419 lines
18 KiB
<!DOCTYPE html>
|
|
<html lang="zh-cn">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<!--#include file="/widget/head.html"-->
|
|
<style>
|
|
.layui-form-label {
|
|
width: 120px !important;
|
|
}
|
|
|
|
#mdiv .layui-form-item {
|
|
margin-bottom: 5px !important;
|
|
}
|
|
|
|
.layui-tab-card > .layui-tab-title {
|
|
background-color: #009688 !important;
|
|
}
|
|
|
|
.none {
|
|
cursor: not-allowed !important;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="wrapper" class="layui-card layui-col-md12">
|
|
<!-- <input type="file" id="imgfile" method="post" onchange="ToBase64()" enctype="multipart/form-data" style="display:none;"> -->
|
|
<!-- Navigation -->
|
|
<form class="layui-form layui-card layui-col-md12" lay-filter="mform" action="">
|
|
<div style="height:250px;border: solid 1px #a3a3a3;margin-top: 10px" id="mdiv">
|
|
<div style="height:250px;">
|
|
<div style="float:left;width:49%; margin-top: 10px">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">ID</label>
|
|
<div class="layui-input-inline" style="width:200px">
|
|
<input type="text" name="Id" id="Id" required lay-verify="required" disabled="disabled" value="0" autocomplete="off" class="layui-input none">
|
|
|
|
<input type="text" name="ExchangeNum" id="ExchangeNum" style="display:none;" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">礼包码</label>
|
|
<div class="layui-input-inline" style="width:200px">
|
|
<input type="text" name="ExchangeCode" id="ExchangeCode" required lay-verify="exchangeCode" placeholder="请输入礼包码" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">兑换开始时间</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="BeginTime" id="BeginTime" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">兑换结束时间</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="EndTime" id="EndTime" autocomplete="off" class="layui-input">
|
|
<label style="color:red;"> 不填为不限制结束时间 </label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div style="float:right;width:49%;margin-top: 10px">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">最大兑换数量</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="MaxExchangeNum" id="MaxExchangeNum" value="99999999" lay-verify="number" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">是否开启</label>
|
|
<div class="layui-input-inline">
|
|
<label> <input type="radio" name="Status" checked="checked" data-Status="1" lay-ignore value="1" /> 开启 </label>
|
|
<label> <input type="radio" name="Status" lay-ignore data-Status="2" value="2" /> 关闭 </label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="border: 1px solid #ccc; border-radius: 4px;padding-bottom: 5px;" id="djdiv">
|
|
<div class="form-group" style="margin-top:10px;" data-id="djdiv">
|
|
<div class="layui-form-item" data-id="djdiv1" data-djdiv="djdiv">
|
|
<label class="layui-form-label" for="dj1">道具1 id</label>
|
|
<div class="layui-input-inline" style="width:180px;">
|
|
<select class="form-control zero" data-id="dj" id="dj1">
|
|
<option value="-1">-----请选择-----</option>
|
|
</select>
|
|
</div>
|
|
|
|
<label class="layui-form-label">道具1 数量</label>
|
|
<div class="layui-input-inline" style="width:80px;">
|
|
<input type="number" name="djCount1" value="0" lay-verify="number" data-id="djCount" id="djCount1" autocomplete="off" class="layui-input">
|
|
</div>
|
|
|
|
</div>
|
|
<button type="button" class="layui-btn" id="adddj" >
|
|
增加道具
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="layui-input-inline" style="text-align: center;float: none;margin: 0px auto;display: block;user-select:initial;">
|
|
<div class="layui-input-inline">
|
|
<button class="layui-btn layui-bg-red" lay-submit lay-filter="formDemo">保存</button>
|
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
|
|
<script type="text/template" id="djhtml">
|
|
<div class="layui-form-item" data-id="djdiv{{djnum}}" data-djdiv='djdiv'>
|
|
|
|
|
|
<label class="layui-form-label">道具{{djnum}} ID</label>
|
|
<div class="layui-input-inline" style="width:180px;">
|
|
<select class="form-control zero" data-id="dj" id="dj{{djnum}}">
|
|
<option value="-1">-----请选择-----</option>
|
|
</select>
|
|
</div>
|
|
<label class="layui-form-label">道具{{djnum}} 数量</label>
|
|
<div class="layui-input-inline" style="width:80px;">
|
|
<input type="text" name="djCount{{djnum}}" value="0" lay-verify="number" data-id="djCount" id="djCount{{djnum}}" autocomplete="off" class="layui-input">
|
|
</div>
|
|
|
|
{{if curnum==1}}
|
|
|
|
{{else}}
|
|
<button type="button" class="layui-btn layui-btn-danger col-sm-2" data-toggle="modal" onclick="deldj({{djnum}})" style="float:left;">
|
|
删除道具
|
|
</button>
|
|
{{/if}}
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/template" id="selectrealmlist">
|
|
<div id='test7' style="height:720px;">
|
|
<input type="checkbox" name="realm_0" id="realm_0" value="{{v.id}}" title="{{v.name}}" />
|
|
{{each t v k}}
|
|
<input type="checkbox" name="realm_{{v.id}}" id="realm_{{v.id}}" value="{{v.id}}" title="{{v.name}}" />
|
|
{{/each}}
|
|
</div>
|
|
</script>
|
|
<script>
|
|
var languagelist;
|
|
var itemList;
|
|
|
|
function AddItemList(uiId){
|
|
var data =new Array();
|
|
|
|
$('#'+uiId).html('');
|
|
for (let [key, value] of Object.entries(itemList)) {
|
|
data.push({id:key,text:value})
|
|
$('#'+uiId).append('<option value="'+key+'">'+value+'</option>');
|
|
}
|
|
layui.form.render('select');
|
|
}
|
|
function Load_ItemList() {
|
|
$.get(Page.SvrIp + "/api/select_itemlist",
|
|
{ token: cookie.get("token") }
|
|
, function (d) {
|
|
itemList = d.data;
|
|
AddItemList("dj1");
|
|
});
|
|
}
|
|
|
|
|
|
//兑换码id 0表示新增 非0编辑
|
|
var dataid = Page.GetQueryString("id");
|
|
|
|
var djnum = 1;
|
|
var curnum = 1;
|
|
|
|
function delcur(i) {
|
|
--curnum;
|
|
$("div[data-id=curdiv" + i + "]").remove();
|
|
}
|
|
|
|
function deldj(i) {
|
|
--djnum;
|
|
$("div[data-id=djdiv" + i + "]").remove();
|
|
}
|
|
|
|
|
|
$("#adddj").click(function () {
|
|
++djnum;
|
|
$("#adddj").before(template("djhtml", {
|
|
djnum: djnum
|
|
}));
|
|
AddItemList('dj'+djnum);
|
|
});
|
|
|
|
function curtype(t) {
|
|
var val = $(t).val();
|
|
$(t).parents("[data-curdiv='curdiv']").find("[data-id='curCount']").attr('disabled', false)
|
|
$(t).parents("[data-curdiv='curdiv']").find("[data-id='curCount']").removeClass('none')
|
|
}
|
|
|
|
function LoadExchange(id) {
|
|
if (id == "0") {
|
|
return;
|
|
} else {
|
|
$("#Id").addClass("none");
|
|
$("#ExchangeCode").addClass("none");
|
|
$("#ExchangeCode").attr("disabled", "true");
|
|
}
|
|
var data = {
|
|
id: id,
|
|
token: cookie.get("token")
|
|
};
|
|
$.ajax({
|
|
type: "get",
|
|
url: Page.SvrIp + "/api/select_exchange",
|
|
data: data,
|
|
dataType: "json",
|
|
success: function (d) {
|
|
if (d.ret == 0) {
|
|
d.data = JSON.parse(d.data)[0];
|
|
LoadExchange_data(d.data);
|
|
}
|
|
},
|
|
error: function () {
|
|
alert("加载失败");
|
|
}
|
|
});
|
|
}
|
|
|
|
function sub_Exchange() {
|
|
layui.form.on('submit(formDemo)', function (data) {
|
|
console.info(data);
|
|
|
|
|
|
data.field.token = cookie.get("token");
|
|
|
|
data.field.BeginTime = data.field.BeginTime == '' ? 0 : (new Date(new Date(data.field.BeginTime)).getTime() / 1000);
|
|
|
|
data.field.EndTime = data.field.EndTime == '' ? 0 : (new Date(new Date(data.field.EndTime)).getTime() / 1000);
|
|
|
|
var itemstr = "";
|
|
$("div[data-curdiv='curdiv']").each(function (i, e) {
|
|
var curtype = 2;
|
|
var curcount = $(e).find("input[data-id='curCount']").val();
|
|
var curid = $(e).find("select[data-id='curid']").val();
|
|
|
|
if (curcount == 0 || curid == 0)
|
|
{
|
|
curhaszero = true
|
|
}
|
|
else{
|
|
if (i != 0) {
|
|
itemstr += '#';
|
|
}
|
|
itemstr += `${curtype}|${curid}|${curcount}`;
|
|
}
|
|
});
|
|
$("div[data-djdiv='djdiv']").each(function (j, e) {
|
|
var djid = $(e).find("select[data-id='dj']").val();
|
|
var djcount = $(e).find("input[data-id='djCount']").val();
|
|
var djtype =2; //$(e).find("input[data-id='djtype']").val();
|
|
|
|
if (djtype == 0 || djcount == 0 || djid == 0)
|
|
{
|
|
djhaszero = true
|
|
}
|
|
else{
|
|
if (itemstr != "") {
|
|
itemstr += '#';
|
|
}
|
|
itemstr += `${djtype}|${djid}|${djcount}`;
|
|
}
|
|
});
|
|
if (itemstr == "") {
|
|
layui.msg("没有任何奖励道具")
|
|
return
|
|
}
|
|
data.field.Content = itemstr;
|
|
$.ajax({
|
|
type: "get",
|
|
url: Page.SvrIp + "/api/add_exchange",
|
|
data: data.field,
|
|
dataType: "json",
|
|
success: function (d) {
|
|
alert(d.msg);
|
|
if (d.ret == 1) {
|
|
|
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
|
parent.location.reload();
|
|
}
|
|
},
|
|
error: function () {
|
|
alert("保存失败");
|
|
}
|
|
});
|
|
return false;
|
|
})
|
|
layui.form.verify({
|
|
exchangeCode: function (value) {
|
|
var reg = /^[0-9a-zA-Z]{5,16}$/
|
|
console.log(value)
|
|
console.log("curhaszero==" + curhaszero + "djhaszero" + djhaszero + "curnum" + curnum)
|
|
if(!reg.test(value.toString())) {
|
|
return '礼包码需为5-16位英文或数字!';
|
|
}
|
|
|
|
let rewardNum = 0;
|
|
var curhaszero = false;
|
|
|
|
var djhaszero = false;
|
|
var djallzero = false;
|
|
$("div[data-curdiv='curdiv']").each(function (i, e) {
|
|
var curtype = 2;
|
|
var curcount = $(e).find("input[data-id='curCount']").val();
|
|
debugger
|
|
var curid = $(e).find("select[data-id='curid']").val();
|
|
|
|
if (curid != 0 && curcount <= 0) {
|
|
curhaszero = true
|
|
}
|
|
if (curid != 0 && curcount > 0) {
|
|
rewardNum++;
|
|
}
|
|
});
|
|
|
|
if(curhaszero) {
|
|
return '货币存在非法输入!';
|
|
}
|
|
|
|
|
|
$("div[data-djdiv='djdiv']").each(function (j, e) {
|
|
var djid = $(e).find("input[data-id='dj']").val();
|
|
var djcount = $(e).find("input[data-id='djCount']").val();
|
|
if (djid !== 0 && djcount < 0) {
|
|
djallzero = true;
|
|
}
|
|
if (djid != 0 && djcount > 0) {
|
|
rewardNum++;
|
|
}
|
|
});
|
|
if (djallzero) {
|
|
return '道具存在非法输入!';
|
|
}
|
|
|
|
if (rewardNum === 0) {
|
|
return '没有任何奖励!';
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
|
|
function LoadExchange_data(data) {
|
|
console.info(data);
|
|
var field = ["Id", "ExchangeCode", "MaxExchangeNum", "ExchangeNum"];
|
|
for (var i in field) {
|
|
var name = field[i];
|
|
$("#" + name).val(data[name]);
|
|
}
|
|
if (data.BeginTime != 0) {
|
|
$("#BeginTime").val(Page.formatDate(data.BeginTime));
|
|
}
|
|
if (data.EndTime != 0) {
|
|
$("#EndTime").val(Page.formatDate(data.EndTime));
|
|
}
|
|
$("input[data-Status=" + data.Status + "]").attr("checked", "checked");
|
|
$("div[data-id=itemdiv]").empty();
|
|
var itemhtml = "";
|
|
for (var i in data.Content.AddGoods) {
|
|
var c = data.Content.AddGoods[i];
|
|
itemhtml += template("itemhtml", {
|
|
djnum: djnum,
|
|
djtype: c.Type,
|
|
djCount: c.Count,
|
|
djid: c.ID
|
|
});
|
|
++djnum;
|
|
}
|
|
$("div[data-id=itemdiv]").html(itemhtml);
|
|
}
|
|
layui.laydate.render({
|
|
elem: '#BeginTime',
|
|
type: "datetime"
|
|
});
|
|
layui.laydate.render({
|
|
elem: '#EndTime',
|
|
type: "datetime"
|
|
|
|
});
|
|
|
|
|
|
// function djnumfun() {
|
|
// if ($("div[data-itemdiv=itemdiv]").length == 6) {
|
|
// alert("道具数量不能多于6种");
|
|
// return;
|
|
// }
|
|
// ++djnum;
|
|
// $("#itemdiv").append(template("itemhtml", {
|
|
// djnum: djnum,
|
|
// djtype: 1000,
|
|
// djCount: 1,
|
|
// djid: 0
|
|
// }));
|
|
// }
|
|
</script>
|
|
<script>
|
|
$(function () {
|
|
sub_Exchange();
|
|
LoadExchange(dataid);
|
|
Load_ItemList();
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
<script type="text/javascript" src="../js/template-web.js"></script>
|
|
|
|
<link href="../bower_components/select2/select2.min.css" rel="stylesheet" type="text/css">
|
|
<script type="text/javascript" src="../bower_components/select2/select2.min.js"></script>
|