Merge remote-tracking branch 'origin/hotfix/questionnaire' into release/0704
Showing
5 changed files
with
35 additions
and
17 deletions
@@ -71,6 +71,9 @@ exports.submit = (req, res, next) => { | @@ -71,6 +71,9 @@ exports.submit = (req, res, next) => { | ||
71 | exports.detail = (req, res, next) => { | 71 | exports.detail = (req, res, next) => { |
72 | let id = parseInt(`0${req.params.id}`, 10); | 72 | let id = parseInt(`0${req.params.id}`, 10); |
73 | 73 | ||
74 | + req.yoho.captchaShow = false; | ||
75 | + res.locals.useGeetest = true; | ||
76 | + | ||
74 | req.ctx(questionModel).getQuestionDetail(id, req.user.uid).then(result => { | 77 | req.ctx(questionModel).getQuestionDetail(id, req.user.uid).then(result => { |
75 | if (result && result.detail && req.yoho.isApp) { | 78 | if (result && result.detail && req.yoho.isApp) { |
76 | result.detail.uid = req.user.uid; | 79 | result.detail.uid = req.user.uid; |
@@ -13,6 +13,8 @@ const check = require(`${cRoot}/check`); | @@ -13,6 +13,8 @@ const check = require(`${cRoot}/check`); | ||
13 | const question = require(`${cRoot}/question`); | 13 | const question = require(`${cRoot}/question`); |
14 | const auth = require('../../doraemon/middleware/auth'); | 14 | const auth = require('../../doraemon/middleware/auth'); |
15 | 15 | ||
16 | +const validateCode = require('../passport/controllers/validateCode'); | ||
17 | + | ||
16 | // const material = require(`${cRoot}/material`); | 18 | // const material = require(`${cRoot}/material`); |
17 | const materialNew = require(`${cRoot}/material-new`); | 19 | const materialNew = require(`${cRoot}/material-new`); |
18 | 20 | ||
@@ -25,8 +27,8 @@ router.post('/check/submit', check.submit); | @@ -25,8 +27,8 @@ router.post('/check/submit', check.submit); | ||
25 | 27 | ||
26 | router.get('/questionnaire', auth, question.list); | 28 | router.get('/questionnaire', auth, question.list); |
27 | router.post('/questionnaire/check', question.check); | 29 | router.post('/questionnaire/check', question.check); |
28 | -router.post('/questionnaire/submit', question.submit); | ||
29 | -router.get('/questionnaire/:id', question.detail); | 30 | +router.post('/questionnaire/submit', validateCode.check, question.submit); |
31 | +router.get('/questionnaire/:id', validateCode.load, question.detail); | ||
30 | router.get('/material', auth, materialNew.list); | 32 | router.get('/material', auth, materialNew.list); |
31 | 33 | ||
32 | module.exports = router; | 34 | module.exports = router; |
@@ -3,7 +3,15 @@ require('3party/question-detail.page.css'); | @@ -3,7 +3,15 @@ require('3party/question-detail.page.css'); | ||
3 | let $ = require('yoho-jquery'), | 3 | let $ = require('yoho-jquery'), |
4 | yoho = require('yoho-app'), | 4 | yoho = require('yoho-app'), |
5 | tipDg = require('plugin/tip'), | 5 | tipDg = require('plugin/tip'), |
6 | - share = require('common/share'); | 6 | + share = require('common/share'), |
7 | + Validate = require('plugin/validata'); | ||
8 | + | ||
9 | +let validate = new Validate('#js-img-check', { | ||
10 | + useREM: { | ||
11 | + rootFontSize: 40, | ||
12 | + picWidth: 150 | ||
13 | + } | ||
14 | +}); | ||
7 | 15 | ||
8 | let question = { | 16 | let question = { |
9 | $base: $('#qs-wrap'), | 17 | $base: $('#qs-wrap'), |
@@ -197,31 +205,31 @@ let question = { | @@ -197,31 +205,31 @@ let question = { | ||
197 | } | 205 | } |
198 | }, | 206 | }, |
199 | saveAnswers: function(info) { | 207 | saveAnswers: function(info) { |
200 | - var that = this; | ||
201 | - | ||
202 | - if (this.saving || !info || !info.length) { | 208 | + if (!info || !info.length) { |
203 | return; | 209 | return; |
204 | } | 210 | } |
205 | 211 | ||
206 | - this.saving = true; | ||
207 | - | ||
208 | - setTimeout(function() { | ||
209 | - that.saving = false; | ||
210 | - }, 5000); | 212 | + return validate.getResults().then(result => { |
213 | + if (typeof result === 'undefined') { | ||
214 | + return; | ||
215 | + } | ||
211 | 216 | ||
212 | - $.ajax({ | ||
213 | - type: 'POST', | ||
214 | - url: '/3party/questionnaire/submit', | ||
215 | - data: { | 217 | + let params = { |
216 | id: this.$base.data('id'), | 218 | id: this.$base.data('id'), |
217 | uid: this.$base.data('cid'), | 219 | uid: this.$base.data('cid'), |
218 | startTime: this.startTime, | 220 | startTime: this.startTime, |
219 | endTime: Date.parse(new Date()) / 1000, | 221 | endTime: Date.parse(new Date()) / 1000, |
220 | frontAnswers: JSON.stringify(info), | 222 | frontAnswers: JSON.stringify(info), |
221 | mobile: this.$mobile.val() | 223 | mobile: this.$mobile.val() |
222 | - } | 224 | + }; |
225 | + | ||
226 | + $.extend(params, result); | ||
227 | + | ||
228 | + $.ajax({ | ||
229 | + type: 'POST', | ||
230 | + url: '/3party/questionnaire/submit', | ||
231 | + data: params | ||
223 | }).then(function(data) { | 232 | }).then(function(data) { |
224 | - that.saving = false; | ||
225 | if (data.code === 200 || data.code === 206) { | 233 | if (data.code === 200 || data.code === 206) { |
226 | let tip = '调查问卷已成功提交,感谢您的帮助!'; | 234 | let tip = '调查问卷已成功提交,感谢您的帮助!'; |
227 | 235 | ||
@@ -242,6 +250,7 @@ let question = { | @@ -242,6 +250,7 @@ let question = { | ||
242 | tipDg.show(data.message || '网络出了点问题~'); | 250 | tipDg.show(data.message || '网络出了点问题~'); |
243 | } | 251 | } |
244 | }); | 252 | }); |
253 | + }); | ||
245 | } | 254 | } |
246 | }; | 255 | }; |
247 | 256 |
-
Please register or login to post a comment