Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop
Showing
7 changed files
with
74 additions
and
23 deletions
@@ -14,8 +14,8 @@ exports.getNewData = (params) => { | @@ -14,8 +14,8 @@ exports.getNewData = (params) => { | ||
14 | return api.get('', params).then(result => { | 14 | return api.get('', params).then(result => { |
15 | if (result.data) { | 15 | if (result.data) { |
16 | prettyFilter(result.data.filter); | 16 | prettyFilter(result.data.filter); |
17 | - result.data.productList = processProductList(result.data.productList); | ||
18 | result = camelCase(result); | 17 | result = camelCase(result); |
18 | + result.data.productList = processProductList(result.data.productList, {gender: params.gender}); | ||
19 | } | 19 | } |
20 | 20 | ||
21 | return result; | 21 | return result; |
@@ -28,7 +28,7 @@ const search = { | @@ -28,7 +28,7 @@ const search = { | ||
28 | if (result.code === 200) { | 28 | if (result.code === 200) { |
29 | prettyFilter(result.data.filter); | 29 | prettyFilter(result.data.filter); |
30 | result = camelCase(result); | 30 | result = camelCase(result); |
31 | - result.data.productList = processProductList(result.data.productList); | 31 | + result.data.productList = processProductList(result.data.productList, {gender: params.gender}); |
32 | } | 32 | } |
33 | return result; | 33 | return result; |
34 | }); | 34 | }); |
@@ -4,10 +4,15 @@ | @@ -4,10 +4,15 @@ | ||
4 | * @author: Aiden Xu<aiden.xu@yoho.cn> | 4 | * @author: Aiden Xu<aiden.xu@yoho.cn> |
5 | * @date: 2016/4/27 | 5 | * @date: 2016/4/27 |
6 | */ | 6 | */ |
7 | +const channelGender = require('./doraemon/middleware/channel-gender').channelGender; | ||
7 | 8 | ||
8 | module.exports = app => { | 9 | module.exports = app => { |
9 | app.use('/', require('./apps/channel')); // 一级频道模块 | 10 | app.use('/', require('./apps/channel')); // 一级频道模块 |
10 | - app.use('/', require('./apps/product')); // 商品模块 | 11 | + // 商品模块 |
12 | + app.use('/' | ||
13 | + , channelGender | ||
14 | + , require('./apps/product') | ||
15 | + ); | ||
11 | app.use('/', require('./apps/me')); // 个人中心 | 16 | app.use('/', require('./apps/me')); // 个人中心 |
12 | app.use('/api', require('./apps/api')); // 各模块公有 API | 17 | app.use('/api', require('./apps/api')); // 各模块公有 API |
13 | app.use('/editorial', require('./apps/editorial')); // 资讯 | 18 | app.use('/editorial', require('./apps/editorial')); // 资讯 |
doraemon/middleware/channel-gender.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +const path = require('path'); | ||
4 | +const utilsPath = path.join(global.utils, '/constant'); | ||
5 | +const channelDict = require(utilsPath).channelDict; | ||
6 | + | ||
7 | + | ||
8 | +// 如果 没有 gender, 根据channel,设置gender | ||
9 | +// Notice: 如果 没有 channel,则不设 gender | ||
10 | +exports.channelGender = (req, res, next) => { | ||
11 | + if (!req.query.hasOwnProperty('gender')) { | ||
12 | + const channel = channelDict(req.cookies._Channel); | ||
13 | + | ||
14 | + channel && (req.query.gender = channel); | ||
15 | + } | ||
16 | + | ||
17 | + next(); | ||
18 | +}; |
@@ -7,9 +7,9 @@ | @@ -7,9 +7,9 @@ | ||
7 | <img v-lazy="editorial.src | resize 750 470" alt="" /> | 7 | <img v-lazy="editorial.src | resize 750 470" alt="" /> |
8 | </a> | 8 | </a> |
9 | </div> | 9 | </div> |
10 | - <div class="title"><a href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a></div> | 10 | + <div class="title"><a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a></div> |
11 | <div class="editorial-des"> | 11 | <div class="editorial-des"> |
12 | - {{editorial.intro}} | 12 | + <p class="line-clamp-2">{{editorial.intro}}</p> |
13 | </div> | 13 | </div> |
14 | <hr> | 14 | <hr> |
15 | <div class="bottom clearfix"> | 15 | <div class="bottom clearfix"> |
@@ -40,11 +40,6 @@ | @@ -40,11 +40,6 @@ | ||
40 | font-size: 32px; | 40 | font-size: 32px; |
41 | font-weight: 700; | 41 | font-weight: 700; |
42 | padding: 10px 20px; | 42 | padding: 10px 20px; |
43 | - text-overflow: ellipsis; | ||
44 | - overflow-y: hidden; | ||
45 | - display: -webkit-box; | ||
46 | - -webkit-line-clamp: 2; | ||
47 | - -webkit-box-orient: vertical; | ||
48 | } | 43 | } |
49 | 44 | ||
50 | .editorial-des { | 45 | .editorial-des { |
1 | 'use strict'; | 1 | 'use strict'; |
2 | +const path = require('path'); | ||
2 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
3 | const camelCase = global.yoho.camelCase; | 4 | const camelCase = global.yoho.camelCase; |
4 | const helpers = global.yoho.helpers; | 5 | const helpers = global.yoho.helpers; |
6 | +const utilsPath = path.join(global.utils, '/constant'); | ||
7 | +const genderMap = require(utilsPath).genderMap; | ||
5 | 8 | ||
6 | /** | 9 | /** |
7 | * 根据性别来决定 默认图片获取字段 如果是 2、3 | 10 | * 根据性别来决定 默认图片获取字段 如果是 2、3 |
8 | - * | ||
9 | - * 则优先从cover2 --》 cover1 -- 》 images_url | ||
10 | - * 否则优先从cover1 --》 cover2 -- 》 images_url | ||
11 | - * | ||
12 | */ | 11 | */ |
13 | -const _procProductImg = (product, gender, yhChannel) => { | ||
14 | - if (gender === '2,3' || gender === '2' || gender === '3' && yhChannel === '2') { | ||
15 | - return product.cover2 || product.imagesUrl || product.cover1 || ''; | 12 | +const _procProductImg = (product, genderVal) => { |
13 | + let defaultImages; | ||
14 | + | ||
15 | + switch (genderVal) { | ||
16 | + case genderMap.men: | ||
17 | + defaultImages = product.cover1 || product.imagesUrl; | ||
18 | + break; | ||
19 | + case genderMap.women: | ||
20 | + defaultImages = product.cover2 || product.imagesUrl; | ||
21 | + break; | ||
22 | + default: | ||
23 | + defaultImages = product.imagesUrl || product.cover1 || product.cover2; | ||
24 | + break; | ||
16 | } | 25 | } |
17 | 26 | ||
18 | - return product.cover1 || product.imagesUrl || product.cover2 || ''; | 27 | + defaultImages || (defaultImages = ''); |
28 | + | ||
29 | + return defaultImages; | ||
19 | }; | 30 | }; |
20 | 31 | ||
21 | /** | 32 | /** |
@@ -32,11 +43,13 @@ module.exports = (list, options) => { | @@ -32,11 +43,13 @@ module.exports = (list, options) => { | ||
32 | height: 388, | 43 | height: 388, |
33 | isApp: false, | 44 | isApp: false, |
34 | showPoint: true, | 45 | showPoint: true, |
35 | - gender: '2,3', | 46 | + gender: '', |
36 | yhChannel: '' | 47 | yhChannel: '' |
37 | }, options); | 48 | }, options); |
38 | list = camelCase(list); | 49 | list = camelCase(list); |
39 | 50 | ||
51 | + let genderVal = options.gender.split(',')[0]; | ||
52 | + | ||
40 | _.forEach(list, (product) => { | 53 | _.forEach(list, (product) => { |
41 | // 商品信息有问题,则不显示 | 54 | // 商品信息有问题,则不显示 |
42 | if (!product.productId || !product.goodsList.length) { | 55 | if (!product.productId || !product.goodsList.length) { |
@@ -59,18 +72,17 @@ module.exports = (list, options) => { | @@ -59,18 +72,17 @@ module.exports = (list, options) => { | ||
59 | // 如果设置了默认图片,就取默认的图片 | 72 | // 如果设置了默认图片,就取默认的图片 |
60 | _.forEach(product.goodsList, (goods) => { | 73 | _.forEach(product.goodsList, (goods) => { |
61 | if (flag) { | 74 | if (flag) { |
62 | - return; | 75 | + return false; |
63 | } | 76 | } |
64 | if (goods.isDefault === 'Y') { | 77 | if (goods.isDefault === 'Y') { |
65 | - // product.defaultImages = procProductImg(goods); | ||
66 | - product.defaultImages = product.defaultImages; | 78 | + product.defaultImages = _procProductImg(goods, genderVal); |
67 | flag = true; | 79 | flag = true; |
68 | } | 80 | } |
69 | }); | 81 | }); |
70 | 82 | ||
71 | // 如果还未赋值,则取第一个skc产品的默认图片 | 83 | // 如果还未赋值,则取第一个skc产品的默认图片 |
72 | if (!flag) { | 84 | if (!flag) { |
73 | - product.defaultImages = _procProductImg(product.goodsList[0], product.gender, options.yhChannel); | 85 | + product.defaultImages = _procProductImg(product.goodsList[0], genderVal); |
74 | } | 86 | } |
75 | 87 | ||
76 | product.isSoonSoldOut = product.isSoonSoldOut === 'Y'; | 88 | product.isSoonSoldOut = product.isSoonSoldOut === 'Y'; |
utils/constant.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +/** | ||
4 | + * 获取 频道值 | ||
5 | + */ | ||
6 | +const channelMap = { | ||
7 | + men: '1,3', | ||
8 | + women: '2,3', | ||
9 | + lifestyle: '4', | ||
10 | +}; | ||
11 | + | ||
12 | +exports.genderMap = { | ||
13 | + men: '1', | ||
14 | + women: '2' | ||
15 | +}; | ||
16 | + | ||
17 | +exports.channelDict = (channelName) => { | ||
18 | + let val = channelMap[channelName]; | ||
19 | + | ||
20 | + return val ? val : ''; | ||
21 | +}; |
-
Please register or login to post a comment