$(document).ready(function(){
	$("#activityId").select2({
		placeholder : "请选择",
		allowClear : true
	});
	
})


var wish = {
	
	search : function(){
		var activityId = $("#activityId").val();
		var searchStr = $("#searchStr").val();
		var url = webPath + "/rainbow/wish/list";
		
		if(activityId!="" || searchStr!=""){
			var param = "?"
			if (activityId != ""){
				param = param + "activityId=" + activityId ;
			}
			
			if (searchStr != ""){
				if (param == "?"){
					param = param + "searchStr=" + searchStr;
				} else {
					param = param + "&searchStr=" + searchStr;
				}
				
			}
			url = url + param;
		}
		window.location.href = url;
	},
	batchUpdateStatus : function(){
		var ids = []
		$("#table-data input[name='id']:checked").each(function(index){
			ids.push($(this).val())
		})
		
		if (ids.length==0){
			bootbox.dialog({
				message:"请选择愿望！",
				buttons:{
					"success":{
						"label":"OK",
						"className":"btn-sm btn-primary"
						}
					}
				});
		} else {
			wish.openlayer();
		}
		
		
		//页面层
		
		
//		$.ajax({
//			  type: 'POST',
//			  url: '/rainbow/wish/status/update',
//			  dataType:'json',
//			  data: {
//				  status:
//				  
//			  }
//		  })
		
	},
	openlayer: function() {
		var html = '<div style="display: block;margin-left:auto;margin-right:auto;margin-top:20px;text-align: center;">'
				  +'<select class="" id="changeStatus" >'
				  +'<option value="">请选择</option>'
				  +'<option value="0">发布</option>'
				  +'<option value="1">领取</option>'
				  +'<option value="2">寄送中</option>'
				  +'<option value="3">红会代收</option>'
				  +'<option value="4">完成</option>'
				  +'</select>'
				  +'<button class="btn-xs" onclick="wish.updateStatus()">确定</button>'
				  +'</div>'

	
		layer.open({
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['300px', '200px'], //宽高
			  content: html
			});

	},
	updateStatus: function() {
		var ids=[];
		$("#table-data input[name='id']:checked").each(function(index){
			ids.push($(this).val())
		})
		$.ajax({
			  type: 'POST',
			  url: '/rainbow/wish/status/update',
			  dataType:'json',
			  data: {
				  status: $("#changeStatus").val(),
				  id:ids
				  
			  }
		  })
	}
	
	
	
}