Authored by yyq

material

... ... @@ -33,6 +33,27 @@ const index = (req, res, next) => {
}).catch(next);
};
const indexNew = (req, res, next) => {
let unionType = req.query.union_type;
let params = req.query;
Model.canLogin(req.user.uid).then(canLogin => {
if (canLogin === 'N') {
return next();
} else {
Model.getApiRecommendProductList(params, unionType).then(result => {
res.render('material-new', Object.assign(result, {
unionType: unionType,
module: '3party',
page: 'material-new',
layout: false,
}));
}).catch(next);
}
}).catch(next);
};
const newBrandList = (req, res, next) => {
Model.newBrandList(req).then(data => {
res.send(data);
... ... @@ -83,6 +104,7 @@ const getRecommendlist = (req, res, next) => {
module.exports = {
index,
indexNew,
newBrandList,
getCategory,
getList,
... ...
'use strict';
const _ = require('lodash');
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const searchHandler = require('../../product/models/search-handler');
const platformApi = new global.yoho.ApiBase(global.yoho.config.domains.platformApi, {
name: 'imCs',
cache: global.yoho.cache,
... ... @@ -39,6 +44,42 @@ const getRecommendProductList = (params) => {
});
};
const getApiRecommendProductList = (params, unionType) => {
let qs = Object.assign({limit: 60}, params, {method: 'app.search.recommendProduct'}),
bqs = unionType ? {union_type: unionType} : {};
qs.size = qs.limit;
return Promise.all([
api.get('', qs, {code: 200}),
api.get('', {method: 'app.search.recommendProduct', size: 1}, {code: 200})
]).then(result => {
let resData = {};
let data = result[0].data;
if (data) {
data.paramBrand = _.split(qs.brand || '', ',');
resData = {
leftContent: searchHandler.handleSortData(_.get(result[1], 'data.filter.group_sort', []), bqs, params),
filters: searchHandler.handleFilterDataAll(data, params),
opts: searchHandler.handleOptsData(params, data.total, data.filter),
totalCount: data.total,
footPager: searchHandler.handlePagerData(data.total, params),
goods: _.map(productProcess.processProductList(data.product_list,
Object.assign({showDiscount: false}, params)), it => {
it.url += unionType ? `?union_type=${unionType}` : '';
return it;
})
};
_.set(resData, 'filters.brand.showAllBrands', true);
}
return resData;
});
};
const getRecommendlist = () => {
return platformApi.get('/platform/product/material/getRecommendlist', {
page: 1
... ... @@ -53,5 +94,6 @@ module.exports = {
getCategory,
getList,
getRecommendlist,
getApiRecommendProductList,
getRecommendProductList
};
... ...
... ... @@ -22,7 +22,8 @@ router.get('/ads', ads.jump);
router.get('/check', captcha.tryGeetest, robot.index);
router.post('/check', robot.check, robot.isHuman);
router.get('/material', auth, materialController.index);
router.get('/material', auth, materialController.indexNew);
router.get('/material/old', auth, materialController.index);
router.get('/material/newBrandList', auth, materialController.newBrandList);
router.get('/material/getCategory', auth, materialController.getCategory);
router.get('/material/getList', auth, materialController.getList);
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}"> {{#if cononicalURL}}
<link rel="cononical" href="{{cononicalURL}}" /> {{/if}}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="cleartype" content="on">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" /> {{#dnsPrefetch.hosts}}
<link rel="dns-prefetch" href="{{this}}"> {{/dnsPrefetch.hosts}}
{{#if devEnv}}
<link rel="stylesheet" href="//{{devHost}}:5002/css/base.css">
<link rel="stylesheet" href="//{{devHost}}:5002/css/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}">
{{^}}
<link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/base.css">
<link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}">
{{/if}}
</head>
<body>
<div class="product-material-new">
<h1><i class="logo"></i>商品素材列表页</h1>
<div class="product-page center-content clearfix">
{{> common/path-nav}}
<div class="list-left pull-left">
{{> product/left-content}}
</div>
<div class="list-right pull-right">
{{> product/standard-content}}
</div>
</div>
</div>
{{#if devEnv}}
<script src="//{{devHost}}:5002/libs.js"></script>
<script src="//{{devHost}}:5002/{{module}}.{{page}}.js"></script>
{{^}}
<script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/libs.js"></script>
<script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
{{> analysis}}
{{/if}}
</body>
</html>
... ...
... ... @@ -260,6 +260,7 @@ const formatterFilterBrands = (source, paramBrand, params) => {
if (source) {
let count = 0;
let checkedBrand = [];
_.forEach(source, function(value) {
let brand = {
... ... @@ -284,6 +285,10 @@ const formatterFilterBrands = (source, paramBrand, params) => {
dbrand.default.push(brand);
}
if (brand.checked) {
checkedBrand.push(brand);
}
dbrand.brandsShow.push(brand);
count++;
});
... ... @@ -305,6 +310,8 @@ const formatterFilterBrands = (source, paramBrand, params) => {
dbrand.selectedBrands.push(brand);
});
} else { // 当接口不返回paramBrand时,选中品牌设为遍历匹配出的品牌
dbrand.selectedBrands = checkedBrand;
}
// 没有品牌的情况下将 brand 设置为 false,前端不显示 品牌
... ... @@ -822,6 +829,11 @@ exports.handleFilterData = (origin, params, total) => {
if (params.id) {
remainParams.id = params.id;
}
if (params.union_type) {
remainParams.union_type = params.union_type;
}
dest.checkedConditions.clearUrl = '?' + queryString.stringify(remainParams);
// 处理频道筛选数据
... ...

4.65 KB | W: | H:

3.55 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
var $ = require('yoho-jquery');
var lazyLoad = require('yoho-jquery-lazyload');
var product = require('../product/index/product');
require('../common');
require('../plugins/filter');
require('../plugins/sort-pager');
product.init(4);
lazyLoad($('img.lazy'), {
failure_limit: 20
});
... ...
@import "robot-check";
@import "../variables";
@import "material";
@import "material-new";
@import "activate";
... ...
@import "../product/index";
.product-material-new {
font-family: "微软雅黑";
font-size: 14px;
.logo {
width: 171px;
height: 40px;
display: inline-block;
background-image: resolve(header/logo.png);
background-position: 0 0;
vertical-align: middle;
margin-right: 10px;
}
h1 {
font-size: 22px;
margin: 0 0 50px;
text-align: left;
width: 100%;
padding: 20px;
color: #a5a5a5;
box-sizing: border-box;
border-bottom: 1px solid #e2e2e2;
background: #f7f7f7;
}
.no-result {
.search-again {
display: none;
}
.no-tip {
margin-top: 20px;
}
}
.filter-box .brand .attr-content {
max-width: 730px;
}
}
... ...