Authored by ccbikai

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuywap-node into develop

@@ -5,6 +5,13 @@ @@ -5,6 +5,13 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 7
  8 +const config = require('./config/common');
  9 +
  10 +// use one apm
  11 +if (config.useOneapm) {
  12 + require('oneapm');
  13 +}
  14 +
8 let express = require('express'), 15 let express = require('express'),
9 path = require('path'), 16 path = require('path'),
10 bodyParser = require('body-parser'), 17 bodyParser = require('body-parser'),
@@ -8,8 +8,17 @@ @@ -8,8 +8,17 @@
8 {{! 资源位}} 8 {{! 资源位}}
9 {{> channel/content}} 9 {{> channel/content}}
10 10
  11 + {{! 商品列表}}
  12 + {{#if twoColumnGoods}}
  13 + {{> channel/two-column-goods}}
  14 + {{/if}}
  15 +
11 {{! 你可能喜欢}} 16 {{! 你可能喜欢}}
12 - {{> channel/maybe-like}} 17 + {{#if lifestyleHomePage}}
  18 + {{> channel/maybe-like-lifestyle}}
  19 + {{else}}
  20 + {{> channel/maybe-like}}
  21 + {{/if}}
13 22
14 {{! 底部banner}} 23 {{! 底部banner}}
15 {{#bannerBottom}} 24 {{#bannerBottom}}
1 {{# content}} 1 {{# content}}
2 {{! 头部banner}} 2 {{! 头部banner}}
3 - {{# bannerTop}}  
4 - {{> home/banner_top}}  
5 - {{/ bannerTop}} 3 + {{#if focus}}
  4 + {{> channel/banner-top}}
  5 + {{/if}}
6 {{! 图标入口}} 6 {{! 图标入口}}
7 - {{# iconsEnter}}  
8 - {{> home/icons_enter}}  
9 - {{/ iconsEnter}} 7 + {{#if appIconList}}
  8 + {{> channel/icons-enter}}
  9 + {{/if}}
10 {{! 中间banner}} 10 {{! 中间banner}}
11 - {{# banner}}  
12 - {{> home/banner}}  
13 - {{/ banner}} 11 + {{#if singleImage}}
  12 + {{> channel/banner}}
  13 + {{/if}}
14 {{! 两个小图}} 14 {{! 两个小图}}
15 - {{# smallPic}}  
16 - {{> home/thumb_row}}  
17 - {{/ smallPic}} 15 + {{#if smallPic}}
  16 + {{> channel/thumb-row}}
  17 + {{/if}}
18 {{! 热门品类}} 18 {{! 热门品类}}
19 - {{# hotCategory}}  
20 - {{> home/hot_category}}  
21 - {{/ hotCategory}} 19 + {{#if recommendContentFive}}
  20 + {{> channel/hot-category}}
  21 + {{/if}}
22 {{! 热门品牌}} 22 {{! 热门品牌}}
23 - {{# hotBrands}}  
24 - {{> home/hot_brands_list}}  
25 - {{/ hotBrands}} 23 + {{#if appHotBrands}}
  24 + {{> channel/hot-brands-list}}
  25 + {{/if}}
26 {{! 热门品牌可滑动}} 26 {{! 热门品牌可滑动}}
27 - {{# hotBrandsScroll}}  
28 - {{> home/hot_brands_swipe}}  
29 - {{/ hotBrandsScroll}} 27 + {{#if customBrands}}
  28 + {{> channel/hot-brands-swipe}}
  29 + {{/if}}
30 {{! 潮人搭配}} 30 {{! 潮人搭配}}
31 - {{# trendColloaction}}  
32 - {{> home/trendsetter_collocation}}  
33 - {{/trendColloaction}} 31 + {{#if trendsetterCollocation}}
  32 + {{> channel/trendsetter-collocation}}
  33 + {{/if}}
34 {{! 潮流话题}} 34 {{! 潮流话题}}
35 - {{# trendTopics}}  
36 - {{> home/trend_topics}}  
37 - {{/ trendTopics}} 35 + {{#if trendgoodsTopic}}
  36 + {{> channel/trend-topics}}
  37 + {{/if}}
38 {{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}} 38 {{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}}
39 - {{# goodsCategory}}  
40 - {{> home/goods_category}}  
41 - {{/ goodsCategory}} 39 + {{#if recommendContentOne}}
  40 + {{> channel/goods-category}}
  41 + {{/if}}
42 {{! 新入住品牌/品味生活/创意生活}} 42 {{! 新入住品牌/品味生活/创意生活}}
43 - {{# creativeLife}}  
44 - {{> home/creative_life}}  
45 - {{/ creativeLife}} 43 + {{#if recommendContentTwo}}
  44 + {{> channel/creative-life}}
  45 + {{/if}}
46 {{! PLUS}} 46 {{! PLUS}}
47 - {{# plusStar}}  
48 - {{> home/plus_star}}  
49 - {{/ plusStar}} 47 + {{#if singleNameImage}}
  48 + {{> channel/plus-star}}
  49 + {{/if}}
50 {{! 新人专享}} 50 {{! 新人专享}}
51 - {{# freshOnly}}  
52 - {{> home/fresh_only}}  
53 - {{/ freshOnly}}  
54 -{{/ content}}  
55 -  
56 -{{! 可能喜欢}}  
57 -{{> home/maybe_like_lifestyle}}  
  51 + {{#if newUserFloor}}
  52 + {{> channel/fresh-only}}
  53 + {{/if}}
  54 +{{/ content}}
@@ -55,8 +55,4 @@ @@ -55,8 +55,4 @@
55 {{#if newUserFloor}} 55 {{#if newUserFloor}}
56 {{> channel/fresh-only}} 56 {{> channel/fresh-only}}
57 {{/if}} 57 {{/if}}
58 - {{! 商品列表}}  
59 - {{#if twoColumnGoods}}  
60 - {{> channel/two-column-goods}}  
61 - {{/if}}  
62 {{/content}} 58 {{/content}}
@@ -12,8 +12,8 @@ const mRoot = '../models'; @@ -12,8 +12,8 @@ const mRoot = '../models';
12 const detail = require(`${mRoot}/detail`); 12 const detail = require(`${mRoot}/detail`);
13 13
14 exports.index = (req, res) => { 14 exports.index = (req, res) => {
15 - var uid = null, // 需要修改为正式取 UID 的方式  
16 - vipLevel = 0;// 用户等级 15 + var uid = null, // 需要修改为正式取 UID 的方式
  16 + vipLevel = 0; // 用户等级
17 17
18 detail({ 18 detail({
19 id: req.params.id, 19 id: req.params.id,
@@ -10,10 +10,9 @@ const library = '../../../library'; @@ -10,10 +10,9 @@ const library = '../../../library';
10 const API = require(`${library}/api`).API; 10 const API = require(`${library}/api`).API;
11 const sign = require(`${library}/sign`); 11 const sign = require(`${library}/sign`);
12 const _ = require('lodash'); 12 const _ = require('lodash');
13 -const HELPERS = require(`${library}/helpers`); 13 +const helpers = require(`${library}/helpers`);
14 14
15 var api = new API(); 15 var api = new API();
16 -var helpers = new HELPERS();  
17 16
18 /** 17 /**
19 * 处理品牌关联店铺信息 18 * 处理品牌关联店铺信息
@@ -25,10 +24,10 @@ const getShopsInfo = (data) => { @@ -25,10 +24,10 @@ const getShopsInfo = (data) => {
25 24
26 _.forEach(data, function(value, key) { 25 _.forEach(data, function(value, key) {
27 enterStore[key] = {}; 26 enterStore[key] = {};
28 - enterStore[key].img = helpers.getImageUrl(value.brand_ico, 47, 47); 27 + enterStore[key].img = value.brand_ico;
29 enterStore[key].storeName = value.brand_name; 28 enterStore[key].storeName = value.brand_name;
30 29
31 - if (value.shop_id !== null && value.shop_id !== undefined) { 30 + if (value.shop_id !== null && typeof value.shop_id !== 'undefined') {
32 let params = {}; 31 let params = {};
33 32
34 params.shop_id = value.shop_id; 33 params.shop_id = value.shop_id;
@@ -127,14 +126,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -127,14 +126,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
127 totalStorageNum = 0; 126 totalStorageNum = 0;
128 127
129 // 商品名称 128 // 商品名称
130 - if (origin.productName === null || origin.productName === undefined) { 129 + if (origin.productName === null || typeof origin.productName === 'undefined') {
131 return dest; 130 return dest;
132 } 131 }
133 132
134 dest.goodsName = origin.productName; 133 dest.goodsName = origin.productName;
135 134
136 // 用户未登录时 待处理 135 // 用户未登录时 待处理
137 - if (uid === null || uid === undefined) { 136 + if (uid === null || typeof uid === 'undefined') {
138 let params = {}; 137 let params = {};
139 138
140 params.refer = helpers.url('/product/show_' + origin.erpProductId + '.html'); 139 params.refer = helpers.url('/product/show_' + origin.erpProductId + '.html');
@@ -142,12 +141,12 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -142,12 +141,12 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
142 } 141 }
143 142
144 // 商品促销短语 143 // 商品促销短语
145 - if (origin.salesPhrase !== null && origin.salesPhrase !== undefined) { 144 + if (origin.salesPhrase !== null && typeof origin.salesPhrase !== 'undefined') {
146 dest.goodsSubtitle = origin.salesPhrase; 145 dest.goodsSubtitle = origin.salesPhrase;
147 } 146 }
148 147
149 // 商品标签 148 // 商品标签
150 - if (origin.productTagBoList !== null && origin.productTagBoList !== undefined) { 149 + if (origin.productTagBoList !== null && typeof origin.productTagBoList !== 'undefined') {
151 _.forEach(origin.productTagBoList, function(value) { 150 _.forEach(origin.productTagBoList, function(value) {
152 switch (value.tagLabel) { 151 switch (value.tagLabel) {
153 case 'is_soon_sold_out': 152 case 'is_soon_sold_out':
@@ -177,7 +176,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -177,7 +176,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
177 // 商品价格 176 // 商品价格
178 dest.goodsPrice = {}; 177 dest.goodsPrice = {};
179 178
180 - if (origin.productPriceBo !== null && origin.productPriceBo !== undefined) { 179 + if (origin.productPriceBo !== null && typeof origin.productPriceBo !== 'undefined') {
181 dest.goodsPrice.currentPrice = origin.productPriceBo.formatSalesPrice; 180 dest.goodsPrice.currentPrice = origin.productPriceBo.formatSalesPrice;
182 if (origin.productPriceBo.formatMarketPrice !== origin.productPriceBo.formatSalesPrice) { 181 if (origin.productPriceBo.formatMarketPrice !== origin.productPriceBo.formatSalesPrice) {
183 dest.goodsPrice.previousPrice = origin.productPriceBo.formatMarketPrice; 182 dest.goodsPrice.previousPrice = origin.productPriceBo.formatMarketPrice;
@@ -193,7 +192,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -193,7 +192,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
193 dest.vipLevel = {}; 192 dest.vipLevel = {};
194 dest.vipLevel.list = {}; 193 dest.vipLevel.list = {};
195 194
196 - if (origin.productPriceBo.vipPrices !== null && origin.productPriceBo.vipPrices !== undefined) { 195 + if (origin.productPriceBo.vipPrices !== null && typeof origin.productPriceBo.vipPrices !== 'undefined') {
197 _.forEach(origin.productPriceBo.vipPrices, function(value, key) { 196 _.forEach(origin.productPriceBo.vipPrices, function(value, key) {
198 dest.vipLevel.list[key] = {}; 197 dest.vipLevel.list[key] = {};
199 dest.vipLevel.list[key].level = value.vipLevel; 198 dest.vipLevel.list[key].level = value.vipLevel;
@@ -203,7 +202,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -203,7 +202,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
203 } 202 }
204 203
205 // 上市期 204 // 上市期
206 - if (origin.expectArrivalTime !== null && origin.expectArrivalTime !== undefined) { 205 + if (origin.expectArrivalTime !== null && typeof origin.expectArrivalTime !== 'undefined') {
207 dest.periodOfMarket = origin.expectArrivalTime + '月'; 206 dest.periodOfMarket = origin.expectArrivalTime + '月';
208 } 207 }
209 208
@@ -211,7 +210,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -211,7 +210,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
211 dest.goodsDiscount = {}; 210 dest.goodsDiscount = {};
212 dest.goodsDiscount.list = {}; 211 dest.goodsDiscount.list = {};
213 212
214 - if (origin.promotionBoList !== null && origin.promotionBoList !== undefined) { 213 + if (origin.promotionBoList !== null && typeof origin.promotionBoList !== 'undefined') {
215 _.forEach(origin.promotionBoList, function(value, key) { 214 _.forEach(origin.promotionBoList, function(value, key) {
216 dest.goodsDiscount.list[key] = {}; 215 dest.goodsDiscount.list[key] = {};
217 dest.goodsDiscount.list[key].text = '【' + value.promotionType + '】' + 216 dest.goodsDiscount.list[key].text = '【' + value.promotionType + '】' +
@@ -224,7 +223,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -224,7 +223,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
224 dest.feedbacks.consults = {}; 223 dest.feedbacks.consults = {};
225 dest.feedbacks.consultsNum = 0; 224 dest.feedbacks.consultsNum = 0;
226 225
227 - if (origin.consultBoWrapper !== null && origin.consultBoWrapper !== undefined) { 226 + if (origin.consultBoWrapper !== null && typeof origin.consultBoWrapper !== 'undefined') {
228 dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal; 227 dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal;
229 _.forEach(origin.consultBoWrapper.consultBoList, function(value, key) { 228 _.forEach(origin.consultBoWrapper.consultBoList, function(value, key) {
230 dest.feedbacks.consults[key] = {}; 229 dest.feedbacks.consults[key] = {};
@@ -251,7 +250,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -251,7 +250,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
251 250
252 // 商品评价 251 // 商品评价
253 dest.feedbacks.commentsNum = 0; 252 dest.feedbacks.commentsNum = 0;
254 - if (origin.commentBoWrapper !== null && origin.commentBoWrapper !== undefined) { 253 + if (origin.commentBoWrapper !== null && typeof origin.commentBoWrapper !== 'undefined') {
255 dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal; 254 dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
256 dest.feedbacks.comments = {}; 255 dest.feedbacks.comments = {};
257 256
@@ -261,7 +260,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -261,7 +260,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
261 dest.feedbacks.comments[key].desc = value.colorName + 260 dest.feedbacks.comments[key].desc = value.colorName +
262 '/' + value.sizeName; 261 '/' + value.sizeName;
263 dest.feedbacks.comments[key].content = (value.content !== null && 262 dest.feedbacks.comments[key].content = (value.content !== null &&
264 - value.content !== undefined) ? value.content : ''; 263 + typeof value.content !== 'undefined') ? value.content : '';
265 dest.feedbacks.comments[key].time = value.createTime; 264 dest.feedbacks.comments[key].time = value.createTime;
266 }); 265 });
267 266
@@ -274,13 +273,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -274,13 +273,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
274 } 273 }
275 274
276 // 品牌信息 275 // 品牌信息
277 - if (origin.brand !== null && origin.brand !== undefined) {  
278 -  
279 - // dest.enterStore[0] = {};  
280 - // dest.enterStore[0].img =  
281 - // helpers.getImageUrl(origin.brand.brandIco, 47, 47);  
282 - // dest.enterStore[0].storeName = origin.brand.brandName;  
283 - // dest.enterStore[0].url = helpers.url('', null, origin.brand.brandDomain); 276 + if (origin.brand !== null && typeof origin.brand !== 'undefined') {
284 277
285 // 为你优选的链接 278 // 为你优选的链接
286 let params = {}; 279 let params = {};
@@ -293,7 +286,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -293,7 +286,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
293 dest.productSkn = origin.erpProductId; 286 dest.productSkn = origin.erpProductId;
294 287
295 // 商品信息 288 // 商品信息
296 - if (origin.goodsList !== null && origin.goodsList !== undefined) { 289 + if (origin.goodsList !== null && typeof origin.goodsList !== 'undefined') {
297 let goodsGroup = {}, 290 let goodsGroup = {},
298 sizeName = '', 291 sizeName = '',
299 colorList = {}, 292 colorList = {},
@@ -310,7 +303,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -310,7 +303,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
310 colorStorageNum = 0; 303 colorStorageNum = 0;
311 304
312 // 商品分组 305 // 商品分组
313 - if (value.goodsImagesList !== null && value.goodsImagesList !== undefined) { 306 + if (value.goodsImagesList !== null && typeof value.goodsImagesList !== 'undefined') {
314 _.forEach(value.goodsImagesList, function(good, keyForGood) { 307 _.forEach(value.goodsImagesList, function(good, keyForGood) {
315 goodsGroup[keyForGood] = {}; 308 goodsGroup[keyForGood] = {};
316 goodsGroup[keyForGood].goodsId = good.goodsId; 309 goodsGroup[keyForGood].goodsId = good.goodsId;
@@ -320,7 +313,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -320,7 +313,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
320 313
321 // 商品的尺码列表 314 // 商品的尺码列表
322 colorStorageGroup[value.productSkc] = {}; 315 colorStorageGroup[value.productSkc] = {};
323 - if (value.goodsSizeBoList !== null && value.goodsSizeBoList !== undefined) { 316 + if (value.goodsSizeBoList !== null && typeof value.goodsSizeBoList !== 'undefined') {
324 317
325 _.forEach(value.goodsSizeBoList, function(size, keyForSize) { 318 _.forEach(value.goodsSizeBoList, function(size, keyForSize) {
326 sizeList[value.productSkc] = {}; 319 sizeList[value.productSkc] = {};
@@ -341,11 +334,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -341,11 +334,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
341 build.storage = size.goodsSizeStorageNum; 334 build.storage = size.goodsSizeStorageNum;
342 build.id = size.id; 335 build.id = size.id;
343 allSizeList[sizeName] = (allSizeList[sizeName] === null || 336 allSizeList[sizeName] = (allSizeList[sizeName] === null ||
344 - allSizeList[sizeName] === undefined) ? build : 337 + typeof allSizeList[sizeName] === 'undefined') ? build :
345 allSizeList[sizeName]; 338 allSizeList[sizeName];
346 339
347 - colorStorageNum += parseInt(size.goodsSizeStorageNum);  
348 - colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum); 340 + colorStorageNum += parseInt(size.goodsSizeStorageNum, 10);
  341 + colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum, 10);
349 }); 342 });
350 343
351 // 颜色分组 344 // 颜色分组
@@ -360,7 +353,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -360,7 +353,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
360 // 缩略图 353 // 缩略图
361 let params = {}; 354 let params = {};
362 355
363 - params.img = helpers.getImageUrl(value.colorImage, 60, 60); 356 + params.img = value.colorImage;
364 thumbImageList[key] = params; 357 thumbImageList[key] = params;
365 358
366 // 商品库存总数 359 // 商品库存总数
@@ -378,7 +371,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -378,7 +371,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
378 sizeGroup[0].size = {}; 371 sizeGroup[0].size = {};
379 sizeGroup[0].size[key] = {}; 372 sizeGroup[0].size[key] = {};
380 sizeGroup[0].size[key].name = sizeName; 373 sizeGroup[0].size[key].name = sizeName;
381 - sizeGroup[0].size[key].sizeNum = (value.storage === undefined || value.storage === null) ? false : true; 374 + sizeGroup[0].size[key].sizeNum = (typeof value.storage === 'undefined' ||
  375 + value.storage === null) ? false : true;
382 sizeGroup[0].size[key].id = value.id; 376 sizeGroup[0].size[key].id = value.id;
383 377
384 // 各个颜色的尺码, 每行显示一个尺码对应的颜色 378 // 各个颜色的尺码, 每行显示一个尺码对应的颜色
@@ -388,7 +382,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -388,7 +382,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
388 colorGroup[i].color[keyForColorArr] = {}; 382 colorGroup[i].color[keyForColorArr] = {};
389 colorGroup[i].color[keyForColorArr].colorNum = 383 colorGroup[i].color[keyForColorArr].colorNum =
390 (colorStorageGroup[colorArr.skcId][sizeName] !== null && 384 (colorStorageGroup[colorArr.skcId][sizeName] !== null &&
391 - colorStorageGroup[colorArr.skcId][sizeName] !== undefined) ? 385 + typeof colorStorageGroup[colorArr.skcId][sizeName] !== 'undefined') ?
392 colorStorageGroup[colorArr.skcId][sizeName] : 0; 386 colorStorageGroup[colorArr.skcId][sizeName] : 0;
393 }); 387 });
394 colorGroup[i].id = value.id; 388 colorGroup[i].id = value.id;
@@ -414,19 +408,19 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -414,19 +408,19 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
414 }); 408 });
415 409
416 // 商品图:多个 410 // 商品图:多个
417 - if (goodsGroup[1] !== null && goodsGroup[1] !== undefined) { 411 + if (goodsGroup[1] !== null && typeof goodsGroup[1] !== 'undefined') {
418 _.forEach(goodsGroup, function(value, key) { 412 _.forEach(goodsGroup, function(value, key) {
419 dest.bannerTop = {}; 413 dest.bannerTop = {};
420 414
421 dest.bannerTop.list = {}; 415 dest.bannerTop.list = {};
422 let params = {}; 416 let params = {};
423 417
424 - params.img = helpers.getImageUrl(value.img, 450, 600); 418 + params.img = value.img;
425 dest.bannerTop.list[key] = params; 419 dest.bannerTop.list[key] = params;
426 }); 420 });
427 - } else if (goodsGroup[0] !== null && goodsGroup[0] !== undefined) { 421 + } else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
428 dest.bannerTop = {}; 422 dest.bannerTop = {};
429 - dest.bannerTop.img = helpers.getImageUrl(goodsGroup[0].img, 450, 600); 423 + dest.bannerTop.img = goodsGroup[0].img;
430 } 424 }
431 } 425 }
432 426
@@ -446,11 +440,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -446,11 +440,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
446 dest.cartInfo = {}; 440 dest.cartInfo = {};
447 dest.cartInfo.productId = origin.id; 441 dest.cartInfo.productId = origin.id;
448 dest.cartInfo.thumbs = thumbImageList; 442 dest.cartInfo.thumbs = thumbImageList;
449 - dest.cartInfo.name = (dest.goodsName !== null && dest.goodsName !== undefined) ? dest.goodsName : ''; 443 + dest.cartInfo.name = (dest.goodsName !== null && typeof dest.goodsName !== 'undefined') ? dest.goodsName : '';
450 dest.cartInfo.price = (dest.goodsPrice.previousPrice !== null && 444 dest.cartInfo.price = (dest.goodsPrice.previousPrice !== null &&
451 - dest.goodsPrice.previousPrice !== undefined) ? dest.goodsPrice.previousPrice : ''; 445 + typeof dest.goodsPrice.previousPrice !== 'undefined') ? dest.goodsPrice.previousPrice : '';
452 dest.cartInfo.salePrice = (dest.goodsPrice.currentPrice !== null && 446 dest.cartInfo.salePrice = (dest.goodsPrice.currentPrice !== null &&
453 - dest.goodsPrice.currentPrice !== undefined) ? dest.goodsPrice.currentPrice : ''; 447 + typeof dest.goodsPrice.currentPrice !== 'undefined') ? dest.goodsPrice.currentPrice : '';
454 dest.cartInfo.totalNum = totalStorageNum; 448 dest.cartInfo.totalNum = totalStorageNum;
455 dest.cartInfo.colors = colorGroup; 449 dest.cartInfo.colors = colorGroup;
456 dest.cartInfo.sizes = sizeGroup; 450 dest.cartInfo.sizes = sizeGroup;
@@ -458,14 +452,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -458,14 +452,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
458 // 限购商品 452 // 限购商品
459 if (origin.isLimitBuy === 'Y') { 453 if (origin.isLimitBuy === 'Y') {
460 // 是否开售 454 // 是否开售
461 - let isBeginSale = (origin.saleStatus !== null && origin.saleStatus !== undefined && 455 + let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
462 origin.saleStatus === 1); 456 origin.saleStatus === 1);
463 457
464 // 限购商品有关的展示状态 458 // 限购商品有关的展示状态
465 let showStatus = 1; 459 let showStatus = 1;
466 460
467 - if (origin.showStatus !== null && origin.showStatus !== undefined) {  
468 - showStatus = parseInt(origin.showStatus); 461 + if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') {
  462 + showStatus = parseInt(origin.showStatus, 10);
469 } 463 }
470 464
471 // 处理限购商品有关的按钮状态 465 // 处理限购商品有关的按钮状态
@@ -486,7 +480,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -486,7 +480,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
486 // 是否收藏 480 // 是否收藏
487 481
488 dest.isCollect = false; 482 dest.isCollect = false;
489 - if (origin.isCollect !== null && origin.isCollect !== undefined && origin.isCollect === 'Y') { 483 + if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') {
490 dest.isCollect = true; 484 dest.isCollect = true;
491 } 485 }
492 486
@@ -5,21 +5,28 @@ @@ -5,21 +5,28 @@
5 * @date 2016/05/06 5 * @date 2016/05/06
6 */ 6 */
7 7
  8 +
  9 +const isProduction = process.env.NODE_ENV === 'production';
  10 +const isTest = process.env.NODE_ENV === 'test';
  11 +
8 module.exports = { 12 module.exports = {
9 siteUrl: 'http://m.yohobuy.com', 13 siteUrl: 'http://m.yohobuy.com',
10 domains: { 14 domains: {
11 - api: 'http://testapi.yoho.cn:28078/',  
12 - service: 'http://testservice.yoho.cn:28077/' 15 + api: 'http://testapi.yoho.cn:28078/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/
  16 + service: 'http://devapi.yoho.cn:58078/'
13 }, 17 },
14 loggers: { 18 loggers: {
15 - file: { 19 + infoFile: {
  20 + name: 'info',
16 level: 'info', 21 level: 'info',
17 - maxsize: 100 * 1024 * 1024,  
18 - handleExceptions: true,  
19 - zippedArchive: true,  
20 - timestamp: true,  
21 filename: 'info.log' 22 filename: 'info.log'
22 }, 23 },
  24 + errorFile: {
  25 + name: 'error',
  26 + level: 'error',
  27 + filename: 'error.log',
  28 + handleExceptions: true
  29 + },
23 udp: { // send by udp 30 udp: { // send by udp
24 level: 'debug', // logger level 31 level: 'debug', // logger level
25 host: '192.168.102.162', // influxdb host 32 host: '192.168.102.162', // influxdb host
@@ -32,3 +39,15 @@ module.exports = { @@ -32,3 +39,15 @@ module.exports = {
32 } 39 }
33 } 40 }
34 }; 41 };
  42 +
  43 +if (isProduction) {
  44 + Object.assign(module.exports, {
  45 + appName: 'm.yohobuy.com',
  46 + useOneapm: true
  47 + });
  48 +} else if (isTest) {
  49 + Object.assign(module.exports, {
  50 + appName: 'm.yohobuy.com for test',
  51 + useOneapm: true
  52 + });
  53 +}
@@ -12,5 +12,5 @@ module.exports = app => { @@ -12,5 +12,5 @@ module.exports = app => {
12 app.use(require('./apps/channel')); 12 app.use(require('./apps/channel'));
13 13
14 // 业务模块 14 // 业务模块
15 - //app.use('/product', require('./apps/product')); 15 + app.use('/product', require('./apps/product'));
16 }; 16 };
@@ -75,92 +75,3 @@ exports.upperCase = (str) => { @@ -75,92 +75,3 @@ exports.upperCase = (str) => {
75 str = str || ''; 75 str = str || '';
76 return str.toUpperCase(); 76 return str.toUpperCase();
77 }; 77 };
78 -  
79 -/*  
80 - * @Author: Targaryen  
81 - * @Date: 2016-05-10 10:11:34  
82 - * @Last Modified by: Targaryen  
83 - * @Last Modified time: 2016-05-12 11:25:53  
84 - */  
85 -/* -----------------------------------------  
86 - * 实现 PHP 的 Helpers 函数  
87 - * -----------------------------------------  
88 - */  
89 -  
90 -//'use strict';  
91 -//  
92 -//const SUB_DOMAIN = '.yohobuy.com';  
93 -//const SITE_MAIN = 'http://www.yohobuy.com';  
94 -//const _ = require('lodash');  
95 -//  
96 -//class HELPERS {  
97 -//  
98 -// /**  
99 -// * 构建网站的URL  
100 -// * @param uri String  
101 -// * @param param Array  
102 -// * @param module String  
103 -// */  
104 -// url(uri, param, module) {  
105 -// let url = '';  
106 -//  
107 -// if (module === null) {  
108 -// module = 'index';  
109 -// }  
110 -// switch (module) {  
111 -// case 'default':  
112 -// url = 'http://m.yohobuy.com';  
113 -// break;  
114 -// case 'guang':  
115 -// url = 'http://guang' + SUB_DOMAIN;  
116 -// break;  
117 -// case 'list':  
118 -// url = 'http://list' + SUB_DOMAIN;  
119 -// break;  
120 -// case 'search':  
121 -// url = 'http://search' + SUB_DOMAIN;  
122 -// break;  
123 -// case 'index':  
124 -// url = SITE_MAIN;  
125 -// break;  
126 -// case '':  
127 -// break;  
128 -// case undefined:  
129 -// break;  
130 -// default:  
131 -// url = 'http://' + module + SUB_DOMAIN;  
132 -// break;  
133 -// }  
134 -//  
135 -// url += uri;  
136 -// if (param !== null && param !== undefined) {  
137 -// url += '?';  
138 -// _.forEach(param, function(value, key) {  
139 -// url += (key + '=' + value + '&');  
140 -// });  
141 -// }  
142 -// if (url.substr(-1, 1) === '&') {  
143 -// return url.substr(0, url.length - 1);  
144 -// } else {  
145 -// return url;  
146 -// }  
147 -//  
148 -// }  
149 -//  
150 -// /**  
151 -// * 根据尺寸获得图片url  
152 -// * @param uri String  
153 -// * @param param Array  
154 -// * @param module String  
155 -// */  
156 -// getImageUrl(url, width, height, mode) {  
157 -// if (mode === null) {  
158 -// mode = 2;  
159 -// }  
160 -// return url.replace(/{width}/g, width)  
161 -// .replace(/{height}/g, height)  
162 -// .replace(/{mode}/g, mode);  
163 -// }  
164 -//}  
165 -//  
166 -//module.exports = HELPERS;  
@@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
14 14
15 let logger = new (winston.Logger)({ 15 let logger = new (winston.Logger)({
16 transports: [ 16 transports: [
17 - // new (FileTransport)(config.loggers.infoFile),  
18 - // new (FileTransport)(config.loggers.errorFile), 17 + new (FileTransport)(config.loggers.infoFile),
  18 + new (FileTransport)(config.loggers.errorFile),
19 new (winston.transports.UdpTransport)(config.loggers.udp), 19 new (winston.transports.UdpTransport)(config.loggers.udp),
20 new (winston.transports.Console)(config.loggers.console) 20 new (winston.transports.Console)(config.loggers.console)
21 ] 21 ]
  1 +// use for app name
  2 +const commonConfig = require('./config/common');
  3 +
  4 +/**
  5 + * OneAPM agent configuration.
  6 + *
  7 + * See lib/config.defaults.js in the agent distribution for a more complete
  8 + * description of configuration variables and their potential values.
  9 + */
  10 +exports.config = {
  11 + /**
  12 + * Array of application names.
  13 + */
  14 + app_name : [commonConfig.appName], // eslint-disable-line
  15 + /**
  16 + * Your OneAPM license key.
  17 + */
  18 + license_key : 'BwEGA1dRDlQ6357HHQ1AD1xJVkbc9fNfWRtQUwhQG41c5QFWGFIDSQoHc0e8AgMaUlcUVw0=',// eslint-disable-line
  19 + logging : { // eslint-disable-line
  20 + /**
  21 + * Level at which to log. 'trace' is most useful to OneAPM when diagnosing
  22 + * issues with the agent, 'info' and higher will impose the least overhead on
  23 + * production applications.
  24 + */
  25 + level : 'info'// eslint-disable-line
  26 + },
  27 + transaction_events: {// eslint-disable-line
  28 + enabled: true// eslint-disable-line
  29 + }
  30 +};
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
38 "lodash": "^4.12.0", 38 "lodash": "^4.12.0",
39 "md5": "^2.1.0", 39 "md5": "^2.1.0",
40 "morgan": "^1.7.0", 40 "morgan": "^1.7.0",
  41 + "oneapm": "^1.2.20",
41 "request-promise": "^3.0.0", 42 "request-promise": "^3.0.0",
42 "serve-favicon": "^2.3.0", 43 "serve-favicon": "^2.3.0",
43 "winston": "^2.2.0", 44 "winston": "^2.2.0",
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 .classify-list > li { 20 .classify-list > li {
21 float: left; 21 float: left;
22 width: 213.3px; 22 width: 213.3px;
23 - height: 192px; 23 + height: 194px;
24 border-top: 1px solid #e0e0e0; 24 border-top: 1px solid #e0e0e0;
25 border-right: 1px solid #e0e0e0; 25 border-right: 1px solid #e0e0e0;
26 } 26 }