layui.define([ 'form', 'laydate', 'table', 'element'], function(exports) {
|
var form = layui.form;
|
var laydate = layui.laydate;
|
laydate.render({
|
elem: '#date',
|
type: 'time',
|
format: 'HH:mm'
|
});
|
laydate.render({
|
elem: '#date1',
|
type: 'time',
|
format: 'HH:mm'
|
});
|
|
// 赋值
|
var setMoneyAndTime = function(e){
|
console.log(e);
|
$.post(Common.ctxPath+ '/admin/setting/money/list.json', {}, function (data) {
|
var dt = data.data;
|
for(var i = 0; i < dt.length; i++){
|
if(dt[i].configTypeCode == 'OVERDRAW_PRICE'){
|
$("#overdrawPrice").val(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'RECHARGE_PRICE') {
|
var pArray = dt[i].configValue.replace('{','').replace('}','').split(',');
|
var html = '';
|
if(e == 1){
|
$("div[name='xxx']").remove();
|
}
|
for(var h = 0; h < pArray.length; h++){
|
html += '<div class="layui-input-inline" name="xxx">' +
|
'<input type="number" id="rprice'+h+'" name="title" value="'+pArray[h]+'" placeholder="请输入标题" class="layui-input"/>' +
|
'</div>';
|
}
|
$("#recharge").after(html);
|
}else if(dt[i].configTypeCode == 'AGENT_PRICE'){
|
$("#agentPrice").val(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'INTERVAL_TIME'){
|
$("#timeInterval").val(dt[i].configValue);
|
$("#x1").html(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'START_TIME'){
|
$("#date").val(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'END_TIME'){
|
$("#date1").val(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'ORDERTOTAL'){
|
$("#orderTotal").val(dt[i].configValue);
|
}else if(dt[i].configTypeCode == 'ORDERTIMEOUT'){
|
$("#orderTimeout").val(dt[i].configValue);
|
}
|
}
|
})
|
}
|
|
setMoneyAndTime(0);
|
// 更新
|
$("#updateMoney, #updateRecharge").click(function (e) {
|
var rp = "{" + $("#rprice0").val() + "," + $("#rprice1").val() + "," + $("#rprice2").val() + "," + $("#rprice3").val() + "," +
|
$("#rprice4").val() +"," + $("#rprice5").val() + "}";
|
|
var st, et;
|
if($(this).attr('id') == 'updateMoney'){
|
if($("#date").val().length == 0){
|
Common.info('请选择约开始时间');
|
return ;
|
}
|
if($("#date1").val().length == 0){
|
Common.info('请选择预约结束时间');
|
return ;
|
}
|
if($("#timeInterval").val().length == 0){
|
Common.info('请选择间隔时间');
|
return ;
|
}
|
if($("#agentPrice").val().length == 0){
|
Common.info('请添加代丢价格');
|
return ;
|
}
|
if($("#orderTotal").val().length == 0){
|
Common.info('订单数量设置不能为空');
|
return ;
|
}
|
if($("#orderTimeout").val().length == 0){
|
Common.info('订单超时时间不能为空');
|
return ;
|
}
|
var x = $("#date").val().split(':');
|
var y = $("#date1").val().split(':');
|
if(x[0] >= y[0]){
|
Common.info('开始时间不能大于或等于结束时间');
|
return false;
|
}
|
st = $("#date").val();
|
et = $("#date1").val();
|
}else{
|
st = '';
|
et = '';
|
if($("#rprice0").val().length == 0 || $("#rprice1").val().length == 0 || $("#rprice2").val().length == 0
|
|| $("#rprice3").val().length == 0 || $("#rprice4").val().length == 0 || $("#rprice5").val().length == 0){
|
Common.info('金额不能为空');
|
return ;
|
}
|
|
}
|
var data = {"agentPrice":$("#agentPrice").val(),
|
"timeInterval":$("#timeInterval").val(),
|
"startTime":st,
|
"endTime":et,
|
"overdrawPrice":$("#overdrawPrice").val(),
|
"rechargePrice":rp,
|
"orderTotal":$("#orderTotal").val(),
|
"orderTimeout":$("#orderTimeout").val()
|
};
|
$.post(Common.ctxPath+ '/admin/setting/money/updateMoney.json', data, function (value) {
|
setMoneyAndTime(1);
|
Common.info('修改完成');
|
});
|
|
});
|
});
|