Authored by 王水玲

Merge branch 'feature/installment2a' into release/4.9.2

... ... @@ -41,7 +41,9 @@ const _reviewStatus = (res, req, uid, status) => {
},
goods: result[0]
},
url: jumpUrl
url: helpers.appUrlFormat(req.originalUrl, 'go.instalmentlist', {
title: '分期专享'
})
}
};
}).catch(() => {
... ...
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');
... ... @@ -54,7 +57,7 @@ var validateForm = function() {
var checkCard = require('./bind-card-check');
const clearVerifyCode = function() {
var clearVerifyCode = function() {
formModel.snsCheckCode = '';
$('#sns-check-code').val('');
};
... ... @@ -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,12 +232,10 @@ $('#apply-button').click(function() {
}).then(function(result) {
var params;
if (!result) {
// return;
that.removeClass('disabled').text('下一步').data('running', false);
result = {
code: 500
};
if (!result) {
return;
}
params = {
... ... @@ -242,12 +246,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);
... ... @@ -268,7 +281,7 @@ $('input[maxlength]').keyup(function() {
});
$('#agreements').click(function() {
const params = {
var params = {
action: 'go.instalmentProtocol',
params: {
protocolUrl: location.protocol + '//' + location.hostname + location.port + $(this).data('href')
... ...
/**
* 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: function(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: function(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: function(name, callback) {
var appInterface = window.yohoInterface;
// 延迟 500ms 注入
setTimeout(function() {
if (appInterface) {
appInterface[name] = callback;
}
}, 500);
}
};
module.exports = yoho;
... ...