Authored by 沈志敏

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

... ... @@ -14,8 +14,8 @@ exports.getNewData = (params) => {
return api.get('', params).then(result => {
if (result.data) {
prettyFilter(result.data.filter);
result.data.productList = processProductList(result.data.productList);
result = camelCase(result);
result.data.productList = processProductList(result.data.productList, {gender: params.gender});
}
return result;
... ...
... ... @@ -28,7 +28,7 @@ const search = {
if (result.code === 200) {
prettyFilter(result.data.filter);
result = camelCase(result);
result.data.productList = processProductList(result.data.productList);
result.data.productList = processProductList(result.data.productList, {gender: params.gender});
}
return result;
});
... ...
... ... @@ -4,10 +4,15 @@
* @author: Aiden Xu<aiden.xu@yoho.cn>
* @date: 2016/4/27
*/
const channelGender = require('./doraemon/middleware/channel-gender').channelGender;
module.exports = app => {
app.use('/', require('./apps/channel')); // 一级频道模块
app.use('/', require('./apps/product')); // 商品模块
// 商品模块
app.use('/'
, channelGender
, require('./apps/product')
);
app.use('/', require('./apps/me')); // 个人中心
app.use('/api', require('./apps/api')); // 各模块公有 API
app.use('/editorial', require('./apps/editorial')); // 资讯
... ...
'use strict';
const path = require('path');
const utilsPath = path.join(global.utils, '/constant');
const channelDict = require(utilsPath).channelDict;
// 如果 没有 gender, 根据channel,设置gender
// Notice: 如果 没有 channel,则不设 gender
exports.channelGender = (req, res, next) => {
if (!req.query.hasOwnProperty('gender')) {
const channel = channelDict(req.cookies._Channel);
channel && (req.query.gender = channel);
}
next();
};
... ...
... ... @@ -7,9 +7,9 @@
<img v-lazy="editorial.src | resize 750 470" alt="" />
</a>
</div>
<div class="title"><a href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a></div>
<div class="title"><a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a></div>
<div class="editorial-des">
{{editorial.intro}}
<p class="line-clamp-2">{{editorial.intro}}</p>
</div>
<hr>
<div class="bottom clearfix">
... ... @@ -40,11 +40,6 @@
font-size: 32px;
font-weight: 700;
padding: 10px 20px;
text-overflow: ellipsis;
overflow-y: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.editorial-des {
... ...
'use strict';
const path = require('path');
const _ = require('lodash');
const camelCase = global.yoho.camelCase;
const helpers = global.yoho.helpers;
const utilsPath = path.join(global.utils, '/constant');
const genderMap = require(utilsPath).genderMap;
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
*
* 则优先从cover2 --》 cover1 -- 》 images_url
* 否则优先从cover1 --》 cover2 -- 》 images_url
*
*/
const _procProductImg = (product, gender, yhChannel) => {
if (gender === '2,3' || gender === '2' || gender === '3' && yhChannel === '2') {
return product.cover2 || product.imagesUrl || product.cover1 || '';
const _procProductImg = (product, genderVal) => {
let defaultImages;
switch (genderVal) {
case genderMap.men:
defaultImages = product.cover1 || product.imagesUrl;
break;
case genderMap.women:
defaultImages = product.cover2 || product.imagesUrl;
break;
default:
defaultImages = product.imagesUrl || product.cover1 || product.cover2;
break;
}
return product.cover1 || product.imagesUrl || product.cover2 || '';
defaultImages || (defaultImages = '');
return defaultImages;
};
/**
... ... @@ -32,11 +43,13 @@ module.exports = (list, options) => {
height: 388,
isApp: false,
showPoint: true,
gender: '2,3',
gender: '',
yhChannel: ''
}, options);
list = camelCase(list);
let genderVal = options.gender.split(',')[0];
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product.productId || !product.goodsList.length) {
... ... @@ -59,18 +72,17 @@ module.exports = (list, options) => {
// 如果设置了默认图片,就取默认的图片
_.forEach(product.goodsList, (goods) => {
if (flag) {
return;
return false;
}
if (goods.isDefault === 'Y') {
// product.defaultImages = procProductImg(goods);
product.defaultImages = product.defaultImages;
product.defaultImages = _procProductImg(goods, genderVal);
flag = true;
}
});
// 如果还未赋值,则取第一个skc产品的默认图片
if (!flag) {
product.defaultImages = _procProductImg(product.goodsList[0], product.gender, options.yhChannel);
product.defaultImages = _procProductImg(product.goodsList[0], genderVal);
}
product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
... ...
'use strict';
/**
* 获取 频道值
*/
const channelMap = {
men: '1,3',
women: '2,3',
lifestyle: '4',
};
exports.genderMap = {
men: '1',
women: '2'
};
exports.channelDict = (channelName) => {
let val = channelMap[channelName];
return val ? val : '';
};
... ...