Authored by zhangxiaoru

品牌品类树 跳转调整

... ... @@ -31,6 +31,7 @@ const index = (req, res, next) => {
}
brandModel.indexData(gender, brandCode, cateCode).then(result => {
// console.log(result)
res.render('brand/brand', {
module: 'guang',
... ...
... ... @@ -53,7 +53,8 @@ const handleBrandList = origin => {
brands.push({
name: subValue.brand_name_en || subValue.brand_name_cn || subValue.brand_name,
logo: subValue.brand_ico,
domain: subValue.brand_domain
domain: subValue.brand_domain,
brandUrl: '//m.yohobuy.com/product/index/brand?domain=' + subValue.brand_domain
});
});
... ... @@ -164,7 +165,7 @@ const _getBrandListOriginData = (channel) => {
});
};
let _processCateData = (list, channel) => {
const _processCateData = (list, channel) => {
let nav = ['MEN男士', 'WOMEN女士'];
nav = _.map(nav, function(item) {
... ... @@ -213,6 +214,18 @@ let _processCateData = (list, channel) => {
};
};
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;
})
return list;
}
const indexData = (gender, brandCode, cateCode) => {
return Promise.all([_getChannelData(gender), _getResourcesData(brandCode), _getBrandListOriginData(gender), _getResourcesData(cateCode)]).then(result => {
let brandList = {};
... ... @@ -227,14 +240,17 @@ const indexData = (gender, brandCode, cateCode) => {
if (result[1]) {
_.forEach(result[1], function(data) {
if (data.focus_type === '1') {
brandList.bannerTop = data;
brandList.bannerTop = _dealBrandUrl(data);
} else if (data.focus_type === '2') {
brandList.focusData = data.data;
brandList.focusData = _dealBrandUrl(data).data;
}
});
}
if (result[2]) {
brandList.listData = result[2].ListData;
brandList.indexList = result[2].indexList;
}
... ... @@ -242,8 +258,17 @@ 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;
}
});
... ... @@ -263,9 +288,9 @@ const brandListData = (code, gender) => {
if (result[0]) {
_.forEach(result[0], function(data) {
if (data.focus_type === '1') {
brandList.bannerTop = data;
brandList.bannerTop = _dealBrandUrl(data);
} else if (data.focus_type === '2') {
brandList.focusData = data.data;
brandList.focusData = _dealBrandUrl(data).data;
}
});
}
... ... @@ -289,8 +314,18 @@ const categoryData = (code) => {
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;
}
});
... ...
... ... @@ -6,7 +6,15 @@
</ul>
<div class="channel-tab">
<ul>
<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}}">
{{#each channel}}
<li class='{{#if focus}} focus {{/if}}' data-code='{{code}}'>
<span>{{mame}}</span>
... ...
... ... @@ -29,7 +29,7 @@
{{# brands}}
<div class="brand-big-box">
<div class="brand-box">
<a href="">
<a href="{{brandUrl}}">
<div class="brand-logo">
<img src="{{image logo 136 136}}">
</div>
... ...
{{# categoryData}}
{{# categoryData}}
<div class="resources">
<div class="recommend-content-five">
{{# list}}
... ... @@ -10,6 +10,7 @@
<div class="focus-floor">
{{# focusData}}
{{!-- {{{log this}}} --}}
{{> resources/banner-top}}
{{/ focusData}}
</div>
... ...
... ... @@ -2,7 +2,9 @@ var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
var bannerSwiper,
categoryHeight = $('.tab-box').height();
categoryHeight = $('.tab-box').height(),
gender,
isBrand;
var $intercept = $('.no-intercept'),
$list = $('.brand-list-box');
... ... @@ -42,8 +44,8 @@ function loadData(channel, isBrand) {
}
$('.channel-tab').find('li').click(function() {
var gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase(),
isBrand = $('.brand-tab').find('.brand').hasClass('active');
gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase(),
isBrand = $('.brand-tab').find('.brand').hasClass('active');
$(this).addClass('focus').siblings().removeClass('focus');
... ... @@ -67,20 +69,21 @@ $('.brand-tab').find('li').click(function() {
if ($(this).hasClass('brand')) {
$('.brand-content').removeClass('hide').siblings().addClass('hide');
$('.brand-cha').removeClass('hide').siblings().addClass('hide');
} else {
$('.category-content').removeClass('hide').siblings().addClass('hide');
$('.cate-cha').removeClass('hide').siblings().addClass('hide');
}
});
$(function() {
// loadData();
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplay: 2000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
... ...