Authored by Aiden Xu

开通有货分期

... ... @@ -9,11 +9,14 @@ const headerModel = require('../../../doraemon/models/header');
const installmentModel = require('../models/installment');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const index = (req, res) => {
let query = req.query.query || '';
let uid = req.user.uid || 3236556;
installmentModel.getStauts(uid).then((openStatus) => {
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
let openStatus = result[0];
if (openStatus === 0) {
return {
bannerTop: {
... ... @@ -27,16 +30,24 @@ const index = (req, res) => {
notOpen: true,
installmentOnly: {
title: '分期专享',
goods: [
{}
]
goods: result[1]
}
};
} else if (openStatus === 2) {
if (query === 'usable') {
return installmentModel.getQueryCreditInfo(uid).then((data) => {
if (data.status === 2) {
data.replayStatus = '逾期';
} else if (data.status === 3) {
data.replayStatus = '不可用';
}
return _.assign({
isUnable: true
isUnable: true,
installmentOnly: {
title: '分期专享',
goods: result[1]
}
}, data);
});
} else {
... ... @@ -46,52 +57,54 @@ const index = (req, res) => {
}, data);
});
}
}
}).then((result) => {
result.pageHeader = _.assign({
installmentPage: true
}, headerModel.setNav({
navTitle: '有货分期',
navBtn: false
}));
res.render('installment/open-index', _.assign({
module: 'home',
page: 'installment',
title: '有货分期',
pageHeader: headerModel.setNav({
navTitle: '有货分期',
navBtn: false
})
title: '有货分期'
}, result));
});
};
const review = (req, res) => {
let uid = req.user.uid || 20000032;
let params = {};
installmentModel.getStauts(uid).then((status) => {
if (status === 1) {
params = {
return {
review: {
url: helpers.urlFormat('/?go=1')
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
} else if (status === 2) {
params = {
success: {
price: '5000',
installmentOnly: {
title: '分期专享',
goods: [
{}
]
return installmentModel.getSearchIntallment().then((goods) => {
return {
success: {
price: '5000',
installmentOnly: {
title: '分期专享',
goods: goods
}
}
}
};
} else {
params = {
};
});
} else if (status === 3) {
return {
error: {
url: helpers.urlFormat('/?go=1')
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
}
}).then((params) => {
res.render('installment/open-result', _.assign({
module: 'home',
page: 'installment',
... ...
... ... @@ -47,7 +47,7 @@ const getQueryCreditInfo = (uid) => {
data: {
initCredit: '8000.00',
currCredit: '5000.00',
status: 1
status: 2
},
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
... ... @@ -89,42 +89,27 @@ const getQueryAmtInfo = (uid) => {
});
};
/**
* 获取短信验证码
*
* @param uid 用户ID
* @param mobile 手机号码
*/
const sendVerifyCode = (uid, mobile) => {
// 分期专享推荐商品
const getSearchIntallment = () => {
return api.get('', {
method: 'user.instalment.getSnsCheckCode'
}, {
uid,
mobile
method: 'app.search.instalment',
limit: '50',
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('get instalment promote goods return is not 200');
return '';
}
});
};
/**
* 开通服务
*
* @param uid 用户id
* @param userName 姓名
* @param identityCardNo 身份证号码
* @param cardNo 银行卡号码
* @param mobile 手机号码
* @param snsCheckCode 验证码
* @returns {*}
*/
const activateService = (params) => {
return api.get('', {
method: 'user.instalment.activate'
}, params);
};
module.exports = {
getStauts,
getQueryCreditInfo,
getQueryAmtInfo,
getSearchIntallment
sendVerifyCode,
activateService
};
... ...
<div class="installment-page">
<div class="installment-page installment-bg">
{{#if notOpen}}
{{# bannerTop}}
{{> resources/banner-top}}
... ... @@ -34,7 +34,7 @@
<div class="repay-area detail-bg">
<p class="detail-txt1">近7日代还款</p>
<p class="detail-txt1">¥<span class="detail-txt2">{{round dayAmt}}</span></p>
<P class="detail-txt3">您有¥{{round dayAmt}}已逾期3天,点击<a href="">查看详情</a></P>
<p class="detail-txt3">您有¥{{round dayAmt}}已逾期3天,点击<a href="">查看详情</a></p>
<a href="" class="see-btn">明细</a>
</div>
<ul class="group-list">
... ...
... ... @@ -16,6 +16,9 @@
{{#currencyDetailPage}}
<a href="/home/helpDetail?code=20111130-152530&caption=如何使用YOHO币支付" class="iconfont nav-home">&#xe639;</a>
{{/currencyDetailPage}}
{{#installmentPage}}
<a href="/home/helpDetail?code=20151230-102233&caption=有货分期" class="iconfont nav-home">&#xe639;</a>
{{/installmentPage}}
{{#navPhone}}
<a href="{{.}}" class="iconfont nav-home">&#xe641;</a>
{{/navPhone}}
... ...
... ... @@ -73,3 +73,9 @@ if ($installmentOnly.length > 0) {
search();
}
if ($('.installment-bg').length > 0) {
$('body').css({
background: '#efefef'
});
}
... ...