評論語法說明
更新時間:2019-12-10
評論適用于新聞模型、視頻模型、專題模型、圖庫模型 以及通過復(fù)制這幾個模型得到的自定義模型。
使用流程
1.在模型詳情頁中配置評論表單代碼,后臺開啟詢盤業(yè)務(wù)后可正常使用。后臺關(guān)閉評論時,前臺提交評論會失敗。
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" > //評論內(nèi)容
<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="http://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('發(fā)送短信成功');
} 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(), // 加隨機數(shù)防止緩存
type: "get",
dataType: "json",
success: function (data) {
$('#text').hide();
$('#wait').show();
// 調(diào)用 initGeetest 進行初始化
// 參數(shù)1:配置參數(shù)
// 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應(yīng)的接口
initGeetest({
// 以下 4 個配置參數(shù)為必須,不能缺少
gt: data.gt,
challenge: data.challenge,
offline: !data.success, // 表示用戶后臺檢測極驗服務(wù)器是否宕機
new_captcha: data.new_captcha, // 用于宕機時表示是新驗證碼的宕機
product: "float", // 產(chǎn)品形式,包括:float,popup
width: "300px",
https: true
// 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/
}, handler);
}
});
</script>
回復(fù)評論
如果是對某評論樓層的回復(fù),需要增加
<input type="hidden" name="masterid" value="##同被回復(fù)評論的masterid##">
<input type="hidden" name="relaid" value="##被回復(fù)評論的_id##">
評論數(shù)據(jù)調(diào)?。?/span>
“#域名#getcommentlist.html?id=#當前內(nèi)容ID#&page=1”
?