Authored by 王水玲

分期3

... ... @@ -15,57 +15,6 @@ const _serverCrash = (res, params) => {
res.render('installment/server-crash', params);
};
// 判断是否已经获取到了开通的状态值
const _reviewStatus = (res, req, uid, status) => {
let jumpUrl = helpers.appUrlFormat('/product/new', 'go.new');
if (status === '1') {
return {
review: {
url: jumpUrl
}
};
} else if (status === '2') {
return Promise.all([
installmentModel.getSearchIntallment({
page: 1
}),
installmentModel.getQueryCreditInfo(uid),
installmentModel.getAdvertisement()
]).then((result) => {
return {
success: {
price: result[1].currCreditLimit,
installmentOnly: {
title: {
title: '分期专享',
more_url: helpers.appUrlFormat(req.originalUrl, 'go.instalmentlist', {
title: '分期专享'
})
},
goods: result[0]
},
advertisement: result[2],
url: helpers.appUrlFormat(req.originalUrl, 'go.instalmentlist', {
title: '分期专享'
})
}
};
});
} else if (status === '3') {
return {
error: true
};
} else if (status === '4') {
return {
cancel: {
url: jumpUrl
}
};
}
};
// 还款列表公共处理块
const _repaymentList = (req, res, opt, params) => {
params = _.assign({
... ... @@ -91,11 +40,14 @@ const _repaymentList = (req, res, opt, params) => {
const index = (req, res) => {
let uid = req.query.uid;
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment({
page: 1
})]).then((result) => {
Promise.all([
installmentModel.getStauts(uid),
installmentModel.getSearchIntallment({
page: 1
})
]).then((result) => {
// status:0 未申请 1审核中 2已开通 3 审核未通过
// openStatus:0 未申请 1审核中 2已开通 3 审核未通过
let openStatus = result[0];
let installmentOnly = {
title: {
... ... @@ -108,7 +60,7 @@ const index = (req, res) => {
};
if (openStatus === '0') {
return Promise.all([installmentModel.getResources('0876085ff46bed27f1a1eb6ee8b68987'), installmentModel.getNotices()]).then(data => {
return Promise.all([installmentModel.getResources('openN'), installmentModel.getNotices()]).then(data => {
_.forEach(data[0], (item) => {
if (item.singleOne) {
item.data[0].url = 'javascript:void(0)'; //eslint-disable-line
... ... @@ -126,7 +78,7 @@ const index = (req, res) => {
return Promise.all([
installmentModel.getQueryCreditInfo(uid),
installmentModel.getQueryAmtInfo(uid),
installmentModel.getResources('c233ad4ca91fef45ed7d0b26d9953e61'),
installmentModel.getResources('openY'),
installmentModel.getNotices()
]).then((data) => {
let params = _.assign({
... ... @@ -198,17 +150,61 @@ const review = (req, res) => {
page: 'installment',
title: '有货分期'
};
let templete = 'installment/open-result';
let jumpUrl = helpers.appUrlFormat('/product/new', 'go.new');
let params = {};
if (openStatus !== '2') {
res.render('installment/open-result', _.assign(data, _reviewStatus(res, req, uid, openStatus)));
} else {
_reviewStatus(res, req, uid, openStatus).then((params) => {
res.render('installment/open-result', _.assign(data, params));
if (openStatus === '2') {
Promise.all([
installmentModel.getSearchIntallment({
page: 1
}),
installmentModel.getQueryCreditInfo(uid),
installmentModel.getResources('advertisement')
]).then((result) => {
res.render(templete, _.assign({
success: {
price: result[1].currCreditLimit,
installmentOnly: {
title: {
title: '分期专享',
more_url: helpers.appUrlFormat(req.originalUrl, 'go.instalmentlist', {
title: '分期专享'
})
},
goods: result[0]
},
advertisement: result[2][0].data[0],
url: helpers.appUrlFormat(req.originalUrl, 'go.instalmentlist', {
title: '分期专享'
})
}
}, data));
}).catch(() => {
_serverCrash(res, {
url: req.originalUrl
});
});
} else {
if (openStatus === '1') {
params = {
review: {
url: jumpUrl
}
};
} else if (openStatus === '3') {
params = {
error: true
};
} else if (openStatus === '4') {
params = {
cancel: {
url: jumpUrl
}
};
}
res.render(templete, _.assign(params, data));
}
};
... ...
... ... @@ -13,6 +13,11 @@ const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const logger = global.yoho.logger;
const API_TIMEOUT = 10000;
const codeContent = {
openN: '0876085ff46bed27f1a1eb6ee8b68987',
openY: 'c233ad4ca91fef45ed7d0b26d9953e61',
advertisement: 'f3fe0793a7d59479542a14b15359c47d'
};
// 处理还款列表数据
const _processAmtList = (listData, queryDays) => {
... ... @@ -145,21 +150,8 @@ const _processBankCards = (list) => {
list = list || [];
_.forEach(list, (data) => {
// let newCardNo = data.cardNo.split('');
// let cardNo = newCardNo.length;
// data.cardNo = '';
//
//
// for (let i = 1; i < cardNo; i++) {
// if (i < (cardNo - 4)) {
// data.cardNo += '*';
// } else {
// data.cardNo += newCardNo[i - 1];
// }
// }
data.url = '/home/installment/card-detail?cardIdNo=' + data.cardIdNo;
// 正则替换卡号,保留后4位
data.cardNo = data.cardNo.replace(/(\d+)(\d{4})$/, function(a, b, c) {
return b.replace(/\d/g, '*') + c;
... ... @@ -186,7 +178,7 @@ const _processCardDetail = (list) => {
*/
const getResources = (code) => {
return serviceAPI.get('/operations/api/v5/resource/get', {
content_code: code,
content_code: codeContent[code],
platform: 'iphone'
}, {
cache: true
... ... @@ -509,24 +501,6 @@ const getCardDetail = (uid, cardIdNo) => {
timeout: API_TIMEOUT,
cache: true
}).then((result) => {
// result = {
// alg: 'SALT_MD5',
// code: 200,
// data: [
// {
// id: '1',
// userName: '*三',
// cardNo: '0000',
// bankCode: 'ABC',
// bankName: '农业银行',
// mobile: '18021200000',
// cardIdNo: 'BK201610204789114',
// masterType: '1'
// }
// ],
// md5: '6d729d4b35f10fc73531210bd7ecff91',
// message: 'success'
// };
if (result && result.code === 200) {
return _processCardDetail(result.data);
} else {
... ... @@ -574,29 +548,6 @@ const getNotices = () => {
});
};
// 开通成功后的广告
const getAdvertisement = () => {
return api.get('', {
method: ''
}, {
cache: true
}).then(res => {
res = {
code: 200,
data: {
url: '',
img: '//img13.static.yhbimg.com/article/2016/10/27/12/028982cc003a447c4cf59342efd4468bea.jpg?imageView2/2/w/266/h/266/q/90'
}
};
if (res && res.code === 200) {
return res.data;
} else {
logger.error('getAdvertisement return code is not 200');
return {};
}
});
};
module.exports = {
getStauts,
getQueryCreditInfo,
... ... @@ -617,8 +568,7 @@ module.exports = {
getCardDetail,
delBankCard,
setMasterCard,
getNotices,
getAdvertisement
getNotices
};
... ...
... ... @@ -22,7 +22,7 @@
<div class="mask-bg"></div>
<a class="advertisement-box" href="{{url}}">
<i class="close-box"></i>
<img src="{{img}}"/>
<div style="background-image: url('{{image src 540 550}}');" class="advertisement-img"></div>
</a>
</div>
{{/ advertisement}}
... ...
... ... @@ -21,15 +21,15 @@ module.exports = {
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/'
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://192.168.102.205:8080/gateway/',
service: 'http://192.168.102.205:8080/gateway/',
search: 'http://192.168.102.216:8080/yohosearch/'
// favApi: 'http://192.168.102.31:8092/brower',
// api: 'http://192.168.102.205:8080/gateway/',
// service: 'http://192.168.102.205:8080/gateway/',
// search: 'http://192.168.102.216:8080/yohosearch/'
// api: 'http://api.yoho.yohoops.org/',
// service: 'http://service.yoho.yohoops.org/',
... ...
... ... @@ -294,12 +294,16 @@
margin: -275px 0 0 -270px;
overflow: hidden;
img {
.advertisement-img {
position: absolute;
width: 100%;
width: 540px;
height: 550px;
left: 50%;
top: 50%;
transform: translateY(-50%) translateX(-50%);
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
}
}
... ... @@ -452,7 +456,7 @@
display: none;
.banner-center {
margin-top: 30px;
margin: 30px auto;
height: 210px;
.banner-list {
... ...