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.
 
 
 
 
 
 

235 lines
9.3 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;
}
</style>
</head>
<body>
<div id="wrapper">
<input type="file" id="imgfile" method="post" onchange="ToBase64()" enctype="multipart/form-data" style="display:none;">
<!-- Navigation -->
<form class="layui-form" lay-filter="mform" action="">
<div style="height:300px;border: solid 1px #a3a3a3;" id="mdiv">
<div style="height:250px;">
<div style="float:left;width:49%;">
<div class="layui-form-item" style="display:none;">
<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">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">语言</label>
<div class="layui-input-inline" style="width:200px">
<select id="language" name="language"> </select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline" style="width:200px">
<input type="radio" value="1" data-id="state" name="state" lay-filter='state' title="启用">
<input type="radio" value="2" data-id="state" name="state" lay-filter='state' title="禁用">
<!--<input type="radio" value="3" name="state" lay-filter='state' title="撤回">-->
</div>
</div>
<div class="layui-form-item" data-trigger="0">
<label class="layui-form-label" style="width:120px;">开始时间</label>
<div class="layui-input-inline" style="width:200px">
<input type="text" name="startTime" id="startTime" required lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item" data-trigger="0">
<label class="layui-form-label" style="width:120px;">
结束时间
</label>
<div class="layui-input-inline" style="width:200px">
<input type="text" name="endTime" id="endTime" value="" 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="hidden" data-id="pic" name="pic" id="pic" value="" />
<button type="button" class="layui-btn" onclick="selectimg('pic');">
<i class="layui-icon">&#xe67c;</i>上传图片
</button>
</div>
<img id="pic_img" style="width:50%;height:auto;max-width:300px;" />
</div>
</div>
</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>
</form>
</div>
<script>
function LoadExchange_data(_d) {
for (var i in _d) {
$("#" + i).val(_d[i]);
$("input[type='text'][data-id='" + i + "']").val(_d[i]);
}
$('input:radio[name="state"][value="' + _d.state + '"]').prop("checked", true);
$("#pic_img").attr("src", _d.pic);
layui.form.render();
}
///图片转Base64
function ToBase64() {
var img = document.getElementById('imgfile')
var imgFile = new FileReader();
imgFile.readAsDataURL(img.files[0]);
imgFile.onload = function () {
$("#" + imgflieid).val(this.result);
$("#" + imgflieid + "_img").attr("src", this.result);
}
}
function selectimg(id) {
imgflieid = id;
$("#imgfile").click();
}
function Load_languagelist(f) {
$.get(Page.SvrIp + "/api/select_language",
{ token: cookie.get("token") }
, function (d) {
languagelist = JSON.parse(d.Data);
var html = "";
for (var _i in languagelist) {
var _d = languagelist[_i];
html += ` <option value='${_d.lang_abbr}'>${_d.skip}</option>`;
}
$("#language").html(html);
layui.form.render('select');
console.info(languagelist);
f();
});
}
//兑换码id 0表示新增 非0编辑
var dataid = Page.GetQueryString("id");
function LoadExchange(id) {
var data = {
id: id,
token: cookie.get("token")
};
$.ajax({
type: "get",
url: Page.SvrIp +"/api/select_notice_backgrounds",
data: data,
dataType: "json",
success: function (d) {
if (d.ret == 0) {
LoadExchange_data(d.data[0]);
}
},
error: function () {
alert("加载失败");
}
});
}
function sub_Exchange() {
layui.form.on('submit(formDemo)', function (data) {
data.field.token = cookie.get("token");
$.ajax({
type: "post",
url: Page.SvrIp + "/api/update_notice_backgrounds?token=" + cookie.get("token"),
data: JSON.stringify( data.field),
dataType: "json",
success: function (d) {
if (d.ret == 0) {
//alert(d.msg);
alert(data.Id == 0?"添加成功!":"修改成功!");
parent.layer.close(parent.layer.getFrameIndex(window.name));
parent.location.reload();
}
alert(d.msg);
},
error: function () {
alert("保存失败");
}
});
return false;
})
}
function del(i) {
--djnum;
$("div[data-id=itemdiv" + i+"]").remove();
}
var djnum = 1;
function djnumfun() {
if (djnum == 6) {
alert("道具数量不能多于6种");
return;
}
++djnum;
$("#itemdiv").append(template("itemhtml", {
djnum: djnum,
djtype: 1000,
djCount: 1,
djid: 0
}));
}
</script>
<script>
$(function () {
sub_Exchange();
Load_languagelist(function () {
LoadExchange(dataid);
});
layui.laydate.render({
elem: '#startTime',
type: "datetime"
});
layui.laydate.render({
elem: '#endTime',
type: "datetime"
});
});
</script>
</body>
</html>
<script type="text/javascript" src="../js/template-web.js"></script>