|
|
var $ = require('yoho-jquery');
|
|
|
var tip = require('../plugin/tip');
|
|
|
var yohoApp = require('../yoho-app');
|
|
|
|
|
|
var Timer = function() {
|
|
|
this.counter = 0;
|
...
|
...
|
@@ -35,7 +36,9 @@ var validateForm = function() { |
|
|
formModel.mobile &&
|
|
|
formModel.snsCheckCode &&
|
|
|
formModel.agreements === 'on') {
|
|
|
applyButton.removeClass('disabled');
|
|
|
if (!applyButton.data('running')) {
|
|
|
applyButton.removeClass('disabled');
|
|
|
}
|
|
|
ret = true;
|
|
|
} else {
|
|
|
applyButton.addClass('disabled');
|
...
|
...
|
@@ -162,18 +165,18 @@ $('#send-sms').click(function() { |
|
|
|
|
|
// 输入框改变时同时更新模型
|
|
|
/*
|
|
|
$('input').on('change', function() {
|
|
|
var name = $(this).attr('name');
|
|
|
$('input').on('change', function() {
|
|
|
var name = $(this).attr('name');
|
|
|
|
|
|
if ($(this).is(':checkbox')) {
|
|
|
formModel[name] = $(this).is(':checked') ? $(this).val() : null;
|
|
|
} else {
|
|
|
formModel[name] = $(this).val();
|
|
|
}
|
|
|
if ($(this).is(':checkbox')) {
|
|
|
formModel[name] = $(this).is(':checked') ? $(this).val() : null;
|
|
|
} else {
|
|
|
formModel[name] = $(this).val();
|
|
|
}
|
|
|
|
|
|
validateForm();
|
|
|
});
|
|
|
*/
|
|
|
validateForm();
|
|
|
});
|
|
|
*/
|
|
|
|
|
|
// validateForm();
|
|
|
|
...
|
...
|
@@ -198,14 +201,17 @@ setInterval(function() { |
|
|
$('#apply-button').click(function() {
|
|
|
var ret = false;
|
|
|
var that = $(this);
|
|
|
var asyncMode = yohoApp.isiOS;
|
|
|
|
|
|
if ($(this).hasClass('disabled') || !validateForm()) {
|
|
|
return false;
|
|
|
} else {
|
|
|
$(this).addClass('disabled').text('处理中...').data('running', true);
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
async: false,
|
|
|
async: asyncMode,
|
|
|
url: '/home/installment/starting-service/check-verify-code',
|
|
|
data: {
|
|
|
mobile: formModel.mobile,
|
...
|
...
|
@@ -217,7 +223,7 @@ $('#apply-button').click(function() { |
|
|
method: 'post',
|
|
|
url: '/home/installment/activate-service',
|
|
|
data: formModel,
|
|
|
async: false
|
|
|
async: asyncMode
|
|
|
});
|
|
|
} else {
|
|
|
clearVerifyCode();
|
...
|
...
|
@@ -226,8 +232,12 @@ $('#apply-button').click(function() { |
|
|
}).then(function(result) {
|
|
|
var params;
|
|
|
|
|
|
that.removeClass('disabled').text('下一步').data('running', false);
|
|
|
|
|
|
if (!result) {
|
|
|
return;
|
|
|
result = {
|
|
|
code: 500
|
|
|
};
|
|
|
}
|
|
|
|
|
|
params = {
|
...
|
...
|
@@ -238,12 +248,21 @@ $('#apply-button').click(function() { |
|
|
};
|
|
|
|
|
|
if (result.code === 200 && result.data) {
|
|
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
if (asyncMode) {
|
|
|
yohoApp.invokeMethod('go.instalmentActivated', params.params);
|
|
|
} else {
|
|
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
}
|
|
|
|
|
|
ret = true;
|
|
|
} else if (result.code === 500) {
|
|
|
// 接口可能超时返回审核中 by 孟令阶
|
|
|
params.params.status = '1';
|
|
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
if (asyncMode) {
|
|
|
yohoApp.invokeMethod('go.instalmentActivated', params.params);
|
|
|
} else {
|
|
|
that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params)));
|
|
|
}
|
|
|
ret = true;
|
|
|
} else {
|
|
|
tip.show(result.message);
|
...
|
...
|
|