Showing
20 changed files
with
302 additions
and
241 deletions
@@ -21,7 +21,7 @@ const channels = { | @@ -21,7 +21,7 @@ const channels = { | ||
21 | * [编辑页面] | 21 | * [编辑页面] |
22 | */ | 22 | */ |
23 | const _editor = (req, res, next) => { | 23 | const _editor = (req, res, next) => { |
24 | - | 24 | + |
25 | let uid = req.user.uid, | 25 | let uid = req.user.uid, |
26 | udid = req.sessionID, | 26 | udid = req.sessionID, |
27 | id = req.query.id || 0, | 27 | id = req.query.id || 0, |
@@ -19,13 +19,13 @@ const channels = { | @@ -19,13 +19,13 @@ const channels = { | ||
19 | }; | 19 | }; |
20 | 20 | ||
21 | const _index = (req, res, next) => { | 21 | const _index = (req, res, next) => { |
22 | - let id = req.query.id, | 22 | + let id = req.query.id, |
23 | gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1, | 23 | gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1, |
24 | - isApp = req.query.app_version || req.query.appVersion || false, //标识是不是APP访问的 | 24 | + isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的 |
25 | parameter = {}, | 25 | parameter = {}, |
26 | title = '逛', | 26 | title = '逛', |
27 | userAgent = req.get('User-Agent'), | 27 | userAgent = req.get('User-Agent'), |
28 | - isWeixin = userAgent.includes('MicroMessenger'); //标识是否是微信访问 | 28 | + isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问 |
29 | 29 | ||
30 | // 判断参数是否有效, 无效会跳转到错误页面 | 30 | // 判断参数是否有效, 无效会跳转到错误页面 |
31 | if (!stringProcess.isNumeric(id)) { | 31 | if (!stringProcess.isNumeric(id)) { |
@@ -33,13 +33,6 @@ const _index = (req, res, next) => { | @@ -33,13 +33,6 @@ const _index = (req, res, next) => { | ||
33 | return; | 33 | return; |
34 | } | 34 | } |
35 | 35 | ||
36 | - let data = { | ||
37 | - guangDetail: true,// 模板中使用JS的标识 | ||
38 | - guang: { | ||
39 | - id: id | ||
40 | - } | ||
41 | - } | ||
42 | - | ||
43 | // WAP上设置头部导航 | 36 | // WAP上设置头部导航 |
44 | if (!isApp && !isWeixin) { | 37 | if (!isApp && !isWeixin) { |
45 | parameter = { | 38 | parameter = { |
@@ -52,25 +45,30 @@ const _index = (req, res, next) => { | @@ -52,25 +45,30 @@ const _index = (req, res, next) => { | ||
52 | 45 | ||
53 | // 获取详情内容信息, 异常则跳到错误页面 | 46 | // 获取详情内容信息, 异常则跳到错误页面 |
54 | return infoModel.package(id, isApp).then(detail => { | 47 | return infoModel.package(id, isApp).then(detail => { |
55 | - let data = {}; | 48 | + let data = { |
49 | + guang: {} | ||
50 | + }; | ||
56 | 51 | ||
57 | if (detail.code !== 400) { | 52 | if (detail.code !== 400) { |
58 | if (!detail.getArticle) { | 53 | if (!detail.getArticle) { |
59 | - //TODO 跳转到逛首页 | 54 | + // TODO 跳转到逛首页 |
60 | return; | 55 | return; |
61 | } | 56 | } |
62 | 57 | ||
63 | // 作者信息数据 | 58 | // 作者信息数据 |
64 | if (detail.getAuthor.name) { | 59 | if (detail.getAuthor.name) { |
65 | - data.author = { | ||
66 | - avatar: detail.getAuthor.avatar.replace('http://', '//'), | ||
67 | - name: detail.getAuthor.name, | ||
68 | - intro: detail.getAuthor.author_desc | ||
69 | - } | ||
70 | - //guang双头部的问题 20160601 | ||
71 | - data.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${detail.getAuthor.author_id}"},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${helpers.urlFormat('/author/index', {}, 'guang')}"}}`) | 60 | + data.guang.author = { |
61 | + avatar: detail.getAuthor.avatar.replace('http://', '//'), | ||
62 | + name: detail.getAuthor.name, | ||
63 | + intro: detail.getAuthor.author_desc | ||
64 | + }; | ||
65 | + | ||
66 | + // guang双头部的问题 20160601 | ||
67 | + data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${detail.getAuthor.author_id}"},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${helpers.urlFormat('/author/index', {}, 'guang')}"}}`); | ||
72 | } | 68 | } |
73 | - data.detail = { | 69 | + let guang = data.guang; |
70 | + | ||
71 | + guang.detail = { | ||
74 | title: detail.getArticle.article_title, | 72 | title: detail.getArticle.article_title, |
75 | publishTime: detail.getArticle.publishTime, | 73 | publishTime: detail.getArticle.publishTime, |
76 | pageView: detail.getArticle.pageViews, | 74 | pageView: detail.getArticle.pageViews, |
@@ -79,41 +77,42 @@ const _index = (req, res, next) => { | @@ -79,41 +77,42 @@ const _index = (req, res, next) => { | ||
79 | let callArticleContent = (i, len, resolve) => { | 77 | let callArticleContent = (i, len, resolve) => { |
80 | if (i < len) { | 78 | if (i < len) { |
81 | let art = detail.getArticleContent[i]; | 79 | let art = detail.getArticleContent[i]; |
82 | - let build = {}, | ||
83 | - good = {}, | ||
84 | - skns = {}, | ||
85 | - product = {}; | 80 | + let build = {}; |
81 | + | ||
86 | // 文字 | 82 | // 文字 |
87 | if (art.text && art.text.data && art.text.data.text) { | 83 | if (art.text && art.text.data && art.text.data.text) { |
88 | build.text = art.text.data.text; | 84 | build.text = art.text.data.text; |
89 | - data.detail.content.push(build); | 85 | + guang.detail.content.push(build); |
90 | callArticleContent(++i, len, resolve); | 86 | callArticleContent(++i, len, resolve); |
91 | 87 | ||
92 | } else if (art.singleImage) { // 单张图 | 88 | } else if (art.singleImage) { // 单张图 |
93 | build.bigImage = helpers.image(art.singleImage.data[0].src, 640, 640); | 89 | build.bigImage = helpers.image(art.singleImage.data[0].src, 640, 640); |
94 | - data.detail.content.push(build); | 90 | + guang.detail.content.push(build); |
95 | callArticleContent(++i, len, resolve); | 91 | callArticleContent(++i, len, resolve); |
96 | 92 | ||
97 | } else if (art.smallPic && art.smallPic.data) { | 93 | } else if (art.smallPic && art.smallPic.data) { |
98 | let imgs = art.smallPic.data; | 94 | let imgs = art.smallPic.data; |
99 | - build.smallImage = [{ | ||
100 | - src: helpers.image(imgs[0].src, 315, 420) | ||
101 | - }, { | ||
102 | - src: helpers.image(imgs[1].src, 315, 420) | ||
103 | - } | ||
104 | - ] | ||
105 | - data.detail.content.push(build); | 95 | + |
96 | + build.smallImage = [{ | ||
97 | + src: helpers.image(imgs[0].src, 315, 420) | ||
98 | + }, { | ||
99 | + src: helpers.image(imgs[1].src, 315, 420) | ||
100 | + } | ||
101 | + ]; | ||
102 | + guang.detail.content.push(build); | ||
106 | callArticleContent(++i, len, resolve); | 103 | callArticleContent(++i, len, resolve); |
107 | 104 | ||
108 | } else if (art.goods && art.goods.data) { // 相关推荐 | 105 | } else if (art.goods && art.goods.data) { // 相关推荐 |
109 | let reco = [], | 106 | let reco = [], |
110 | skns = [], | 107 | skns = [], |
111 | arr = []; | 108 | arr = []; |
109 | + | ||
112 | // 遍历取得SKN | 110 | // 遍历取得SKN |
113 | art.goods.data.forEach(goods => { | 111 | art.goods.data.forEach(goods => { |
114 | skns.push(goods.id); | 112 | skns.push(goods.id); |
115 | - arr[goods.id]=goods.src; | 113 | + arr[goods.id] = goods.src; |
116 | }); | 114 | }); |
115 | + | ||
117 | // callArticleContent(++i, len, resolve); | 116 | // callArticleContent(++i, len, resolve); |
118 | // return; | 117 | // return; |
119 | // 通过SKN获取商品信息 | 118 | // 通过SKN获取商品信息 |
@@ -121,22 +120,22 @@ const _index = (req, res, next) => { | @@ -121,22 +120,22 @@ const _index = (req, res, next) => { | ||
121 | // console.log(product) | 120 | // console.log(product) |
122 | if (product.data.product_list) { | 121 | if (product.data.product_list) { |
123 | let d = []; | 122 | let d = []; |
124 | - for (let i = 0; i < product.data.product_list.length; i++) { | ||
125 | - let goods = product.data.product_list[i]; | 123 | + |
124 | + for (let o = 0; o < product.data.product_list.length; o++) { | ||
125 | + let goods = product.data.product_list[o]; | ||
126 | + | ||
126 | // 最多显示4个 | 127 | // 最多显示4个 |
127 | - if (i > 3) { | 128 | + if (o > 3) { |
128 | break; | 129 | break; |
129 | } | 130 | } |
130 | d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender)); | 131 | d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender)); |
131 | } | 132 | } |
132 | - for (id in arr) { | ||
133 | - d.forEach(p => { | ||
134 | - if (id == p.id) { | ||
135 | - p.thumb = helpers.image(arr[id],235,314); | ||
136 | - reco.push(p); | ||
137 | - } | ||
138 | - }) | ||
139 | - } | 133 | + d.forEach(p => { |
134 | + if (arr[p.id]) { | ||
135 | + p.thumb = helpers.image(arr[p.id], 235, 314); | ||
136 | + reco.push(p); | ||
137 | + } | ||
138 | + }); | ||
140 | } | 139 | } |
141 | 140 | ||
142 | // 多个商品 | 141 | // 多个商品 |
@@ -144,15 +143,14 @@ const _index = (req, res, next) => { | @@ -144,15 +143,14 @@ const _index = (req, res, next) => { | ||
144 | build.relatedReco = reco; | 143 | build.relatedReco = reco; |
145 | } else if (product.data.product_list.length === 1) { // 单个商品 | 144 | } else if (product.data.product_list.length === 1) { // 单个商品 |
146 | build.relatedReco = reco[0]; | 145 | build.relatedReco = reco[0]; |
147 | - } | ||
148 | - data.detail.content.push(build); | 146 | + } |
147 | + guang.detail.content.push(build); | ||
149 | callArticleContent(++i, len, resolve); | 148 | callArticleContent(++i, len, resolve); |
150 | }); | 149 | }); |
151 | - } else if (art.goodsGroup && art.goodsGroup.data) {// 悬停浮动商品 | ||
152 | - callArticleContent(++i, len, resolve); | ||
153 | - return; | 150 | + } else if (art.goodsGroup && art.goodsGroup.data) { // 悬停浮动商品 |
154 | let callArtGoodGroup = (ii, len2) => { | 151 | let callArtGoodGroup = (ii, len2) => { |
155 | if (ii < len2) { | 152 | if (ii < len2) { |
153 | + let goods = art.goodsGroup.data[ii]; | ||
156 | let good = { | 154 | let good = { |
157 | thumb: helpers.image(goods.cover.cover, 235, 314), | 155 | thumb: helpers.image(goods.cover.cover, 235, 314), |
158 | type: guangProcess.getProductIcon(goods.cover.maxSortId), | 156 | type: guangProcess.getProductIcon(goods.cover.maxSortId), |
@@ -164,69 +162,71 @@ const _index = (req, res, next) => { | @@ -164,69 +162,71 @@ const _index = (req, res, next) => { | ||
164 | goods.list.forEach((mini) => { | 162 | goods.list.forEach((mini) => { |
165 | skns.push(mini.id); | 163 | skns.push(mini.id); |
166 | arr[mini.id] = mini.src; | 164 | arr[mini.id] = mini.src; |
167 | - }) | 165 | + }); |
166 | + | ||
168 | // 通过SKN获取商品信息 | 167 | // 通过SKN获取商品信息 |
169 | productDetailModel.productInfoBySkns(skns).then((product) => { | 168 | productDetailModel.productInfoBySkns(skns).then((product) => { |
170 | if (product.data.product_list) { | 169 | if (product.data.product_list) { |
171 | let g = []; | 170 | let g = []; |
172 | - product.data.product_list.forEach((goods) => { | ||
173 | - g.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, gender)); | 171 | + |
172 | + product.data.product_list.forEach(_ => { | ||
173 | + g.push(guangProcess.formatProduct(_, false, true, true, 235, 314, isApp, gender)); | ||
174 | + }); | ||
175 | + g.forEach(p => { | ||
176 | + if (arr[p.id]) { | ||
177 | + p.thumb = helpers.image(arr[p.id], 235, 314); | ||
178 | + good.goods.push(p); | ||
179 | + } | ||
174 | }); | 180 | }); |
175 | - for (id in arr) { | ||
176 | - g.forEach(p => { | ||
177 | - if (id == p.id) { | ||
178 | - p.thumb = helpers.image(arr[id],235,314); | ||
179 | - good.goods.push(p); | ||
180 | - } | ||
181 | - }) | ||
182 | - } | ||
183 | if (!build.collocation) { | 181 | if (!build.collocation) { |
184 | build.collocation = []; | 182 | build.collocation = []; |
185 | } | 183 | } |
186 | build.collocation.push(good); | 184 | build.collocation.push(good); |
187 | } | 185 | } |
188 | callArtGoodGroup(++ii, len2); | 186 | callArtGoodGroup(++ii, len2); |
189 | - }) | 187 | + }); |
190 | } else { | 188 | } else { |
191 | - data.detail.content.push(build); | 189 | + guang.detail.content.push(build); |
192 | callArticleContent(++i, len, resolve); | 190 | callArticleContent(++i, len, resolve); |
193 | } | 191 | } |
194 | - } | 192 | + }; |
193 | + | ||
195 | callArtGoodGroup(0, art.goodsGroup.data.length); | 194 | callArtGoodGroup(0, art.goodsGroup.data.length); |
196 | } else if (art.link) { // 更多商品链接 | 195 | } else if (art.link) { // 更多商品链接 |
197 | build.moreLink = art.link.data[0].url; | 196 | build.moreLink = art.link.data[0].url; |
198 | - data.detail.content.push(build); | 197 | + guang.detail.content.push(build); |
199 | callArticleContent(++i, len, resolve); | 198 | callArticleContent(++i, len, resolve); |
200 | } | 199 | } |
201 | } else { | 200 | } else { |
202 | resolve(); | 201 | resolve(); |
203 | } | 202 | } |
204 | - } | 203 | + }; |
204 | + | ||
205 | if (detail.getArticleContent) { | 205 | if (detail.getArticleContent) { |
206 | - return new Promise((resolve, reject) => { | 206 | + return new Promise((resolve) => { |
207 | callArticleContent(0, detail.getArticleContent.length, resolve); | 207 | callArticleContent(0, detail.getArticleContent.length, resolve); |
208 | }).then(() => { | 208 | }).then(() => { |
209 | // 相关品牌 | 209 | // 相关品牌 |
210 | if (detail.getBrand) { | 210 | if (detail.getBrand) { |
211 | - data.relatedBrand = detail.getBrand; | ||
212 | - data.relatedBrand.forEach(brand => { | 211 | + guang.relatedBrand = detail.getBrand; |
212 | + guang.relatedBrand.forEach(brand => { | ||
213 | brand.thumb = brand.thumb.replace('http://', '//'); | 213 | brand.thumb = brand.thumb.replace('http://', '//'); |
214 | - }) | 214 | + }); |
215 | } | 215 | } |
216 | 216 | ||
217 | // 相关标签 | 217 | // 相关标签 |
218 | if (detail.getArticle.tags) { | 218 | if (detail.getArticle.tags) { |
219 | detail.getArticle.tags.forEach(value => { | 219 | detail.getArticle.tags.forEach(value => { |
220 | if (!isApp) { | 220 | if (!isApp) { |
221 | - value.url = helpers.urlFormat('/tags/index', { | ||
222 | - query :value.name | 221 | + value.url = helpers.urlFormat('/tags/index', { |
222 | + query: value.name | ||
223 | }, 'guang'); | 223 | }, 'guang'); |
224 | } | 224 | } |
225 | - if (!data.relatedTag) { | ||
226 | - data.relatedTag = []; | 225 | + if (!guang.relatedTag) { |
226 | + guang.relatedTag = []; | ||
227 | } | 227 | } |
228 | - data.relatedTag.push(value); | ||
229 | - }) | 228 | + guang.relatedTag.push(value); |
229 | + }); | ||
230 | } | 230 | } |
231 | 231 | ||
232 | // 相关文章 | 232 | // 相关文章 |
@@ -238,24 +238,24 @@ const _index = (req, res, next) => { | @@ -238,24 +238,24 @@ const _index = (req, res, next) => { | ||
238 | }, 'guang'); | 238 | }, 'guang'); |
239 | } | 239 | } |
240 | value.thumb = helpers.image(value.thumb, 279, 175); | 240 | value.thumb = helpers.image(value.thumb, 279, 175); |
241 | - if (!data.relatedInfo) { | ||
242 | - data.relatedInfo = []; | 241 | + if (!guang.relatedInfo) { |
242 | + guang.relatedInfo = []; | ||
243 | } | 243 | } |
244 | - data.relatedInfo.push(value); | ||
245 | - }) | 244 | + guang.relatedInfo.push(value); |
245 | + }); | ||
246 | } | 246 | } |
247 | 247 | ||
248 | // 分享参数 | 248 | // 分享参数 |
249 | if (detail.getArticle.cover_image) { | 249 | if (detail.getArticle.cover_image) { |
250 | - data.shareLink = helpers.urlFormat('/info/index', { | 250 | + guang.shareLink = helpers.urlFormat('/info/index', { |
251 | id: id | 251 | id: id |
252 | }, 'guang'); | 252 | }, 'guang'); |
253 | - data.shareTitle = detail.getArticle.article_title; | ||
254 | - data.shareDesc = detail.getArticle.article_summary; | ||
255 | - if (detail.getArticle.cover_image_type == 1) { | ||
256 | - data.shareImg = helpers.image(detail.getArticle.cover_image, 640, 640); | 253 | + guang.shareTitle = detail.getArticle.article_title; |
254 | + guang.shareDesc = detail.getArticle.article_summary; | ||
255 | + if (detail.getArticle.cover_image_type === 1) { | ||
256 | + guang.shareImg = helpers.image(detail.getArticle.cover_image, 640, 640); | ||
257 | } else { | 257 | } else { |
258 | - data.shareImg = helpers.image(detail.getArticle.cover_image, 640, 320); | 258 | + guang.shareImg = helpers.image(detail.getArticle.cover_image, 640, 320); |
259 | } | 259 | } |
260 | data.title = detail.getArticle.article_title; | 260 | data.title = detail.getArticle.article_title; |
261 | data.title_more = true; | 261 | data.title_more = true; |
@@ -270,18 +270,18 @@ const _index = (req, res, next) => { | @@ -270,18 +270,18 @@ const _index = (req, res, next) => { | ||
270 | title: '逛', | 270 | title: '逛', |
271 | gender: gender, | 271 | gender: gender, |
272 | wechatShare: true, | 272 | wechatShare: true, |
273 | - guang: data | ||
274 | - }, parameter)); | 273 | + }, data, parameter)); |
275 | }); | 274 | }); |
276 | } else { | 275 | } else { |
277 | next(); | 276 | next(); |
277 | + return; | ||
278 | } | 278 | } |
279 | - | 279 | + |
280 | } | 280 | } |
281 | }).catch(next); | 281 | }).catch(next); |
282 | -} | 282 | +}; |
283 | 283 | ||
284 | 284 | ||
285 | module.exports = { | 285 | module.exports = { |
286 | - index: _index | ||
287 | -} | ||
286 | + index: _index | ||
287 | +}; |
@@ -5,112 +5,111 @@ | @@ -5,112 +5,111 @@ | ||
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | const serviceAPI = global.yoho.ServiceAPI; | 7 | const serviceAPI = global.yoho.ServiceAPI; |
8 | -const logger = global.yoho.logger; | ||
9 | -const helpers = global.yoho.helpers; | ||
10 | -const sign = global.yoho.sign | ||
11 | -const config = global.yoho.config; | ||
12 | -const url = require('url'); | ||
13 | 8 | ||
14 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; | 9 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; |
15 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; | 10 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; |
11 | + | ||
16 | /** | 12 | /** |
17 | * [逛资讯详情页数据封装] | 13 | * [逛资讯详情页数据封装] |
18 | * @param {[int]} id [内容ID] | 14 | * @param {[int]} id [内容ID] |
19 | * @param {Boolean} isApp [标识是否是APP访问] | 15 | * @param {Boolean} isApp [标识是否是APP访问] |
20 | - * @return {[array]} | 16 | + * @return {[array]} |
21 | */ | 17 | */ |
22 | const _package = (id, isApp) => { | 18 | const _package = (id, isApp) => { |
23 | - let result = { | ||
24 | - getAuthor: {}, | ||
25 | - getArticle: {}, | ||
26 | - getArticleContent: {}, | ||
27 | - getBrand: {}, | ||
28 | - getOtherArticle: {} | ||
29 | - } | 19 | + let result = { |
20 | + getAuthor: {}, | ||
21 | + getArticle: {}, | ||
22 | + getArticleContent: {}, | ||
23 | + getBrand: {}, | ||
24 | + getOtherArticle: {} | ||
25 | + }; | ||
30 | 26 | ||
31 | // 客户端类型 | 27 | // 客户端类型 |
32 | let clientType = isApp ? 'iphone' : 'h5'; | 28 | let clientType = isApp ? 'iphone' : 'h5'; |
33 | 29 | ||
34 | // 获取资讯 | 30 | // 获取资讯 |
35 | let param = { | 31 | let param = { |
36 | - article_id: id, | ||
37 | - client_type: clientType, | ||
38 | - // private_key: sign.privateKey[clientType] | 32 | + article_id: id, |
33 | + client_type: clientType, | ||
34 | + // private_key: sign.privateKey[clientType] | ||
39 | }; | 35 | }; |
40 | 36 | ||
41 | return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, param, { | 37 | return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, param, { |
42 | - cache: true | 38 | + cache: true |
43 | }).then(data => { | 39 | }).then(data => { |
44 | - //接口要判断一下返回状态是否成功,OK,I 服了 YOU | ||
45 | - if (data.code !== 200) { | ||
46 | - result.code = 400; | ||
47 | - return result; | ||
48 | - } | ||
49 | - let article = data.data; | ||
50 | - | ||
51 | - result['getArticle'] = article; | ||
52 | - | ||
53 | - let promises = []; | ||
54 | - | ||
55 | - // 获取作者信息 | ||
56 | - let param = { | ||
57 | - author_id: article.author_id | ||
58 | - }; | ||
59 | - | ||
60 | - // param.client_secret = sign.apiSign(param); | ||
61 | - promises.push(serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, param, { | ||
62 | - cache: true | ||
63 | - })); | ||
64 | - | ||
65 | - // 获取资讯内容 | ||
66 | - param = { | ||
67 | - article_id: id, | ||
68 | - client_type: clientType, | ||
69 | - // private_key: sign.privateKey[clientType] | ||
70 | - }; | ||
71 | - // param.client_secret = sign.apiSign(param); | ||
72 | - promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, { | ||
73 | - cache: true | ||
74 | - })); | ||
75 | - | ||
76 | - // 获取资讯相关的品牌 | ||
77 | - param = { | ||
78 | - article_id: id, | ||
79 | - client_type: clientType, | ||
80 | - // private_key: sign.privateKey[clientType] | ||
81 | - }; | ||
82 | - // param.client_secret = sign.apiSign(param); | ||
83 | - promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, param, { | ||
84 | - cache: true | ||
85 | - })); | ||
86 | - | ||
87 | - // 获取资讯相关的其它资讯 | ||
88 | - if (article.tag) { | ||
89 | - param = { | ||
90 | - article_id: id, | ||
91 | - client_type: clientType, | ||
92 | - tags: article.tag, | ||
93 | - offset: 0, | ||
94 | - limit: 3, | ||
95 | - // private_key: sign.privateKey[clientType] | ||
96 | - }; | ||
97 | - // param.client_secret = sign.apiSign(param); | ||
98 | - promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, param, { | ||
99 | - cache: true | ||
100 | - })); | ||
101 | - } | ||
102 | - return Promise.all(promises).then(datas => { | ||
103 | - result.getAuthor = datas[0].data; | ||
104 | - result.getArticleContent = datas[1].data; | ||
105 | - result.getBrand = datas[2].data; | ||
106 | - if (datas.length == 4) { | ||
107 | - result.getOtherArticle = datas[3].data; | ||
108 | - } | ||
109 | - return result; | ||
110 | - }); | 40 | + // 接口要判断一下返回状态是否成功,OK,I 服了 YOU |
41 | + if (data.code !== 200) { | ||
42 | + result.code = 400; | ||
43 | + return result; | ||
44 | + } | ||
45 | + let article = data.data; | ||
46 | + | ||
47 | + result.getArticle = article; | ||
48 | + | ||
49 | + let promises = []; | ||
50 | + | ||
51 | + // 获取作者信息 | ||
52 | + param = { | ||
53 | + author_id: article.author_id | ||
54 | + }; | ||
55 | + | ||
56 | + // param.client_secret = sign.apiSign(param); | ||
57 | + promises.push(serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, param, { | ||
58 | + cache: true | ||
59 | + })); | ||
60 | + | ||
61 | + // 获取资讯内容 | ||
62 | + param = { | ||
63 | + article_id: id, | ||
64 | + client_type: clientType, | ||
65 | + // private_key: sign.privateKey[clientType] | ||
66 | + }; | ||
67 | + | ||
68 | + // param.client_secret = sign.apiSign(param); | ||
69 | + promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, { | ||
70 | + cache: true | ||
71 | + })); | ||
72 | + | ||
73 | + // 获取资讯相关的品牌 | ||
74 | + param = { | ||
75 | + article_id: id, | ||
76 | + client_type: clientType, | ||
77 | + // private_key: sign.privateKey[clientType] | ||
78 | + }; | ||
79 | + | ||
80 | + // param.client_secret = sign.apiSign(param); | ||
81 | + promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, param, { | ||
82 | + cache: true | ||
83 | + })); | ||
84 | + | ||
85 | + // 获取资讯相关的其它资讯 | ||
86 | + if (article.tag) { | ||
87 | + param = { | ||
88 | + article_id: id, | ||
89 | + client_type: clientType, | ||
90 | + tags: article.tag, | ||
91 | + offset: 0, | ||
92 | + limit: 3, | ||
93 | + // private_key: sign.privateKey[clientType] | ||
94 | + }; | ||
95 | + | ||
96 | + // param.client_secret = sign.apiSign(param); | ||
97 | + promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, param, { | ||
98 | + cache: true | ||
99 | + })); | ||
100 | + } | ||
101 | + return Promise.all(promises).then(datas => { | ||
102 | + result.getAuthor = datas[0].data; | ||
103 | + result.getArticleContent = datas[1].data; | ||
104 | + result.getBrand = datas[2].data; | ||
105 | + if (datas.length === 4) { | ||
106 | + result.getOtherArticle = datas[3].data; | ||
107 | + } | ||
108 | + return result; | ||
109 | + }); | ||
111 | }); | 110 | }); |
112 | -} | 111 | +}; |
113 | 112 | ||
114 | module.exports = { | 113 | module.exports = { |
115 | - package: _package | ||
116 | -} | ||
114 | + package: _package | ||
115 | +}; |
apps/guang/views/partial/good.hbs
0 → 100644
1 | + | ||
2 | +{{#if .}} {{!-- 剔除值为false的项 --}} | ||
3 | + <div class="good-info" data-id="{{id}}"> | ||
4 | + <div class="tag-container clearfix"> | ||
5 | + {{# tags}} | ||
6 | + {{# is_new}} | ||
7 | + <p class="good-tag new-tag">NEW</p> | ||
8 | + {{/ is_new}} | ||
9 | + {{# is_advance}} | ||
10 | + <p class="good-tag renew-tag">再到着</p> | ||
11 | + {{/ is_advance}} | ||
12 | + {{# is_discount}} | ||
13 | + <p class="good-tag sale-tag">SALE</p> | ||
14 | + {{/ is_discount}} | ||
15 | + {{# is_yohood}} | ||
16 | + <p class="good-tag new-festival-tag">新品节</p> | ||
17 | + {{/ is_yohood}} | ||
18 | + {{# is_limited}} | ||
19 | + <p class="good-tag limit-tag">限量商品</p> | ||
20 | + {{/ is_limited}} | ||
21 | + {{/ tags}} | ||
22 | + </div> | ||
23 | + <div class="good-detail-img"> | ||
24 | + <a class="good-thumb buriedpoint" href="{{url}}" data-bp-id="shop_good_{{thumb}}_0"> | ||
25 | + <img class="lazy" data-original="{{thumb}}"> | ||
26 | + </a> | ||
27 | + {{# is_soon_sold_out}} | ||
28 | + <p class="few-tag">即将售罄</p> | ||
29 | + {{/ is_soon_sold_out}} | ||
30 | + </div> | ||
31 | + <div class="good-detail-text"> | ||
32 | + <div class="name"> | ||
33 | + <a href="{{url}}">{{name}}</a> | ||
34 | + </div> | ||
35 | + <div class="price {{#if students}}student-price{{/if}}"> | ||
36 | + {{#if students}} | ||
37 | + <span class="sale-price {{^price}}no-price{{/price}}">¥{{studentPrice}}</span> | ||
38 | + <span class="students-price-tag"></span> | ||
39 | + {{#salePrice}} | ||
40 | + <span class="market-price">¥{{.}}</span> | ||
41 | + {{/salePrice}} | ||
42 | + {{^}} | ||
43 | + <span class="sale-price {{^price}}no-price{{/price}}">¥{{salePrice}}</span> | ||
44 | + {{#price}} | ||
45 | + <span class="market-price">¥{{.}}</span> | ||
46 | + {{/price}} | ||
47 | + {{/if}} | ||
48 | + </div> | ||
49 | + </div> | ||
50 | + </div> | ||
51 | +{{/if}} |
@@ -10,7 +10,6 @@ const comment = require('./consult-comment'); | @@ -10,7 +10,6 @@ const comment = require('./consult-comment'); | ||
10 | 10 | ||
11 | const api = global.yoho.API; | 11 | const api = global.yoho.API; |
12 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
13 | -const sign = global.yoho.sign | ||
14 | 13 | ||
15 | const SINGLE_TICKETS_SKN = 51335912; // 展览票 | 14 | const SINGLE_TICKETS_SKN = 51335912; // 展览票 |
16 | 15 | ||
@@ -692,7 +691,7 @@ let getProductData = (data) => { | @@ -692,7 +691,7 @@ let getProductData = (data) => { | ||
692 | /** | 691 | /** |
693 | * [根据商品SKN获取商品的简要信息] | 692 | * [根据商品SKN获取商品的简要信息] |
694 | * @param {[array]} skns [skns] | 693 | * @param {[array]} skns [skns] |
695 | - * @return {[type]} | 694 | + * @return {[type]} |
696 | */ | 695 | */ |
697 | let _productInfoBySkns = (skns) => { | 696 | let _productInfoBySkns = (skns) => { |
698 | // 调用搜索接口 | 697 | // 调用搜索接口 |
@@ -702,10 +701,11 @@ let _productInfoBySkns = (skns) => { | @@ -702,10 +701,11 @@ let _productInfoBySkns = (skns) => { | ||
702 | limit: skns.length, | 701 | limit: skns.length, |
703 | order: 's_t_desc' | 702 | order: 's_t_desc' |
704 | }; | 703 | }; |
704 | + | ||
705 | return api.get('', param, { | 705 | return api.get('', param, { |
706 | cache: true | 706 | cache: true |
707 | }); | 707 | }); |
708 | -} | 708 | +}; |
709 | 709 | ||
710 | module.exports = { | 710 | module.exports = { |
711 | getProductData, | 711 | getProductData, |
public/img/guang/clothes/bag.png
0 → 100644

1.05 KB
public/img/guang/clothes/cloth.png
0 → 100644

908 Bytes
public/img/guang/clothes/dress.png
0 → 100644

1.63 KB
public/img/guang/clothes/headset.png
0 → 100644

999 Bytes
public/img/guang/clothes/lamp.png
0 → 100644

935 Bytes
public/img/guang/clothes/pants.png
0 → 100644

1.45 KB
public/img/guang/clothes/shoe.png
0 → 100644

821 Bytes
public/img/guang/clothes/swim-suit.png
0 → 100644

1.72 KB
public/img/guang/clothes/under.png
0 → 100644

1.12 KB
public/img/guang/clothes/watch.png
0 → 100644

1.18 KB
@@ -5,9 +5,9 @@ | @@ -5,9 +5,9 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | var $ = require('yoho-jquery'), | 7 | var $ = require('yoho-jquery'), |
8 | - ellipsis = require('yoho-mlellipsis'), | ||
9 | - lazyLoad = require('yoho-jquery-lazyload'), | ||
10 | - IScroll = require('yoho-iscroll/build/iscroll-probe'); | 8 | + ellipsis = require('yoho-mlellipsis'), |
9 | + lazyLoad = require('yoho-jquery-lazyload'), | ||
10 | + IScroll = require('yoho-iscroll/build/iscroll-probe'); | ||
11 | 11 | ||
12 | var $authorIntro = $('.author .intro'); | 12 | var $authorIntro = $('.author .intro'); |
13 | 13 | ||
@@ -15,17 +15,17 @@ var pageInIscroll = false; | @@ -15,17 +15,17 @@ var pageInIscroll = false; | ||
15 | 15 | ||
16 | var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false; | 16 | var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false; |
17 | 17 | ||
18 | -//collocation block variable | 18 | +// collocation block variable |
19 | var thumbWidth = 0, | 19 | var thumbWidth = 0, |
20 | - $fixedThumbContainer = $(''), | ||
21 | - $coBlock, $thumbContainer, $thumbs, $prods, | ||
22 | - scrollToEl; | 20 | + $fixedThumbContainer = $(''), |
21 | + $coBlock, $thumbContainer, $thumbs, $prods, | ||
22 | + scrollToEl, | ||
23 | + myScroll, | ||
24 | + winW = $(window).width(); | ||
23 | 25 | ||
24 | -var scrollToEl = document.querySelector('#wrapper .collocation-block'); | ||
25 | 26 | ||
26 | -var winW = $(window).width(); | 27 | +scrollToEl = document.querySelector('#wrapper .collocation-block'); |
27 | 28 | ||
28 | -var myScroll; | ||
29 | 29 | ||
30 | require('../plugin/wx-share')(); | 30 | require('../plugin/wx-share')(); |
31 | 31 | ||
@@ -35,7 +35,7 @@ require('../plugin/wx-share')(); | @@ -35,7 +35,7 @@ require('../plugin/wx-share')(); | ||
35 | */ | 35 | */ |
36 | function posCollocationArrow($curCo) { | 36 | function posCollocationArrow($curCo) { |
37 | var left = $curCo.offset().left, | 37 | var left = $curCo.offset().left, |
38 | - bgPos = -winW + left + (thumbWidth / 2) + 'px'; | 38 | + bgPos = -winW + left + (thumbWidth / 2) + 'px'; |
39 | 39 | ||
40 | $thumbContainer.css({ | 40 | $thumbContainer.css({ |
41 | backgroundPosition: bgPos + ' bottom' | 41 | backgroundPosition: bgPos + ' bottom' |
@@ -48,12 +48,12 @@ function posCollocationArrow($curCo) { | @@ -48,12 +48,12 @@ function posCollocationArrow($curCo) { | ||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | -//搭配thumb的touch事件句柄 | 51 | +// 搭配thumb的touch事件句柄 |
52 | function thumbTouchEvt(e) { | 52 | function thumbTouchEvt(e) { |
53 | var $curCo = $(e.currentTarget), | 53 | var $curCo = $(e.currentTarget), |
54 | - index = $curCo.index(), | ||
55 | - $brother, $brotherCo, | ||
56 | - $curProds; | 54 | + index = $curCo.index(), |
55 | + $brother, $brotherCo, | ||
56 | + $curProds; | ||
57 | 57 | ||
58 | if ($curCo.hasClass('focus')) { | 58 | if ($curCo.hasClass('focus')) { |
59 | return; | 59 | return; |
@@ -75,7 +75,7 @@ function thumbTouchEvt(e) { | @@ -75,7 +75,7 @@ function thumbTouchEvt(e) { | ||
75 | 75 | ||
76 | $curCo.addClass('focus'); | 76 | $curCo.addClass('focus'); |
77 | 77 | ||
78 | - //定位arrow | 78 | + // 定位arrow |
79 | posCollocationArrow($curCo); | 79 | posCollocationArrow($curCo); |
80 | 80 | ||
81 | $prods.not('.hide').addClass('hide'); | 81 | $prods.not('.hide').addClass('hide'); |
@@ -106,7 +106,7 @@ function initIscroll() { | @@ -106,7 +106,7 @@ function initIscroll() { | ||
106 | var hH = 0, | 106 | var hH = 0, |
107 | winH, tcH, cbH, cbTop, fixedThumbDom; | 107 | winH, tcH, cbH, cbTop, fixedThumbDom; |
108 | 108 | ||
109 | - //考虑通用头部的影响:对offset().top以及winH做对应偏移 | 109 | + // 考虑通用头部的影响:对offset().top以及winH做对应偏移 |
110 | if ($yohoHeader.length > 0) { | 110 | if ($yohoHeader.length > 0) { |
111 | hH = $yohoHeader.outerHeight(); | 111 | hH = $yohoHeader.outerHeight(); |
112 | } | 112 | } |
@@ -176,7 +176,7 @@ function initIscroll() { | @@ -176,7 +176,7 @@ function initIscroll() { | ||
176 | }); | 176 | }); |
177 | } | 177 | } |
178 | 178 | ||
179 | -//window onload 后重新refresh iscroll | 179 | +// window onload 后重新refresh iscroll |
180 | window.onload = function() { | 180 | window.onload = function() { |
181 | myScroll && myScroll.refresh(); | 181 | myScroll && myScroll.refresh(); |
182 | }; | 182 | }; |
@@ -186,8 +186,8 @@ $('img').on('load', function() { | @@ -186,8 +186,8 @@ $('img').on('load', function() { | ||
186 | myScroll && myScroll.refresh(); | 186 | myScroll && myScroll.refresh(); |
187 | }); | 187 | }); |
188 | 188 | ||
189 | -//初始化页面,包括是否使用iscorll初始化页面 | ||
190 | -//接口暴露在HTML中,使用压缩名 | 189 | +// 初始化页面,包括是否使用iscorll初始化页面 |
190 | +// 接口暴露在HTML中,使用压缩名 | ||
191 | (function(useIscroll) { | 191 | (function(useIscroll) { |
192 | var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; | 192 | var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; |
193 | var $this, $title; | 193 | var $this, $title; |
@@ -206,12 +206,12 @@ $('img').on('load', function() { | @@ -206,12 +206,12 @@ $('img').on('load', function() { | ||
206 | } | 206 | } |
207 | lazyLoad($('.lazy')); | 207 | lazyLoad($('.lazy')); |
208 | 208 | ||
209 | - //title mlellipsis | 209 | + // title mlellipsis |
210 | $('.info-list .title, .one-good .reco-name').each(function() { | 210 | $('.info-list .title, .one-good .reco-name').each(function() { |
211 | this.mlellipsis(2); | 211 | this.mlellipsis(2); |
212 | }); | 212 | }); |
213 | 213 | ||
214 | - //offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名 | 214 | + // offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名 |
215 | if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) === | 215 | if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) === |
216 | parseInt($authorIntro.css('margin-left'), 10))) { | 216 | parseInt($authorIntro.css('margin-left'), 10))) { |
217 | $authorIntro.css('padding-top', 0); | 217 | $authorIntro.css('padding-top', 0); |
@@ -225,7 +225,7 @@ $('img').on('load', function() { | @@ -225,7 +225,7 @@ $('img').on('load', function() { | ||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | - //有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有 | 228 | + // 有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有 |
229 | if (hasCollocationBlock) { | 229 | if (hasCollocationBlock) { |
230 | $coBlock = $('.collocation-block'); | 230 | $coBlock = $('.collocation-block'); |
231 | $thumbContainer = $coBlock.children('.thumb-container'); | 231 | $thumbContainer = $coBlock.children('.thumb-container'); |
@@ -239,13 +239,13 @@ $('img').on('load', function() { | @@ -239,13 +239,13 @@ $('img').on('load', function() { | ||
239 | .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom')) | 239 | .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom')) |
240 | .next('.thumb-container'); | 240 | .next('.thumb-container'); |
241 | 241 | ||
242 | - //load img of fixed thumb container | 242 | + // load img of fixed thumb container |
243 | lazyLoad($fixedThumbContainer.find('.lazy'), { | 243 | lazyLoad($fixedThumbContainer.find('.lazy'), { |
244 | event: 'sporty' | 244 | event: 'sporty' |
245 | }); | 245 | }); |
246 | } | 246 | } |
247 | 247 | ||
248 | - //Init Arrow Position | 248 | + // Init Arrow Position |
249 | posCollocationArrow($thumbs.filter('.focus')); | 249 | posCollocationArrow($thumbs.filter('.focus')); |
250 | 250 | ||
251 | $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | 251 | $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); |
@@ -259,4 +259,4 @@ $('img').on('load', function() { | @@ -259,4 +259,4 @@ $('img').on('load', function() { | ||
259 | if (pageInIscroll) { | 259 | if (pageInIscroll) { |
260 | initIscroll(); | 260 | initIscroll(); |
261 | } | 261 | } |
262 | -})(false); | ||
262 | +}(false)); |
1 | +/* global wx */ | ||
1 | /** | 2 | /** |
2 | * 微信分享 | 3 | * 微信分享 |
3 | * @author: xuqi<qi.xu@yoho.cn> | 4 | * @author: xuqi<qi.xu@yoho.cn> |
4 | * @date: 2015/10/30 | 5 | * @date: 2015/10/30 |
5 | */ | 6 | */ |
6 | 7 | ||
7 | -var $ = require('yoho-jquery'); | ||
8 | 8 | ||
9 | module.exports = function() { | 9 | module.exports = function() { |
10 | + var $ = require('yoho-jquery'); | ||
10 | var _weChatInterface = '/life/getSignPackage'; | 11 | var _weChatInterface = '/life/getSignPackage'; |
12 | + | ||
11 | $.getJSON(_weChatInterface + '?pageurl=' + | 13 | $.getJSON(_weChatInterface + '?pageurl=' + |
12 | - encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function (json) { | 14 | + encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) { |
13 | var _appId, _timestamp, _nonceStr, _signature; | 15 | var _appId, _timestamp, _nonceStr, _signature; |
14 | 16 | ||
17 | + | ||
15 | if (!wx) { | 18 | if (!wx) { |
16 | return; | 19 | return; |
17 | } | 20 | } |
@@ -68,7 +71,7 @@ module.exports = function() { | @@ -68,7 +71,7 @@ module.exports = function() { | ||
68 | } | 71 | } |
69 | }); | 72 | }); |
70 | 73 | ||
71 | - wx.ready(function () { | 74 | + wx.ready(function() { |
72 | var shareTitle = $('#shareTitle').val(); | 75 | var shareTitle = $('#shareTitle').val(); |
73 | var shareImg = $('#shareImg').val(); | 76 | var shareImg = $('#shareImg').val(); |
74 | var shareDesc = $('#shareDesc').val(); | 77 | var shareDesc = $('#shareDesc').val(); |
@@ -116,14 +116,14 @@ | @@ -116,14 +116,14 @@ | ||
116 | background: #fff; | 116 | background: #fff; |
117 | 117 | ||
118 | .good-list { | 118 | .good-list { |
119 | - padding-left:15px; | 119 | + padding-left: 15px; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | .thumb-container { | 123 | .thumb-container { |
124 | padding-top: 30px; | 124 | padding-top: 30px; |
125 | padding-left: 20px; | 125 | padding-left: 20px; |
126 | - background: transparent resolve('guang/thumb-container-bg.png') no-repeat; | 126 | + background: transparent resolve("guang/thumb-container-bg.png") no-repeat; |
127 | background-size: 200% 100%; | 127 | background-size: 200% 100%; |
128 | 128 | ||
129 | &.fixed-top { | 129 | &.fixed-top { |
@@ -138,7 +138,7 @@ | @@ -138,7 +138,7 @@ | ||
138 | left: 0; | 138 | left: 0; |
139 | right: 0; | 139 | right: 0; |
140 | bottom: 0; | 140 | bottom: 0; |
141 | - background: rgba(255,255,255,0.9); | 141 | + background: rgba(255, 255, 255, 0.9); |
142 | } | 142 | } |
143 | 143 | ||
144 | &.absolute { | 144 | &.absolute { |
@@ -345,7 +345,7 @@ | @@ -345,7 +345,7 @@ | ||
345 | .brand-list { | 345 | .brand-list { |
346 | border-top: 1px solid #e0e0e0; | 346 | border-top: 1px solid #e0e0e0; |
347 | border-bottom: 1px solid #e0e0e0; | 347 | border-bottom: 1px solid #e0e0e0; |
348 | - padding: 30px 0 30px; | 348 | + padding: 30px 0; |
349 | background: #fff; | 349 | background: #fff; |
350 | } | 350 | } |
351 | 351 | ||
@@ -375,13 +375,12 @@ | @@ -375,13 +375,12 @@ | ||
375 | display: block; | 375 | display: block; |
376 | max-width: 158px; | 376 | max-width: 158px; |
377 | max-height: 94px; | 377 | max-height: 94px; |
378 | - vertical-align: middle; | ||
379 | margin: 0 auto; | 378 | margin: 0 auto; |
380 | } | 379 | } |
381 | } | 380 | } |
382 | 381 | ||
383 | .brand-name { | 382 | .brand-name { |
384 | - margin: 10px 0 0 0; | 383 | + margin: 10px 0 0; |
385 | line-height: 24px; | 384 | line-height: 24px; |
386 | font-size: 18px; | 385 | font-size: 18px; |
387 | color: #babac2; | 386 | color: #babac2; |
@@ -404,7 +403,7 @@ | @@ -404,7 +403,7 @@ | ||
404 | position: absolute; | 403 | position: absolute; |
405 | height: 40px; | 404 | height: 40px; |
406 | width: 40px; | 405 | width: 40px; |
407 | - background: resolve('guang/tag.png') no-repeat; | 406 | + background: resolve("guang/tag.png") no-repeat; |
408 | background-size: 100% 100%; | 407 | background-size: 100% 100%; |
409 | top: 35px; | 408 | top: 35px; |
410 | left: 20px; | 409 | left: 20px; |
@@ -414,7 +413,7 @@ | @@ -414,7 +413,7 @@ | ||
414 | margin-left: 50px; | 413 | margin-left: 50px; |
415 | } | 414 | } |
416 | 415 | ||
417 | - li { | 416 | + li { |
418 | float: left; | 417 | float: left; |
419 | margin-top: 31px; | 418 | margin-top: 31px; |
420 | margin-left: 31px; | 419 | margin-left: 31px; |
@@ -463,14 +462,14 @@ | @@ -463,14 +462,14 @@ | ||
463 | } | 462 | } |
464 | } | 463 | } |
465 | 464 | ||
466 | - .title, .publish-time { | 465 | + .title, |
466 | + .publish-time { | ||
467 | float: left; | 467 | float: left; |
468 | width: 360px; | 468 | width: 360px; |
469 | margin-left: 30px; | 469 | margin-left: 30px; |
470 | line-height: 40px; | 470 | line-height: 40px; |
471 | color: #444; | 471 | color: #444; |
472 | font-size: 28px; | 472 | font-size: 28px; |
473 | - | ||
474 | } | 473 | } |
475 | 474 | ||
476 | .publish-time { | 475 | .publish-time { |
@@ -146,23 +146,24 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQuerySt | @@ -146,23 +146,24 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQuerySt | ||
146 | /** | 146 | /** |
147 | * [获取商品的ICON] | 147 | * [获取商品的ICON] |
148 | * @param {[int]} type [类型] | 148 | * @param {[int]} type [类型] |
149 | - * @return {[type]} | 149 | + * @return {[type]} |
150 | */ | 150 | */ |
151 | const _getProductIcon = (type) => { | 151 | const _getProductIcon = (type) => { |
152 | const icons = { | 152 | const icons = { |
153 | - '1': 'cloth', | ||
154 | - '3': 'pants', | ||
155 | - '4': 'dress', | ||
156 | - '6': 'shoe', | ||
157 | - '7': 'bag', | ||
158 | - '10': 'lamp', | ||
159 | - '241': 'headset', | ||
160 | - '8': 'watch', | ||
161 | - '360': 'swim-suit', | ||
162 | - '308': 'under' | 153 | + 1: 'cloth', |
154 | + 3: 'pants', | ||
155 | + 4: 'dress', | ||
156 | + 6: 'shoe', | ||
157 | + 7: 'bag', | ||
158 | + 10: 'lamp', | ||
159 | + 241: 'headset', | ||
160 | + 8: 'watch', | ||
161 | + 360: 'swim-suit', | ||
162 | + 308: 'under' | ||
163 | }; | 163 | }; |
164 | + | ||
164 | return icons[type] || ''; | 165 | return icons[type] || ''; |
165 | -} | 166 | +}; |
166 | 167 | ||
167 | /** | 168 | /** |
168 | * [根据性别获取] | 169 | * [根据性别获取] |
@@ -178,28 +179,31 @@ const _getGenderByCookie = (gender) => { | @@ -178,28 +179,31 @@ const _getGenderByCookie = (gender) => { | ||
178 | default: // 其它 | 179 | default: // 其它 |
179 | return '1,2,3'; | 180 | return '1,2,3'; |
180 | } | 181 | } |
181 | -} | 182 | +}; |
183 | + | ||
182 | /** | 184 | /** |
183 | * [根据性别来决定 默认图片获取字段 如果是 2、3] | 185 | * [根据性别来决定 默认图片获取字段 如果是 2、3] |
184 | - * | 186 | + * |
185 | * 则优先从cover2 --》 cover1 -- 》 images_url | 187 | * 则优先从cover2 --》 cover1 -- 》 images_url |
186 | * 否则优先从cover1 --》 cover2 -- 》 images_url | 188 | * 否则优先从cover1 --》 cover2 -- 》 images_url |
187 | - * | 189 | + * |
188 | * @param {[array]} images [images] | 190 | * @param {[array]} images [images] |
189 | * @param {[Boolean]} gender [性别] | 191 | * @param {[Boolean]} gender [性别] |
190 | - * @return {[type]} | 192 | + * @return {[type]} |
191 | */ | 193 | */ |
192 | const _procProductImg = (images, gender) => { | 194 | const _procProductImg = (images, gender) => { |
193 | let imgUrl = images.images_url || ''; | 195 | let imgUrl = images.images_url || ''; |
194 | let cover1 = images.cover_1 || ''; | 196 | let cover1 = images.cover_1 || ''; |
195 | let cover2 = images.cover_2 || ''; | 197 | let cover2 = images.cover_2 || ''; |
198 | + | ||
196 | gender = _getGenderByCookie(gender); | 199 | gender = _getGenderByCookie(gender); |
197 | if (gender === '2,3') { | 200 | if (gender === '2,3') { |
198 | return cover2 || (cover1 || imgUrl); | 201 | return cover2 || (cover1 || imgUrl); |
199 | } else { | 202 | } else { |
200 | return cover1 || (cover2 || imgUrl); | 203 | return cover1 || (cover2 || imgUrl); |
201 | } | 204 | } |
202 | -} | 205 | +}; |
206 | + | ||
203 | /** | 207 | /** |
204 | * 格式化商品信息 | 208 | * 格式化商品信息 |
205 | * | 209 | * |
@@ -221,6 +225,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | @@ -221,6 +225,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | ||
221 | } | 225 | } |
222 | productData.sales_price = productData.sales_price || ''; | 226 | productData.sales_price = productData.sales_price || ''; |
223 | productData.market_price = productData.market_price || ''; | 227 | productData.market_price = productData.market_price || ''; |
228 | + | ||
224 | // 市场价和售价一样,则不显示市场价 | 229 | // 市场价和售价一样,则不显示市场价 |
225 | if (parseInt(productData.market_price) === parseInt(productData.sales_price)) { | 230 | if (parseInt(productData.market_price) === parseInt(productData.sales_price)) { |
226 | productData.market_price = false; | 231 | productData.market_price = false; |
@@ -238,6 +243,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | @@ -238,6 +243,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | ||
238 | break; | 243 | break; |
239 | } | 244 | } |
240 | } | 245 | } |
246 | + | ||
241 | // 如果还未赋值,则取第一个skc产品的默认图片 | 247 | // 如果还未赋值,则取第一个skc产品的默认图片 |
242 | if (!flag) { | 248 | if (!flag) { |
243 | productData.default_images = _procProductImg(productData.goods_list[0], gender); | 249 | productData.default_images = _procProductImg(productData.goods_list[0], gender); |
@@ -251,14 +257,17 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | @@ -251,14 +257,17 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | ||
251 | price: productData.market_price || false, | 257 | price: productData.market_price || false, |
252 | salePrice: productData.sales_price | 258 | salePrice: productData.sales_price |
253 | }; | 259 | }; |
260 | + | ||
254 | if (showPoint) { | 261 | if (showPoint) { |
255 | result.price = result.price + '.00'; | 262 | result.price = result.price + '.00'; |
256 | result.salePrice = result.salePrice + '.00'; | 263 | result.salePrice = result.salePrice + '.00'; |
257 | } | 264 | } |
265 | + | ||
258 | // TODO student price | 266 | // TODO student price |
259 | result.studentPrice = parseInt(productData.sales_price * 100 * 0.9) / 100; | 267 | result.studentPrice = parseInt(productData.sales_price * 100 * 0.9) / 100; |
260 | result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y'); | 268 | result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y'); |
261 | let url = helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`); | 269 | let url = helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`); |
270 | + | ||
262 | result.url = url.replace('http://', '//'); | 271 | result.url = url.replace('http://', '//'); |
263 | 272 | ||
264 | // APP访问需要加附加的参数 | 273 | // APP访问需要加附加的参数 |
@@ -274,7 +283,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | @@ -274,7 +283,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | ||
274 | // is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量 | 283 | // is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量 |
275 | // is_yohood: productData.is_yohood && productData.is_yohood === 'Y', //YOHOOD | 284 | // is_yohood: productData.is_yohood && productData.is_yohood === 'Y', //YOHOOD |
276 | // midYear: productData.midear && productData.midear === 'Y', //年中 | 285 | // midYear: productData.midear && productData.midear === 'Y', //年中 |
277 | - // yearEnd: productData.yearnd && productData.yearnd === 'Y', //年末 | 286 | + // yearEnd: productData.yearnd && productData.yearnd === 'Y', //年末 |
278 | // is_advance: productData.is_advance && productData.is_advance === 'Y' // 再到着 | 287 | // is_advance: productData.is_advance && productData.is_advance === 'Y' // 再到着 |
279 | // }; | 288 | // }; |
280 | // // 打折与即将售完组合显示打折 | 289 | // // 打折与即将售完组合显示打折 |
@@ -290,7 +299,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | @@ -290,7 +299,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height, | ||
290 | // } | 299 | // } |
291 | 300 | ||
292 | return result; | 301 | return result; |
293 | -} | 302 | +}; |
294 | 303 | ||
295 | 304 | ||
296 | module.exports = { | 305 | module.exports = { |
-
Please register or login to post a comment