/// <reference path="jquery-1.10.2.min.js" />
var pageindex = 1;
var pagesize = 10;
var pagecount = 0;

$(function () {
    $.post("/ajax/Admin_GameBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "GameLists" }, function (data) {
        var data = eval('(' + data + ')');
        pagecount = data.pagecount;
        $("#gameslists").html("").append(data.pagelist);
        layui.use(['laypage', 'layer'], function () {
            var nums = pagesize; //每页出现的数据量
            var laypage = layui.laypage
            , layer = layui.layer;
            laypage.render({
                elem: 'pager'
               , count: pagecount //总页数
               , groups: 1
                , jump: function (obj) {
                    pageindex = obj.curr;//获取到当前页
                    $.post("/ajax/Admin_GameBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "GameLists" }, function (data) {
                        var data = eval('(' + data + ')');
                        pagecount = data.pagecount;
                        $("#gameslists").html("").append(data.pagelist);

                    });

                }
            });
        });
    });
});

function gamedel_btn() {
    var gamedelid = $.trim($("#game_del_id").val());
    if (!confirm("确定要删除吗？") == true) {
        return true;
    } else {
        $.post("/ajax/Admin_GameBase.ashx", { "type": "gamedel", "gamedelid": gamedelid }, function (data) {
            if (data == "ok") {
                alert("删除成功");
                window.location.href = "./Admin_GameList.aspx";

            } else {
                alert("删除失败");
            }


        })

    }

}