Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/feature/brandsTree' into release/5.4.1

... ... @@ -20,28 +20,32 @@ const index = (req, res, next) => {
let categoryTab = req.query.tab || '';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
let brandCode;
let cateCode;
let isCate = categoryTab === 'category' ? true : false;
let appType = req.query.app_type || 1;
if (parseInt(gender, 10) === 1) {
brandCode = '7317a4701a1d3ddc8d93a5df77a63b75';
cateCode = '7f885e9cab53231cff34ea236f3f1120';
} else {
brandCode = '84313c4b293a1c0aea985aa16a42a6b5';
cateCode = 'a6f9dc00219eb7d08520a18864929a30';
}
brandModel.indexData(gender, brandCode, cateCode).then(result => {
brandModel.indexData(gender, brandCode, req.yoho.channel, appType).then(result => {
res.render('brand/brand', {
module: 'guang',
page: 'brand-list',
width750: true,
pageHeader: headerModel.setNav({
navTitle: ''
}),
categoryTab: isCate,
channel: result.channel ? result.channel : '',
brandList: result.brandList,
list: result.list ? result.list : '',
categoryData: result.categoryData
category: {
nav: result.categoryData.nav,
list: result.categoryData.list
}
});
}).catch(next);
};
... ... @@ -64,52 +68,7 @@ const brandList = (req, res, next) => {
}).catch(next);
};
const categoryData = (req, res, next) => {
let code;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (parseInt(gender, 10) === 1) {
code = '7f885e9cab53231cff34ea236f3f1120';
} else {
code = 'a6f9dc00219eb7d08520a18864929a30';
}
brandModel.categoryData(code).then(result => {
res.render('brand/category', {
layout: false,
categoryData: result.categoryData
});
}).catch(next);
};
// 全部分类
const cateAll = (req, res, next) => {
let appType = req.query.app_type || 1;
brandModel.getCateData(req.yoho.channel, appType).then((result) => {
res.render('brand/cate-all', {
module: 'guang',
page: 'cate-all',
title: '全部分类',
pageHeader: headerModel.setNav({
navTitle: '全部分类'
}),
pageFooter: false,
category: {
nav: result.nav,
list: result.list
// searchUrl: helpers.urlFormat('/search', null, 'search')
}
// showFooterTab: footerModel.getUrlData('category')
});
}).catch(next);
};
module.exports = {
index,
brandList,
categoryData,
cateAll
brandList
};
... ...
... ... @@ -6,13 +6,13 @@ const helpers = global.yoho.helpers;
const yhChannel = {
1: {
channel: '301'
channel: '1'
},
2: {
channel: '302'
channel: '2'
},
4: {
channel: '303'
channel: '3'
}
};
... ... @@ -219,20 +219,25 @@ const _processCateData = (list, channel, appType) => {
};
};
// const _dealBrandUrl = (list) => {
// var domain;
// _.forEach(list.data, function(val) {
// domain = val.url.substring(val.url.indexOf('shop/') + 5, val.url.indexOf('?'));
// val.url = '//m.yohobuy.com/product/index/brand?domain=' + domain;
// });
const _getCateData = (channel, appType) => {
return api.get('', {
method: 'app.sort.get',
app_type: 1
}, {
cache: true
}).then((result) => {
if (!result.code || result.code !== 200 || !result.data) {
return [];
}
// return list;
// };
return result.data;
}).then((list) => {
return _processCateData(list, channel, appType);
});
};
const indexData = (gender, brandCode, cateCode) => {
return Promise.all([_getChannelData(gender), _getResourcesData(brandCode), _getBrandListOriginData(gender), _getResourcesData(cateCode)]).then(result => {
const indexData = (gender, brandCode, channel, appType) => {
return Promise.all([_getChannelData(gender), _getResourcesData(brandCode), _getBrandListOriginData(gender), _getCateData(channel, appType)]).then(result => {
let brandList = {};
let list = {};
let categoryData = {};
... ... @@ -245,10 +250,8 @@ const indexData = (gender, brandCode, cateCode) => {
if (result[1]) {
_.forEach(result[1], function(data) {
if (data.focus_type && data.focus_type === '1') {
// brandList.bannerTop = _dealBrandUrl(data);
brandList.bannerTop = data;
} else if (data.focus_type && data.focus_type === '2') {
// brandList.focusData = _dealBrandUrl(data).data;
brandList.focusData = data.data;
} else if (data.template_name === 'single_image') {
brandList.bannerTop = data;
... ... @@ -263,26 +266,12 @@ const indexData = (gender, brandCode, cateCode) => {
}
if (result[3]) {
_.forEach(result[3], function(data) {
if (data.template_name === 'recommend_content_five') {
// _.forEach(data.data.list, function(val) {
// var param = val.url.substring(val.url.indexOf('list?') + 5);
// val.url = '//list.m.yohobuy.com/?' + param;
// });
categoryData.list = data.data.list;
} else if (data.template_name === 'focus') {
// _.forEach(data.data, function(val) {
// val.url = '//m.yohobuy.com/guang/cate-all';
// });
categoryData.focusData = data;
}
});
list.categoryData = result[3];
}
list.brandList = brandList;
list.categoryData = categoryData;
return list;
});
};
... ... @@ -295,10 +284,8 @@ const brandListData = (code, gender) => {
if (result[0]) {
_.forEach(result[0], function(data) {
if (data.focus_type && data.focus_type === '1') {
// brandList.bannerTop = _dealBrandUrl(data);
brandList.bannerTop = data;
} else if (data.focus_type && data.focus_type === '2') {
// brandList.focusData = _dealBrandUrl(data).data;
brandList.focusData = data.data;
} else if (data.template_name === 'single_image') {
brandList.bannerTop = data;
... ... @@ -316,64 +303,9 @@ const brandListData = (code, gender) => {
});
};
const categoryData = (code) => {
return _getResourcesData(code).then(result => {
let category = {};
let list = {};
if (result) {
_.forEach(result, function(data) {
if (data.template_name === 'recommend_content_five') {
// _.forEach(data.data.list, function(val) {
// var param = val.url.substring(val.url.indexOf('list?') + 5);
// val.url = '//list.m.yohobuy.com/?' + param;
// });
category.list = data.data.list;
} else if (data.template_name === 'focus') {
// _.forEach(data.data, function(val) {
// val.url = '//m.yohobuy.com/guang/cate-all';
// });
category.focusData = data;
}
});
}
list.categoryData = category;
return list;
});
};
const getCateData = (channel, appType) => {
return api.get('', {
method: 'app.sort.get',
app_type: 1
}, {
cache: true
}).then((result) => {
if (!result.code || result.code !== 200 || !result.data) {
return [];
}
// 统一频道名称
// result.data.boys = result.data.boy;
// result.data.girls = result.data.girl;
// _.unset(result.data, 'boy');
// _.unset(result.data, 'girl');
return result.data;
}).then((list) => {
return _processCateData(list, channel, appType);
});
};
module.exports = {
indexData,
brandListData,
categoryData,
getCateData
brandListData
};
... ...
... ... @@ -63,9 +63,7 @@ router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯
router.get('/info/listData', index.listDynamicData);
router.get('/info/detailData', index.detailDynamicData);
router.get('/brand', brand.index);
router.get('/brandList', brand.brandList);
router.get('/category', brand.categoryData);
router.get('/cate-all', brand.cateAll);
router.get('/plusstar/cate', brand.index);
router.get('/plusstar/brandList', brand.brandList);
module.exports = router;
... ...
... ... @@ -9,16 +9,8 @@
<li class="cate {{# categoryTab}}active{{/ categoryTab}}">鍝佺被</li>
</ul>
<div class="channel-tab">
<ul class="brand-cha{{# categoryTab}} hide{{/ categoryTab}}">
{{#each channel}}
<li class='{{#if focus}} focus {{/if}}' data-code='{{code}}'>
<span>{{mame}}</span>
</li>
{{/each}}
</ul>
<ul class="cate-cha{{#unless categoryTab}} hide{{/unless}}">
<div class="channel-tab{{# categoryTab}} hide{{/ categoryTab}}">
<ul class="brand-cha">
{{#each channel}}
<li class='{{#if focus}} focus {{/if}}' data-code='{{code}}'>
<span>{{mame}}</span>
... ... @@ -33,7 +25,7 @@
{{> brand/brand-list}}
</div>
<div class="category-content content{{#unless categoryTab}} hide{{/ unless}}">
{{> brand/category}}
{{> brand/cate-all}}
</div>
</div>
</div>
\ No newline at end of file
... ...
{{> brand/category}}
\ No newline at end of file
{{# categoryData}}
<div class="resources">
<div class="recommend-content-five">
{{# list}}
<a href="{{url}}">
<img src="{{image src 375 375}}">
</a>
{{/ list}}
</div>
<div class="focus-floor">
{{# focusData}}
{{> resources/banner-top}}
{{/ focusData}}
</div>
</div>
{{/ categoryData}}
... ... @@ -13,9 +13,6 @@ var $nav = $('.category-nav'),
$contents = $categoryContainer.children('.content'),
$subLevelItem = $categoryContainer.find('.sub-level li');
// $primaryItem = $categoryContainer.find('.primary-level li');
require('../common');
$(function() {
FastClick.attach(document.body);
... ... @@ -92,23 +89,9 @@ $categoryContainer.on('click', function(e) {
}
});
// $categoryContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
// $primaryItem.removeClass('highlight');
// $(this).addClass('highlight');
// }).on('touchend touchcancel', 'li', function() {
// $(this).removeClass('highlight');
// });
$categoryContainer.find('.sub-level').on('touchstart', 'li', function() {
$subLevelItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$nav.on('touchstart', 'li', function() {
$nav.find('li').removeClass('bytouch');
$(this).addClass('bytouch');
}).on('touchend touchcancel', 'li', function() {
$nav.find('li').removeClass('bytouch');
});
... ...
... ... @@ -2,13 +2,15 @@ var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper2');
var categoryHeight = $('.tab-box').height(),
gender,
isBrand;
gender;
var $intercept = $('.no-intercept'),
$list = $('.brand-list-box'),
$listBox = $('.list-box');
require('../common');
require('./brand-cate/cate-all');
function channels(key) {
var channel = {
men: 1,
... ... @@ -37,40 +39,28 @@ function initialize() {
});
}
function loadData(channel, isBrand) {
var preUrl;
if (isBrand) {
preUrl = '/guang/brandList';
} else {
preUrl = '/guang/category';
}
function loadData(channel) {
$.ajax({
method: 'get',
url: preUrl,
url: '/guang/plusstar/brandList',
data: {
gender: channel
},
success: function(data) {
if (isBrand) {
$('.brand-content').html(data);
} else {
$('.category-content').html(data);
}
$('.brand-content').html(data);
initialize();
}
});
}
$('.channel-tab').find('li').click(function() {
$('.brand-cha').find('li').click(function() {
gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase();
isBrand = $('.brand-tab').find('.brand').hasClass('active');
$(this).addClass('focus').siblings().removeClass('focus');
loadData(channels(gender), isBrand);
loadData(channels(gender));
});
// 点击字母,页面滚动到相关区域
... ... @@ -90,10 +80,11 @@ $('.brand-tab').find('li').click(function() {
if ($(this).hasClass('brand')) {
$('.brand-content').removeClass('hide').siblings().addClass('hide');
$('.channel-tab').removeClass('hide');
$('.brand-cha').removeClass('hide').siblings().addClass('hide');
} else {
$('.category-content').removeClass('hide').siblings().addClass('hide');
$('.cate-cha').removeClass('hide').siblings().addClass('hide');
$('.channel-tab').addClass('hide');
}
initialize();
... ... @@ -103,6 +94,32 @@ if ($listBox.find('li').length <= 0) {
$listBox.hide();
}
$(window).scroll(function() {
var totalHeight = $('#yoho-header').height() + $('.tab-box').height();
if (!$('.brand-content').hasClass('hide')) {
if ($(this).scrollTop() >= $('#yoho-header').height()) {
$('.tab-box').addClass('fastening');
$('.content-index').addClass('distance');
$('.list-box').css('top', $('.tab-box').height());
} else {
$('.tab-box').removeClass('fastening');
$('.content-index').removeClass('distance');
$('.list-box').css('top', totalHeight - $(this).scrollTop());
}
} else {
if ($(this).scrollTop() >= $('#yoho-header').height()) {
$('.tab-box').addClass('fastening');
$('.category-nav').addClass('loca');
$('.blk-cate-all .content').addClass('living');
} else {
$('.tab-box').removeClass('fastening');
$('.category-nav').removeClass('loca');
$('.blk-cate-all .content').removeClass('living');
}
}
});
$(function() {
$('.banner-swiper').each(function() {
if (!$(this).parents('.content').hasClass('hide') && $(this).hasClass('swiper-container-horizontal') === false && $(this).find('li').length > 1) {
... ...
... ... @@ -2,8 +2,11 @@
font-size: 15PX;
.category-nav {
height: 70px;
height: 80px;
border-bottom: 1px solid #e6e6e6;
width: 100%;
background: #fff;
z-index: 10;
li {
display: block;
... ... @@ -33,13 +36,13 @@
width: 100%;
height: 30px;
line-height: 30px;
font-size: 15PX;
border-right: 1px solid #e6e6e6;
font-size: 80%;
}
}
li:last-child span {
border-right: 0;
}
.loca {
position: fixed;
top: 88px;
}
.content {
... ... @@ -51,6 +54,10 @@
}
}
.living {
margin-top: 160px;
}
.primary-level {
float: left;
box-sizing: border-box;
... ...
... ... @@ -12,5 +12,4 @@
@import "info-list";
@import "detail";
@import "star-classroom";
@import "brand";
@import "cate-all";
@import "brand-cate/index";
... ...
.brand-blk-page {
.tab-box {
position: fixed;
top: 0;
z-index: 9;
width: 100%;
}
.fastening {
position: fixed;
}
.distance {
margin-top: 170px;
}
.brand-tab {
max-width: inherit;
height: 80px;
... ... @@ -63,7 +70,6 @@
}
.content-index {
margin-top: 170px;
.search {
width: 100%;
... ... @@ -190,7 +196,7 @@
right: 0;
background: #fff;
opacity: 0.8;
top: 170px;
top: 270px;
overflow-y: auto;
z-index: 10;
... ... @@ -250,7 +256,7 @@
display: none;
}
.category-content {
/*.category-content {
.category-container {
margin-bottom: 100px;
}
... ... @@ -327,15 +333,15 @@
color: #000;
}
}
}
}*/
.resources {
.recommend-content-five {
margin-top: -1px;
width: 100%;
overflow: hidden;
a {
height: 218px;
width: 50%;
outline: none;
color: #000;
... ...
.blk-cate-all {
font-size: 15PX;
.category-nav {
height: 80px;
border-bottom: 1px solid #e6e6e6;
width: 100%;
background: #fff;
z-index: 10;
li {
display: block;
box-sizing: border-box;
float: left;
height: 100%;
padding: 20px 0;
width: 50%;
text-align: center;
color: #999;
&:last-child {
border-right: none;
}
&.focus {
color: #000;
}
&.bytouch {
background: #eee;
}
}
span {
display: block;
width: 100%;
height: 30px;
line-height: 35px;
font-size: 90%;
}
}
.loca {
position: fixed;
top: 88px;
}
.content {
overflow: hidden;
position: relative;
&.hide {
display: none;
}
}
.living {
margin-top: 160px;
}
.primary-level {
float: left;
box-sizing: border-box;
width: 45%;
> li {
height: 89px;
line-height: 89px;
padding: 0 32px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
border-bottom: 1px solid #e6e6e6;
&.focus {
background-color: #fff;
}
&.highlight {
background-color: #eee;
}
}
}
.trilanglefont {
font-family: "iconfont" !important;
font-size: 30px;
font-style: normal;
text-decoration: none;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
color: #f4f4f4;
}
.primary-level-trilangle {
float: right;
background-image: url(/product/arrow.png) no-repeat;
margin-top: 22px;
width: 20px;
height: 46px;
position: relative;
right: -32px;
}
.sub-level-container {
float: left;
overflow-x: auto;
box-sizing: border-box;
background: #fff;
width: 55%;
height: 100%;
background: #f4f4f4;
}
.sub-level {
width: 100%;
height: 100%;
&.hide {
display: none;
}
> li {
box-sizing: border-box;
height: 79px;
line-height: 79px;
border-bottom: 1px solid #e6e6e6;
padding-left: 20px;
&.highlight {
background: #eee;
}
&:last-child {
border-bottom: none;
}
}
a {
display: block;
height: 100%;
width: 100%;
color: #afafaf;
}
}
}
... ...
@import "brand";
@import "cate-all";
... ...