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.
545 lines
24 KiB
545 lines
24 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>
|
|
<script type="text/javascript" src="../js/notice/xm-select.js"></script>
|
|
<script type="text/javascript" src="../js/load_realmlist.js"></script>
|
|
|
|
<div id="wrapper">
|
|
|
|
<form class="layui-form" lay-filter="mform" action="" id="form" style="margin-top: 20px">
|
|
<div id="mdiv" style="margin-top: 20px">
|
|
<div id="djdiv" style="margin-top: 20px">
|
|
<div class="form-group" data-id="djdiv" style="margin-top: 20px">
|
|
|
|
<div class="layui-form-item" >
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">服务器</label>
|
|
<div class="col-sm-10" id="realmlistdiv">
|
|
<div id="realmlistSelect" style="display: inline-block;width: 300px;margin-left: 20px;"></div>
|
|
<div id="realmlistRule" style="display: inline-block;margin-left: 20px;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">生效时间</label>
|
|
<div class="col-sm-5">
|
|
<input type="text" lay-verify="required" class="form-control zero" id="start_time" placeholder="">
|
|
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<input type="text" lay-verify="required" class="form-control zero" id="end_time" placeholder="">
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="layui-form-item" style="border: 1px solid #ccc;border-radius: 4px;padding-bottom: 50px;">
|
|
<div class="form-group" style="margin-top:10px;" data-id="itemdiv">
|
|
<label class="col-sm-2 control-label">道具ID1</label>
|
|
<div class="col-sm-3">
|
|
|
|
<select class="form-control zero" data-id="itemid" id="item1">
|
|
<option value="-1">-----请选择-----</option>
|
|
</select>
|
|
|
|
</div>
|
|
<label class="col-sm-2 control-label">道具1数量</label>
|
|
<div class="col-sm-2">
|
|
<input lay-verify="required" type="text" class="form-control zero" id="itemCount1" data-id="itemnum" value="0" placeholder="">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<button type="button" class="layui-btn col-sm-2" id="adddj" style=" float:left; ">
|
|
增加道具
|
|
</button>
|
|
</div>
|
|
<div class="layui-form-item" style="border: 1px solid #ccc;border-radius: 4px;padding-bottom: 50px;" id="customItemDiv">
|
|
<div class="form-group" style="margin-top:10px;" data-id="customItemDiv" id="customItemDv1">
|
|
<label class="col-sm-1 control-label">其他1类型</label>
|
|
<div class="col-sm-3">
|
|
<select lay-filter="customItemSelect" class="form-control zero" data-id="customItemType" id="customItemType1" onchange="selectCustomItem(1,this.options[this.options.selectedIndex].value,0)">
|
|
<option value="-1">-----请选择-----</option>
|
|
<option value="2">武器</option>
|
|
<option value="3">翅膀</option>
|
|
<option value="4">坐骑</option>
|
|
<option value="5">称号</option>
|
|
<option value="6">宝石</option>
|
|
<option value="7">宝石图纸</option>
|
|
<option value="8">领地资源</option>
|
|
<option value="9">伙伴</option>
|
|
<option value="10">赛马技能</option>
|
|
<option value="13">装备幻化</option>
|
|
<option value="15">钓鱼鱼饵</option>
|
|
<option value="16">伙伴礼物</option>
|
|
</select>
|
|
</div>
|
|
|
|
<label class="col-sm-1 control-label">其他1ID</label>
|
|
<div class="col-sm-2">
|
|
<select class="form-control zero" id="customItemId1" data-id="customItemId"></select>
|
|
|
|
</div>
|
|
<label class="col-sm-1 control-label">其他1数量</label>
|
|
<div class="col-sm-1">
|
|
<input type="text" lay-verify="required" class="form-control zero" id="customItemCount1" data-id="customItemNum" value="0" placeholder="">
|
|
</div>
|
|
</div>
|
|
<button type="button" class="layui-btn col-sm-2" id="addCustomItem" style="float:left; ">
|
|
增加自定义
|
|
</button>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-form-item">
|
|
<div class="layui-input-block">
|
|
<button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
<script type="text/template" id="itemhtml">
|
|
<div class="form-group" style="margin-top:10px;" data-id="itemdiv" id="itemdiv{{djnum}}">
|
|
<div class="layui-form-item">
|
|
<label class="col-sm-2 control-label">道具ID{{djnum}}</label>
|
|
<div class="col-sm-3">
|
|
<!-- <input type="text" class="form-control zero" data-id="itemid" id="item{{djnum}}" value="0" placeholder=""> -->
|
|
<select class="form-control zero" data-id="itemid" id="item{{djnum}}">
|
|
<option value="-1">-----请选择-----</option>
|
|
</select>
|
|
|
|
</div>
|
|
<label class="col-sm-2 control-label">道具{{djnum}}数量</label>
|
|
<div class="col-sm-2">
|
|
<input type="text" class="form-control zero" id="itemCount{{djnum}}" data-id="itemnum" value="0" placeholder="">
|
|
</div>
|
|
<button type="button" class="layui-btn layui-btn-danger col-sm-2" data-toggle="modal" onclick="del({{djnum}})" style="float:left;">
|
|
删除道具
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
<script type="text/template" id="customItemhtml">
|
|
|
|
<div class="form-group" style="margin-top:10px;" data-id="customItemDiv" id="customItemDiv{{djnum}}">
|
|
<div class="layui-form-item">
|
|
<label class="col-sm-1 control-label">其他{{djnum}}类型</label>
|
|
<div class="col-sm-3">
|
|
<select lay-filter="customItemSelect" class="form-control zero" data-id="customItemType" id="customItemType{{djnum}}">
|
|
<option value="-1">-----请选择-----</option>
|
|
<option value="2">武器</option>
|
|
<option value="3">翅膀</option>
|
|
<option value="4">坐骑</option>
|
|
<option value="5">称号</option>
|
|
<option value="6">宝石</option>
|
|
<option value="7">宝石图纸</option>
|
|
<option value="8">领地资源</option>
|
|
<option value="9">伙伴</option>
|
|
<option value="10">赛马技能</option>
|
|
<option value="11">赛马血统</option>
|
|
<option value="15">钓鱼鱼饵</option>
|
|
<option value="16">伙伴礼物</option>
|
|
</select>
|
|
</div>
|
|
<label class="col-sm-1 control-label">其他{{djnum}}ID</label>
|
|
<div class="col-sm-2">
|
|
<select class="form-control zero" id="customItemId{{djnum}}" data-id="customItemId"></select>
|
|
</div>
|
|
<label class="col-sm-1 control-label">其他{{djnum}}数量</label>
|
|
<div class="col-sm-1">
|
|
<input type="text" class="form-control zero" id="customItemCount{{djnum}}"
|
|
data-id="customItemNum" value="0" placeholder="">
|
|
</div>
|
|
<button type="button" class="layui-btn layui-btn-danger col-sm-1" data-toggle="modal"
|
|
onclick="delCustomItem({{djnum}})" style="float:left;">
|
|
删除自定义
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
<script type="application/javascript">
|
|
var id;
|
|
var herolist;
|
|
var djnum = 1;
|
|
var adddjcur = 1;
|
|
var heronum = 1;
|
|
var equipNum = 1;
|
|
var customItemNum = 1;
|
|
var skinItemNum = 1;
|
|
|
|
var languagelist;
|
|
var skinList
|
|
var itemCostList;
|
|
var itemList;
|
|
|
|
var pageTail=0;
|
|
const hashMap = new Map();
|
|
window.addEventListener('message', function(event) {
|
|
// 获取传递的数据
|
|
var data = event.data;
|
|
id=data.data;
|
|
// 在控制台输出数据
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
layui.use(['layer', 'form'], function () {
|
|
var layer = layui.layer;
|
|
var form = layui.form;
|
|
|
|
|
|
form.on('select(customItemSelect)', function (data) {
|
|
var fid=data.elem.id;
|
|
let cid=fid.replaceAll("customItemType","")
|
|
selectCustomItem(cid,data.value,0)
|
|
console.dir(cid)
|
|
console.log(data.value); // 选择的值
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
async function load() {
|
|
await Load_realmlist();
|
|
await sub_Exchange()
|
|
await Load_ItemList();
|
|
if(id>0){
|
|
await Load_Preset()
|
|
}
|
|
}
|
|
load();
|
|
|
|
var _d = new Date();
|
|
layui.laydate.render({
|
|
elem: '#start_time'
|
|
, type: 'datetime'
|
|
});
|
|
|
|
layui.laydate.render({
|
|
elem: '#end_time',
|
|
type: 'datetime',
|
|
format: 'yyyy-MM-dd HH:mm:ss',
|
|
});
|
|
});
|
|
|
|
|
|
function Load_Preset(){
|
|
$.get(
|
|
Page.SvrIp + "/api/select_preset",
|
|
{
|
|
token: cookie.get("token"),
|
|
id: id,
|
|
},
|
|
function (d) {
|
|
var _d = d.data[0];
|
|
let presetData = _d;
|
|
console.log(presetData)
|
|
|
|
for (var i in _d) {
|
|
$("#" + i).val(_d[i]);
|
|
if (i == "start_time"||i=="end_time") {
|
|
$("input[data-id='" + i + "']").val(_d[i]);
|
|
}
|
|
}
|
|
//全服
|
|
if (_d.realms === "") {
|
|
//选中全服
|
|
realmlistSelect.setValue([0]);
|
|
} else {
|
|
var realmlistArr = _d.realms.split(",");
|
|
realmlistSelect.setValue(realmlistArr);
|
|
}
|
|
var items=_d.items.split("#");
|
|
let cj=0;
|
|
let ij=0;
|
|
for (var i=0; i<items.length; i++) {
|
|
var item=items[i];
|
|
let it=item.split("|");
|
|
if(it[0]==="1"){//普通道具
|
|
if(ij==0){
|
|
//todo
|
|
$("#item1").val(it[1])
|
|
$("#itemCount1").val(it[2])
|
|
ij++
|
|
}else{
|
|
AddItemView(it[1],it[2])
|
|
}
|
|
}else{//自定义道具
|
|
if(cj==0){
|
|
$("#customItemType1").val(it[0])
|
|
$("#customItemCount1").val(it[2]);
|
|
selectCustomItem(1,it[0],it[1]);
|
|
cj++;
|
|
}else{
|
|
AddCustomItView(it[0],it[1],it[2])
|
|
}
|
|
}
|
|
}
|
|
layui.form.render();
|
|
}
|
|
);
|
|
|
|
}
|
|
function Load_ItemList() {
|
|
$.get(Page.SvrIp + "/api/select_itemlist",
|
|
{ token: cookie.get("token") }
|
|
, function (d) {
|
|
itemList = d.data;
|
|
AddItemList("item1");
|
|
});
|
|
}
|
|
|
|
|
|
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 sub_Exchange() {
|
|
|
|
layui.form.on('submit(formDemo)', function (data) {
|
|
var sub_data = {};
|
|
sub_data.token= cookie.get("token");
|
|
sub_data.id =id;
|
|
|
|
let start = $('#start_time').val();
|
|
let end = $('#end_time').val();
|
|
if (start === "" || start == null) {
|
|
parent.layer.msg("请设置生效时间");
|
|
return;
|
|
}
|
|
if (end === "" || end == null) {
|
|
parent.layer.msg("请设置生效时间");
|
|
return;
|
|
}
|
|
var startTime = new Date(start);
|
|
var endTime = new Date(end);
|
|
|
|
if (startTime >= endTime) {
|
|
parent.layer.msg('开始时间不能晚于或等于结束时间!');
|
|
return
|
|
}
|
|
sub_data.start=start;
|
|
sub_data.end=end;
|
|
|
|
//支持的服务器
|
|
|
|
var _realmlist = realmlistSelect?.getValue('value');
|
|
_realmlist.sort((a, b) => a - b);
|
|
sub_data.realmlist = _realmlist.join(',');
|
|
if(sub_data.realmlist == '0') {
|
|
sub_data.realmlist = ''
|
|
}
|
|
//常规道具
|
|
sub_data.itemstr = "";
|
|
$("div[data-id='itemdiv']").each(function (i, e) {
|
|
var itemid = $(e).find("select[data-id='itemid']").select().val();
|
|
var itemnum = $(e).find("input[data-id='itemnum']").val();
|
|
if (itemid == "0" || itemnum == "") {
|
|
return true; //结束本次循环
|
|
}
|
|
if (itemid == '-1') {
|
|
return true;
|
|
}
|
|
if (itemnum == '0') {
|
|
return true;
|
|
}
|
|
if (i == 0) {
|
|
sub_data.itemstr += `1|${itemid}|${itemnum}`;
|
|
} else {
|
|
sub_data.itemstr += `#1|${itemid}|${itemnum}`;
|
|
}
|
|
});
|
|
//自定义道具
|
|
$("div[data-id='customItemDiv']").each(function (i, e) {
|
|
var curtype = $(e).find("select[data-id='customItemType']").select().val();
|
|
var curid = $(e).find("select[data-id='customItemId']").select().val();
|
|
var curnum = $(e).find("input[data-id='customItemNum']").val();
|
|
if (curtype == "0" ||curtype == "" || curid == "0" || curid == "" || curnum == "0"|| curnum == "") {
|
|
return true; //结束本次循环
|
|
}
|
|
if (sub_data.itemstr==='') {
|
|
sub_data.itemstr += `${curtype}|${curid}|${curnum}`;
|
|
} else {
|
|
sub_data.itemstr += `#${curtype}|${curid}|${curnum}`;
|
|
}
|
|
});
|
|
if(sub_data.itemstr==""){
|
|
parent.layer.msg('请配置正确的道具!');
|
|
return;
|
|
}
|
|
|
|
var loadIndex = parent.layer.msg('请稍等', {
|
|
icon: 16,
|
|
shade: 0.01
|
|
});
|
|
|
|
$.ajax({
|
|
type: "get",
|
|
url: Page.SvrIp + "/api/update_preset",
|
|
data: sub_data,
|
|
dataType: "json",
|
|
success: function (d) {
|
|
console.dir(d);
|
|
layer.close(loadIndex)
|
|
if (d.code == 0) {
|
|
parent.layer.msg("操作完成,请刷新")
|
|
}else{
|
|
let msg=d.msg;
|
|
if(msg==""||msg==null){
|
|
msg="操作完成"
|
|
}
|
|
parent.layer.msg(d.msg)
|
|
}
|
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
|
parent.location.reload();
|
|
},
|
|
error: function (status) {
|
|
layer.close(loadIndex)
|
|
parent.layer.msg("操作完成,请刷新")
|
|
}
|
|
});
|
|
return false;
|
|
})
|
|
|
|
}
|
|
|
|
|
|
function selectCustomItem(id,type,target){
|
|
if(type==-1){
|
|
$('#customItemId'+id).html('')
|
|
return;
|
|
}
|
|
console.log(id+"--"+type)
|
|
if(hashMap.has(type)){
|
|
let data=hashMap.get(type);
|
|
viewCustomItem(id,data,target)
|
|
return;
|
|
}
|
|
$.get(Page.SvrIp + "/api/select_itemlist",
|
|
{ token: cookie.get("token"),type:type }
|
|
, function (d) {
|
|
if (d.data !== undefined) {
|
|
hashMap[type] = d.data;
|
|
viewCustomItem(id,d.data,target)
|
|
}
|
|
});
|
|
}
|
|
function viewCustomItem(id,data,target){
|
|
|
|
$('#customItemId'+id).html('')
|
|
var list =new Array();
|
|
|
|
for (let [key, value] of Object.entries(data)) {
|
|
list.push({id:key,text:value})
|
|
if(target==key){
|
|
$('#customItemId'+id).append('<option value="'+key+'" selected>'+value+'</option>');
|
|
}else {
|
|
$('#customItemId'+id).append('<option value="'+key+'">'+value+'</option>');
|
|
}
|
|
}
|
|
layui.form.render('select');
|
|
}
|
|
|
|
|
|
|
|
$("#addCustomItem").click(function () {
|
|
++customItemNum;
|
|
$("#addCustomItem").before().before(template("customItemhtml", {
|
|
djnum: customItemNum
|
|
}));
|
|
layui.form.render('select');
|
|
});
|
|
function delCustomItem(i) {
|
|
--customItemNum;
|
|
$("#customItemDiv" + i).remove();
|
|
}
|
|
|
|
$("#adddj").click(function () {
|
|
if(djnum >= 12) {
|
|
layer.alert("附件总量不超过12");
|
|
return;
|
|
}
|
|
if (djnum == 12) {
|
|
alert("道具数量不能多于12种");
|
|
return;
|
|
}
|
|
++djnum;
|
|
$("#adddj").before(template("itemhtml", {
|
|
djnum: djnum
|
|
}));
|
|
AddItemList('item'+djnum);
|
|
});
|
|
function del(i) {
|
|
--djnum;
|
|
$("#itemdiv" + i).remove();
|
|
}
|
|
function AddItemView(id,num){
|
|
++djnum;
|
|
$("#adddj").before(template("itemhtml", {
|
|
djnum: djnum,
|
|
}));
|
|
AddItemList('item'+djnum);
|
|
$("#item"+djnum).val(id)
|
|
$("#itemCount"+djnum).val(num)
|
|
layui.form.render('select');
|
|
}
|
|
function AddCustomItView(type,id,num){
|
|
debugger
|
|
++customItemNum;
|
|
$("#addCustomItem").before().before(template("customItemhtml", {
|
|
djnum: customItemNum
|
|
}));
|
|
$("#customItemCount"+customItemNum).val(num);
|
|
$("#customItemType"+customItemNum).val(type);
|
|
selectCustomItem(customItemNum,type,id);
|
|
}
|
|
</script>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|
|
<script type="text/javascript" src="../js/template-web.js"></script>
|
|
<script type="text/javascript" src="../js/notice/xm-select.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> -->
|