Authored by 陈峰

Merge branch 'feature/guang' of http://git.yoho.cn/fe/yohobuywap-node into feature/guang

/**
* 国际优选
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/12
*/
'use strict';
const mRoot = '../models';
const plustarModel = require(`${mRoot}/plustar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
};
const getListData = (req, res, next) => {
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
let recom = '4';
let all = '1';
// console.log(gender);
plustarModel.getListData(gender, recom, all).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
};
module.exports = {
getListData
};
... ...
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const productProcess = require('../../../utils/product-process');
const formaData = (data, gender) => {
let build = [];
//console.log(data)
_.forEach(data, function(val) {
//多张图
if(val.data[1]) {
let imgs = [];
_.forEach(val.data, function(list) {
let obj = {};
obj = _.assign(obj, {
url: '/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
img: list.src,
deps: val.brand_title
});
imgs.push(obj);
})
build.push({
imgs: imgs
})
}
//单张图
if(val.data[0]) {
_.forEach(val.data, function(list) {
build.push({
url: '/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
img: list.src,
deps: val.brand_title
})
})
}
})
return build;
}
const getContentData = (gender, type) => {
return serviceAPI.get('guang/api/v3/plustar/getlist', {
gender: gender,
brand_type: type
}).then((result) => {
if (result && result.code === 200) {
//console.log(result)
return formaData(result.data.data.list[0].data, gender);
} else {
logger.error('列表 list data return code is not 200');
return {};
}
});
};
const getListData = (gender, recom, all) => {
return Promise.all([getContentData(gender, recom), getContentData(gender, all)]).then((result) => {
return {
star: result[0],
plus: result[1]
};
});
};
module.exports = {
getListData,
getContentData
};
... ...
... ... @@ -13,6 +13,7 @@ const plusstar = require(cRoot + '/plusstar');
const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
const info = require(cRoot + '/info');
const plustar = require(cRoot + '/plustar');
const router = express.Router(); // eslint-disable-line
... ... @@ -40,4 +41,6 @@ router.get('/info/index', info.index); // 逛详情页
router.get('/info/mini', info.mini); // 逛mini内容页
router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
router.get('/plustar', plustar.getListData); // 国际优选
module.exports = router;
... ...
... ... @@ -16,14 +16,14 @@
{{#if ../swiper}}
<div class="swiper-container swiper-cont-{{typeId}}">
<div class="swiper-wrapper swiper-wrap-{{typeId}}">
{{# swiper}}
{{# ../swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
{{/ ../swiper}}
</div>
<div class="swiper-pagination swiper-pagi-{{typeId}}"></div>
</div>
... ...
{{#if swiper}}
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
... ...
<div class="ps-list-page ps-page yoho-page">
{{# ps}}
<ul id="nav-tab" class="nav-tab clearfix">
<li class="star-nav focus">{{sName}}</li>
<li class="plus-nav">{{pName}}</li>
</ul>
<div id="ps-content" class="ps-content">
<ul class="star-content content">
{{# star}}
{{> ps_item}}
{{/ star}}
</ul>
<ul class="plus-content content hide">
{{# plus}}
{{> ps_item}}
{{/ plus}}
</ul>
</div>
{{/ ps}}
</div>
\ No newline at end of file
... ...
<li class="plus-star-row">
{{#if imgs}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# imgs}}
<div class="swiper-slide">
<a href={{url}}>
<img class="swiper-lazy" data-src={{image img 640 310 2}}>
</a>
</div>
{{/ imgs}}
</div>
<div class="swiper-pagination">
<div class="pagination-inner">
</div>
</div>
</div>
{{^}}
<a href={{url}}>
<img class="lazy" data-original={{image img 640 310 2}}>
</a>
{{/if}}
{{# deps}}
<p class="brand-deps">{{.}}</p>
{{/ deps}}
</li>
\ No newline at end of file
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
Swiper = require('yoho-swiper');
var $navs = $('#nav-tab > li'),
$contents = $('#ps-content > .content');
var mySwiper;
require('../common');
lazyLoad($('img.lazy'));
$('.star-content li').each(function(key, item) {
$(item).find('.swiper-container').addClass('swiper-' + key);
mySwiper = new Swiper('.swiper-' + key, {
lazyLoading: true,
pagination: '.swiper-' + key + ' .pagination-inner'
});
});
$('#nav-tab').bind('contextmenu', function(e) {
return false;
});
$('#nav-tab').on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li');
if ($this.hasClass('focus')) {
return;
}
$navs.toggleClass('focus');
$contents.toggleClass('hide');
$(document).trigger('scroll'); //Trigger lazyLoad
});
$('#nav-tab').on('touchstart', function(e) {
var target = e.target || e.srcElement;
target.className = 'bytouch ' + target.className;
}).on('touchend touchcancel', function() {
$navs.removeClass('bytouch');
});
\ No newline at end of file
... ...
... ... @@ -6,7 +6,7 @@
}
.nav-tab {
height: 60px;
/*height: 60px;*/
padding: 10px 0;
background-color: #fff;
}
... ... @@ -49,6 +49,8 @@
}
}
.content.hide {
display: none;
}
... ...