$(document).ready(function(){
	var demandId = GetQueryString("demandId");
	var consuId, demandTitle, demandContent, oDemandAim;

	function angleDemand() {
		$.ajax({
			url: "/ajax/demand/queryOne",
			type: "GET",
			timeout: 10000,
			dataType: "json",
			data: {
				"demandId": demandId,
			},
			beforeSend: function() {},
			success: function(data, textState) {
				if(data.success) {
					console.log(data);
					var $data = data.data;
					var oTime, oDemandType;
					$("#dialog_consultTitle").text($data.demandTitle);
					oTime = $data["createTime"].substr(0, 4) + "年" + $data.createTime.substr(4, 2) + "月" + $data.createTime.substr(6, 2) + "日" +
						$data.createTime.substr(8, 2) + ":" + $data.createTime.substr(10, 2);
					$("#dialog_consultTime").text(oTime);
					if($data.closeTime){
						$("#dil_consultStatus").text("已关闭");
						$(".displayNone").show();
						var oCloseTime=$data["closeTime"].substr(0, 4) + "年" + $data.closeTime.substr(4, 2) + "月" + $data.createTime.substr(6, 2) + "日" +
						$data.closeTime.substr(8, 2) + ":" + $data.closeTime.substr(10, 2);
						$("#dialog_consultTime1").text(oCloseTime);
						$(".closeBtn").hide();
					}else{
						$("#dil_consultStatus").text("发布中");
					}
					if($data.demandType == 1) {
						oDemandType = "个人需求"
					} else {
						oDemandType = "企业需求"
					}
					$("#dialog_consultType1").text(oDemandType);
					if($data.demandAim == 1) {
						oDemandAim = "技术咨询"
					} else if($data.demandAim == 2) {
						oDemandAim = "资源咨询"
					} else if($data.demandAim == 3) {
						oDemandAim = "其他咨询"
					}
					$("#dialog_consultType2").text(oDemandAim);
					$("#dialog_consultContent").text($data.demandContent);										
					consuId = $data.professor.id;
					demandTitle = $data.demandTitle;
					demandContent = $data.demandContent;
					demandType = $data.demandAim
				}
			},
			error: function(XMLHttpRequest, textStats, errorThrown) {

			}
		})
	}
	angleDemand() ;
	$(".closeBtn").click(function(){
		$.MsgBox.Confirm("消息", "确认关闭此需求？", closeDemand)
	})
	function closeDemand(){
		$.ajax({
			url: "/ajax/demand/close",
			type: "POST",
			timeout: 10000,
			dataType: "json",
			data: {
				"demandId": demandId,
			},
			beforeSend: function() {},
			success: function(data, textState) {
				if(data.success) {
					$(".closeBtn").hide();
					$("#dil_consultStatus").text("已关闭");
				}
			},
			error: function(XMLHttpRequest, textStats, errorThrown) {

			}
		})
	}
})
