1
|
var $ = require('yoho-jquery');
|
1
|
var $ = require('yoho-jquery');
|
2
|
var tip = require('../plugin/tip');
|
2
|
var tip = require('../plugin/tip');
|
|
|
3
|
+var yohoApp = require('../yoho-app');
|
3
|
|
4
|
|
4
|
var Timer = function() {
|
5
|
var Timer = function() {
|
5
|
this.counter = 0;
|
6
|
this.counter = 0;
|
|
@@ -35,7 +36,9 @@ var validateForm = function() { |
|
@@ -35,7 +36,9 @@ var validateForm = function() { |
35
|
formModel.mobile &&
|
36
|
formModel.mobile &&
|
36
|
formModel.snsCheckCode &&
|
37
|
formModel.snsCheckCode &&
|
37
|
formModel.agreements === 'on') {
|
38
|
formModel.agreements === 'on') {
|
|
|
39
|
+ if (!applyButton.data('running')) {
|
38
|
applyButton.removeClass('disabled');
|
40
|
applyButton.removeClass('disabled');
|
|
|
41
|
+ }
|
39
|
ret = true;
|
42
|
ret = true;
|
40
|
} else {
|
43
|
} else {
|
41
|
applyButton.addClass('disabled');
|
44
|
applyButton.addClass('disabled');
|
|
@@ -54,7 +57,7 @@ var validateForm = function() { |
|
@@ -54,7 +57,7 @@ var validateForm = function() { |
54
|
|
57
|
|
55
|
var checkCard = require('./bind-card-check');
|
58
|
var checkCard = require('./bind-card-check');
|
56
|
|
59
|
|
57
|
-const clearVerifyCode = function() {
|
60
|
+var clearVerifyCode = function() {
|
58
|
formModel.snsCheckCode = '';
|
61
|
formModel.snsCheckCode = '';
|
59
|
$('#sns-check-code').val('');
|
62
|
$('#sns-check-code').val('');
|
60
|
};
|
63
|
};
|
|
@@ -162,7 +165,7 @@ $('#send-sms').click(function() { |
|
@@ -162,7 +165,7 @@ $('#send-sms').click(function() { |
162
|
|
165
|
|
163
|
// 输入框改变时同时更新模型
|
166
|
// 输入框改变时同时更新模型
|
164
|
/*
|
167
|
/*
|
165
|
-$('input').on('change', function() {
|
168
|
+ $('input').on('change', function() {
|
166
|
var name = $(this).attr('name');
|
169
|
var name = $(this).attr('name');
|
167
|
|
170
|
|
168
|
if ($(this).is(':checkbox')) {
|
171
|
if ($(this).is(':checkbox')) {
|
|
@@ -172,8 +175,8 @@ $('input').on('change', function() { |
|
@@ -172,8 +175,8 @@ $('input').on('change', function() { |
172
|
}
|
175
|
}
|
173
|
|
176
|
|
174
|
validateForm();
|
177
|
validateForm();
|
175
|
-});
|
|
|
176
|
-*/
|
178
|
+ });
|
|
|
179
|
+ */
|
177
|
|
180
|
|
178
|
// validateForm();
|
181
|
// validateForm();
|
179
|
|
182
|
|
|
@@ -198,14 +201,17 @@ setInterval(function() { |
|
@@ -198,14 +201,17 @@ setInterval(function() { |
198
|
$('#apply-button').click(function() {
|
201
|
$('#apply-button').click(function() {
|
199
|
var ret = false;
|
202
|
var ret = false;
|
200
|
var that = $(this);
|
203
|
var that = $(this);
|
|
|
204
|
+ var asyncMode = yohoApp.isiOS;
|
201
|
|
205
|
|
202
|
if ($(this).hasClass('disabled') || !validateForm()) {
|
206
|
if ($(this).hasClass('disabled') || !validateForm()) {
|
203
|
return false;
|
207
|
return false;
|
|
|
208
|
+ } else {
|
|
|
209
|
+ $(this).addClass('disabled').text('处理中...').data('running', true);
|
204
|
}
|
210
|
}
|
205
|
|
211
|
|
206
|
$.ajax({
|
212
|
$.ajax({
|
207
|
method: 'get',
|
213
|
method: 'get',
|
208
|
- async: false,
|
214
|
+ async: asyncMode,
|
209
|
url: '/home/installment/starting-service/check-verify-code',
|
215
|
url: '/home/installment/starting-service/check-verify-code',
|
210
|
data: {
|
216
|
data: {
|
211
|
mobile: formModel.mobile,
|
217
|
mobile: formModel.mobile,
|
|
@@ -217,7 +223,7 @@ $('#apply-button').click(function() { |
|
@@ -217,7 +223,7 @@ $('#apply-button').click(function() { |
217
|
method: 'post',
|
223
|
method: 'post',
|
218
|
url: '/home/installment/activate-service',
|
224
|
url: '/home/installment/activate-service',
|
219
|
data: formModel,
|
225
|
data: formModel,
|
220
|
- async: false
|
226
|
+ async: asyncMode
|
221
|
});
|
227
|
});
|
222
|
} else {
|
228
|
} else {
|
223
|
clearVerifyCode();
|
229
|
clearVerifyCode();
|
|
@@ -226,12 +232,10 @@ $('#apply-button').click(function() { |
|
@@ -226,12 +232,10 @@ $('#apply-button').click(function() { |
226
|
}).then(function(result) {
|
232
|
}).then(function(result) {
|
227
|
var params;
|
233
|
var params;
|
228
|
|
234
|
|
229
|
- if (!result) {
|
|
|
230
|
- // return;
|
235
|
+ that.removeClass('disabled').text('下一步').data('running', false);
|
231
|
|
236
|
|
232
|
- result = {
|
|
|
233
|
- code: 500
|
|
|
234
|
- };
|
237
|
+ if (!result) {
|
|
|
238
|
+ return;
|
235
|
}
|
239
|
}
|
236
|
|
240
|
|
237
|
params = {
|
241
|
params = {
|
|
@@ -242,12 +246,21 @@ $('#apply-button').click(function() { |
|
@@ -242,12 +246,21 @@ $('#apply-button').click(function() { |
242
|
};
|
246
|
};
|
243
|
|
247
|
|
244
|
if (result.code === 200 && result.data) {
|
248
|
if (result.code === 200 && result.data) {
|
|
|
249
|
+ if (asyncMode) {
|
|
|
250
|
+ yohoApp.invokeMethod('go.instalmentActivated', params.params);
|
|
|
251
|
+ } else {
|
245
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
252
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
253
|
+ }
|
|
|
254
|
+
|
246
|
ret = true;
|
255
|
ret = true;
|
247
|
} else if (result.code === 500) {
|
256
|
} else if (result.code === 500) {
|
248
|
// 接口可能超时返回审核中 by 孟令阶
|
257
|
// 接口可能超时返回审核中 by 孟令阶
|
249
|
params.params.status = '1';
|
258
|
params.params.status = '1';
|
|
|
259
|
+ if (asyncMode) {
|
|
|
260
|
+ yohoApp.invokeMethod('go.instalmentActivated', params.params);
|
|
|
261
|
+ } else {
|
250
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
262
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
263
|
+ }
|
251
|
ret = true;
|
264
|
ret = true;
|
252
|
} else {
|
265
|
} else {
|
253
|
tip.show(result.message);
|
266
|
tip.show(result.message);
|
|
@@ -268,7 +281,7 @@ $('input[maxlength]').keyup(function() { |
|
@@ -268,7 +281,7 @@ $('input[maxlength]').keyup(function() { |
268
|
});
|
281
|
});
|
269
|
|
282
|
|
270
|
$('#agreements').click(function() {
|
283
|
$('#agreements').click(function() {
|
271
|
- const params = {
|
284
|
+ var params = {
|
272
|
action: 'go.instalmentProtocol',
|
285
|
action: 'go.instalmentProtocol',
|
273
|
params: {
|
286
|
params: {
|
274
|
protocolUrl: location.protocol + '//' + location.hostname + location.port + $(this).data('href')
|
287
|
protocolUrl: location.protocol + '//' + location.hostname + location.port + $(this).data('href')
|