Showing
9 changed files
with
186 additions
and
1 deletions
@@ -33,6 +33,27 @@ const index = (req, res, next) => { | @@ -33,6 +33,27 @@ const index = (req, res, next) => { | ||
33 | }).catch(next); | 33 | }).catch(next); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | + | ||
37 | +const indexNew = (req, res, next) => { | ||
38 | + let unionType = req.query.union_type; | ||
39 | + let params = req.query; | ||
40 | + | ||
41 | + Model.canLogin(req.user.uid).then(canLogin => { | ||
42 | + if (canLogin === 'N') { | ||
43 | + return next(); | ||
44 | + } else { | ||
45 | + Model.getApiRecommendProductList(params, unionType).then(result => { | ||
46 | + res.render('material-new', Object.assign(result, { | ||
47 | + unionType: unionType, | ||
48 | + module: '3party', | ||
49 | + page: 'material-new', | ||
50 | + layout: false, | ||
51 | + })); | ||
52 | + }).catch(next); | ||
53 | + } | ||
54 | + }).catch(next); | ||
55 | +}; | ||
56 | + | ||
36 | const newBrandList = (req, res, next) => { | 57 | const newBrandList = (req, res, next) => { |
37 | Model.newBrandList(req).then(data => { | 58 | Model.newBrandList(req).then(data => { |
38 | res.send(data); | 59 | res.send(data); |
@@ -83,6 +104,7 @@ const getRecommendlist = (req, res, next) => { | @@ -83,6 +104,7 @@ const getRecommendlist = (req, res, next) => { | ||
83 | 104 | ||
84 | module.exports = { | 105 | module.exports = { |
85 | index, | 106 | index, |
107 | + indexNew, | ||
86 | newBrandList, | 108 | newBrandList, |
87 | getCategory, | 109 | getCategory, |
88 | getList, | 110 | getList, |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | +const _ = require('lodash'); | ||
4 | +const utils = '../../../utils'; | ||
5 | +const productProcess = require(`${utils}/product-process`); | ||
6 | +const searchHandler = require('../../product/models/search-handler'); | ||
7 | + | ||
3 | const platformApi = new global.yoho.ApiBase(global.yoho.config.domains.platformApi, { | 8 | const platformApi = new global.yoho.ApiBase(global.yoho.config.domains.platformApi, { |
4 | name: 'imCs', | 9 | name: 'imCs', |
5 | cache: global.yoho.cache, | 10 | cache: global.yoho.cache, |
@@ -39,6 +44,42 @@ const getRecommendProductList = (params) => { | @@ -39,6 +44,42 @@ const getRecommendProductList = (params) => { | ||
39 | }); | 44 | }); |
40 | }; | 45 | }; |
41 | 46 | ||
47 | +const getApiRecommendProductList = (params, unionType) => { | ||
48 | + let qs = Object.assign({limit: 60}, params, {method: 'app.search.recommendProduct'}), | ||
49 | + bqs = unionType ? {union_type: unionType} : {}; | ||
50 | + | ||
51 | + qs.size = qs.limit; | ||
52 | + | ||
53 | + return Promise.all([ | ||
54 | + api.get('', qs, {code: 200}), | ||
55 | + api.get('', {method: 'app.search.recommendProduct', size: 1}, {code: 200}) | ||
56 | + ]).then(result => { | ||
57 | + let resData = {}; | ||
58 | + let data = result[0].data; | ||
59 | + | ||
60 | + if (data) { | ||
61 | + data.paramBrand = _.split(qs.brand || '', ','); | ||
62 | + resData = { | ||
63 | + leftContent: searchHandler.handleSortData(_.get(result[1], 'data.filter.group_sort', []), bqs, params), | ||
64 | + filters: searchHandler.handleFilterDataAll(data, params), | ||
65 | + opts: searchHandler.handleOptsData(params, data.total, data.filter), | ||
66 | + totalCount: data.total, | ||
67 | + footPager: searchHandler.handlePagerData(data.total, params), | ||
68 | + goods: _.map(productProcess.processProductList(data.product_list, | ||
69 | + Object.assign({showDiscount: false}, params)), it => { | ||
70 | + it.url += unionType ? `?union_type=${unionType}` : ''; | ||
71 | + | ||
72 | + return it; | ||
73 | + }) | ||
74 | + }; | ||
75 | + | ||
76 | + _.set(resData, 'filters.brand.showAllBrands', true); | ||
77 | + } | ||
78 | + | ||
79 | + return resData; | ||
80 | + }); | ||
81 | +}; | ||
82 | + | ||
42 | const getRecommendlist = () => { | 83 | const getRecommendlist = () => { |
43 | return platformApi.get('/platform/product/material/getRecommendlist', { | 84 | return platformApi.get('/platform/product/material/getRecommendlist', { |
44 | page: 1 | 85 | page: 1 |
@@ -53,5 +94,6 @@ module.exports = { | @@ -53,5 +94,6 @@ module.exports = { | ||
53 | getCategory, | 94 | getCategory, |
54 | getList, | 95 | getList, |
55 | getRecommendlist, | 96 | getRecommendlist, |
97 | + getApiRecommendProductList, | ||
56 | getRecommendProductList | 98 | getRecommendProductList |
57 | }; | 99 | }; |
@@ -22,7 +22,8 @@ router.get('/ads', ads.jump); | @@ -22,7 +22,8 @@ router.get('/ads', ads.jump); | ||
22 | router.get('/check', captcha.tryGeetest, robot.index); | 22 | router.get('/check', captcha.tryGeetest, robot.index); |
23 | router.post('/check', robot.check, robot.isHuman); | 23 | router.post('/check', robot.check, robot.isHuman); |
24 | 24 | ||
25 | -router.get('/material', auth, materialController.index); | 25 | +router.get('/material', auth, materialController.indexNew); |
26 | +router.get('/material/old', auth, materialController.index); | ||
26 | router.get('/material/newBrandList', auth, materialController.newBrandList); | 27 | router.get('/material/newBrandList', auth, materialController.newBrandList); |
27 | router.get('/material/getCategory', auth, materialController.getCategory); | 28 | router.get('/material/getCategory', auth, materialController.getCategory); |
28 | router.get('/material/getList', auth, materialController.getList); | 29 | router.get('/material/getList', auth, materialController.getList); |
apps/3party/views/action/material-new.hbs
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html lang="en"> | ||
3 | + | ||
4 | +<head> | ||
5 | + <meta charset="UTF-8"> | ||
6 | + <title>{{title}}</title> | ||
7 | + <meta name="keywords" content="{{keywords}}"> | ||
8 | + <meta name="description" content="{{description}}"> {{#if cononicalURL}} | ||
9 | + <link rel="cononical" href="{{cononicalURL}}" /> {{/if}} | ||
10 | + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
11 | + <meta http-equiv="cleartype" content="on"> | ||
12 | + <meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
13 | + <meta content="telephone=no" name="format-detection" /> | ||
14 | + <meta content="email=no" name="format-detection" /> {{#dnsPrefetch.hosts}} | ||
15 | + <link rel="dns-prefetch" href="{{this}}"> {{/dnsPrefetch.hosts}} | ||
16 | + {{#if devEnv}} | ||
17 | + <link rel="stylesheet" href="//{{devHost}}:5002/css/base.css"> | ||
18 | + <link rel="stylesheet" href="//{{devHost}}:5002/css/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}"> | ||
19 | + {{^}} | ||
20 | + <link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/base.css"> | ||
21 | + <link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}"> | ||
22 | + {{/if}} | ||
23 | +</head> | ||
24 | + | ||
25 | +<body> | ||
26 | + | ||
27 | + <div class="product-material-new"> | ||
28 | + <h1><i class="logo"></i>商品素材列表页</h1> | ||
29 | + <div class="product-page center-content clearfix"> | ||
30 | + {{> common/path-nav}} | ||
31 | + | ||
32 | + <div class="list-left pull-left"> | ||
33 | + {{> product/left-content}} | ||
34 | + </div> | ||
35 | + <div class="list-right pull-right"> | ||
36 | + {{> product/standard-content}} | ||
37 | + </div> | ||
38 | + </div> | ||
39 | + </div> | ||
40 | + {{#if devEnv}} | ||
41 | + <script src="//{{devHost}}:5002/libs.js"></script> | ||
42 | + <script src="//{{devHost}}:5002/{{module}}.{{page}}.js"></script> | ||
43 | + {{^}} | ||
44 | + <script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/libs.js"></script> | ||
45 | + <script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script> | ||
46 | + {{> analysis}} | ||
47 | + {{/if}} | ||
48 | +</body> | ||
49 | + | ||
50 | +</html> |
@@ -260,6 +260,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -260,6 +260,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
260 | 260 | ||
261 | if (source) { | 261 | if (source) { |
262 | let count = 0; | 262 | let count = 0; |
263 | + let checkedBrand = []; | ||
263 | 264 | ||
264 | _.forEach(source, function(value) { | 265 | _.forEach(source, function(value) { |
265 | let brand = { | 266 | let brand = { |
@@ -284,6 +285,10 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -284,6 +285,10 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
284 | dbrand.default.push(brand); | 285 | dbrand.default.push(brand); |
285 | } | 286 | } |
286 | 287 | ||
288 | + if (brand.checked) { | ||
289 | + checkedBrand.push(brand); | ||
290 | + } | ||
291 | + | ||
287 | dbrand.brandsShow.push(brand); | 292 | dbrand.brandsShow.push(brand); |
288 | count++; | 293 | count++; |
289 | }); | 294 | }); |
@@ -305,6 +310,8 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -305,6 +310,8 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
305 | 310 | ||
306 | dbrand.selectedBrands.push(brand); | 311 | dbrand.selectedBrands.push(brand); |
307 | }); | 312 | }); |
313 | + } else { // 当接口不返回paramBrand时,选中品牌设为遍历匹配出的品牌 | ||
314 | + dbrand.selectedBrands = checkedBrand; | ||
308 | } | 315 | } |
309 | 316 | ||
310 | // 没有品牌的情况下将 brand 设置为 false,前端不显示 品牌 | 317 | // 没有品牌的情况下将 brand 设置为 false,前端不显示 品牌 |
@@ -822,6 +829,11 @@ exports.handleFilterData = (origin, params, total) => { | @@ -822,6 +829,11 @@ exports.handleFilterData = (origin, params, total) => { | ||
822 | if (params.id) { | 829 | if (params.id) { |
823 | remainParams.id = params.id; | 830 | remainParams.id = params.id; |
824 | } | 831 | } |
832 | + | ||
833 | + if (params.union_type) { | ||
834 | + remainParams.union_type = params.union_type; | ||
835 | + } | ||
836 | + | ||
825 | dest.checkedConditions.clearUrl = '?' + queryString.stringify(remainParams); | 837 | dest.checkedConditions.clearUrl = '?' + queryString.stringify(remainParams); |
826 | 838 | ||
827 | // 处理频道筛选数据 | 839 | // 处理频道筛选数据 |
public/js/3party/material-new.page.js
0 → 100644
1 | +var $ = require('yoho-jquery'); | ||
2 | +var lazyLoad = require('yoho-jquery-lazyload'); | ||
3 | + | ||
4 | +var product = require('../product/index/product'); | ||
5 | + | ||
6 | +require('../common'); | ||
7 | +require('../plugins/filter'); | ||
8 | +require('../plugins/sort-pager'); | ||
9 | + | ||
10 | + | ||
11 | +product.init(4); | ||
12 | + | ||
13 | +lazyLoad($('img.lazy'), { | ||
14 | + failure_limit: 20 | ||
15 | +}); |
public/scss/3party/_material-new.css
0 → 100644
1 | +@import "../product/index"; | ||
2 | + | ||
3 | +.product-material-new { | ||
4 | + font-family: "微软雅黑"; | ||
5 | + font-size: 14px; | ||
6 | + | ||
7 | + .logo { | ||
8 | + width: 171px; | ||
9 | + height: 40px; | ||
10 | + display: inline-block; | ||
11 | + background-image: resolve(header/logo.png); | ||
12 | + background-position: 0 0; | ||
13 | + vertical-align: middle; | ||
14 | + margin-right: 10px; | ||
15 | + } | ||
16 | + | ||
17 | + h1 { | ||
18 | + font-size: 22px; | ||
19 | + margin: 0 0 50px; | ||
20 | + text-align: left; | ||
21 | + width: 100%; | ||
22 | + padding: 20px; | ||
23 | + color: #a5a5a5; | ||
24 | + box-sizing: border-box; | ||
25 | + border-bottom: 1px solid #e2e2e2; | ||
26 | + background: #f7f7f7; | ||
27 | + } | ||
28 | + | ||
29 | + .no-result { | ||
30 | + .search-again { | ||
31 | + display: none; | ||
32 | + } | ||
33 | + | ||
34 | + .no-tip { | ||
35 | + margin-top: 20px; | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + .filter-box .brand .attr-content { | ||
40 | + max-width: 730px; | ||
41 | + } | ||
42 | +} |
-
Please register or login to post a comment