listMange.js 3.12 KB
var listMangeJS = {};
var urls = {
    "reportbyday": "/marketing/hapi/reportbyday",
    "reportbymonth": "/marketing/hapi/reportbymonth"
};

listMangeJS.list = function() {
    //var status = $("#status").val();
    var status = 1;
    var begin_time = $("#begin_time").val();
    var end_time = $("#end_time").val();
    var type = $("input[name='type']:checked").val();
    var url = "";
    if (type == 0) {
        url = _REQUESTURL + urls.reportbyday;
    } else {
        url = _REQUESTURL + urls.reportbymonth;
    }
    $.ajax({
        "url": url,
        "data": { beginTime: begin_time, endTime: end_time, page: 1, size: 15 },
        "success": function(res) {
            if (res.success && res.code == 2000) {
                if (res.content) {

                    var context = "<thead>" +
                        "<tr>" +
                        "<th>时间</th>" +
                        "<th>注册数量</th>" +
                        "<th>领取数量</th>" +
                        "</tr>" +
                        "</thead>";
                    if (res.content) {
                        $.each(res.content, function(k, v) {
                            context = context +
                                "<tr>" +
                                "    <td>" + _nullValue(k) + "</td>" +
                                "    <td>" + (v.registerCount) + "</td>" +
                                "    <td>" + (v.genereportCount) + "</td>";
                            context = context +
                                "    </td>" +
                                "</tr>";
                        });
                    }
                    $("#data_table").html(context);
                } else {}
            } else {
                alert("系统错误");
            }
        }
    });

}





$(function() {
    var myDate = new Date();
    var lw = new Date(myDate - 1000 * 60 * 60 * 24 * 30); //最后一个数字30可改,30天的意思
    var lastY = lw.getFullYear();
    var lastM = lw.getMonth() + 1;
    var lastD = lw.getDate();
    var startdate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD); //三十天之前日期
    var nowY = myDate.getFullYear();
    var nowM = myDate.getMonth() + 1;
    var nowD = myDate.getDate();
    var enddate = nowY + "-" + (nowM < 10 ? "0" + nowM : nowM) + "-" + (nowD < 10 ? "0" + nowD : nowD); //当前日期
    $("#begin_time").val(startdate);
    $("#end_time").val(enddate);
    //时间空间初始化
    jeDate({
        dateCell: "#begin_time",
        format: "YYYY-MM-DD",
        isinitVal: false,
        isTime: true, //isClear:false,
        okfun: function(val) {}
    })

    //时间空间初始化
    jeDate({
        dateCell: "#end_time",
        format: "YYYY-MM-DD",
        isinitVal: false,
        isTime: true, //isClear:false,
        okfun: function(val) {}
    })

    listMangeJS.list();

    $("#search").on("click", function() {
        listMangeJS.list();
    });

    $(document).keypress(function(e) {
        // 回车键事件 
        if (e.which == 13) {
            listMangeJS.list();
            return;
        }
    });

});