Authored by zzzzzzz

图片轮播

... ... @@ -134,6 +134,11 @@ const _getChannelResource = (params) => {
cache: true
}).then(result => {
if (result && result.code === 200) {
for (let item of result.data.list) {
item.template_name === 'single_image' &&
item.data.length === 1 &&
(item.singleOne = true);
}
return resourcesProcess(result.data.list);
} else {
logger.error('index resouce is not 200');
... ...
... ... @@ -16,9 +16,11 @@ module.exports = {
domains: {
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://testapi.live.yohops.com:9999/'
api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
},
subDomains: {
host: '.m.yohobuy.com',
... ...
{{#data}}
<div class="banner-center">
<a href="{{url}}">
<img class="lazy" data-original="{{image src 640 200}}" alt="">
</a>
</div>
{{/data}}
\ No newline at end of file
<div class="banner-center banner-center-swiper">
{{#if singleOne}}
{{#data}}
<div class="banner-list">
<a href="{{url}}">
<img class="swiper-lazy swiper-lazy-loaded" src="{{image src 640 200}}" alt="">
</a>
</div>
{{/data}}
{{else}}
<ul class="banner-list swiper-wrapper clearfix">
{{#data}}
<li class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy swiper-lazy-loaded" src="{{image src 640 200}}" alt="">
</a>
</li>
{{/data}}
</ul>
{{/if}}
</div>
\ No newline at end of file
... ...
... ... @@ -108,6 +108,19 @@ if ($('.banner-swiper').find('li').size() > 1) {
});
}
// single_image的轮播
if ($('.banner-center-swiper').find('li').size() > 1) {
new Swiper('.banner-center-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
});
}
// 热门品牌滑动
new Swiper('.brands-swiper', {
grabCursor: true,
... ...
... ... @@ -2,9 +2,45 @@
margin: 30px 0 0;
height: 200px;
overflow: hidden;
img {
display: block;
width: 100%;
height: 100%;
}
}
.banner-center-swiper {
background: #fff;
width: 100%;
height: 200px;
border-top: 1px solid #e0e0e0;
overflow: hidden;
.banner-list {
position: relative;
height: 200px;
li {
float: left;
width: 100%;
height: 200px;
a {
position: relative;
display: block;
width: 100%;
height: 100%;
line-height: 200px;
font-size: 0;
}
img {
display: inline-block;
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
}
}
}
... ...