<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Comment</title>
<script src="~/Script/jquery-1.10.2.min.js"></script>
</head>
<body>
<div style="1010px; margin:50px; border-color:antiquewhite" id="refreshContainer">
<input type="button" value="显示"/>
<div style="1000px; margin:50px">
<p>
<img src='' width="40" height="40" id="img" />
<label id="s1"></label><label id="s2" style="margin:200px;"></label>
</p>
<p>
<span>发布人:</span><label id="L"></label>
</p>
<p>
<h3>
宝贝介绍
</h3>
<div id="s3" style="height:80px;"> </div>
<img src="" id="Img1" width="600" height="300" />
</p>
</div>
<h2 style="1000px; margin:50px">评论</h2>
<p style="border-bottom-style:double;1000px; margin:50px"></p>
<div id="P1" style="1000px; margin:50px">
<table style="margin-left:50px"></table>
</div>
<p style="border-bottom-style:double; 1000px; margin:50px"></p>
<div style="1000px; margin:100px">
<form id="f1">
<p>
<input type="hidden" name="NewsID" value="@Request.QueryString["ID"]"/>
<input type="hidden" name="FileName" value="/Image/QQ图片20181115110035.gif" />
评论称呼:<input type="text" name="Name" id="Name" /><span style="color:red;" id="Ping1">*</span>
</p>
<div>
<textarea id="Context" name="Context" style="500px;height:100px"></textarea>
</div>
<input type="button" onclick="AddBut()" value="评论" />
</form>
</div>
</div>
<p class="refreshText"></p>
</body>
</html>
<script>
$(function () {
//查询单个集市信息
$.ajax({
url: "http://localhost:8888/News/GetNew",
data: {
id:@Request.QueryString["ID"],
},
type: "get",
success: function (data)
{
$("#img").attr("src",data.TypeImg);
$("#s1").text(data.Title);
$("#s2").text(data.CreateTime);
$("#L").text(data.Name);
$("#s3").text(data.Context);
$("#Img1").attr("src", data.FileName);
}
})
//查询所有评论
$.ajax({
url: "http://localhost:8888/Comment/GetComments",
data: {
ID:@Request.QueryString["ID"],
},
type: "get",
success: function (data)
{
$(data).each(function (i,data) {
$("table").append("<tr><td style = "240px" > <img src="" + data.FileName + "" width="40" height="40" /> <span>" + data.Name + "</span> <br /> <span>" + data.CreateTime + "</span></td><td><span>" + data.Context + "</span></td></tr>");
})
}
})
})
//添加评论
function AddBut()
{
if ($("#Name").val().trim().length <= 0 && $("#Name").val().trim().length >=10 )
{
$("#Ping1").html("必填项,不超过10个字");
}
$.ajax({
url: "http://localhost:8888/Comment/AddComment",
data:
$("#f1").serialize()
,
type: "post",
success: function (data)
{
if (data > 0) {
alert("评论成功");
location.href = "/News/Comment?ID=@Request.QueryString["ID"]"
}
else {
alert("失败!!")
}
}
})
}
</script>