Authored by yyq

Merge branch 'release/5.4.1' of git.yoho.cn:fe/yohobuy-node into release/5.4.1

... ... @@ -91,10 +91,6 @@ const miniCart = (req, res, next) => {
data: ret
};
if (req.query.json === '1') {
return res.send(dest);
}
res.type('text/javascript');
res.send(req.query.callback + '(' + JSON.stringify(dest) + ')');
}).catch(next);
... ... @@ -153,10 +149,6 @@ const cart = (req, res, next) => {
service.getCartData(uid, shoppingKey)
.then(ret => {
if (req.query.json === '1') {
return res.send(ret);
}
return res.render('cart', {
title: '购物车 | ' + (res.locals.title || ''),
module: 'cart',
... ...
... ... @@ -140,7 +140,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
if (it.min_buy_number) {
goods.minBuyNumber = Number(it.min_buy_number);
if(goods.minBuyNumber > 1) {
if (goods.minBuyNumber > 1) {
goods.tipMessage = goods.minBuyNumber + '件起购';
}
}
... ... @@ -535,6 +535,9 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
let advCartData = _.get(cartData, 'advance_cart_data');
let ordCartData = _.get(cartData, 'ordinary_cart_data');
// 移除的商品列表
result.deleteShop = cartDelList;
// 接口异常时,购物车置为空
if (!cartData) {
result.isEmpty = true;
... ... @@ -595,12 +598,19 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
if (!result.advanceCart && !result.ordinaryCart) {
result.isEmpty = true;
return result;
}
if (_.get(result, 'ordinaryCart.promotionInfos')) {
result.ordinaryCart.promotionInfos = _.filter(result.ordinaryCart.promotionInfos, pinfo => {
return pinfo && pinfo.tag && pinfo.promotionId > 0;
});
}
// promotionInfos, gifts, priceGifts 放一起展示
let hasGifts = result.ordinaryCart.gifts && result.ordinaryCart.gifts.length;
let hasPrices = result.ordinaryCart.priceGifts && result.ordinaryCart.priceGifts.length;
let hasPromo = result.ordinaryCart.promotionInfos && result.ordinaryCart.promotionInfos.length;
let hasGifts = _.get(result, 'ordinaryCart.gifts') && _.get(result, 'ordinaryCart.gifts').length;
let hasPrices = _.get(result, 'ordinaryCart.priceGifts') && _.get(result, 'ordinaryCart.priceGifts').length;
let hasPromo = _.get(result, 'ordinaryCart.promotionInfos') && _.get(result, 'ordinaryCart.promotionInfos').length;
let orderAmount = (parseFloat(_.get(advStat, 'orderAmount', 0)) +
parseFloat(_.get(ordStat, 'orderAmount', 0))).toFixed(2);
let lastOrderAmount = (parseFloat(_.get(advStat, 'lastOrderAmount', 0)) +
... ... @@ -618,9 +628,6 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
selectedGoodsCount: _.get(advStat, 'selectedGoodsCount', 0) + _.get(ordStat, 'selectedGoodsCount', 0)
};
// 移除的商品列表
result.deleteShop = cartDelList;
// 普通购物车和预售购物车都为空
/* if (ordinaryCount === 0 && advanceCount === 0 && ordinarySoldOut && advanceSoldOut) {
result.isEmpty = true;
... ...
... ... @@ -11,6 +11,7 @@ const _ = require('lodash');
const guangModel = require('../models/index');
const headerModel = require('../../../doraemon/models/header');
const ghelper = require('../models/guang-helper');
const urlHelper = require('../models/url-helper');
const querystring = require('querystring');
const helpers = global.yoho.helpers;
... ... @@ -58,7 +59,7 @@ exports.index = (req, res, next) => {
pageSize: pageSize,
type: type,
pathNav: pathNav,
baseUrl: helpers.urlFormat('/' + channel + `-t${type}`, null, 'guang'),
baseUrl: urlHelper.listUrl(channel, type),
page: page,
total: (ret[2] && ret[2].total) || 0
},
... ... @@ -169,7 +170,7 @@ exports.editor = (req, res, next) => {
exRecos: ret[4],
gender: gender,
baseUrl: helpers.urlFormat('/' + channel + `-author-i${authorId}`, null, 'guang'),
baseUrl: urlHelper.editorUrl(channel, authorId),
pageSize: pageSize,
pathNav: pathNav,
page: page,
... ...
... ... @@ -38,7 +38,7 @@ exports.spager = function() {
pageSizeVar = options.hash.pageSizeVar || 'pageSize';
// 清除原来page(page=1&) 重新定义page
let clearPageReg = new RegExp(pageVar + '=[^&]*(&|$)'),
let clearPageReg = /\/$/,
clearSizeReg = new RegExp(pageSizeVar + '=[^&]*(&|$)'),
base = baseUrl.replace(clearPageReg, '');
... ...
... ... @@ -8,7 +8,7 @@
const _ = require('lodash');
const moment = require('moment');
const ghelper = require('./guang-helper');
const urlHelper = require('./urlHelper');
const urlHelper = require('./url-helper');
const helpers = global.yoho.helpers;
const serviceApi = global.yoho.ServiceAPI;
... ...
... ... @@ -7,7 +7,7 @@
const helpers = global.yoho.helpers;
module.exports.editorUrl = function(channel, authorId) {
return helpers.urlFormat(`/${channel}-author-i${authorId}/`, null, 'guang');
return helpers.urlFormat(`/author-${channel}-${authorId}/`, null, 'guang');
};
module.exports.listUrl = function(channel, type) {
... ...
... ... @@ -17,7 +17,7 @@ module.exports = [
return req.path === '/';
},
target: (req) => {
return helpers.urlFormat(`/${req.query.channel || 'boys'}/`, null, 'guang');
return helpers.urlFormat(`/${req.yoho.channel}/`, null, 'guang');
}
},
... ... @@ -25,9 +25,22 @@ module.exports = [
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)(\/*)$/,
target: (req, match, p1) => {
req.query.channel = p1;
return `/guang/?chanel=${p1}`;
target: (req, match, channel) => {
req.query.channel = channel;
return `/guang/?chanel=${channel}`;
}
},
// 老的首页 + 类型 + 翻页
{
type: TYPE.redirect,
origin: req => /index\/index/i.test(req.path),
target: (req) => {
return helpers.urlFormat(
`/${req.yoho.channel}-t${req.query.type || 0}${req.query.page ? '-p' + req.query.page : ''}/`,
null,
'guang'
);
}
},
... ... @@ -35,10 +48,10 @@ module.exports = [
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
target: (req, match, p1, p2) => {
req.query.channel = p1;
req.query.type = p2;
return `/guang/?chanel=${p1}&type=${p2}`;
target: (req, match, channel, type) => {
req.query.channel = channel;
req.query.type = type;
return `/guang/?chanel=${channel}&type=${type}`;
}
},
... ... @@ -46,11 +59,11 @@ module.exports = [
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, p1, p2, p3) => {
req.query.channel = p1;
req.query.type = p2;
req.query.page = p3;
return `/guang/index/index/?type=${p2}&channel=${p3}`;
target: (req, match, channel, type, page) => {
req.query.channel = channel;
req.query.type = type;
req.query.page = page;
return `/guang/index/index/?type=${type}&channel=${page}`;
}
},
... ... @@ -62,39 +75,39 @@ module.exports = [
},
target: (req) => {
let channel = req.yoho.channel;
let aid = req.query.author_id;
let authorId = req.query.author_id;
let page = req.query.page;
if (!aid) {
if (!authorId) {
return helpers.urlFormat(`/${channel}/`, null, 'guang');
}
req.mobileUrl = `${MOBILE_DOMAIN}/author/${aid}/`;
return helpers.urlFormat(`/${channel}-author-i${aid}/`, null, 'guang');
return helpers.urlFormat(`/author-${channel}-${authorId}${page ? '-p' + page : ''}/`, null, 'guang');
}
},
// 编缉首页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-author-i([\d]+)(\/*)$/,
target: (req, match, p1, p2) => {
req.query.channel = p1;
req.query.author_id = p2;
req.mobileUrl = `${MOBILE_DOMAIN}/author/${p2}/`;
return `/guang/index/editor?channel=${p1}&author_id=${p2}`;
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
target: (req, match, channel, authorId) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
}
},
// 编缉首页 + 翻页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-author-i([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, p1, p2, p3) => {
req.query.channel = p1;
req.query.author_id = p2;
req.query.page = p3;
req.mobileUrl = `${MOBILE_DOMAIN}/author/${p2}`;
return `/guang/index/editor?channel=${p1}&author_id=${p2}&page=${p3}`;
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, authorId, page) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.query.page = page;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
}
}
... ...
... ... @@ -55,7 +55,8 @@ module.exports = () => {
if (guangDetailReg.test(url)) {
data.mobileRefer += url.replace(/\/guang\/info\/index/, '/info/index');
} else if (url === '/guang/index/editor') {
data.mobileRefer += `/author/${req.query.author_id}/`;
data.mobileRefer += `/author-${req.yoho.channel}-${req.query.author_id}/`;
req.query = {};
}
} else if (proRegNew.test(url)) {
data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`);
... ...
... ... @@ -209,29 +209,29 @@
</div>
{{/stat}}
{{#if deleteShop}}
<div class="cart-del-goods">
<div class="cart-del-goods-title">已删除商品,您可以重新购买或移入收藏:</div>
<ul id="Y_delReselWrap">
{{#each deleteShop}}
<li data-sku="{{productSku}}"
data-promotionid="{{promotionId}}"
data-num="{{productNum}}">
{{> mix/cart/cart-pre-sell-tpl }}
</div>
{{/if}}
{{#if deleteShop}}
<div class="cart-del-goods">
<div class="cart-del-goods-title">已删除商品,您可以重新购买或移入收藏:</div>
<ul id="Y_delReselWrap">
{{#each deleteShop}}
<li data-sku="{{productSku}}"
data-promotionid="{{promotionId}}"
data-num="{{productNum}}">
<span class="good-name" style="width: 392px;">
<a href="{{link}}" target="_blank" title="{{productTitle}}">{{productTitle}}</a>
</span>
<span class="good-price" style="width: 148px;">{{productPrice}}</span>
<span class="good-num" style="width: 128px;">{{productNum}}</span>
<span class="good-price" style="width: 148px;">{{productPrice}}</span>
<span class="good-num" style="width: 128px;">{{productNum}}</span>
<span class="good-operate" style="width: 260px;">
<a href="javascript:void(0);" data-role="readd2cart">重新购买</a>
<a href="javascript:void(0);" data-role="reFav">移入收藏</a>
</span>
</li>
{{/each}}
</ul>
</div>
{{/if}}
{{> mix/cart/cart-pre-sell-tpl }}
</li>
{{/each}}
</ul>
</div>
{{/if}}
... ...
... ... @@ -1025,7 +1025,7 @@
background: transparent;
font-size: 14px;
font-weight: 300;
margin-top: 5px;
margin-top: 3px;
color:#ff575c;
&.tip-message-coin {
color: #000;
... ...