<?php
/**
 * 芋头CMS
 * ============================================================================
 * 版权所有 2016-2028 沅陵县乌托邦网络服务有限公司，并保留所有权利。
 * 网站地址: http://www.yutoucms.cn
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷。
 * ============================================================================
 * Author: 芋头 <mxgsf@qq.com>
 * Date: 2026-5-30
 */
if (!defined('ROOT_PATH')) { exit('Access Denied'); }
$pageTitle = '在线留言';
require_once __DIR__ . '/_header.php';
?>
<div class="bannern c" style="background:url(<?php echo $site['template_dir']; ?>static/upload/image/20220801/1659354277651388.jpg) no-repeat center;"></div>
<div class="n_cont c">
  <div class="jz c">
    <div class="ny_nav" id="my_sticky">
      <div class="wjssbt c">在线留言</div>
      <ul class="wjsndh c"></ul>
      <div class="search_l">
        <form method="get" action="<?php echo getUrl('search'); ?>">
          <input type="hidden" name="m" value="search">
          <input type="text" class="ip" name="keyword" placeholder="请输入关键字">
          <input type="submit" class="btn" value="搜索">
        </form>
      </div>
    </div>
    <div class="ny_zqw ny_zqw_chb">
      <div class="nw_top"><span class="top_tzbt l">在线留言</span><span class="top_mbx r am-icon-home">您的位置： <a href="<?php echo getUrl('home'); ?>">首页</a> >> <a href="javascript:;">在线留言</a></span></div>
      <div class="h20"></div>
      <div class="bjbld">
        <div class="xqxq">
          <form class="layui-form" id="guestbookForm" method="post" action="/public/guestbook.php" style="margin:30px 0;">
            <input type="hidden" name="ajax" value="1">
            <div class="layui-form-item">
              <label class="layui-form-label">姓名<i class="red">*</i></label>
              <div class="layui-input-block"><input type="text" name="name" required class="layui-input"></div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">手机号<i class="red">*</i></label>
              <div class="layui-input-block"><input type="text" name="contact" required class="layui-input"></div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">内容</label>
              <div class="layui-input-block"><textarea name="content" required class="layui-textarea"></textarea></div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block"><button class="layui-btn" type="submit">提交留言</button> <span id="guestbookTip"></span></div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
(function(){
var form = document.getElementById('guestbookForm');
if (!form) return;
form.addEventListener('submit', function(e){
 e.preventDefault();
 var fd = new FormData(form);
 var xhr = new XMLHttpRequest();
 xhr.open('POST', form.action, true);
 xhr.onload = function(){
   var tip = document.getElementById('guestbookTip');
   try { var r = JSON.parse(this.responseText); } catch(e) { var r = {code:200,msg:'提交成功'}; }
   tip.innerHTML = r.msg || '提交完成';
   tip.style.color = r.code == 200 ? '#16a34a' : '#dc2626';
   if (r.code == 200) form.reset();
 };
 xhr.send(fd);
});
})();
</script>
<?php require_once __DIR__ . '/_footer.php'; ?>
