Showing
5 changed files
with
68 additions
and
0 deletions
apps/3party/controllers/check.js
0 → 100644
1 | +const _ = require('lodash'); | ||
2 | + | ||
3 | +exports.index = (req, res) => { | ||
4 | + res.render('check', { | ||
5 | + width750: true, | ||
6 | + localCss: true | ||
7 | + }); | ||
8 | +}; | ||
9 | + | ||
10 | +exports.submit = (req, res) => { | ||
11 | + let captchaCode = _.get(req.session, 'captcha'); | ||
12 | + | ||
13 | + if (req.body.captcha === captchaCode) { | ||
14 | + return res.send('ok'); | ||
15 | + } | ||
16 | + return res.send('fail'); | ||
17 | +}; |
@@ -9,9 +9,12 @@ | @@ -9,9 +9,12 @@ | ||
9 | const router = require('express').Router(); // eslint-disable-line | 9 | const router = require('express').Router(); // eslint-disable-line |
10 | const cRoot = './controllers'; | 10 | const cRoot = './controllers'; |
11 | const ads = require(`${cRoot}/ads`); | 11 | const ads = require(`${cRoot}/ads`); |
12 | +const check = require(`${cRoot}/check`); | ||
12 | 13 | ||
13 | // routers | 14 | // routers |
14 | 15 | ||
15 | router.get('/ads', ads.index); | 16 | router.get('/ads', ads.index); |
17 | +router.get('/check', check.index); | ||
18 | +router.post('/check/submit', check.submit); | ||
16 | 19 | ||
17 | module.exports = router; | 20 | module.exports = router; |
apps/3party/views/action/check.hbs
0 → 100644
public/js/3party/check.page.js
0 → 100644
1 | +require('3party/check.page.css'); | ||
2 | + | ||
3 | +// 图片验证码 | ||
4 | +let ImgCheck = require('plugin/img-check'); | ||
5 | + | ||
6 | +let imgCheck = new ImgCheck('#js-img-check', { | ||
7 | + useREM: { | ||
8 | + rootFontSize: 40, | ||
9 | + picWidth: 150 | ||
10 | + } | ||
11 | +}); | ||
12 | + | ||
13 | +imgCheck.init(); | ||
14 | + | ||
15 | +$(function() { | ||
16 | + $('.submit').on('click', function() { | ||
17 | + $.ajax({ | ||
18 | + method: 'POST', | ||
19 | + url: '/3party/check/submit', | ||
20 | + data: { | ||
21 | + captcha: $.trim(imgCheck.getResults()) | ||
22 | + } | ||
23 | + }); | ||
24 | + }); | ||
25 | +}); |
public/scss/3party/check.page.css
0 → 100644
1 | +@import "layout/img-check"; | ||
2 | + | ||
3 | +.check-page { | ||
4 | + margin: 20px auto; | ||
5 | + width: 700px; | ||
6 | + | ||
7 | + .submit { | ||
8 | + width: 100%; | ||
9 | + height: 100px; | ||
10 | + line-height: 100px; | ||
11 | + text-align: center; | ||
12 | + font-size: 32px; | ||
13 | + color: #fff; | ||
14 | + background: #5cb85c; | ||
15 | + border-radius: 10px; | ||
16 | + } | ||
17 | +} |
-
Please register or login to post a comment