Helius
2021-06-16 5728be2af515b2200e782aa201ca5d4d67d9ea47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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('修改完成');
        });
 
    });
});