Merge remote-tracking branch 'origin/feature/installment' into feature/installment
Showing
4 changed files
with
193 additions
and
102 deletions
@@ -10,11 +10,43 @@ const installmentModel = require('../models/installment'); | @@ -10,11 +10,43 @@ 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 | ||
13 | +// 判断是否已经获取到了开通的状态值 | ||
14 | +const _reviewStatus = (status) => { | ||
15 | + if (status === 1) { | ||
16 | + return { | ||
17 | + review: { | ||
18 | + url: helpers.urlFormat('/product/new') | ||
19 | + } | ||
20 | + }; | ||
21 | + } else if (status === 2) { | ||
22 | + return installmentModel.getSearchIntallment().then((goods) => { | ||
23 | + return { | ||
24 | + success: { | ||
25 | + price: '5000', | ||
26 | + installmentOnly: { | ||
27 | + title: '分期专享', | ||
28 | + goods: goods | ||
29 | + } | ||
30 | + } | ||
31 | + }; | ||
32 | + }); | ||
33 | + | ||
34 | + } else if (status === 3) { | ||
35 | + return { | ||
36 | + error: { | ||
37 | + url: helpers.urlFormat('/product/new') | ||
38 | + } | ||
39 | + }; | ||
40 | + } | ||
41 | +}; | ||
42 | + | ||
13 | const index = (req, res) => { | 43 | const index = (req, res) => { |
14 | let query = req.query.query || ''; | 44 | let query = req.query.query || ''; |
15 | let uid = req.user.uid || 3236556; | 45 | let uid = req.user.uid || 3236556; |
16 | 46 | ||
17 | Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => { | 47 | Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => { |
48 | + | ||
49 | + // status:0 未申请 1审核中 2已开通 3 审核未通过 | ||
18 | let openStatus = result[0]; | 50 | let openStatus = result[0]; |
19 | 51 | ||
20 | if (openStatus === 0) { | 52 | if (openStatus === 0) { |
@@ -57,6 +89,10 @@ const index = (req, res) => { | @@ -57,6 +89,10 @@ const index = (req, res) => { | ||
57 | }, data); | 89 | }, data); |
58 | }); | 90 | }); |
59 | } | 91 | } |
92 | + } else if (openStatus === 1) { | ||
93 | + res.redirect('/home/installment/review?status=' + openStatus); | ||
94 | + } else { | ||
95 | + res.redirect('/home/installment/review?status=' + openStatus); | ||
60 | } | 96 | } |
61 | }).then((result) => { | 97 | }).then((result) => { |
62 | result.pageHeader = _.assign({ | 98 | result.pageHeader = _.assign({ |
@@ -75,46 +111,27 @@ const index = (req, res) => { | @@ -75,46 +111,27 @@ const index = (req, res) => { | ||
75 | }; | 111 | }; |
76 | 112 | ||
77 | const review = (req, res) => { | 113 | const review = (req, res) => { |
114 | + let openStatus = req.query.status || false; | ||
78 | let uid = req.user.uid || 20000032; | 115 | let uid = req.user.uid || 20000032; |
116 | + let data = { | ||
117 | + module: 'home', | ||
118 | + page: 'installment', | ||
119 | + title: '有货分期', | ||
120 | + pageHeader: headerModel.setNav({ | ||
121 | + navTitle: '有货分期', | ||
122 | + navBtn: false | ||
123 | + }) | ||
124 | + }; | ||
79 | 125 | ||
80 | - installmentModel.getStauts(uid).then((status) => { | ||
81 | - if (status === 1) { | ||
82 | - return { | ||
83 | - review: { | ||
84 | - url: helpers.urlFormat('//m.yohobuy.com/product/new') | ||
85 | - } | ||
86 | - }; | ||
87 | - } else if (status === 2) { | ||
88 | - return installmentModel.getSearchIntallment().then((goods) => { | ||
89 | - return { | ||
90 | - success: { | ||
91 | - price: '5000', | ||
92 | - installmentOnly: { | ||
93 | - title: '分期专享', | ||
94 | - goods: goods | ||
95 | - } | ||
96 | - } | ||
97 | - }; | ||
98 | - }); | ||
99 | - | ||
100 | - } else if (status === 3) { | ||
101 | - return { | ||
102 | - error: { | ||
103 | - url: helpers.urlFormat('//m.yohobuy.com/product/new') | ||
104 | - } | ||
105 | - }; | ||
106 | - } | ||
107 | - }).then((params) => { | ||
108 | - res.render('installment/open-result', _.assign({ | ||
109 | - module: 'home', | ||
110 | - page: 'installment', | ||
111 | - title: '有货分期', | ||
112 | - pageHeader: headerModel.setNav({ | ||
113 | - navTitle: '有货分期', | ||
114 | - navBtn: false | ||
115 | - }) | ||
116 | - }, params)); | ||
117 | - }); | 126 | + if (openStatus) { |
127 | + res.render('installment/open-result', _.assign(data, _reviewStatus(+openStatus))); | ||
128 | + } else { | ||
129 | + installmentModel.getStauts(uid).then((status) => { | ||
130 | + return _reviewStatus(status); | ||
131 | + }).then((params) => { | ||
132 | + res.render('installment/open-result', _.assign(data, params)); | ||
133 | + }); | ||
134 | + } | ||
118 | }; | 135 | }; |
119 | 136 | ||
120 | 137 |
@@ -4,7 +4,8 @@ | @@ -4,7 +4,8 @@ | ||
4 | * @date: 2016/08/01 | 4 | * @date: 2016/08/01 |
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | - | 7 | +const utils = '../../../utils'; |
8 | +const productProcess = require(`${utils}/product-process`); | ||
8 | const api = global.yoho.API; | 9 | const api = global.yoho.API; |
9 | const logger = global.yoho.logger; | 10 | const logger = global.yoho.logger; |
10 | 11 | ||
@@ -21,7 +22,7 @@ const getStauts = (uid) => { | @@ -21,7 +22,7 @@ const getStauts = (uid) => { | ||
21 | alg: 'SALT_MD5', | 22 | alg: 'SALT_MD5', |
22 | code: 200, | 23 | code: 200, |
23 | data: { | 24 | data: { |
24 | - status: 2 | 25 | + status: 0 |
25 | }, | 26 | }, |
26 | md5: '6d729d4b35f10fc73531210bd7ecff91', | 27 | md5: '6d729d4b35f10fc73531210bd7ecff91', |
27 | message: 'success' | 28 | message: 'success' |
@@ -91,13 +92,133 @@ const getQueryAmtInfo = (uid) => { | @@ -91,13 +92,133 @@ const getQueryAmtInfo = (uid) => { | ||
91 | 92 | ||
92 | // 分期专享推荐商品 | 93 | // 分期专享推荐商品 |
93 | const getSearchIntallment = () => { | 94 | const getSearchIntallment = () => { |
94 | - return api.get('', { | 95 | + return api.post('', { |
95 | method: 'app.search.instalment', | 96 | method: 'app.search.instalment', |
96 | limit: '50', | 97 | limit: '50', |
98 | + order: 's_t_desc' | ||
99 | + }, { | ||
97 | cache: true | 100 | cache: true |
98 | }).then((result) => { | 101 | }).then((result) => { |
102 | + result = { | ||
103 | + alg: 'SALT_MD5', | ||
104 | + code: 200, | ||
105 | + data: { | ||
106 | + product_list: [ | ||
107 | + { | ||
108 | + brand_domain: '5cm', | ||
109 | + brand_id: 4, | ||
110 | + brand_name: '5CM', | ||
111 | + cn_alphabet: '5CMPeiShi5CXTIT0600S66', | ||
112 | + default_images: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
113 | + edit_time: 1456119592, | ||
114 | + gender: '1', | ||
115 | + goods_list: [ | ||
116 | + { | ||
117 | + color_code: '333333', | ||
118 | + color_id: '2', | ||
119 | + color_name: '黑色', | ||
120 | + color_value: '', | ||
121 | + cover_1: '', | ||
122 | + cover_2: '', | ||
123 | + goods_id: '476147', | ||
124 | + images_url: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
125 | + is_default: 'N', | ||
126 | + product_skc: '346699', | ||
127 | + status: '1' | ||
128 | + } | ||
129 | + ], | ||
130 | + is_advance: 'N', | ||
131 | + is_discount: 'N', | ||
132 | + is_limited: 'N', | ||
133 | + is_new: 'Y', | ||
134 | + is_outlets: 2, | ||
135 | + is_promotion: 104, | ||
136 | + is_soon_sold_out: 'N', | ||
137 | + is_special: 'N', | ||
138 | + market_price: 359, | ||
139 | + max_sort_id: 8, | ||
140 | + middle_sort_id: 66, | ||
141 | + product_id: 373507, | ||
142 | + product_name: '5CM 字母印花领带', | ||
143 | + product_skn: 51206745, | ||
144 | + sales_num: 0, | ||
145 | + sales_phrase: '春潮新势力', | ||
146 | + sales_price: 359, | ||
147 | + shelve_time: 1457140500, | ||
148 | + small_sort_id: 77, | ||
149 | + status: 1, | ||
150 | + stock_number: 25, | ||
151 | + storage_num: 25, | ||
152 | + tags: [ | ||
153 | + 'is_new' | ||
154 | + ], | ||
155 | + vip1_price: 341.05, | ||
156 | + vip2_price: 323.1, | ||
157 | + vip3_price: 315.92, | ||
158 | + vip_discount_type: 1, | ||
159 | + vip_price: 0 | ||
160 | + }, { | ||
161 | + brand_domain: '5cm', | ||
162 | + brand_id: 4, | ||
163 | + brand_name: '5CM', | ||
164 | + cn_alphabet: '5CMPeiShi5CXTIT0603S66', | ||
165 | + default_images: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
166 | + edit_time: 1456119581, | ||
167 | + gender: '1', | ||
168 | + goods_list: [ | ||
169 | + { | ||
170 | + color_code: '333333', | ||
171 | + color_id: '2', | ||
172 | + color_name: '黑色', | ||
173 | + color_value: '', | ||
174 | + cover_1: '', | ||
175 | + cover_2: '', | ||
176 | + goods_id: '476153', | ||
177 | + images_url: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
178 | + is_default: 'N', | ||
179 | + product_skc: '346702', | ||
180 | + status: '1' | ||
181 | + } | ||
182 | + ], | ||
183 | + is_advance: 'N', | ||
184 | + is_discount: 'N', | ||
185 | + is_limited: 'N', | ||
186 | + is_new: 'Y', | ||
187 | + is_outlets: 2, | ||
188 | + is_promotion: 104, | ||
189 | + is_soon_sold_out: 'N', | ||
190 | + is_special: 'N', | ||
191 | + market_price: 359, | ||
192 | + max_sort_id: 8, | ||
193 | + middle_sort_id: 66, | ||
194 | + product_id: 373513, | ||
195 | + product_name: '5CM 字母印花领结', | ||
196 | + product_skn: 51206748, | ||
197 | + sales_num: 0, | ||
198 | + sales_phrase: '春潮新势力', | ||
199 | + sales_price: 359, | ||
200 | + shelve_time: 1457140500, | ||
201 | + small_sort_id: 77, | ||
202 | + status: 1, | ||
203 | + stock_number: 19, | ||
204 | + storage_num: 19, | ||
205 | + tags: [ | ||
206 | + 'is_new' | ||
207 | + ], | ||
208 | + vip1_price: 341.05, | ||
209 | + vip2_price: 323.1, | ||
210 | + vip3_price: 315.92, | ||
211 | + vip_discount_type: 1, | ||
212 | + vip_price: 0 | ||
213 | + } | ||
214 | + ], | ||
215 | + rec_id: '00f185af-936a-4053-97f8-1c802cb91e8b' | ||
216 | + }, | ||
217 | + md5: 'ace93d0f598db0bebec30234381c0cbf', | ||
218 | + message: 'Product List.' | ||
219 | + }; | ||
99 | if (result && result.code === 200) { | 220 | if (result && result.code === 200) { |
100 | - return result.data; | 221 | + return productProcess.processProductList(result.data.product_list); |
101 | } else { | 222 | } else { |
102 | logger.error('get instalment promote goods return is not 200'); | 223 | logger.error('get instalment promote goods return is not 200'); |
103 | return ''; | 224 | return ''; |
1 | var $ = require('yoho-jquery'), | 1 | var $ = require('yoho-jquery'), |
2 | ellipsis = require('yoho-mlellipsis'), | 2 | ellipsis = require('yoho-mlellipsis'), |
3 | - tip = require('../plugin/tip'), | ||
4 | - loading = require('../plugin/loading'); | 3 | + lazyLoad = require('yoho-jquery-lazyload'); |
5 | 4 | ||
6 | -var winH = $(window).height(), | ||
7 | - $installmentOnly = $('.installment-only'), | ||
8 | - searching = false, | ||
9 | - page = 0; | 5 | +var $installmentOnly = $('.installment-only'); |
10 | 6 | ||
7 | +var $this, $title; | ||
11 | 8 | ||
9 | +lazyLoad($('img.lazy')); | ||
12 | ellipsis.init(); | 10 | ellipsis.init(); |
13 | 11 | ||
14 | -function search() { | ||
15 | - if (searching) { | ||
16 | - return; | ||
17 | - } | ||
18 | - searching = true; | 12 | +$('.good-detail-text .name').each(function() { |
13 | + $this = $(this); | ||
14 | + $title = $this.find('a'); | ||
19 | 15 | ||
20 | - loading.showLoadingMask(); | ||
21 | - | ||
22 | - $.ajax({ | ||
23 | - type: 'GET', | ||
24 | - url: '/product/recom/maylike?gender=1,3', | ||
25 | - data: { | ||
26 | - page: page + 1 | ||
27 | - }, | ||
28 | - success: function(data) { | ||
29 | - | ||
30 | - if (data === '') { | ||
31 | - loading.hideLoadingMask(); | ||
32 | - } else { | ||
33 | - searching = false; | ||
34 | - $('#goods-list').append(data); | ||
35 | - | ||
36 | - loading.hideLoadingMask(); | ||
37 | - page++; | ||
38 | - | ||
39 | - $('.good-detail-text .name').each(function() { | ||
40 | - var $this = $(this), | ||
41 | - $title = $this.find('a'); | ||
42 | - | ||
43 | - $title[0].mlellipsis(2); | ||
44 | - }); | ||
45 | - } | ||
46 | - }, | ||
47 | - error: function() { | ||
48 | - tip.show('网络断开连接了~'); | ||
49 | - searching = false; | ||
50 | - loading.hideLoadingMask(); | ||
51 | - } | ||
52 | - }); | ||
53 | -} | ||
54 | - | ||
55 | -function scrollHandler() { | ||
56 | - if ($(window).scrollTop() + winH >= $(document).height() - 200) { | ||
57 | - search(); | ||
58 | - } | ||
59 | -} | ||
60 | - | ||
61 | -// srcoll to load more | ||
62 | -$(window).scroll(function() { | ||
63 | - if ($installmentOnly.length > 0) { | ||
64 | - window.requestAnimationFrame(scrollHandler); | ||
65 | - } | 16 | + $title[0].mlellipsis(2); |
66 | }); | 17 | }); |
67 | 18 | ||
68 | - | ||
69 | if ($installmentOnly.length > 0) { | 19 | if ($installmentOnly.length > 0) { |
70 | $('.installment-page').css({ | 20 | $('.installment-page').css({ |
71 | background: '#efefef' | 21 | background: '#efefef' |
72 | }); | 22 | }); |
73 | - | ||
74 | - search(); | ||
75 | } | 23 | } |
76 | 24 | ||
77 | if ($('.installment-bg').length > 0) { | 25 | if ($('.installment-bg').length > 0) { |
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | height: auto; | 5 | height: auto; |
6 | overflow: hidden; | 6 | overflow: hidden; |
7 | padding-bottom: 70px; | 7 | padding-bottom: 70px; |
8 | + border-bottom: 1px solid #dedee0; | ||
8 | } | 9 | } |
9 | 10 | ||
10 | .open-info { | 11 | .open-info { |
@@ -67,6 +68,10 @@ | @@ -67,6 +68,10 @@ | ||
67 | font-size: 16PX; | 68 | font-size: 16PX; |
68 | border-bottom: 1px solid #dedee0; | 69 | border-bottom: 1px solid #dedee0; |
69 | } | 70 | } |
71 | + | ||
72 | + #goods-list { | ||
73 | + margin: 15px 0 0 15px; | ||
74 | + } | ||
70 | } | 75 | } |
71 | 76 | ||
72 | .review-icon { | 77 | .review-icon { |
-
Please register or login to post a comment