|
@@ -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,50 +205,51 @@ let question = { |
|
@@ -197,50 +205,51 @@ 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
|
- }
|
|
|
223
|
- }).then(function(data) {
|
|
|
224
|
- that.saving = false;
|
|
|
225
|
- if (data.code === 200 || data.code === 206) {
|
|
|
226
|
- let tip = '调查问卷已成功提交,感谢您的帮助!';
|
224
|
+ };
|
227
|
|
225
|
|
228
|
- if (data.code === 206 && data.message) {
|
|
|
229
|
- tip = data.message;
|
|
|
230
|
- }
|
226
|
+ $.extend(params, result);
|
231
|
|
227
|
|
232
|
- tipDg.show(tip);
|
228
|
+ $.ajax({
|
|
|
229
|
+ type: 'POST',
|
|
|
230
|
+ url: '/3party/questionnaire/submit',
|
|
|
231
|
+ data: params
|
|
|
232
|
+ }).then(function(data) {
|
|
|
233
|
+ if (data.code === 200 || data.code === 206) {
|
|
|
234
|
+ let tip = '调查问卷已成功提交,感谢您的帮助!';
|
233
|
|
235
|
|
234
|
- setTimeout(function() {
|
|
|
235
|
- if (yoho.isApp) {
|
|
|
236
|
- yoho.invokeMethod('go.back');
|
|
|
237
|
- } else {
|
|
|
238
|
- window.history.go(-1);
|
236
|
+ if (data.code === 206 && data.message) {
|
|
|
237
|
+ tip = data.message;
|
239
|
}
|
238
|
}
|
240
|
- }, 2000);
|
|
|
241
|
- } else {
|
|
|
242
|
- tipDg.show(data.message || '网络出了点问题~');
|
|
|
243
|
- }
|
239
|
+
|
|
|
240
|
+ tipDg.show(tip);
|
|
|
241
|
+
|
|
|
242
|
+ setTimeout(function() {
|
|
|
243
|
+ if (yoho.isApp) {
|
|
|
244
|
+ yoho.invokeMethod('go.back');
|
|
|
245
|
+ } else {
|
|
|
246
|
+ window.history.go(-1);
|
|
|
247
|
+ }
|
|
|
248
|
+ }, 2000);
|
|
|
249
|
+ } else {
|
|
|
250
|
+ tipDg.show(data.message || '网络出了点问题~');
|
|
|
251
|
+ }
|
|
|
252
|
+ });
|
244
|
});
|
253
|
});
|
245
|
}
|
254
|
}
|
246
|
};
|
255
|
};
|