Authored by Aiden Xu

开通有货分期

@@ -9,11 +9,14 @@ const headerModel = require('../../../doraemon/models/header'); @@ -9,11 +9,14 @@ const headerModel = require('../../../doraemon/models/header');
9 const installmentModel = require('../models/installment'); 9 const installmentModel = require('../models/installment');
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 const helpers = global.yoho.helpers; 11 const helpers = global.yoho.helpers;
  12 +
12 const index = (req, res) => { 13 const index = (req, res) => {
13 let query = req.query.query || ''; 14 let query = req.query.query || '';
14 let uid = req.user.uid || 3236556; 15 let uid = req.user.uid || 3236556;
15 16
16 - installmentModel.getStauts(uid).then((openStatus) => { 17 + Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
  18 + let openStatus = result[0];
  19 +
17 if (openStatus === 0) { 20 if (openStatus === 0) {
18 return { 21 return {
19 bannerTop: { 22 bannerTop: {
@@ -27,16 +30,24 @@ const index = (req, res) => { @@ -27,16 +30,24 @@ const index = (req, res) => {
27 notOpen: true, 30 notOpen: true,
28 installmentOnly: { 31 installmentOnly: {
29 title: '分期专享', 32 title: '分期专享',
30 - goods: [  
31 - {}  
32 - ] 33 + goods: result[1]
33 } 34 }
34 }; 35 };
35 } else if (openStatus === 2) { 36 } else if (openStatus === 2) {
36 if (query === 'usable') { 37 if (query === 'usable') {
37 return installmentModel.getQueryCreditInfo(uid).then((data) => { 38 return installmentModel.getQueryCreditInfo(uid).then((data) => {
  39 + if (data.status === 2) {
  40 + data.replayStatus = '逾期';
  41 + } else if (data.status === 3) {
  42 + data.replayStatus = '不可用';
  43 + }
  44 +
38 return _.assign({ 45 return _.assign({
39 - isUnable: true 46 + isUnable: true,
  47 + installmentOnly: {
  48 + title: '分期专享',
  49 + goods: result[1]
  50 + }
40 }, data); 51 }, data);
41 }); 52 });
42 } else { 53 } else {
@@ -46,52 +57,54 @@ const index = (req, res) => { @@ -46,52 +57,54 @@ const index = (req, res) => {
46 }, data); 57 }, data);
47 }); 58 });
48 } 59 }
49 -  
50 } 60 }
51 }).then((result) => { 61 }).then((result) => {
  62 + result.pageHeader = _.assign({
  63 + installmentPage: true
  64 + }, headerModel.setNav({
  65 + navTitle: '有货分期',
  66 + navBtn: false
  67 + }));
  68 +
52 res.render('installment/open-index', _.assign({ 69 res.render('installment/open-index', _.assign({
53 module: 'home', 70 module: 'home',
54 page: 'installment', 71 page: 'installment',
55 - title: '有货分期',  
56 - pageHeader: headerModel.setNav({  
57 - navTitle: '有货分期',  
58 - navBtn: false  
59 - }) 72 + title: '有货分期'
60 }, result)); 73 }, result));
61 }); 74 });
62 }; 75 };
63 76
64 const review = (req, res) => { 77 const review = (req, res) => {
65 let uid = req.user.uid || 20000032; 78 let uid = req.user.uid || 20000032;
66 - let params = {};  
67 79
68 installmentModel.getStauts(uid).then((status) => { 80 installmentModel.getStauts(uid).then((status) => {
69 if (status === 1) { 81 if (status === 1) {
70 - params = { 82 + return {
71 review: { 83 review: {
72 - url: helpers.urlFormat('/?go=1') 84 + url: helpers.urlFormat('//m.yohobuy.com/product/new')
73 } 85 }
74 }; 86 };
75 } else if (status === 2) { 87 } else if (status === 2) {
76 - params = { 88 + return installmentModel.getSearchIntallment().then((goods) => {
  89 + return {
77 success: { 90 success: {
78 price: '5000', 91 price: '5000',
79 installmentOnly: { 92 installmentOnly: {
80 title: '分期专享', 93 title: '分期专享',
81 - goods: [  
82 - {}  
83 - ] 94 + goods: goods
84 } 95 }
85 } 96 }
86 }; 97 };
87 - } else {  
88 - params = { 98 + });
  99 +
  100 + } else if (status === 3) {
  101 + return {
89 error: { 102 error: {
90 - url: helpers.urlFormat('/?go=1') 103 + url: helpers.urlFormat('//m.yohobuy.com/product/new')
91 } 104 }
92 }; 105 };
93 } 106 }
94 - 107 + }).then((params) => {
95 res.render('installment/open-result', _.assign({ 108 res.render('installment/open-result', _.assign({
96 module: 'home', 109 module: 'home',
97 page: 'installment', 110 page: 'installment',
@@ -47,7 +47,7 @@ const getQueryCreditInfo = (uid) => { @@ -47,7 +47,7 @@ const getQueryCreditInfo = (uid) => {
47 data: { 47 data: {
48 initCredit: '8000.00', 48 initCredit: '8000.00',
49 currCredit: '5000.00', 49 currCredit: '5000.00',
50 - status: 1 50 + status: 2
51 }, 51 },
52 md5: 'c1d725306fb09dcbf504776d276521cb', 52 md5: 'c1d725306fb09dcbf504776d276521cb',
53 message: 'ok' 53 message: 'ok'
@@ -89,42 +89,27 @@ const getQueryAmtInfo = (uid) => { @@ -89,42 +89,27 @@ const getQueryAmtInfo = (uid) => {
89 }); 89 });
90 }; 90 };
91 91
92 -/**  
93 - * 获取短信验证码  
94 - *  
95 - * @param uid 用户ID  
96 - * @param mobile 手机号码  
97 - */  
98 -const sendVerifyCode = (uid, mobile) => { 92 +// 分期专享推荐商品
  93 +const getSearchIntallment = () => {
99 return api.get('', { 94 return api.get('', {
100 - method: 'user.instalment.getSnsCheckCode'  
101 - }, {  
102 - uid,  
103 - mobile 95 + method: 'app.search.instalment',
  96 + limit: '50',
  97 + cache: true
  98 + }).then((result) => {
  99 + if (result && result.code === 200) {
  100 + return result.data;
  101 + } else {
  102 + logger.error('get instalment promote goods return is not 200');
  103 + return '';
  104 + }
104 }); 105 });
105 }; 106 };
106 107
107 -/**  
108 - * 开通服务  
109 - *  
110 - * @param uid 用户id  
111 - * @param userName 姓名  
112 - * @param identityCardNo 身份证号码  
113 - * @param cardNo 银行卡号码  
114 - * @param mobile 手机号码  
115 - * @param snsCheckCode 验证码  
116 - * @returns {*}  
117 - */  
118 -const activateService = (params) => {  
119 - return api.get('', {  
120 - method: 'user.instalment.activate'  
121 - }, params);  
122 -};  
123 -  
124 module.exports = { 108 module.exports = {
125 getStauts, 109 getStauts,
126 getQueryCreditInfo, 110 getQueryCreditInfo,
127 getQueryAmtInfo, 111 getQueryAmtInfo,
  112 + getSearchIntallment
128 sendVerifyCode, 113 sendVerifyCode,
129 activateService 114 activateService
130 }; 115 };
1 -<div class="installment-page"> 1 +<div class="installment-page installment-bg">
2 {{#if notOpen}} 2 {{#if notOpen}}
3 {{# bannerTop}} 3 {{# bannerTop}}
4 {{> resources/banner-top}} 4 {{> resources/banner-top}}
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <div class="repay-area detail-bg"> 34 <div class="repay-area detail-bg">
35 <p class="detail-txt1">近7日代还款</p> 35 <p class="detail-txt1">近7日代还款</p>
36 <p class="detail-txt1">¥<span class="detail-txt2">{{round dayAmt}}</span></p> 36 <p class="detail-txt1">¥<span class="detail-txt2">{{round dayAmt}}</span></p>
37 - <P class="detail-txt3">您有¥{{round dayAmt}}已逾期3天,点击<a href="">查看详情</a></P> 37 + <p class="detail-txt3">您有¥{{round dayAmt}}已逾期3天,点击<a href="">查看详情</a></p>
38 <a href="" class="see-btn">明细</a> 38 <a href="" class="see-btn">明细</a>
39 </div> 39 </div>
40 <ul class="group-list"> 40 <ul class="group-list">
@@ -16,6 +16,9 @@ @@ -16,6 +16,9 @@
16 {{#currencyDetailPage}} 16 {{#currencyDetailPage}}
17 <a href="/home/helpDetail?code=20111130-152530&caption=如何使用YOHO币支付" class="iconfont nav-home">&#xe639;</a> 17 <a href="/home/helpDetail?code=20111130-152530&caption=如何使用YOHO币支付" class="iconfont nav-home">&#xe639;</a>
18 {{/currencyDetailPage}} 18 {{/currencyDetailPage}}
  19 + {{#installmentPage}}
  20 + <a href="/home/helpDetail?code=20151230-102233&caption=有货分期" class="iconfont nav-home">&#xe639;</a>
  21 + {{/installmentPage}}
19 {{#navPhone}} 22 {{#navPhone}}
20 <a href="{{.}}" class="iconfont nav-home">&#xe641;</a> 23 <a href="{{.}}" class="iconfont nav-home">&#xe641;</a>
21 {{/navPhone}} 24 {{/navPhone}}
@@ -73,3 +73,9 @@ if ($installmentOnly.length > 0) { @@ -73,3 +73,9 @@ if ($installmentOnly.length > 0) {
73 73
74 search(); 74 search();
75 } 75 }
  76 +
  77 +if ($('.installment-bg').length > 0) {
  78 + $('body').css({
  79 + background: '#efefef'
  80 + });
  81 +}