message页面

作者:管理员发布时间:阅读数:74


当前cms是没有做评论功能的,所以通过用户的交互就需要一个独立的留言页面出来,默认是message.html,基本的内容如下

{{ define "message.html" }}
<!doctype html>
<html lang="zh-cn">
<head>
{{template "header" .}}
</head>
<body>
{{template "nav" .}}
{{template "bread" .}}

<div class="container">
<div class="panel panel-default">
<div class="panel-heading text-center background-white">
<h4>信息留言</h4>
<p>发表您对本站的建议</p>
</div>
<div class="panel-body">

<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-sm-2 control-label">您的称呼</label>
<div class="col-sm-10">
<input type="nickname" class="form-control" id="nickname" required name="nick_name">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">联系电话</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="phone" required name="phone">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">网站</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="web_site">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">邮箱</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="email">
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">留言内容</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="message" name="message">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" id="submit" class="btn btn-primary" value="提交">
</div>
</div>
</form>
</div>
</div>
</div>
{{template "footer" .}}
{{template "js" .}}
<script>
$(function() {
$('#submit').click(function() {
var d = {};
var t = $('form').serializeArray();
$.each(t, function() {
d[this.name] = this.value;
});
//数据转换
$.ajax({
url: "/message?&_csrf="+{{.csrf}},
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(d),
success: function (data) {
if (data.code == 200){
alert("您的留言已经收到,感谢您的支持与建议!")
window.location.href="/";
} else {
alert(data.message)
}

}
})

});
});
</script>
</body>
</html>
{{ end }}