dongfeng-pay/legend/views/template-add.html

343 lines
20 KiB
Go
Raw Normal View History

2021-04-27 15:33:49 +08:00
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>充值商户后台</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
2021-05-19 13:46:49 +08:00
{{/* <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />*/}}
2021-04-27 15:33:49 +08:00
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="../static/x-admin/css/font.css">
<link rel="stylesheet" href="../static/x-admin/css/xadmin.css">
<!-- <link rel="stylesheet" href="./css/theme5.css"> -->
<script src="../static/x-admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../static/x-admin/js/xadmin.js"></script>
<script type="text/javascript" src="../static/js/jquery-3.5.1.min.js"></script>
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-header"><b>配置模板</b></div>
<div class="layui-card-body">
<div class="layui-row">
2021-05-16 15:21:52 +08:00
<form class="layui-form" action="" method="post">
2021-04-27 15:33:49 +08:00
<div class="layui-collapse">
<div class="layui-colla-item">
<h1 class="layui-colla-title">基础配置</h1>
<div class="layui-colla-content layui-show">
2021-05-16 15:21:52 +08:00
2021-04-27 15:33:49 +08:00
<div class="layui-form-item">
<label class="layui-form-label"><strong>模板名称</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="scaleTemplateName" required lay-verify="required" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">取名保证唯一性</div>
</div>
2021-05-16 15:21:52 +08:00
2021-04-27 15:33:49 +08:00
<div class="layui-form-item">
<label class="layui-form-label"><strong>用户标识</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="scaleUserName" required lay-verify="required" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">可填写角色名或者角色ID不可为空</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><strong>用户标识提示</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="scaleUserNamePoint" placeholder="如通过角色属性面板查看角色ID" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">此提示会在充值页面显示提示玩家如何查看用户标识</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><strong>金额类型</strong></label>
<div class="layui-input-block">
2021-05-16 15:21:52 +08:00
<input type="radio" lay-filter="money-type-filter" name="moneyType" value="radio-any-money" title="任意金额" checked>
<input type="radio" lay-filter="money-type-filter" name="moneyType" value="radio-fixed-money" title="固定金额">
2021-04-27 15:33:49 +08:00
</div>
</div>
<!-- 任意金额的样式 -->
<div id="any-money-style">
<div class="layui-form-item">
<label class="layui-form-label"><strong>游戏币名称</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="gameMoneyName" placeholder="" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">默认是元宝也可以是钻石点券</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><strong>游戏币比例</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="gameMoneyScale" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">默认是100既充值1元人命币转为100游戏币</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><strong>最低充值金额</strong></label>
<div class="layui-input-inline">
2021-05-16 15:21:52 +08:00
<input type="text" name="limitLowMoney" autocomplete="off" class="layui-input">
2021-04-27 15:33:49 +08:00
</div>
<div class="layui-form-mid layui-word-aux">默认最低为10元</div>
</div>
</div>
<!-- 固定金额的样式-->
<div id="fixed-money-style" class="layui-row" style="margin-left: 40px;">
<div id="fixed-money-child-style"></div>
<div class="layui-btn" style="margin-left: 10px;" onclick="addFixedMoenyStyle();"><i class="layui-icon layui-icon-add-circle">添加商品</i></div>
<div style="color: red; margin-left: 10px;"><h3><p>说明请根据游戏内设置的商品道具进行设置切勿乱填</p><p>可购次数填0代表不限填1代表一个帐号仅可购买一次依此类推</p></h3></div>
</div>
</div>
</div>
<div class="layui-colla-item">
<h1 class="layui-colla-title">激励赠送</h1>
<div class="layui-colla-content layui-show">
<div class="layui-form-item">
<label class="layui-form-label"><strong>赠送方式</strong></label>
<div class="layui-input-block">
2021-05-16 15:21:52 +08:00
<input type="radio" lay-filter="present-type-filter" name="presentType" value="close-present" title="关闭" checked>
<input type="radio" lay-filter="present-type-filter" name="presentType" value="fixed-money-present" title="固定金额赠送">
<input type="radio" lay-filter="present-type-filter" name="presentType" value="scale-present" title="按百分比赠送">
2021-04-27 15:33:49 +08:00
</div>
</div>
<!-- 按金额赠送-->
<div id="present-type-money-style">
<div id="present-type-money-child-style"></div>
<div class="layui-btn" style="margin-left: 50px;" onclick="addPresentTypeMoneyStyle();"><i class="layui-icon layui-icon-add-circle"></i>添加</div>
</div>
<!-- 按百分比赠送-->
<div id="present-type-scale-style">
<div id="present-type-scale-child-style"></div>
<div class="layui-btn" style="margin-left: 50px;" onclick="addPresentTypeScaleStyle();"><i class="layui-icon layui-icon-add-circle"></i>添加</div>
</div>
</div>
</div>
2021-05-16 15:21:52 +08:00
</div>
<div class="layui-form-item">
<br>
2021-05-19 13:46:49 +08:00
<button class="layui-btn" lay-filter="add" lay-submit="">添加</button>
2021-05-16 15:21:52 +08:00
<div class="layui-btn layui-btn-danger" onclick="back();">返回当前页</div>
2021-04-27 15:33:49 +08:00
</div>
</form>
</div>
2021-05-16 15:21:52 +08:00
2021-04-27 15:33:49 +08:00
</div>
</div>
</div>
{{/* </div>*/}}
<script>
// 动态添加固定金额赠送input框
function addPresentTypeMoneyStyle() {
2021-05-16 15:21:52 +08:00
let s = randomString(20)
2021-04-27 15:33:49 +08:00
let str = '<div class="layui-form-item"><label class="layui-form-label"><strong>充值</strong></label><div class="layui-input-inline">' +
2021-05-16 15:21:52 +08:00
'<input type="text" name="present-fix-money" placeholder="金额(元)" autocomplete="off" class="layui-input present-fix-money">' +
'<input type="hidden" name="present-fix-uid" value="' + s + '" autocomplete="off" class="layui-input present-fix-uid">' +
'</div><div class="layui-input-inline">' +
'<input type="text" name="present-fix-present-money" placeholder="赠送金额(元)" autocomplete="off" class="layui-input present-fix-present-money">' +
2021-04-27 15:33:49 +08:00
'</div><div class="layui-inline"><div class="layui-btn layui-btn-danger fixed-money-child-del"><i class="layui-icon layui-icon-delete">删除</i></div></div></div>';
$("#present-type-money-child-style").append(str);
}
// 动态添加按百分比赠送input框
function addPresentTypeScaleStyle() {
2021-05-16 15:21:52 +08:00
let s = randomString(20)
2021-04-27 15:33:49 +08:00
let str = '<div class="layui-form-item"><label class="layui-form-label"><strong>充值</strong></label><div class="layui-input-inline">' +
2021-05-16 15:21:52 +08:00
'<input type="text" name="present-scale-money" placeholder="金额(元)" autocomplete="off" class="layui-input present-scale-money">' +
'<input type="hidden" name="present-scale-uid" value="' + s + '" autocomplete="off" class="layui-input present-scale-uid">' +
'</div><div class="layui-input-inline"><input type="text" name="present-scale" placeholder="赠送比例(%" autocomplete="off" class="layui-input present-scale">' +
2021-04-27 15:33:49 +08:00
'</div><div class="layui-inline"><div class="layui-btn layui-btn-danger fixed-money-child-del"><i class="layui-icon layui-icon-delete">删除</i></div></div></div>';
$("#present-type-scale-child-style").append(str);
}
// 动态添加固定金额的input输入框
function addFixedMoenyStyle() {
2021-05-16 15:21:52 +08:00
let s = randomString(20)
2021-04-27 15:33:49 +08:00
let str = '<div class="layui-form-item">' +
'<div class="layui-col-md1" style="margin-left: 10px;">' +
2021-05-16 15:21:52 +08:00
'<input type="text" name="fix-price" placeholder="售价(元)" autocomplete="off" class="layui-input fix-price">' +
'<input type="hidden" name="fix-uid" autocomplete="off" class="layui-input fix-uid" value="' + s + '">' +
2021-04-27 15:33:49 +08:00
'</div><div class=" layui-col-md2" style="margin-left: 10px;">' +
2021-05-16 15:21:52 +08:00
'<input type="text" name="fix-goods-name" placeholder="商品名称" autocomplete="off" class="layui-input fix-goods-name">' +
2021-04-27 15:33:49 +08:00
'</div><div class="layui-col-md2" style="margin-left: 10px;">' +
2021-05-16 15:21:52 +08:00
'<input type="text" name="fix-goods-no" placeholder="商品编号" autocomplete="off" class="layui-input fix-goods-no">' +
'</div><div class="layui-col-md1" style="margin-left: 10px;"><input type="text" name="fix-limit-low" placeholder="可够次数" autocomplete="off" class="layui-input fix-limit-low">' +
2021-04-27 15:33:49 +08:00
'</div><div class="layui-inline" style="margin-left: 10px;">' +
'<div class="layui-btn layui-btn-danger fixed-money-child-del"><i class="layui-icon layui-icon-delete"> 删除</i></div></div></div>';
$("#fixed-money-child-style").append(str);
2021-05-16 15:21:52 +08:00
// $(".fix-uid").val(randomString(20))
2021-04-27 15:33:49 +08:00
}
// 删除固金额input
$("div").on('click', '.fixed-money-child-del', function () {
$(this).parent().parent().remove();
})
layui.use(['form', 'layer', 'element'], function() {
let element = layui.element;
$ = layui.jquery;
2021-05-16 15:21:52 +08:00
let form = layui.form,
2021-04-27 15:33:49 +08:00
layer = layui.layer;
// 进入该页面首先做的事情
$(document).ready(function () {
2021-05-16 15:21:52 +08:00
// $("#fixed-money-style").toggle();
$("#fixed-money-style").hide();
$("#any-money-style").show();
2021-04-27 15:33:49 +08:00
$("#present-type-money-style").hide();
$("#present-type-scale-style").hide();
})
//自定义验证规则
form.verify({
nikename: function(value) {
if (value.length < 5) {
return '昵称至少得5个字符啊';
}
},
pass: [/(.+){6,12}$/, '密码必须6到12位'],
repass: function(value) {
if ($('#L_pass').val() != $('#L_repass').val()) {
return '两次密码不一致';
}
}
});
// 监听赠送类型的radio
form.on('radio(present-type-filter)', function (data) {
let radioValue = data.value;
if ("close-present" === radioValue) {
$("#present-type-money-style").hide();
$("#present-type-scale-style").hide();
} else if ("fixed-money-present" === radioValue) {
$("#present-type-money-style").show();
$("#present-type-scale-style").hide();
2021-05-16 15:21:52 +08:00
} else if ("scale-present" === radioValue) {
2021-04-27 15:33:49 +08:00
$("#present-type-money-style").hide();
$("#present-type-scale-style").show();
}
})
// 监听金额类型的radio
form.on('radio(money-type-filter)', function (data) {
let value = data.value;
2021-05-16 15:21:52 +08:00
if ("radio-any-money" === value) {
2021-04-27 15:33:49 +08:00
//处理任何金额
2021-05-16 15:21:52 +08:00
$("#any-money-style").show();
$("#fixed-money-style").hide();
2021-04-27 15:33:49 +08:00
} else {
// 处理固定金额
2021-05-16 15:21:52 +08:00
$("#any-money-style").hide();
$("#fixed-money-style").show();
2021-04-27 15:33:49 +08:00
}
})
//监听提交
form.on('submit(add)', function(data) {
2021-05-16 15:21:52 +08:00
let jsonObj = {}
jsonObj.scaleTemplateName = data.field.scaleTemplateName
jsonObj.scaleUserName = data.field.scaleUserName
jsonObj.scaleUserNamePoint = data.field.scaleUserNamePoint
jsonObj.moneyType = data.field.moneyType
jsonObj.gameMoneyName = data.field.gameMoneyName
jsonObj.gameMoneyScale = data.field.gameMoneyScale
if (data.field.limitLowMoney === "" || data.field.limitLowMoney === null) {
jsonObj.limitLowMoney = "10"
} else {
jsonObj.limitLowMoney = data.field.limitLowMoney
}
jsonObj.presentType = data.field.presentType
jsonObj.fixPrices = getArrays(".fix-price")
jsonObj.goodsNames = getArrays(".fix-goods-name")
jsonObj.goodsNos = getArrays(".fix-goods-no")
jsonObj.limits = getArrays(".fix-limit-low")
jsonObj.presentFixMoneys = getArrays(".present-fix-money")
jsonObj.presentFixPresentMoneys = getArrays(".present-fix-present-money")
jsonObj.presentScaleMoneys =getArrays(".present-scale-money")
jsonObj.presentScales = getArrays(".present-scale")
jsonObj.fixUids = getArrays(".fix-uid")
jsonObj.presentScaleUids = getArrays(".present-scale-uid")
jsonObj.presentFixUids = getArrays(".present-fix-uid")
console.log(JSON.stringify(jsonObj))
2021-04-27 15:33:49 +08:00
//发异步把数据提交给php
2021-05-16 15:21:52 +08:00
$.ajax({
url: "/add/template",
data: jsonObj,
success: function (res) {
alert(res.Msg)
if (res.Code === 0) {
window.history.back(-1);
}
},
error: function () {
layer.alert("系统异常")
}
2021-04-27 15:33:49 +08:00
});
2021-05-16 15:21:52 +08:00
2021-04-27 15:33:49 +08:00
return false;
});
});
2021-05-16 15:21:52 +08:00
function getArrays(obj) {
let arrays = []
$(obj).each(function () {
let v = $(this).val();
if (v === null || v.length <=0) {
arrays.push(0)
} else {
arrays.push(v)
}
})
return arrays.join(",")
}
function back() {
window.history.back(-1);
}
function randomString(n) {
let chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
let res = "";
for(let i = 0; i < n ; i ++) {
let id = Math.ceil(Math.random()*35);
res += chars[id];
}
return res;
}
2021-04-27 15:33:49 +08:00
</script>
</body>
</html>