Authored by ccbikai

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

... ... @@ -5,6 +5,13 @@
*/
'use strict';
const config = require('./config/common');
// use one apm
if (config.useOneapm) {
require('oneapm');
}
let express = require('express'),
path = require('path'),
bodyParser = require('body-parser'),
... ...
... ... @@ -8,8 +8,17 @@
{{! 资源位}}
{{> channel/content}}
{{! 商品列表}}
{{#if twoColumnGoods}}
{{> channel/two-column-goods}}
{{/if}}
{{! 你可能喜欢}}
{{> channel/maybe-like}}
{{#if lifestyleHomePage}}
{{> channel/maybe-like-lifestyle}}
{{else}}
{{> channel/maybe-like}}
{{/if}}
{{! 底部banner}}
{{#bannerBottom}}
... ...
{{# content}}
{{! 头部banner}}
{{# bannerTop}}
{{> home/banner_top}}
{{/ bannerTop}}
{{#if focus}}
{{> channel/banner-top}}
{{/if}}
{{! 图标入口}}
{{# iconsEnter}}
{{> home/icons_enter}}
{{/ iconsEnter}}
{{#if appIconList}}
{{> channel/icons-enter}}
{{/if}}
{{! 中间banner}}
{{# banner}}
{{> home/banner}}
{{/ banner}}
{{#if singleImage}}
{{> channel/banner}}
{{/if}}
{{! 两个小图}}
{{# smallPic}}
{{> home/thumb_row}}
{{/ smallPic}}
{{#if smallPic}}
{{> channel/thumb-row}}
{{/if}}
{{! 热门品类}}
{{# hotCategory}}
{{> home/hot_category}}
{{/ hotCategory}}
{{#if recommendContentFive}}
{{> channel/hot-category}}
{{/if}}
{{! 热门品牌}}
{{# hotBrands}}
{{> home/hot_brands_list}}
{{/ hotBrands}}
{{#if appHotBrands}}
{{> channel/hot-brands-list}}
{{/if}}
{{! 热门品牌可滑动}}
{{# hotBrandsScroll}}
{{> home/hot_brands_swipe}}
{{/ hotBrandsScroll}}
{{#if customBrands}}
{{> channel/hot-brands-swipe}}
{{/if}}
{{! 潮人搭配}}
{{# trendColloaction}}
{{> home/trendsetter_collocation}}
{{/trendColloaction}}
{{#if trendsetterCollocation}}
{{> channel/trendsetter-collocation}}
{{/if}}
{{! 潮流话题}}
{{# trendTopics}}
{{> home/trend_topics}}
{{/ trendTopics}}
{{#if trendgoodsTopic}}
{{> channel/trend-topics}}
{{/if}}
{{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}}
{{# goodsCategory}}
{{> home/goods_category}}
{{/ goodsCategory}}
{{#if recommendContentOne}}
{{> channel/goods-category}}
{{/if}}
{{! 新入住品牌/品味生活/创意生活}}
{{# creativeLife}}
{{> home/creative_life}}
{{/ creativeLife}}
{{#if recommendContentTwo}}
{{> channel/creative-life}}
{{/if}}
{{! PLUS}}
{{# plusStar}}
{{> home/plus_star}}
{{/ plusStar}}
{{#if singleNameImage}}
{{> channel/plus-star}}
{{/if}}
{{! 新人专享}}
{{# freshOnly}}
{{> home/fresh_only}}
{{/ freshOnly}}
{{/ content}}
{{! 可能喜欢}}
{{> home/maybe_like_lifestyle}}
\ No newline at end of file
{{#if newUserFloor}}
{{> channel/fresh-only}}
{{/if}}
{{/ content}}
\ No newline at end of file
... ...
... ... @@ -55,8 +55,4 @@
{{#if newUserFloor}}
{{> channel/fresh-only}}
{{/if}}
{{! 商品列表}}
{{#if twoColumnGoods}}
{{> channel/two-column-goods}}
{{/if}}
{{/content}}
... ...
... ... @@ -12,8 +12,8 @@ const mRoot = '../models';
const detail = require(`${mRoot}/detail`);
exports.index = (req, res) => {
var uid = null, // 需要修改为正式取 UID 的方式
vipLevel = 0;// 用户等级
var uid = null, // 需要修改为正式取 UID 的方式
vipLevel = 0; // 用户等级
detail({
id: req.params.id,
... ...
... ... @@ -10,10 +10,9 @@ const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const _ = require('lodash');
const HELPERS = require(`${library}/helpers`);
const helpers = require(`${library}/helpers`);
var api = new API();
var helpers = new HELPERS();
/**
* 处理品牌关联店铺信息
... ... @@ -25,10 +24,10 @@ const getShopsInfo = (data) => {
_.forEach(data, function(value, key) {
enterStore[key] = {};
enterStore[key].img = helpers.getImageUrl(value.brand_ico, 47, 47);
enterStore[key].img = value.brand_ico;
enterStore[key].storeName = value.brand_name;
if (value.shop_id !== null && value.shop_id !== undefined) {
if (value.shop_id !== null && typeof value.shop_id !== 'undefined') {
let params = {};
params.shop_id = value.shop_id;
... ... @@ -127,14 +126,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
totalStorageNum = 0;
// 商品名称
if (origin.productName === null || origin.productName === undefined) {
if (origin.productName === null || typeof origin.productName === 'undefined') {
return dest;
}
dest.goodsName = origin.productName;
// 用户未登录时 待处理
if (uid === null || uid === undefined) {
if (uid === null || typeof uid === 'undefined') {
let params = {};
params.refer = helpers.url('/product/show_' + origin.erpProductId + '.html');
... ... @@ -142,12 +141,12 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
}
// 商品促销短语
if (origin.salesPhrase !== null && origin.salesPhrase !== undefined) {
if (origin.salesPhrase !== null && typeof origin.salesPhrase !== 'undefined') {
dest.goodsSubtitle = origin.salesPhrase;
}
// 商品标签
if (origin.productTagBoList !== null && origin.productTagBoList !== undefined) {
if (origin.productTagBoList !== null && typeof origin.productTagBoList !== 'undefined') {
_.forEach(origin.productTagBoList, function(value) {
switch (value.tagLabel) {
case 'is_soon_sold_out':
... ... @@ -177,7 +176,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 商品价格
dest.goodsPrice = {};
if (origin.productPriceBo !== null && origin.productPriceBo !== undefined) {
if (origin.productPriceBo !== null && typeof origin.productPriceBo !== 'undefined') {
dest.goodsPrice.currentPrice = origin.productPriceBo.formatSalesPrice;
if (origin.productPriceBo.formatMarketPrice !== origin.productPriceBo.formatSalesPrice) {
dest.goodsPrice.previousPrice = origin.productPriceBo.formatMarketPrice;
... ... @@ -193,7 +192,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.vipLevel = {};
dest.vipLevel.list = {};
if (origin.productPriceBo.vipPrices !== null && origin.productPriceBo.vipPrices !== undefined) {
if (origin.productPriceBo.vipPrices !== null && typeof origin.productPriceBo.vipPrices !== 'undefined') {
_.forEach(origin.productPriceBo.vipPrices, function(value, key) {
dest.vipLevel.list[key] = {};
dest.vipLevel.list[key].level = value.vipLevel;
... ... @@ -203,7 +202,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
}
// 上市期
if (origin.expectArrivalTime !== null && origin.expectArrivalTime !== undefined) {
if (origin.expectArrivalTime !== null && typeof origin.expectArrivalTime !== 'undefined') {
dest.periodOfMarket = origin.expectArrivalTime + '月';
}
... ... @@ -211,7 +210,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.goodsDiscount = {};
dest.goodsDiscount.list = {};
if (origin.promotionBoList !== null && origin.promotionBoList !== undefined) {
if (origin.promotionBoList !== null && typeof origin.promotionBoList !== 'undefined') {
_.forEach(origin.promotionBoList, function(value, key) {
dest.goodsDiscount.list[key] = {};
dest.goodsDiscount.list[key].text = '【' + value.promotionType + '】' +
... ... @@ -224,7 +223,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.feedbacks.consults = {};
dest.feedbacks.consultsNum = 0;
if (origin.consultBoWrapper !== null && origin.consultBoWrapper !== undefined) {
if (origin.consultBoWrapper !== null && typeof origin.consultBoWrapper !== 'undefined') {
dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal;
_.forEach(origin.consultBoWrapper.consultBoList, function(value, key) {
dest.feedbacks.consults[key] = {};
... ... @@ -251,7 +250,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 商品评价
dest.feedbacks.commentsNum = 0;
if (origin.commentBoWrapper !== null && origin.commentBoWrapper !== undefined) {
if (origin.commentBoWrapper !== null && typeof origin.commentBoWrapper !== 'undefined') {
dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
dest.feedbacks.comments = {};
... ... @@ -261,7 +260,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.feedbacks.comments[key].desc = value.colorName +
'/' + value.sizeName;
dest.feedbacks.comments[key].content = (value.content !== null &&
value.content !== undefined) ? value.content : '';
typeof value.content !== 'undefined') ? value.content : '';
dest.feedbacks.comments[key].time = value.createTime;
});
... ... @@ -274,13 +273,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
}
// 品牌信息
if (origin.brand !== null && origin.brand !== undefined) {
// dest.enterStore[0] = {};
// dest.enterStore[0].img =
// helpers.getImageUrl(origin.brand.brandIco, 47, 47);
// dest.enterStore[0].storeName = origin.brand.brandName;
// dest.enterStore[0].url = helpers.url('', null, origin.brand.brandDomain);
if (origin.brand !== null && typeof origin.brand !== 'undefined') {
// 为你优选的链接
let params = {};
... ... @@ -293,7 +286,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.productSkn = origin.erpProductId;
// 商品信息
if (origin.goodsList !== null && origin.goodsList !== undefined) {
if (origin.goodsList !== null && typeof origin.goodsList !== 'undefined') {
let goodsGroup = {},
sizeName = '',
colorList = {},
... ... @@ -310,7 +303,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
colorStorageNum = 0;
// 商品分组
if (value.goodsImagesList !== null && value.goodsImagesList !== undefined) {
if (value.goodsImagesList !== null && typeof value.goodsImagesList !== 'undefined') {
_.forEach(value.goodsImagesList, function(good, keyForGood) {
goodsGroup[keyForGood] = {};
goodsGroup[keyForGood].goodsId = good.goodsId;
... ... @@ -320,7 +313,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 商品的尺码列表
colorStorageGroup[value.productSkc] = {};
if (value.goodsSizeBoList !== null && value.goodsSizeBoList !== undefined) {
if (value.goodsSizeBoList !== null && typeof value.goodsSizeBoList !== 'undefined') {
_.forEach(value.goodsSizeBoList, function(size, keyForSize) {
sizeList[value.productSkc] = {};
... ... @@ -341,11 +334,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
build.storage = size.goodsSizeStorageNum;
build.id = size.id;
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
allSizeList[sizeName] === undefined) ? build :
typeof allSizeList[sizeName] === 'undefined') ? build :
allSizeList[sizeName];
colorStorageNum += parseInt(size.goodsSizeStorageNum);
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum);
colorStorageNum += parseInt(size.goodsSizeStorageNum, 10);
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum, 10);
});
// 颜色分组
... ... @@ -360,7 +353,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 缩略图
let params = {};
params.img = helpers.getImageUrl(value.colorImage, 60, 60);
params.img = value.colorImage;
thumbImageList[key] = params;
// 商品库存总数
... ... @@ -378,7 +371,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
sizeGroup[0].size = {};
sizeGroup[0].size[key] = {};
sizeGroup[0].size[key].name = sizeName;
sizeGroup[0].size[key].sizeNum = (value.storage === undefined || value.storage === null) ? false : true;
sizeGroup[0].size[key].sizeNum = (typeof value.storage === 'undefined' ||
value.storage === null) ? false : true;
sizeGroup[0].size[key].id = value.id;
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
... ... @@ -388,7 +382,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
colorGroup[i].color[keyForColorArr] = {};
colorGroup[i].color[keyForColorArr].colorNum =
(colorStorageGroup[colorArr.skcId][sizeName] !== null &&
colorStorageGroup[colorArr.skcId][sizeName] !== undefined) ?
typeof colorStorageGroup[colorArr.skcId][sizeName] !== 'undefined') ?
colorStorageGroup[colorArr.skcId][sizeName] : 0;
});
colorGroup[i].id = value.id;
... ... @@ -414,19 +408,19 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
});
// 商品图:多个
if (goodsGroup[1] !== null && goodsGroup[1] !== undefined) {
if (goodsGroup[1] !== null && typeof goodsGroup[1] !== 'undefined') {
_.forEach(goodsGroup, function(value, key) {
dest.bannerTop = {};
dest.bannerTop.list = {};
let params = {};
params.img = helpers.getImageUrl(value.img, 450, 600);
params.img = value.img;
dest.bannerTop.list[key] = params;
});
} else if (goodsGroup[0] !== null && goodsGroup[0] !== undefined) {
} else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
dest.bannerTop = {};
dest.bannerTop.img = helpers.getImageUrl(goodsGroup[0].img, 450, 600);
dest.bannerTop.img = goodsGroup[0].img;
}
}
... ... @@ -446,11 +440,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.cartInfo = {};
dest.cartInfo.productId = origin.id;
dest.cartInfo.thumbs = thumbImageList;
dest.cartInfo.name = (dest.goodsName !== null && dest.goodsName !== undefined) ? dest.goodsName : '';
dest.cartInfo.name = (dest.goodsName !== null && typeof dest.goodsName !== 'undefined') ? dest.goodsName : '';
dest.cartInfo.price = (dest.goodsPrice.previousPrice !== null &&
dest.goodsPrice.previousPrice !== undefined) ? dest.goodsPrice.previousPrice : '';
typeof dest.goodsPrice.previousPrice !== 'undefined') ? dest.goodsPrice.previousPrice : '';
dest.cartInfo.salePrice = (dest.goodsPrice.currentPrice !== null &&
dest.goodsPrice.currentPrice !== undefined) ? dest.goodsPrice.currentPrice : '';
typeof dest.goodsPrice.currentPrice !== 'undefined') ? dest.goodsPrice.currentPrice : '';
dest.cartInfo.totalNum = totalStorageNum;
dest.cartInfo.colors = colorGroup;
dest.cartInfo.sizes = sizeGroup;
... ... @@ -458,14 +452,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 限购商品
if (origin.isLimitBuy === 'Y') {
// 是否开售
let isBeginSale = (origin.saleStatus !== null && origin.saleStatus !== undefined &&
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
origin.saleStatus === 1);
// 限购商品有关的展示状态
let showStatus = 1;
if (origin.showStatus !== null && origin.showStatus !== undefined) {
showStatus = parseInt(origin.showStatus);
if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') {
showStatus = parseInt(origin.showStatus, 10);
}
// 处理限购商品有关的按钮状态
... ... @@ -486,7 +480,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
// 是否收藏
dest.isCollect = false;
if (origin.isCollect !== null && origin.isCollect !== undefined && origin.isCollect === 'Y') {
if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') {
dest.isCollect = true;
}
... ...
... ... @@ -5,21 +5,28 @@
* @date 2016/05/06
*/
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
module.exports = {
siteUrl: 'http://m.yohobuy.com',
domains: {
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/'
api: 'http://testapi.yoho.cn:28078/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/
service: 'http://devapi.yoho.cn:58078/'
},
loggers: {
file: {
infoFile: {
name: 'info',
level: 'info',
maxsize: 100 * 1024 * 1024,
handleExceptions: true,
zippedArchive: true,
timestamp: true,
filename: 'info.log'
},
errorFile: {
name: 'error',
level: 'error',
filename: 'error.log',
handleExceptions: true
},
udp: { // send by udp
level: 'debug', // logger level
host: '192.168.102.162', // influxdb host
... ... @@ -32,3 +39,15 @@ module.exports = {
}
}
};
if (isProduction) {
Object.assign(module.exports, {
appName: 'm.yohobuy.com',
useOneapm: true
});
} else if (isTest) {
Object.assign(module.exports, {
appName: 'm.yohobuy.com for test',
useOneapm: true
});
}
... ...
... ... @@ -12,5 +12,5 @@ module.exports = app => {
app.use(require('./apps/channel'));
// 业务模块
//app.use('/product', require('./apps/product'));
app.use('/product', require('./apps/product'));
};
... ...
... ... @@ -75,92 +75,3 @@ exports.upperCase = (str) => {
str = str || '';
return str.toUpperCase();
};
/*
* @Author: Targaryen
* @Date: 2016-05-10 10:11:34
* @Last Modified by: Targaryen
* @Last Modified time: 2016-05-12 11:25:53
*/
/* -----------------------------------------
* 实现 PHP 的 Helpers 函数
* -----------------------------------------
*/
//'use strict';
//
//const SUB_DOMAIN = '.yohobuy.com';
//const SITE_MAIN = 'http://www.yohobuy.com';
//const _ = require('lodash');
//
//class HELPERS {
//
// /**
// * 构建网站的URL
// * @param uri String
// * @param param Array
// * @param module String
// */
// url(uri, param, module) {
// let url = '';
//
// if (module === null) {
// module = 'index';
// }
// switch (module) {
// case 'default':
// url = 'http://m.yohobuy.com';
// break;
// case 'guang':
// url = 'http://guang' + SUB_DOMAIN;
// break;
// case 'list':
// url = 'http://list' + SUB_DOMAIN;
// break;
// case 'search':
// url = 'http://search' + SUB_DOMAIN;
// break;
// case 'index':
// url = SITE_MAIN;
// break;
// case '':
// break;
// case undefined:
// break;
// default:
// url = 'http://' + module + SUB_DOMAIN;
// break;
// }
//
// url += uri;
// if (param !== null && param !== undefined) {
// url += '?';
// _.forEach(param, function(value, key) {
// url += (key + '=' + value + '&');
// });
// }
// if (url.substr(-1, 1) === '&') {
// return url.substr(0, url.length - 1);
// } else {
// return url;
// }
//
// }
//
// /**
// * 根据尺寸获得图片url
// * @param uri String
// * @param param Array
// * @param module String
// */
// getImageUrl(url, width, height, mode) {
// if (mode === null) {
// mode = 2;
// }
// return url.replace(/{width}/g, width)
// .replace(/{height}/g, height)
// .replace(/{mode}/g, mode);
// }
//}
//
//module.exports = HELPERS;
... ...
... ... @@ -14,8 +14,8 @@
let logger = new (winston.Logger)({
transports: [
// new (FileTransport)(config.loggers.infoFile),
// new (FileTransport)(config.loggers.errorFile),
new (FileTransport)(config.loggers.infoFile),
new (FileTransport)(config.loggers.errorFile),
new (winston.transports.UdpTransport)(config.loggers.udp),
new (winston.transports.Console)(config.loggers.console)
]
... ...
// use for app name
const commonConfig = require('./config/common');
/**
* OneAPM agent configuration.
*
* See lib/config.defaults.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
*/
app_name : [commonConfig.appName], // eslint-disable-line
/**
* Your OneAPM license key.
*/
license_key : 'BwEGA1dRDlQ6357HHQ1AD1xJVkbc9fNfWRtQUwhQG41c5QFWGFIDSQoHc0e8AgMaUlcUVw0=',// eslint-disable-line
logging : { // eslint-disable-line
/**
* Level at which to log. 'trace' is most useful to OneAPM when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level : 'info'// eslint-disable-line
},
transaction_events: {// eslint-disable-line
enabled: true// eslint-disable-line
}
};
... ...
... ... @@ -38,6 +38,7 @@
"lodash": "^4.12.0",
"md5": "^2.1.0",
"morgan": "^1.7.0",
"oneapm": "^1.2.20",
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"winston": "^2.2.0",
... ...
... ... @@ -20,7 +20,7 @@
.classify-list > li {
float: left;
width: 213.3px;
height: 192px;
height: 194px;
border-top: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
}
... ...