define (['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
   var agent={
        pageNo:1,
        pageSize:15,
        init:function () {
            //初始化dot
            $("body").append(template);
            agent.getList();
            agent.event();
        },
        event:function () {
            $('#search').click(function (pageNo) {
                 agent.getList(1);
            });

        },
        getList:function(pageNo){
            agent.pageNo =pageNo;
            var params ={};
            params.pageNo =agent.pageNo;
            params.pageSize=agent.pageSize;
            params.search = $("input[name='search']").val();
            $.ajax({
                url: '/index/AgentList.html',
                type: 'GET',
                async: true,
                data: params,
                dataType: 'json',
                success: function (data) {
                    var temp=document.getElementById('agent_tpl').innerHTML;
                    var doTempl=doT.template(temp);
                    $("#agentlist").html(doTempl(data.data.list));
                    /*分页代码*/
                    $ ("#pagediv").pagination ({
                        length: data.data.total,
                        current: pageNo,
                        every: agent.pageSize,
                        onClick: function (el) {
                            agent.getList (el.num.current);
                        }
                    });
                }
            })
        }

    }
    return agent;
});