Authored by 陈峰

Merge branch 'gray' into 'master'

Gray



See merge request !336
... ... @@ -9,6 +9,8 @@
const _ = require('lodash');
const helper = global.yoho.helpers;
const utils = require('./utils');
/**
* 处理商品
*/
... ... @@ -33,7 +35,6 @@ function index(skn, limit) {
limit: limit
}
}).then(result => {
if (result.code === 200) {
let data = [];
let historyProduct = result.data.product_list;
... ... @@ -45,12 +46,10 @@ function index(skn, limit) {
let mp = hp.market_price;
let sp = hp.sales_price;
let goodsImg = hp.default_images || '';
let defaultGoods = _.find(hp.goods_list, {is_default: 'Y'});
// 无默认商品取商品列表第一个
if (!defaultGoods) {
defaultGoods = hp.goods_list[0];
if (goodsImg && goodsImg.indexOf('static.') < 0) {
goodsImg = utils.getUploadImgAbsoluteUrl(goodsImg, 'goodsimg');
}
data.push({
... ... @@ -58,7 +57,7 @@ function index(skn, limit) {
price: ${helper.round(sp, 2)}`,
product_name: hp.product_name,
url: helper.getUrlBySkc(hp.product_skn),
pic_url: defaultGoods && helper.image(defaultGoods.images_url, 280, 382, 2, 70)
pic_url: goodsImg && helper.image(goodsImg, 280, 382, 2, 70)
});
});
... ...
... ... @@ -41,8 +41,10 @@ exports.editAddress = (req, res, next) => {
// 真实数据输出
req.ctx(addressModel).editAddress(req.body, uid).then(result => {
result.data.address = cleanHtml.htmlDecode(result.data.address);
result.data.consignee = cleanHtml.htmlDecode(result.data.consignee);
if (result && result.data) {
result.data.address = cleanHtml.htmlDecode(result.data.address);
result.data.consignee = cleanHtml.htmlDecode(result.data.consignee);
}
res.json(result);
}).catch(next);
... ...
... ... @@ -91,8 +91,7 @@ module.exports = class extends global.yoho.BaseModel {
let product = yield currencyDataModel.getProduct(Number(val.key), 1);
if (_.get(product, 'code') === 200 &&
!_.isEmpty(product.data.product_list) &&
!_.isEmpty(product.data.product_list[0].goods_list)) {
!_.isEmpty(product.data.product_list)) {
let productSkn = _.get(product, 'data.product_list[0].product_skn');
result.list[key].detailUrl = helpers.getUrlBySkc(productSkn);
... ...
... ... @@ -167,8 +167,10 @@
<div class="content">
<span>付款方式:{{payMode}}</span>
<br />
{{#if phone}}
<br />
<span>电话号码:{{phone}}</span>
{{/if}}
</div>
</div>
{{/ virtualPayMode}}
... ...
... ... @@ -1619,7 +1619,7 @@ function recommendAsync(skn, page, limit) {
// 无默认商品取商品列表第一个
if (!defaultGoods) {
defaultGoods = rp.goods_list[0];
defaultGoods = rp.goods_list[0] || {};
}
return {
... ...
... ... @@ -117,12 +117,6 @@ const _proListHandler = (data, params) => {
// 普通商品
if (!pro.recommend_type) {
let defaultGoods = _.find(pro.goods_list, {is_default: 'Y'});
// 无默认商品取商品列表第一个
if (!defaultGoods) {
defaultGoods = pro.goods_list[0];
}
proObj = {
url: helpers.getUrlBySkc(pro.product_skn),
src: pro.default_images,
... ...
... ... @@ -613,7 +613,7 @@ exports.setShopSort = (data, params) => {
if (list.length) {
resData.goodsMenu = {
menuList: list,
url: `/product/shoplist?navBar=1&shopId=${params.shopId}`
url: `${params.baseUrl}?navBar=1`
};
}
}
... ...
... ... @@ -130,7 +130,7 @@ function _getShopData(channel, params, shopInfo) {
if (resData.allGoods) {
Object.assign(resData.allGoods, searchHandler.setShopSort(groupSort, Object.assign({},
params, {page: 1})), searchHandler.setGenderFilter(params));
params, {baseUrl, page: 1})), searchHandler.setGenderFilter(params));
}
}
... ...
... ... @@ -128,10 +128,10 @@
<div class="line"></div>
{{#if virtualGoods}}
{{!-- 电子门票按钮 --}}
{{#if isVirtualBtn}}
{{!-- 电子门票按钮 --}}
{{!-- {{#if isVirtualBtn}}
<span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}" data-base="{{buyNowBase}}">立即购买</span>
{{/if}}
{{/if}} --}}
{{else}}
{{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
{{#unless soldOut}}
... ... @@ -151,9 +151,7 @@
<span id="buy-now" class="item-buy buy-now{{#if dis}} dis{{/if}}"
data-base="{{buyNowBase}}">立即购买</span>
{{/ buyNow}}
{{/unless}}
{{/if}}
<span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}">
... ... @@ -163,10 +161,11 @@
<span id="enable-notify" class="buy-btn hide"> <i class="iconfont">
&#xe6e2;</i> <span>到货通知</span></span>
<span id="collect-product" class="{{#if isCollect}}coled {{/if}}collect-product">
<i class="iconfont">&#xe641;</i> {{#if isCollect}} <em>已收藏</em> {{^}} <em>收藏商品</em> {{/if}}
</span>
{{#unless isVirtualBtn}}
<span id="collect-product" class="{{#if isCollect}}coled {{/if}}collect-product">
<i class="iconfont">&#xe641;</i> {{#if isCollect}} <em>已收藏</em> {{^}} <em>收藏商品</em> {{/if}}
</span>
{{/unless}}
<span id="code-buy" class="code-buy" skn="{{skn}}">
<div class="code-box">
... ...
... ... @@ -7,6 +7,8 @@ module.exports = (req, res, next) => {
return csrfInit(req, res, (e) => {
res.locals.csrfToken = req.csrfToken();
e && (e.code = 403);
return next(e);
});
};
... ...
... ... @@ -57,6 +57,8 @@ exports.notFound = () => {
* @return {[type]}
*/
exports.serverError = () => {
const statusCodeList = [403];
return async(err, req, res, next) => {
forceNoCache(res);
... ... @@ -70,6 +72,10 @@ exports.serverError = () => {
err.code = parseInt(err.code || err.statusCode, 10) || 500;
if (statusCodeList.indexOf(err.code) >= 0) {
errorCode = err.code;
}
if (req.isApmReport && !err.apiError) { // apierror在node lib中已经上报过了 不需要再次上报
// 上报服务端错误
sender.addMessage({
... ...
... ... @@ -88,7 +88,7 @@
"postcss-clearfix": "^2.0.1",
"postcss-crip": "^2.0.1",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.4",
"postcss-loader": "^2.1.6",
"postcss-opacity": "^5.0.0",
"postcss-position": "^1.0.0",
"postcss-scss": "^1.0.5",
... ...
... ... @@ -11,6 +11,33 @@ const genderName = {
};
/**
* 处理接口返回图片链接,兼容非正常链接(如:/2015/10/22/08/023a5aa1cbdac7bdcd1685bfdab118b0c5.jpg)
*
*/
const handleGoodsThumb = (url, bucket) => {
url = url || '';
if (!url || url.indexOf('http') >= 0) {
return url;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/${bucket}`;
url = domain + url.split('?')[0] + '?imageMogr2/thumbnail/{width}x{height}/background/d2hpdGU=/position/center/quality/80'; // eslint-disable-line
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
};
/**
* 商品搜索商品数据处理
*/
exports.processProductList = (list, options) => {
... ... @@ -48,10 +75,17 @@ exports.processProductList = (list, options) => {
}
// 商品信息有问题,则不显示
if (!product || !product.product_skn || !_.get(product, 'goods_list.length', 0)) {
if (!product || !product.product_skn) {
return;
}
// 6.7 搜索去掉goods_list, 兼容处理
if (_.isEmpty(product.goods_list)) {
product.goods_list = [{
images_url: product.default_images
}];
}
let proInfo = {
skn: product.product_skn,
product_name: product.product_name,
... ... @@ -105,7 +139,7 @@ exports.processProductList = (list, options) => {
Object.assign(proInfo, {
goods_list: goodsList,
thumb: product.default_images || defaultColorImg
thumb: handleGoodsThumb(product.default_images || defaultColorImg, 'goodsimg')
});
// 处理标签
... ...
... ... @@ -14,6 +14,34 @@ const logger = global.yoho.logger;
// brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名]
// saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
// };
//
//
/**
* 处理接口返回图片链接,兼容非正常链接(如:/2015/10/22/08/023a5aa1cbdac7bdcd1685bfdab118b0c5.jpg)
*
*/
const handleGoodsThumb = (url, bucket) => {
url = url || '';
if (!url || url.indexOf('http') >= 0) {
return url;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/${bucket}`;
url = domain + url.split('?')[0] + '?imageMogr2/thumbnail/{width}x{height}/background/d2hpdGU=/position/center/quality/80'; // eslint-disable-line
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
};
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
... ... @@ -172,7 +200,7 @@ exports.processProductList = (list, options) => {
}
// 商品信息有问题,则不显示
if (!product || !product.product_skn || !_.get(product, 'goods_list.length', 0)) {
if (!product || !product.product_skn) {
return;
}
... ... @@ -186,6 +214,13 @@ exports.processProductList = (list, options) => {
// 判别默认的商品是否将默认的图片URL赋值到skn
let flag = false;
// 6.7 搜索去掉goods_list, 兼容处理
if (_.isEmpty(product.goods_list)) {
product.goods_list = [{
images_url: product.default_images
}];
}
_.remove(product.goods_list, function(n) {
return !+n.status;
});
... ... @@ -210,6 +245,9 @@ exports.processProductList = (list, options) => {
product.default_images = procProductImg(product.goods_list[0]);
}
}
product.default_images = handleGoodsThumb(product.default_images, 'goodsimg');
product = Object.assign(product, {
id: product.product_skn,
thumb: product.default_images
... ...