评论语法说明
更新时间:2019-12-10
评论适用于新闻模型、视频模型、专题模型、图库模型 以及通过复制这几个模型得到的自定义模型。
使用流程
1.在模型详情页中配置评论表单代码,后台开启询盘业务后可正常使用。后台关闭评论时,前台提交评论会失败。
2.评论使用到的语法:
/addcomment.html //文件提交地址
method=“POST” //表单提交方法
3.代码 示例:
<form action="/addcomment.html" method="post"> //提交地址
<input type="text" name="nickname" > //昵称
<input type="text" name="mobile" > //手机
<input type="text" name="code" > //验证码
<input type="text" name="content" > //评论内容
<input type="hidden" name="id" value="{{Pageinfo['_id']}}">
<input type="hidden" name="moduletype" value="{{globalviewdata['model']}}">
<input type="hidden" name="basetype" value="{{globalviewdata['basetype']}}" >
使用举例:获取手机验证码之前需要先进行图片验证,否则无法获取验证码
<form action="/addcomment.html" method="post">
<input type="text" name="nickname" ><br>
<input type="text" name="mobile" class="mobile" >
<button class="send" data-url="/sendsmscode.html">获取验证码</button>
<br>
<input type="text" name="code" >
<textarea name="content" ></textarea>
<input type="hidden" name="id" value="{{Pageinfo['_id']}}"><br>
<input type="hidden" name="moduletype" value="{{globalviewdata['model']}}"><br>
<input type="hidden" name="basetype" value="{{globalviewdata['basetype']}}" >
<div>
<label>完成验证:</label>
<div id="captcha">
<div id="text">
行为验证™ 安全组件加载中
</div>
</div>
</div>
<input type="submit" value="submit">
</form>
<script src="//static.westarcloud.com/test/5c048df6a8497e03aa0665a0/js/jquery1.11.3.min.js"></script>
<script src="https://www.geetest.com/demo/libs/gt.js"></script>
<script>
let handler = function (captchaObj) {
captchaObj.appendTo('#captcha');
captchaObj.onReady(function () {
$("#wait").hide();
});
$('.send').click(function (e) {
e.preventDefault();
let result = captchaObj.getValidate();
if (!result) {
return alert('请完成验证');
}
$.ajax({
url: '/sendsmscode.html',
type: 'POST',
dataType: 'json',
data: {
mobile: $('input[name="mobile"]').val(),
geetest_challenge: result.geetest_challenge,
geetest_validate: result.geetest_validate,
geetest_seccode: result.geetest_seccode
},
success: function (data) {
if (data.status === 'true') {
alert('发送短信成功');
} else if (data.status === 'false') {
alert('验证失败');
captchaObj.reset();
}
}
});
});
// 更多接口说明请参见:http://docs.geetest.com/install/client/web-front/
window.gt = captchaObj;
};
$.ajax({
url: "/front/interface/geetest?t=" + (new Date()).getTime(), // 加随机数防止缓存
type: "get",
dataType: "json",
success: function (data) {
$('#text').hide();
$('#wait').show();
// 调用 initGeetest 进行初始化
// 参数1:配置参数
// 参数2:回调,回调的第一个参数验证码对象,之后可以使用它调用相应的接口
initGeetest({
// 以下 4 个配置参数为必须,不能缺少
gt: data.gt,
challenge: data.challenge,
offline: !data.success, // 表示用户后台检测极验服务器是否宕机
new_captcha: data.new_captcha, // 用于宕机时表示是新验证码的宕机
product: "float", // 产品形式,包括:float,popup
width: "300px",
https: true
// 更多配置参数说明请参见:http://docs.geetest.com/install/client/web-front/
}, handler);
}
});
</script>
回复评论
如果是对某评论楼层的回复,需要增加
<input type="hidden" name="masterid" value="##同被回复评论的masterid##">
<input type="hidden" name="relaid" value="##被回复评论的_id##">
评论数据调取:
“#域名#getcommentlist.html?id=#当前内容ID#&page=1”