var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "playerId",
			width : "100px",
			hide : true
		}, {
			name : "头像",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.ext=='png'||rowdata.ext=='jpg'||rowdata.ext=='gif'){
					return "<img style='max-width:150px;height:80px;' src='"+rootPath+"/upload/"+rowdata.head+"'>";
				}else{
					return "<img src='"+rootPath+"/images/filedefault.jpg'>";
				}
			}
		}, {
			colkey : "playerName",
			name : "姓名"
		}
		, {
			colkey : "sex",
			name : "性别",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.sex=='1'){
					return "男";
				}else{
					return "女";
				}
			}
		}, {
			colkey : "signTime",
			name : "报名时间",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				return new Date(rowdata.uploadTime).format("yyyy/MM/dd hh:mm:ss");
			}
		}, {
			colkey : "origin",
			name : "来源",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.origin=='1'){
					return "个人报名";
				}else{
					return "渠道推荐";
				}
			}
		}, {
			colkey : "vote",
			name : "人气数"
		}, {
			colkey : "phone",
			name : "电话"
		}, {
			colkey : "weixin",
			name : "微信号"
		}, {
			colkey : "qq",
			name : "QQ号"
		}, {
			colkey : "status",
			name : "状态",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.status=='0'){
					return "等待审核";
				}else if(rowdata.status=='1'){
					return "审核通过";
				}else if(rowdata.status=='2'){
					return "审核不通过";
				}else{
					return "-";
				}
			}
		}, {
			colkey : "recmm",
			name : "是否推荐",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.recmm=='1'){
					return "推荐";
				}else{
					return "普通";
				}
			}
		}],
		jsonUrl : rootPath + '/eventplayer/find.shtml',
		checkbox : true,
		serNumber : false,
		checkValue:'playerId'
	});

	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		grid.setOptions({
			data : searchParams
		});
	});
	
	
	$("#editBtn").click(function() {
		var cbox = grid.getSelectedCheckbox();
		if (cbox.length > 1 || cbox == "") {
			layer.msg("只能选中一个");
			return;
		}
		pageii = layer.open({
			title : "编辑",
			type : 2,
			area : [ "600px", "70%" ],
			content : rootPath + '/eventplayer/editUI.shtml?id=' + cbox
		});
	});
	
	$("#delBtn").click(function() {
		var cbox = grid.getSelectedCheckbox();
		if (cbox == "") {
			layer.msg("请选择删除项！！");
			return;
		}
		layer.confirm('确认删除吗？', function(index) {
			var _URL = rootPath + '/eventplayer/delete.shtml';
			var resp = CommnUtil.ajax(_URL, {
				ids : cbox.join(",")
			}, "json");
			layer.msg(resp.code,{icon: 5});
			if (resp.code == "01") {
				layer.msg(resp.msg,{icon: 1});
				grid.loadData();
			} else {
				layer.msg('删除失败',{icon: 5});
			}
		});
	});
	
	$("#authBtn").click(function(){
		
	});
});

