index.js 3.61 KB
var indexJS = {};
var urls = {
    "list": "/marketing/hapi/memberlist"
};

indexJS.list = function() {
    var keyWord = $("#keyWord").val();
    var status = $("input[id='status']:checked").val();
    if(!status){
        status = -1;
    }
    $("#page_div").hdpPages({
        dataType: "JSON",
        url: _REQUESTURL + urls.list,
        pageable: { page: 1, size: 15 },
        param: { keyWord: keyWord,status:status },
        success: function(data, op) {
            if (data.success && data.code == 2000) {
                var context = "<thead>" +
                    "<tr>" +
                    "<th>注册时间</th>" +
					"<th>姓名</th>" +
                    "<th>产品编号</th>" +
                    "<th>是否领取报告</th>" +
                    "<th>领取时间</th>" +
                    "</tr>" +
                    "</thead>";
                op.count = data.content.count;
                if (data.content.list) {

                    $.each(data.content.list, function(k, v) {
                        var create_atString = "";
                        if (v.createAt) {
                            var date = new Date(v.createAt);
                            create_atString =
                                date.getFullYear() + "-" +
                                (date.getMonth() + 1) + "-" +
                                date.getDate() + " " +
                                date.getHours() + ":" +
                                date.getMinutes() + ":" +
                                date.getSeconds();

                        }
                        var genereportAtString = "";
                        if (v.genereportAt) {
                            var date = new Date(v.genereportAt);
                            genereportAtString =
                                date.getFullYear() + "-" +
                                (date.getMonth() + 1) + "-" +
                                date.getDate() + " " +
                                date.getHours() + ":" +
                                date.getMinutes() + ":" +
                                date.getSeconds();

                        }
                        var genereport = "";
                        if(v.isGenereport == 1){
                            genereport = "已领取";
                        }
                       
                        context = context +
                            "<tr>" +
							    "    <td>" + _nullValue(create_atString) + "</td>" +
                                    "    <td>" + _nullValue(v.name) + "</td>" +
                                    "    <td>" + _nullValue(v.barcode) + "</td>" +
                                    "    <td>" + _nullValue(genereport) + "</td>" +
                                    "    <td>" + _nullValue(genereportAtString) + "</td>" +

                            "</tr>";
                    });
                }
                $("#data_table").html(context);
            } else {
                if (data.code == 503) {
                    logout();
                } else {
                    alert("系统错误");
                }
            }
        }
    });
}

indexJS.list();




indexJS.reflashList = function() {
    var keyWord = $("#keyWord").val();
    var status = $("input[id='status']:checked").val();
    if(!status){
        status = -1;
    }
    $("#page_div").hdpPages("reSetParam", { keyWord: keyWord,status:status });
    $("#page_div").hdpPages("reflash");
	
	
}


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

});