message页面


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

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

    <div class="container pd-10">
        <div class="panel panel-default">
            <div class="panel-heading text-center background-white">
                <p>信息留言</p>
            </div>
            <div class="panel-body">

                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color: red;">*</span>您的称呼</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"><span style="color: red;">*</span>留言内容</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.html" .}}
    {{template "js.html" .}}
    <script>
        $(function() {
            $('#submit').click(function() {
                var d = {};
                var t = $('form').serializeArray();
                $.each(t, function() {
                    d[this.name] = this.value;
                });
                //数据转换
                $.ajax({
                    url: "/message",
                    headers:{"X-CSRF-Token": {{ .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>