Merge branch 'feature/verifyimg' into hotfix/errorlog
Showing
3 changed files
with
19 additions
and
2 deletions
@@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => { | @@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => { | ||
38 | }, ''); | 38 | }, ''); |
39 | 39 | ||
40 | req.session.captcha = codeStr; | 40 | req.session.captcha = codeStr; |
41 | + req.session.captchaTimeout = new Date().getTime() + 1000 * 60; | ||
41 | req.session.captchaSrc = result.data.verifiedGraphicCode; | 42 | req.session.captchaSrc = result.data.verifiedGraphicCode; |
42 | 43 | ||
43 | return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line | 44 | return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line |
@@ -52,6 +53,17 @@ exports.imgCheck = (req, res, next) => { | @@ -52,6 +53,17 @@ exports.imgCheck = (req, res, next) => { | ||
52 | exports.validate = (req, res, next) => { | 53 | exports.validate = (req, res, next) => { |
53 | let captchaInput = req.body.captcha; | 54 | let captchaInput = req.body.captcha; |
54 | let captchaCode = _.get(req.session, 'captcha'); | 55 | let captchaCode = _.get(req.session, 'captcha'); |
56 | + let captchaTimeout = _.get(req.session, 'captchaTimeout'); | ||
57 | + | ||
58 | + if (new Date().getTime() > captchaTimeout) { | ||
59 | + _.set(req.session, 'captchaValidCount', 5); | ||
60 | + req.session.captcha = null; | ||
61 | + return res.json({ | ||
62 | + code: 400, | ||
63 | + message: '验证码超时,请重试', | ||
64 | + captchaShow: true | ||
65 | + }); | ||
66 | + } | ||
55 | 67 | ||
56 | let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次 | 68 | let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次 |
57 | 69 |
@@ -14,8 +14,8 @@ const domains = { | @@ -14,8 +14,8 @@ const domains = { | ||
14 | liveApi: 'http://testapi.live.yohops.com:9999/', | 14 | liveApi: 'http://testapi.live.yohops.com:9999/', |
15 | singleApi: 'http://api-test3.yohops.com:9999/', | 15 | singleApi: 'http://api-test3.yohops.com:9999/', |
16 | 16 | ||
17 | - api: 'http://api.yoho.cn/', | ||
18 | - service: 'http://service.yoho.cn/', | 17 | + api: 'http://api-test3.yohops.com:9999/', |
18 | + service: 'http://service-test3.yohops.com:9999/', | ||
19 | global: 'http://api-global.yohobuy.com', | 19 | global: 'http://api-global.yohobuy.com', |
20 | 20 | ||
21 | // liveApi: 'http://api.live.yoho.cn/', | 21 | // liveApi: 'http://api.live.yoho.cn/', |
@@ -6,6 +6,9 @@ | @@ -6,6 +6,9 @@ | ||
6 | let $ = require('yoho-jquery'), | 6 | let $ = require('yoho-jquery'), |
7 | ImgCheck = require('plugin/img-check'), | 7 | ImgCheck = require('plugin/img-check'), |
8 | tip = require('plugin/tip'); | 8 | tip = require('plugin/tip'); |
9 | + | ||
10 | +let loading = require('plugin/loading'); | ||
11 | + | ||
9 | const validType = { | 12 | const validType = { |
10 | IMG_CHECK: 1, | 13 | IMG_CHECK: 1, |
11 | GEETEST: 2 | 14 | GEETEST: 2 |
@@ -94,7 +97,9 @@ class Validate { | @@ -94,7 +97,9 @@ class Validate { | ||
94 | } | 97 | } |
95 | return Promise.resolve({captcha}); | 98 | return Promise.resolve({captcha}); |
96 | } else { | 99 | } else { |
100 | + loading.showLoadingMask(); | ||
97 | return new Promise((resolve) => { | 101 | return new Promise((resolve) => { |
102 | + loading.hideLoadingMask(); | ||
98 | this.$container.removeClass('hide'); | 103 | this.$container.removeClass('hide'); |
99 | this.captchaObj.onSuccess(() => { | 104 | this.captchaObj.onSuccess(() => { |
100 | resolve(this.captchaObj.getValidate()); | 105 | resolve(this.captchaObj.getValidate()); |
-
Please register or login to post a comment