问答业务语法说明
更新时间:2019-12-09
问答业务适用于问答模型。
在模型详情页中配置提问表单代码,在 “ 模型管理 ->问答 ->”开启提问业务后可使用该功能。后台关闭提问业务时,前台提交业务表单会失败。
访客提问发起页面:问答列表页和问答详情页
访客回复发起页面:问答详情页
1.网站访客在前台发布提问
说明:网站访客前台提交问题,必填的内容有标题、问题分类、问题描述、称呼、手机、手机验证码。
提问提交地址:/addquestion.html
<form action="/addquestion.html" method="post">
问题标题:<input type="text" name="title" placeholder="一句话描述您的问题">
问题分类:<input type="text" name="catename" placeholder="请输入分类">
分类ID:<input type="text" name="cateid" placeholder="请输入分类ID">
问题描述: <textarea name="introfck" placeholder="请详细描述您的问题"></textarea>
称呼:<input type="text" name="nickname" placeholder="请输入称呼">
手机:<input type="text" name="mobile" placeholder="请输入手机号码">
<button class="send" data-url="/sendsmscode.html">获取验证码</button>
验证码:<input type="text" name="code" placeholder="请输入验证码">
<input type="hidden" name="id" value="{{Pageinfo['_id']}}">
<input type="hidden" name="moduletype" value="{{globalviewdata['model']}}">
<input type="hidden" name="basetype" value="{{globalviewdata['basetype']}}" >
<div>
<label>完成验证:</label>
<div id="captcha">
<div id="text">
行为验证™ 安全组件加载中
</div>
</div>
</div>
<input type="submit" value="提交">
</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>
2.网站访客回复访客提问
访客对网站的提问做出回复
使用示例:
<form action="/addfaq.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="/addfaq.html" method="post">
<input type="text" name="nickname" >
<input type="text" name="mobile" class="mobile" > <button class="send" data-url="/sendsmscode.html">获取验证码</button>
<input type="text" name="code" >
<textarea name="content" ></textarea>
<input type="hidden" name="id" value="{{Pageinfo['_id']}}">
<input type="hidden" name="moduletype" value="{{globalviewdata['model']}}">
<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>
获取回复数据:
”#域名#/getfaqlist.html?id=#当前内容id#&page=1”
获取最佳回复:
{{System.getTakeAnswer('faq', Pageinfo['_id']) }}