Authored by 徐炜

Merge branch 'feature/installment2a' into release/4.9.2

... ... @@ -476,7 +476,9 @@ const postAccount = (params) => {
return api.get('', _.assign({
method: 'user.instalment.bindingCards',
debug: 'XYZ'
}, params));
}, params), {
timeout: 6000
});
};
module.exports = {
... ...
<div class="installment-page add-account-page">
<div class="installment-page add-account-page yoho-page">
{{#bindCard}}
<ul class="add-form">
<li>
... ...
... ... @@ -13,7 +13,7 @@
<input id="list-{{key}}" type="checkbox" class="installment-check-btn" {{#if isChecked}}checked{{/if}}/>
<label for="list-{{key}}">
<div class="cont">
<p>¥{{currNoFeeAmt}}</p>
<p>¥{{currAmt}}</p>
<p>【全{{stage}}期】{{billInfo}}</p>
</div>
</label>
... ...
... ... @@ -46,6 +46,7 @@ $('input').on('input', function() {
applyButton.on('click', function() {
var self = this;
var ret = false;
if (!flag || $(this).hasClass('disabled') || !validateForm()) {
return false;
... ... @@ -74,17 +75,24 @@ applyButton.on('click', function() {
if (data.code === 200) {
params.params.status = 1;
ret = true;
} else if (data.code === 500) {
tip.show('连接超时');
flag = true;
} else {
params.params.message = data.message;
ret = true;
}
url += encodeURIComponent(JSON.stringify(params));
$(self).attr('href', url);
return true;
},
error: function() {
tip.show('网络断开连接了~');
flag = true;
return false;
}
});
return ret;
});
... ...
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);
... ...
... ... @@ -19,7 +19,7 @@ var repayment = new Repayment({
index: li.index(),
orderCode: li.data('billNo'),
termNo: li.data('currterm'),
amount: parseFloat(li.data('currnofeeamt')),
amount: parseFloat(li.data('curramt')),
fee: parseFloat(li.data('currfee')) + 0
};
... ... @@ -49,10 +49,10 @@ $(CHECKBOX_SELECTOR + ':checkbox').click(function() {
billNo = $(self).parent().data('billNo'),
li = $('li[data-bill-no=' + billNo + ']'),
selection = li.find('input:checked'),
lastIndex = li.eq(0).index();
lastIndex = li.eq(0).data('currterm');
selection.parent().each(function(index, sel) {
var key = $(sel).index();
var key = $(sel).data('currterm');
if ((key + 1) - lastIndex > 1) {
isSkipped = true;
... ...
/**
* YOHO-SDK
*
* 与原生 APP 交互的代码
* 所有函数要做降级处理
* 假如不是 YOHO App,在浏览器实现对应的功能
* 浏览器不支持的功能,给出提示,控制台不能报错,不影响后续代码执行
*
* 希望能与 微信 JS-SDK 一样方便
*/
var tip = require('./plugin/tip');
/* 空方法 */
var emptyFn = function() {};
/* 提示信息 */
var tipInfo = '暂不支持,请在YOHO!BUY应用中打开';
var yoho = {
/**
* 判断是否是 APP
*/
isApp: /YohoBuy/i.test(navigator.userAgent || ''),
isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''),
isAndroid: /Android/i.test(navigator.userAgent || ''),
/**
* JS 与 APP 共享的对象
*/
data: window.yohoInterfaceData,
ready(callback) {
if (this.isApp) {
document.addEventListener('deviceready', callback);
} else {
return callback();
}
},
/**
* 调用APP原生方法
* @param method 方法名称
* @param args 传递给 APP 的参数 {"index":tab_index}
* @param success 调用成功的回调方法
* @param fail 调用失败的回调方法
*/
invokeMethod(method, args, success, fail) {
var appInterface = window.yohoInterface;
if (this.isApp && appInterface) {
appInterface.triggerEvent(success || emptyFn, fail || emptyFn, {
method: method,
arguments: args
});
} else {
tip.show(tipInfo);
}
},
/**
* 原生调用 JS 方法
* @param name 方法名
* @param callback 回调
*/
addNativeMethod(name, callback) {
var appInterface = window.yohoInterface;
// 延迟 500ms 注入
setTimeout(function() {
if (appInterface) {
appInterface[name] = callback;
}
}, 500);
}
};
module.exports = yoho;
... ...