Authored by 王水玲

有货分期

... ... @@ -11,13 +11,13 @@ const helpers = global.yoho.helpers;
// 判断是否已经获取到了开通的状态值
const _reviewStatus = (uid, status) => {
if (status === 1) {
if (status === '1') {
return {
review: {
url: helpers.urlFormat('/product/new')
}
};
} else if (status === 2) {
} else if (status === '2') {
return Promise.all([installmentModel.getSearchIntallment(), installmentModel.getQueryCreditInfo(uid)]).then((result) => { //eslint-disable-line
return {
success: {
... ... @@ -30,7 +30,7 @@ const _reviewStatus = (uid, status) => {
};
});
} else if (status === 3) {
} else if (status === '3') {
return {
error: {
url: helpers.urlFormat('/product/new')
... ... @@ -49,6 +49,7 @@ const _repaymentList = (req, res, next, title, params) => {
res.render('installment/repayment-list', {
module: 'home',
page: 'repayment-list',
isInstallmentPage: true,
title: title,
data: result
});
... ... @@ -57,14 +58,14 @@ const _repaymentList = (req, res, next, title, params) => {
// 开通分期首页
const index = (req, res, next) => {
let uid = req.user.uid || 3236556;
let uid = req.user.uid || 512579468;
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
// status:0 未申请 1审核中 2已开通 3 审核未通过
let openStatus = result[0];
if (openStatus === 0) {
if (openStatus === '0') {
return installmentModel.getResources().then(data => {
return {
bannerTop: data,
... ... @@ -75,7 +76,7 @@ const index = (req, res, next) => {
}
};
});
} else if (openStatus === 2) {
} else if (openStatus === '2') {
return Promise.all([installmentModel.getQueryCreditInfo(uid), installmentModel.getQueryAmtInfo(uid)]).then((data) => { //eslint-disable-line
let params = _.assign({
isOverdue: false,
... ... @@ -111,6 +112,7 @@ const index = (req, res, next) => {
res.render('installment/open-index', _.assign({
module: 'home',
page: 'installment',
isInstallmentPage: true,
title: '有货分期'
}, result));
}).catch(next);
... ... @@ -119,11 +121,12 @@ const index = (req, res, next) => {
// 开通结果显示
const review = (req, res, next) => {
let openStatus = req.query.status || false;
let uid = req.user.uid || 20000032;
let uid = req.user.uid || 512579468;
let data = {
module: 'home',
page: 'installment',
title: '有货分期'
title: '有货分期',
isInstallmentPage: true
};
if (openStatus) {
... ... @@ -170,6 +173,7 @@ const repayRecordPage = (req, res) => {
res.render('installment/repay-record', {
module: 'home',
page: 'repay-record',
isInstallmentPage: true,
title: '还款记录'
});
};
... ... @@ -201,6 +205,7 @@ const account = (req, res, next) => {
res.render('installment/account', {
accountList: result,
title: '账号管理',
isInstallmentPage: true,
repaymentList: result
});
}).catch(next);
... ... @@ -232,7 +237,7 @@ const activateService = (req, res, next) => {
const getBankInfo = (req, res, next) => {
installmentModel.getBankInfo({
cardNo: req.query.cardNo,
uid: req.user.uid || 3096590 // TODO: fix uid
uid: req.user.uid || 512579468 // TODO: fix uid
}).then((result)=> {
res.json(result);
}).catch(next);
... ... @@ -255,7 +260,7 @@ const orderIndex = (req, res) => {
const orderList = (req, res) => {
const params = {
uid: req.user.uid || 8041876, // TODO: fix me
uid: req.user.uid || 512579468, // TODO: fix me
type: req.query.type || 1,
page: req.query.page || 1,
limit: req.query.limit || 10
... ... @@ -271,7 +276,7 @@ const orderList = (req, res) => {
const orderDetail = (req, res) => {
const params = {
uid: req.user.id || 8041876, // TODO: fix me
uid: req.user.id || 512579468, // TODO: fix me
orderCode: req.params.id
};
... ... @@ -287,8 +292,20 @@ const orderDetail = (req, res) => {
};
// 还款详情
const repayDetail = (req, res) => {
res.render('installment/repay-detail');
const repayDetail = (req, res, next) => {
let params = {
uid: req.user.id || 512579468,
rePayNo: req.query.id || '',
pageNo: 1
};
installmentModel.getQueryRePayList(params).then((result) => {
res.render('installment/repay-detail', _.assign({
title: '还款详情',
isInstallmentPage: true,
isOne: true
}, result[0]));
}).catch(next);
};
module.exports = {
... ...
... ... @@ -113,6 +113,24 @@ const _processRepayList = (list) => {
} else {
data.stage = data.termNo + '/' + data.terms;
}
if (data.status === 1) {
data.repayStatus = '已还清';
data.txt = '还款成功!';
data.isTwo = true;
data.isThree = true;
} else if (data.status === 2) {
data.repayStatus = '还款失败';
data.txt = `还款失败,${data.desc}`;
data.isTwo = true;
data.isThree = true;
} else {
data.repayStatus = '还款中';
data.txt = '预计1-2分钟内还款成功,<br>请到还款记录查看还款结果';
}
data.url = `/home/installment/repay/detail?id=${data.prePayNo}`;
});
return list;
... ... @@ -182,7 +200,9 @@ const getStauts = (uid) => {
alg: 'SALT_MD5',
code: 200,
data: {
status: 2
status: '2',
isShow: '1',
currCreditLimit: '3125.20'
},
md5: '6d729d4b35f10fc73531210bd7ecff91',
message: 'success'
... ... @@ -202,18 +222,18 @@ const getQueryCreditInfo = (uid) => {
method: 'user.instalment.queryCreditLimit',
uid: uid
}).then((result) => {
result = {
alg: 'SALT_MD5',
code: 200,
data: {
initCreditLimit: '5000',
currCreditLimit: '2000',
status: '2',
maxOverdueDay: '5'
},
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
};
// result = {
// alg: 'SALT_MD5',
// code: 200,
// data: {
// initCreditLimit: '5000',
// currCreditLimit: '2000',
// status: '2',
// maxOverdueDay: '5'
// },
// md5: 'c1d725306fb09dcbf504776d276521cb',
// message: 'ok'
// };
if (result && result.code === 200) {
return result.data;
} else {
... ... @@ -229,18 +249,18 @@ const getQueryAmtInfo = (uid) => {
method: 'app.order.queryAmtInfo',
uid: uid
}).then((result) => {
result = {
alg: 'SALT_MD5',
code: 200,
data: {
totalAmt: '2000.00',
monthAmt: '800.00',
s_7daysAmt: '400.00',
overAmt: '400.00'
},
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
};
// result = {
// alg: 'SALT_MD5',
// code: 200,
// data: {
// totalAmt: '2000.00',
// monthAmt: '800.00',
// s_7daysAmt: '400.00',
// overAmt: '400.00'
// },
// md5: 'c1d725306fb09dcbf504776d276521cb',
// message: 'ok'
// };
if (result && result.code === 200) {
result.data.dayAmt = result.data.s_7daysAmt;
... ... @@ -261,47 +281,47 @@ const getQueryAmtList = (params) => {
}, params), {
cache: true
}).then((result) => {
result = {
alg: 'SALT_MD5',
code: 200,
data: {
amtList: [
{
billNo: 'x00001',
terms: 3,
currTerm: 1,
unExpireDays: -3,
billInfo: '三叶草运动休闲鞋',
currAmt: '845.00',
currNoFeeAmt: '840.00',
currFee: '5.00'
}, {
billNo: 'x00002',
terms: 3,
currTerm: 2,
unExpireDays: 10,
billInfo: '三叶草运动休闲鞋',
currAmt: '840.00',
currNoFeeAmt: '840.00',
currFee: '0.00'
}, {
billNo: 'x00003',
terms: 3,
currTerm: 1,
unExpireDays: -3,
billInfo: '三叶草运动休闲鞋',
currAmt: '845.00',
currNoFeeAmt: '840.00',
currFee: '5.00'
}
],
pageNo: 1,
pageTotal: 1,
total: 2
},
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
};
// result = {
// alg: 'SALT_MD5',
// code: 200,
// data: {
// amtList: [
// {
// billNo: 'x00001',
// terms: 3,
// currTerm: 1,
// unExpireDays: -3,
// billInfo: '三叶草运动休闲鞋',
// currAmt: '845.00',
// currNoFeeAmt: '840.00',
// currFee: '5.00'
// }, {
// billNo: 'x00002',
// terms: 3,
// currTerm: 2,
// unExpireDays: 10,
// billInfo: '三叶草运动休闲鞋',
// currAmt: '840.00',
// currNoFeeAmt: '840.00',
// currFee: '0.00'
// }, {
// billNo: 'x00003',
// terms: 3,
// currTerm: 1,
// unExpireDays: -3,
// billInfo: '三叶草运动休闲鞋',
// currAmt: '845.00',
// currNoFeeAmt: '840.00',
// currFee: '5.00'
// }
// ],
// pageNo: 1,
// pageTotal: 1,
// total: 2
// },
// md5: 'c1d725306fb09dcbf504776d276521cb',
// message: 'ok'
// };
if (result && result.code === 200) {
return _processAmtList(result.data.amtList, params.queryDays);
} else {
... ... @@ -541,32 +561,26 @@ const getQueryRePayList = (params) => {
// data: {
// rePayList: [
// {
// billNo: "00001",
// terms: 3,
// termNo: 1,
// prePayNo: "00001",
// time: "2016.06.01",
// status: 1,
// amt: "200.00",
// billInfo: "三叶草运动休闲鞋"
// desc: null,
// amt: "200.00"
// },
// {
// billNo: "00001",
// terms: 3,
// termNo: 1,
// time: "2016.06.01",
// status: 1,
// amt: "200.00",
// billInfo: "三叶草运动休闲鞋"
// prePayNo: "00001",
// time: "2016.07.01",
// status: 2,
// desc: "银行卡余额不足",
// amt: "200.00"
// },
// {
// billNo: "00001",
// terms: 3,
// termNo: 1,
// time: "2016.06.01",
// status: 1,
// amt: "200.00",
// billInfo: "三叶草运动休闲鞋"
// },
// prePayNo: "00001",
// time: "2016.08.01",
// status: 3,
// desc: null,
// amt: "200.00"
// }
// ],
// pageNo: 1,
// pageTotal: 1,
... ...
... ... @@ -26,7 +26,6 @@
{{> installment/installment-only}}
{{/ installmentOnly}}
{{else}}
{{log this}}
<div class="detail-tab">
<span class="on is-repay">待还款金额</span>
<span class="is-usable">可用额度</span>
... ...
{{#recordData}}
<li>
<div class="repay-time">{{time}}</div>
<div class="record-cont">
<p>{{round amt}}</p>
<p>【全{{stage}}期】{{billInfo}}</p>
</div>
<div class="record-right">已还清</div>
<a href="{{url}}">
<div class="record-cont">
<p>¥{{round amt}}</p>
<p>{{time}}</p>
</div>
<div class="record-right">
<div class="right-status">{{repayStatus}}{{#desc}}<br><span class="color-r">{{.}}</span>{{/desc}}</div>
<span class="iconfont">&#xe604;</span>
</div>
</a>
</li>
{{/recordData}}
\ No newline at end of file
... ...
<div class="repayment-list-page">
<div class="repay-now">本次还款<span>¥</span></div>
<div class="repay-now">本次还款<span>¥{{round amt}}</span></div>
<div class="repay-detail">
<ul class="repay-status">
<li>
<li {{#isOne}}class="on"{{/isOne}}>
<span>付款</span>
<span class="spot"></span>
</li>
<li>
<li {{#isTwo}}class="on"{{/isTwo}}>
<span>银行处理</span>
<span class="spot"></span>
</li>
<li>
<li {{#isThree}}class="on"{{/isThree}}>
<span>还款结果</span>
<span class="spot"></span>
</li>
</ul>
<p>预计1-2分钟内还款成功,请到还款记录查看还款结果</p>
<p class="txt">{{{txt}}}</p>
</div>
<a href="" class="contact-cs">如有问题请联系客服</a>
<p class="contact-cs">如有问题请联系客服</p>
</div>
\ No newline at end of file
... ...
<div class="repayment-list-page">
<div class="repayment-list-page yoho-page">
{{#if isNoResult}}
<div class="no-result">
<i class="result-icon"></i>
... ... @@ -9,7 +9,7 @@
{{#data}}
<ul class="repay-list">
{{#each repaymentList}}
<li data-currfee="{{currFee}}" data-curramt="{{currAmt}}">
<li data-currfee="{{currFee}}" data-curramt="{{currAmt}}" data-billno="{{billNo}}" data-termNo={{currTerm}}>
<input id="list-{{billNo}}" type="checkbox" class="installment-check-btn" {{#if isChecked}}checked{{/if}}/>
<label for="list-{{billNo}}">
<div class="cont">
... ...
... ... @@ -18,7 +18,7 @@
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
{{#if devEnv}}
<link rel="stylesheet" href="//172.16.6.180:5001/css/index.css">
<link rel="stylesheet" href="//localhost:5001/css/index.css">
{{^}}
<link rel="stylesheet" href="//cdn.yoho.cn/m-yohobuy-node/{{version}}/index.css">
{{/if}}
... ... @@ -26,7 +26,7 @@
<link rel="apple-touch-startup-image" sizes="640x920" href="http://static.yohobuy.com/m/v1/img/startup/startup-retina.png" media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
<link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
</head>
<body {{#if isPassportPage}}class=passport-body{{/if}} {{#if isStarIndexPage}} class="star-index-bg"{{/if}} {{#if isStarDetailPage}}class="star-class-body"{{/if}}>
<body {{#if isPassportPage}}class=passport-body{{/if}} {{#if isStarIndexPage}} class="star-index-bg"{{/if}} {{#if isStarDetailPage}}class="star-class-body"{{/if}} {{#if isInstallmentPage}}class=installment-body{{/if}}>
<div class="main-wrap">
{{#if systemUpdate}}
{{> updata}}
... ... @@ -41,8 +41,8 @@
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
{{/wechatShare}}
{{#if devEnv}}
<script src="//172.16.6.180:5001/libs.js"></script>
<script src="//172.16.6.180:5001/{{module}}.{{page}}.js"></script>
<script src="//localhost:5001/libs.js"></script>
<script src="//localhost:5001/{{module}}.{{page}}.js"></script>
{{^}}
<script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js"></script>
<script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
... ...
... ... @@ -2,8 +2,6 @@ var $ = require('yoho-jquery'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload');
var $installmentOnly = $('.installment-only');
var $this, $title;
lazyLoad($('img.lazy'));
... ... @@ -16,18 +14,6 @@ $('.good-detail-text .name').each(function() {
$title[0].mlellipsis(2);
});
if ($installmentOnly.length > 0) {
$('.installment-page').css({
background: '#efefef'
});
}
if ($('.installment-bg').length > 0) {
$('body').css({
background: '#efefef'
});
}
$('.detail-tab span').on('click', function() {
$(this).addClass('on').siblings().removeClass('on');
$('.installment-cont').hide().eq($(this).index()).show();
... ...
... ... @@ -4,12 +4,40 @@
* @date: 2016/08/04
*/
var $ = require('yoho-jquery');
var $ = require('yoho-jquery'),
tip = require('../plugin/tip');
var $notice = $('.installment-overdue-notice'),
$currAmt = $('.repayment-bottom').find('.curr-amt'),
$currFee = $('.repayment-bottom').find('.curr-fee');
// 选择分期统计
function totalChecked(index) {
var total = 0;
// 按时间顺序选择还款,不可以跨期
$('.repay-list input').each(function(key, item) {
if (key < index && $(item).is(':checked')) {
total++;
}
});
return total;
}
// 取消分期统计
function totalCancelChecked(index) {
var total = 0;
$('.repay-list input').each(function(key, item) {
if (key > index && $(item).is(':checked')) {
total++;
}
});
return total;
}
$('.repay-list .notice').on('click', function() {
$notice.show();
... ... @@ -20,26 +48,43 @@ $('.think-ok, .mask-bg').on('click', function() {
$notice.hide();
});
$('.repay-list .cont').on('click', function() {
var $input = $(this).parent().prev(),
$('.repay-list label').on('click', function() {
var li = $(this).parents('li'),
index = li.index(),
$input = $(this).prev(),
currAmt = +$currAmt.html(),
currFee = +$currFee.html(),
amt = +$(this).parents('li').attr('data-curramt'),
fee = +$(this).parents('li').attr('data-currfee'),
count = 0;
amt = +li.attr('data-curramt'),
fee = +li.attr('data-currfee'),
count = 0,
total = 0;
if ($input.is(':checked')) {
$currAmt.html(currAmt - amt);
$currFee.html(currFee - fee);
total = totalCancelChecked(index);
if (total === 0) {
$currAmt.html(currAmt - amt);
$currFee.html(currFee - fee);
} else {
tip.show('请按时间顺序取消选择,不可以跨期');
return false;
}
} else {
$currAmt.html(amt + currAmt);
$currFee.html(fee + currFee);
total = totalChecked(index);
if (total === index) {
$currAmt.html(amt + currAmt);
$currFee.html(fee + currFee);
} else {
tip.show('请按时间顺序添加还款,不可以跨期');
return false;
}
}
setTimeout(function() {
count = $('.repay-list input:checked').length;
$('#repayment-total').prop('checked', count === $('.repay-list li').length);
}, 0);
});
// 全选||全不选
... ... @@ -65,7 +110,24 @@ $('.repayment-bottom label').on('click', function() {
$('.repayment-btn').on('click', function() {
var path = location.pathname;
var list = [];
$('.repay-list li').each(function(key, item) {
if ($(item).find('input').is(':checked')) {
list.push({
index: key, // 分期列表序号
orderCode: $(item).attr('data-billno'), // 订单号
termNo: $(item).attr('data-termNo') // 第几期还款
});
}
});
$(this).attr('href',
path + '?openby:yohobuy={"action":"go.instalmentRepayment","params":{"amount":' + (+$currAmt.html()) + '}}');
path + '?openby:yohobuy={"action":"go.instalmentRepayment","params":{"list":' + list + '}}');
});
// 跳转到还款详情
window.jumpDetail = function(id) {
location.href = '/home/installment/repay/detail?id=' + id;
};
... ...
... ... @@ -217,6 +217,10 @@
font-size: 28px;
overflow: hidden;
a {
display: block;
}
.list-right {
float: right;
margin-right: 30px;
... ... @@ -270,3 +274,7 @@
}
}
}
.installment-body {
background: #efefef;
}
... ...
... ... @@ -63,6 +63,8 @@
height: 120px;
background: #fff;
border-bottom: 1px solid #e0e0e0;
padding-top: 30px;
box-sizing: border-box;
.repay-time {
width: 200px;
... ... @@ -73,35 +75,44 @@
}
.record-cont {
width: 265px;
width: 360px;
height: 120px;
float: left;
overflow: hidden;
margin: 0 0 0 30px;
color: #444;
p {
line-height: 40px;
line-height: 30px;
font-size: 26px;
}
p:first-child {
margin: 20px 0 0 10px;
}
p:last-child {
width: 100%;
height: 40px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
font-size: 22px;
}
}
.right-status {
float: left;
}
.record-right {
float: right;
color: #ccc;
padding-right: 30px;
line-height: 120px;
line-height: 30px;
text-align: right;
.color-r {
color: #d0021b;
}
.iconfont {
position: relative;
top: 18px;
margin-left: 15px;
}
}
}
... ... @@ -157,8 +168,17 @@
}
.repay-detail {
background: #fff;
border-top: 1px solid #e0e0e0;
margin-top: 30px;
.txt {
color: #b0b0b0;
line-height: 38px;
font-size: 24px;
text-align: center;
padding: 80px 0 50px;
}
}
.repay-status {
... ... @@ -173,6 +193,31 @@
width: 134px;
text-align: center;
margin: 0 30px;
position: relative;
&:first-child:before {
content: "";
border: none;
}
&:before {
content: "";
position: absolute;
bottom: 7px;
left: -118px;
width: 180px;
border-bottom: 5px solid #b0b0b0;
}
&.on {
.spot {
background: #444;
}
&:before {
border-color: #444;
}
}
}
.spot {
... ... @@ -184,6 +229,14 @@
margin: 0 auto;
}
}
.contact-cs {
width: 100%;
position: fixed;
bottom: 45px;
text-align: center;
color: #444;
}
}
.installment-overdue-notice {
... ...