Authored by 周少峰

Merge branch 'master' into feature/students

... ... @@ -9,6 +9,8 @@
const helpers = global.yoho.helpers;
const mRoot = '../models';
const service = require(`${mRoot}/detail-service`);
const detailHelper = require(`${mRoot}/detail-helper`);
const Actions = require('./lib/actions');
const YohoAction = require('./lib/yoho-action');
const moment = require('moment');
... ... @@ -26,7 +28,7 @@ class DetailAction extends YohoAction {
let pid = req.params[0];
let gid = req.params[1];
let uid = req.user.uid || '';
let vipLevel = req.user.vip || '';
let vipLevel = detailHelper.vipLevel(req.user.vip);
return service.showMainAsync({
pid: pid,
... ... @@ -43,9 +45,7 @@ class DetailAction extends YohoAction {
this.setDescription(seo.description, true);
this.setEntry('product', 'detail');
this.renderTemplate('product/detail', Object.assign({
headerData: result.headerData
}, result));
this.renderTemplate('product/detail', result);
}).catch(err => {
if (err.code === 404) {
return this.next();
... ...
... ... @@ -46,12 +46,29 @@ const getGenderByCookie = (req) => {
return gender;
};
const vipLevel = (vipTitle) => {
return (function(title) {
if (title === '普通会员') {
return 0;
} else if (title === '银卡会员') {
return 1;
} else if (title === '金卡会员') {
return 2;
} else if (title === '白金会员') {
return 3;
} else {
return 0;
}
}(vipTitle));
};
module.exports = {
COOKIE_NAME_BOYS,
COOKIE_DOMAIN,
DEFAULT_AVATAR_ICO,
IMAGE_SERVICE_URL,
setSwitchToCookie,
getGenderByCookie
getGenderByCookie,
vipLevel
};
... ...
... ... @@ -31,7 +31,7 @@ const BLANK_STR = ' ';
const cachedRequestData = {};
// 展览票
const EXHIBITION_TICKET = 512579596;
const EXHIBITION_TICKET = 51335912;
const _getProductAdditionInfoAsync = (data) => {
return co(function * () {
... ... @@ -381,19 +381,19 @@ const _getSkuDataByProductBaseInfo = (data) => {
goodsGroup.size.push({
name: size.sizeName,
sku: size.goodsSizeSkuId,
num: parseInt(size.goodsSizeStorageNum, 10),
num: parseInt(size.goodsSizeStorageNum),
goodsId: size.goodsId
});
// 单个sku商品的总数
goodsGroup.total += parseInt(size.goodsSizeStorageNum, 10);
goodsGroup.total += parseInt(size.goodsSizeStorageNum);
if (goodsGroup.total > 0 && !chooseSkuFlag) { // 默认选中该sku商品
goodsGroup.focus = true;
chooseSkuFlag = true;// 选中sku商品
}
totalStorageNum += parseInt(size.goodsSizeStorageNum, 10);
totalStorageNum += parseInt(size.goodsSizeStorageNum);
});
... ... @@ -423,14 +423,14 @@ const _getSkuDataByProductBaseInfo = (data) => {
const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
// 潮流尖货状态
// getLimitedCode //限购码状态
// hasLimitedCode //是否已经获取限购码
// hadLimitedCode //是否已经获取限购码
// limitedCodeSoldOut //限购码是否已经抢光
// openSoon//即将开售
// dis //失效
// buyNow //是否立即购买
let result = {
getLimitedCode: true,
hasLimitedCode: false,
hadLimitedCode: false,
limitedCodeSoldOut: false,
openSoon: false,
dis: false,
... ... @@ -447,7 +447,7 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
result.dis = true;
} else {
result.openSoon = true;
result.hasLimitedCode = false;
result.hadLimitedCode = false;
}
break;
case 2: // 开售后,限购码已抢光(用户未领取限购码)
... ... @@ -455,7 +455,7 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
result.dis = true;
result.limitedCodeSoldOut = true;
result.getLimitedCode = false;
result.hasLimitedCode = false;
result.hadLimitedCode = false;
break;
case 3: // 开售后,商品已经售罄
result.soldOut = true;
... ... @@ -464,20 +464,20 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
case 4:// 开售后,立即购买(用户已领取限购码)
result.buyNow = true;
result.dis = false;
result.hasLimitedCode = true;
result.hadLimitedCode = true;
if (uid) { // 限购码失效
result.getLimitedCodeDis = true;
}
break;
case 5: // 开售前,限购码已被抢光(用户未领取限购码)
result.openSoon = true;
result.hasLimitedCode = true;
result.hadLimitedCode = true;
result.limitedCodeSoldOut = true;
result.getLimitedCode = false;
break;
case 6: // 开售前,即将开售(用户已领取限购码)
result.openSoon = true;
result.hasLimitedCode = true;
result.hadLimitedCode = true;
if (uid) { // 限购码失效
result.getLimitedCodeDis = true;
}
... ... @@ -485,7 +485,7 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
case 7: // 开售后,用户已经用获得的限购码购买过商品
result.buyNow = true;
result.dis = true;
result.hasLimitedCode = true;
result.hadLimitedCode = true;
if (uid) { // 限购码失效
result.getLimitedCodeDis = true;
}
... ... @@ -571,7 +571,7 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
result.tags = _getTagsDataByProductInfo(origin);
// 商品促销短语
if (origin.salesPhase) {
if (origin.salesPhrase) {
result.saleTip = origin.salesPhrase;
}
... ... @@ -596,7 +596,6 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
// VIP学生数据
result.vipPrice = _getVipDataByProductBaseInfo(origin, vipLevel, uid);
}
// 促销活动banner,虚拟商品无促销
if (origin.attribute !== 3) {
result.activity = _getActivityDataByProductBaseInfo(origin);
... ... @@ -662,9 +661,9 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
let fashTopGoods = _getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
result.fashTopGoods = {
result.fashionTopGoods = {
getLimitedCode: fashTopGoods.getLimitedCode, // 限购码状态
hasLimitedCode: fashTopGoods.hasLimitedCode, // 是否已经获取限购码
hadLimitedCode: fashTopGoods.hadLimitedCode, // 是否已经获取限购码
limitedCodeSoldOut: fashTopGoods.limitedCodeSoldOut, // 限购码是否已经抢光
getLimitedCodeDis: fashTopGoods.getLimitedCodeDis // 限购码是否失效
};
... ... @@ -757,7 +756,9 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
break;
default:
break;
{
break;
}
}
}
}
... ... @@ -765,7 +766,7 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
statGoodsInfo.imageUrl = result.img;
statGoodsInfo.productUrl = result.weixinUrl;
statGoodsInfo.smallSortId = result.smallSortId;
statGoodsInfo.soldOut = parseInt(soldOut, 10);
statGoodsInfo.soldOut = parseInt(soldOut);
return {
goodsInfo: result,
... ... @@ -1130,8 +1131,8 @@ const _getDetailDataBySizeInfo = (sizeInfo) => {
let details = '';
// 详情配图
if (sizeInfo.productIntroBo.productIntro) {
if (sizeInfo.productDescBo.phrase) {
if (_.get(sizeInfo, 'productIntroBo.productIntro', null)) {
if (_.get(sizeInfo, 'productIntroBo.phrase', null)) {
details += `${sizeInfo.productDescBo.phrase}<br/>`;
}
}
... ... @@ -1144,7 +1145,7 @@ const _getDetailDataBySizeInfo = (sizeInfo) => {
'///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==" data-original='
};
let intro = sizeInfo.productIntroBo.productIntro;
let intro = _.get(sizeInfo, 'productIntroBo.productIntro', '');
_(replacePairs).forEach((value, key)=> {
intro = _.replace(intro, key, value);
... ...
... ... @@ -5,14 +5,26 @@
'use strict';
const api = global.yoho.API;
const favApi = global.yoho.FavAPI;
const isFavoriteAsync = (uid, pid) => {
return api.get('', {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
});
let onNewApi = false;
if (onNewApi) {
return favApi.get('', {
method: 'app.favorite.isFavoriteNew',
id: pid,
uid: uid,
type: 'product'
});
} else {
return api.get('', {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
});
}
};
const createAsync = (uid, pid) => {
... ...
... ... @@ -37,6 +37,7 @@ const discountSplit = (text) => {
i;
text = text || '';
for (i = 0; i < text.length; i++) {
if (/^([0-9]|\%)*$/.test(text[i])) {
endNum = i + 1;
... ...
... ... @@ -224,7 +224,7 @@
{{/unless}}
<span class="size-warn warn-tip hide">
<i class="iconfont">&#xe62c;</i>
<i class="iconfont">&#xe61f;</i>
请选择尺码
</span>
</ul>
... ...
... ... @@ -15,8 +15,7 @@ module.exports = {
port: 6002,
siteUrl: 'http://www.yohobuy.com',
domains: {
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/',
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
search: 'http://192.168.102.216:8080/yohosearch/'
... ... @@ -99,12 +98,24 @@ if (isProduction) {
timeout: 3000
},
useOneapm: true,
useCache: true
useCache: true,
interfaceShunt: {
useInterfaceShunt: true,
tencentServers: {
api: ['123.206.1.98', '123.206.2.80'],
service: ['123.206.1.98', '123.206.2.80']
},
awsServers: {
api: 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
service: 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
}
}
});
} else if (isTest) {
Object.assign(module.exports, {
appName: 'www.yohobuy.com for test',
domains: {
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
search: 'http://192.168.102.216:8080/yohosearch/'
... ...
... ... @@ -15,7 +15,7 @@ exports.notFound = () => {
}
headerModel.requestHeaderData().then((result) => {
return res.render('error/404', {
return res.status(404).render('error/404', {
module: 'common',
page: 'error',
title: '页面不存在 | Yoho!Buy有货 | 潮流购物逛不停',
... ... @@ -43,7 +43,7 @@ exports.serverError = () => {
}
const renderErrPage = (result) => {
res.render('error/500', {
res.status(500).render('error/500', {
module: 'common',
page: 'error',
err: err,
... ...
... ... @@ -18,7 +18,7 @@ module.exports = () => {
// 获得vip 信息
if (req.user.uid && req.cookies._UID) {
let getVip = Fp.pipe(Fp.split('::'), Fp.take(2));
let getVip = Fp.pipe(Fp.split('::'), Fp.nth(2));
req.user.vip = getVip(req.cookies._UID);
}
... ...
{
"name": "yohobuy-node",
"version": "4.8.17",
"version": "4.8.18",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -59,7 +59,7 @@
"uuid": "^2.0.2",
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.1.4",
"yoho-node-lib": "0.0.38"
"yoho-node-lib": "0.0.40"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ...