...
|
...
|
@@ -19,10 +19,14 @@ const validType = { |
|
|
})();
|
|
|
|
|
|
class Validate {
|
|
|
constructor(container, options) {
|
|
|
constructor(container, options, type) {
|
|
|
this.$container = container instanceof $ ? container : $(container);
|
|
|
this.options = options;
|
|
|
this.type = this.$container.data('geetest') ? validType.GEETEST : validType.IMG_CHECK;
|
|
|
if (type) {
|
|
|
this.type = type;
|
|
|
} else {
|
|
|
this.type = this.$container.data('geetest') ? validType.GEETEST : validType.IMG_CHECK;
|
|
|
}
|
|
|
this.$container.after('<input id="yohobuy" type="text" style="display:none;">');
|
|
|
if (this.type === validType.IMG_CHECK) {
|
|
|
this.imgCheck = new ImgCheck(this.$container, this.options);
|
...
|
...
|
@@ -32,16 +36,20 @@ class Validate { |
|
|
type: 'get',
|
|
|
dataType: 'json',
|
|
|
success: data => {
|
|
|
window.initGeetest && window.initGeetest({
|
|
|
gt: data.gt,
|
|
|
challenge: data.challenge,
|
|
|
offline: !data.success
|
|
|
}, (captchaObj) => {
|
|
|
this.captchaObj = captchaObj;
|
|
|
captchaObj.appendTo(this.$container);
|
|
|
this._atWorking = true;
|
|
|
this.$container.addClass('hide').addClass('popup');
|
|
|
});
|
|
|
if (data.success) {
|
|
|
window.initGeetest && window.initGeetest({
|
|
|
gt: data.gt,
|
|
|
challenge: data.challenge,
|
|
|
offline: !data.success
|
|
|
}, (captchaObj) => {
|
|
|
this.captchaObj = captchaObj;
|
|
|
captchaObj.appendTo(this.$container);
|
|
|
this._atWorking = true;
|
|
|
this.$container.addClass('hide').addClass('popup');
|
|
|
});
|
|
|
} else {
|
|
|
this.$container.trigger('change');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
$('.yoho-page').on('touchstart', '#js-img-check', (e) => {
|
...
|
...
|
|