我是用的是uniapp的renderjs,经测试,是在guide.js中发现使用jsonp请求//cf.aliyun.com/nvc/nvcPrepare.jsonp触发了script的onerror,onerror回调参数为:
"isTrusted": true,
"NONE": 0,
"CAPTURING_PHASE": 1,
"AT_TARGET": 2,
"BUBBLING_PHASE": 3,
"type": error,
"target": [object HTMLScriptElement],
"currentTarget": [object HTMLScriptElement],
"eventPhase": 2,
"bubbles": false,
"cancelable": false,
"defaultPrevented": false,
"composed": false,
"timeStamp": 607.3999999789521,
"srcElement": [object HTMLScriptElement],
"returnValue": true,
"cancelBubble": false,
"path": [object HTMLScriptElement],
[object HTMLHeadElement],
[object HTMLHtmlElement],
[object HTMLDocument],
[object Window],
"composedPath": function composedPath() {
[native code]
},
"stopPropagation": function stopPropagation() {
[native code]
},
"stopImmediatePropagation": function stopImmediatePropagation() {
[native code]
},
"preventDefault": function _() {
window.__needNotifyNative__ && "touchmove" == this.type && (window.__needNotifyNative__ = t.execSync(e.webview.currentWebview(), "needTouchEvent", [])), l.oldPreventDefault.call(this)
},
"initEvent": function initEvent() {
[native code]
},
}
。renderjs 代码:
export default {
mounted() {
this.init();
},
methods: {
init() {
if (window.NVC_Opt) {
if (!NVC_Result.nvcPreRes) {
this.init_NVC_Opt();
this.createScript('static/smartCaptcha/guide.js');
}
} else {
this.createScript('static/smartCaptcha/flexible.js').then(() => {
this.createScript('static/smartCaptcha/al_smartCaptcha.js').then(() => {
this.createScript('static/smartCaptcha/al_quizCaptcha.js').then(() => {
this.init_NVC_Opt();
this.createScript('static/smartCaptcha/guide.js');
})
})
})
}
},
createScript(src) {
return new Promise(res => {
let script = document.createElement('script')
script.src = src;
script.onload = () => {
res();
};
document.head.appendChild(script)
})
},
init_NVC_Opt() {
window.NVC_Opt = {
// 无痕配置 && 滑动验证、刮刮卡、问答验证码通用配置
appkey: "FFFF0N000000000084BA",
scene: "ic_message_h5",
isH5: false,
popUp: false,
renderTo: "#captcha",
nvcCallback: function(data) {
// data为getNVCVal()的值,此函数为二次验证滑动或者刮刮卡通过后的回调函数
// data跟业务请求一起上传,由后端请求AnalyzeNvc接口,接口会返回100或者900
},
language: "cn",
// 滑动验证长度配置
customWidth: 300,
// 刮刮卡配置项
width: 300,
height: 100,
elements: [
"//img.alicdn.com/tfs/TB17cwllsLJ8KJjy0FnXXcFDpXa-50-74.png",
"//img.alicdn.com/tfs/TB17cwllsLJ8KJjy0FnXXcFDpXa-50-74.png",
],
bg_back_prepared: "//img.alicdn.com/tps/TB1skE5SFXXXXb3XXXXXXXXXXXX-100-80.png",
bg_front: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABQCAMAAADY1yDdAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURefk5w+ruswAAAAfSURBVFjD7cExAQAAAMKg9U9tCU+gAAAAAAAAAIC3AR+QAAFPlUGoAAAAAElFTkSuQmCC",
obj_ok: "//img.alicdn.com/tfs/TB1rmyTltfJ8KJjy0FeXXXKEXXa-50-74.png",
bg_back_pass: "//img.alicdn.com/tfs/TB1KDxCSVXXXXasXFXXXXXXXXXX-100-80.png",
obj_error: "//img.alicdn.com/tfs/TB1q9yTltfJ8KJjy0FeXXXKEXXa-50-74.png",
bg_back_fail: "//img.alicdn.com/tfs/TB1w2oOSFXXXXb4XpXXXXXXXXXX-100-80.png",
upLang: {
cn: {
_ggk_guide: "请在屏幕上滑动,刮出两面盾牌",
_ggk_success: "恭喜您成功刮出盾牌<br/>继续下一步操作吧",
_ggk_loading: "加载中",
_ggk_fail: [
"呀,盾牌不见了<br/>请",
"javascript:NoCaptcha.reset()",
"再来一次",
"或",
"http://survey.taobao.com/survey/QgzQDdDd?token=%TOKEN",
"反馈问题",
],
_ggk_action_timeout: [
"我等得太久啦<br/>请",
"javascript:NoCaptcha.reset()",
"再来一次",
"或",
"http://survey.taobao.com/survey/QgzQDdDd?token=%TOKEN",
"反馈问题",
],
_ggk_net_err: [
"网络实在不给力<br/>请",
"javascript:NoCaptcha.reset()",
"再来一次",
"或",
"http://survey.taobao.com/survey/QgzQDdDd?token=%TOKEN",
"反馈问题",
],
_ggk_too_fast: [
"您刮得太快啦<br/>请",
"javascript:NoCaptcha.reset()",
"再来一次",
"或",
"http://survey.taobao.com/survey/QgzQDdDd?token=%TOKEN",
"反馈问题",
],
},
},
}
},
// 生成 智能验证控件
createSmartCaptcha() {
console.log('window.nvc', window.nvc);
var ic = new window.smartCaptcha({
// 声明智能验证需要渲染的目标元素ID。
renderTo: "#sc",
// 智能验证组件的宽度。
width: 300,
// 智能验证组件的高度。
height: 42,
// 智能验证组件初始状态文案。
default_txt: "点击按钮开始智能验证",
// 智能验证组件验证通过状态文案。
success_txt: "验证成功",
// 智能验证组件验证失败(拦截)状态文案。
fail_txt: "验证失败,请在此点击按钮刷新",
// 智能验证组件验证中状态文案。
scaning_txt: "智能检测中",
// 前端智能验证通过时会触发该回调参数。您可以在该回调参数中将请求标识(token)、会话ID(sessionid)、签名串(sig)字段记录下来,随业务请求一同发送至您的服务端调用验签。
success: (data) => {
// 调用 service 层的方法
// ownerInstance.callMethod('smartCaptchaSuceess', {
// token: NVC_Opt.token,
// sessionId: data.sessionId,
// sig: data.sig,
// })
},
});
ic.init();
},
}
}
</script>
现在挺懵逼的,不知道怎么做,有什么思路都请务必我说说,谢谢!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。