Authored by 郭成尧

Merge branch 'feature/custom' into 'master'

Feature/custom



See merge request !148
... ... @@ -2,17 +2,35 @@
* 自定义频道, 临时方案,暂时写死
*/
'use strict';
const customModel = require('../models/custom');
let index = (req, res) => {
res.render('custom', {
let index = (req, res, next) => {
let contentCode = req.params.id;
if (!contentCode) {
return next();
}
customModel.getResourceData(contentCode).then(result => {
res.render('custom', {
module: 'channel',
page: 'custom',
content: result,
title: req.query.title || 'Yoho!Buy 有货'
});
}).catch(next);
};
let zhihui = (req, res) => {
res.render('zhihui', {
module: 'channel',
page: 'custom',
content_code: req.params.id, // 这是位置码,后边去调用资源位,渲染页面
title: req.query.title || 'Yoho!Buy 有货',
downloadLink: 'http://union.yoho.cn/union/downapp.html?union_type=100000000000081'
});
};
module.exports = {
index
index,
zhihui
};
... ...
/**
* 自定义频道页面 model
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
const utils = '../../../utils';
const resourcesProcess = require(`${utils}/resources-process`);
const service = global.yoho.ServiceAPI;
const getResourceData = (code) => {
return service.get('operations/api/v5/resource/get', {
content_code: code
}, {
cache: true,
code: 200
}).then(result => {
return resourcesProcess(result.data);
});
};
module.exports = {
getResourceData
}
... ...
... ... @@ -36,6 +36,10 @@ router.get('/brands/delBrandHistory', brandController.delBrandHistory); // 删
router.post('/channel/shopRecom', channel.shopRecom); // 店铺推荐收藏状态
router.post('/channel/userVip', channel.userVip);
// 自定义频道,市场推广-智汇
// 此页面做的早,写死发给市场,与自定义的不兼容,所以需要写死
router.get('/channel/2fb054e8315300a1ae1f80c3a4fda862.html', custom.zhihui);
// 自定义频道
router.get('/channel/:id.html', custom.index);
... ...
{{!-- 临时方案 --}}
<style>
html,body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
}
.wrapper {
position: relative;
width: 100%;
}
.container {
position: relative;
margin: 0 auto;
}
img {
width:100%;
float: left;
}
ul {
list-style: none;
overflow: hidden;
margin: 0;
padding: 0;
}
ul li {
position: relative;
width:100%;
overflow: hidden;
}
#btn_download {
position: absolute;
width: 73%;
height: 14%;
top: 75.5%;
left: 13%;
}
</style>
<div class="wrapper">
<div class="container">
<ul>
<li>
<img src="https://feature.yoho.cn/0113/images/01ff33cffc05e280bd701b90801835ad51.jpg?imageView2/2/q/75/">
<a id="btn_download" href="{{downloadLink}}" target="_blank"></a>
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/015d6241108a4db156d4153a5645bd283e.jpg?imageView2/2/q/75/">
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/01651b926f5f22f4b00b6809925e4388a3.jpg?imageView2/2/q/75/">
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/0157ad8f797d97f10cc21bd30333c5a7c5.jpg?imageView2/2/q/75/">
</li>
</ul>
</div>
{{! 资源位}}
<div class="resource-content">
{{> channel/content}}
</div>
... ...
<style>
html,body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
}
.wrapper {
position: relative;
width: 100%;
}
.container {
position: relative;
margin: 0 auto;
}
img {
width:100%;
float: left;
}
ul {
list-style: none;
overflow: hidden;
margin: 0;
padding: 0;
}
ul li {
position: relative;
width:100%;
overflow: hidden;
}
#btn_download {
position: absolute;
width: 73%;
height: 14%;
top: 75.5%;
left: 13%;
}
</style>
<div class="wrapper">
<div class="container">
<ul>
<li>
<img src="https://feature.yoho.cn/0113/images/01ff33cffc05e280bd701b90801835ad51.jpg?imageView2/2/q/75/">
<a id="btn_download" href="{{downloadLink}}" target="_blank"></a>
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/015d6241108a4db156d4153a5645bd283e.jpg?imageView2/2/q/75/">
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/01651b926f5f22f4b00b6809925e4388a3.jpg?imageView2/2/q/75/">
</li>
<li>
<img src="https://feature.yoho.cn/0113/images/0157ad8f797d97f10cc21bd30333c5a7c5.jpg?imageView2/2/q/75/">
</li>
</ul>
</div>
</div>
... ...
... ... @@ -17,21 +17,21 @@ module.exports = {
assetUrl: '//127.0.0.1:5001',
testCode: 'yoho4946abcdef#$%&!@',
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
imSocket: 'ws://im.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
imServer: 'http://im.yohobuy.com/server'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// imSocket: 'ws://im.yohobuy.com:10240',
// imCs: 'http://im.yohobuy.com/api',
// imServer: 'http://im.yohobuy.com/server'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
// imSocket: 'wss://imsocket.yohobuy.com:443',
// imCs: 'https://imhttp.yohobuy.com/api',
// imServer: 'https://imhttp.yohobuy.com/server'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
imServer: 'https://imhttp.yohobuy.com/server'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -2,7 +2,7 @@
{{#data}}
<div class="banner-list">
<a href="{{url}}">
<img src="{{image2 src w=640 h=200 q=60}}" alt="">
<img src="{{image2 src w=640 h=200 q=60 mode=3}}" alt="">
</a>
</div>
{{/data}}
... ... @@ -12,7 +12,7 @@
{{#data}}
<li class="swiper-slide">
<a href="{{url}}">
<img src="{{image2 src w=640 h=200 q=60}}" alt="">
<img src="{{image2 src w=640 h=200 q=60 mode=3}}" alt="">
</a>
</li>
{{/data}}
... ...
var Swiper = require('yoho-swiper2');
var lazyLoad = require('yoho-jquery-lazyload');
var fastclick = require('yoho-fastclick');
var swiperClass;
require('../common');
$(function () {
fastclick.attach(document.body);
lazyLoad($('img.lazy'));
// 头部banner轮播
if ($('.banner-swiper').find('li').size() > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
// 小 banner
$('.banner-center-swiper').each(function () {
if ($(this).find('li').length > 1) {
new Swiper(this, {
preloadImages: false,
lazyLoading: true,
lazyLoadingInPrevNext: true,
lazyLoadingOnTransitionStart: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
slideElement: 'li',
paginationHide: true
});
}
});
// 热门品牌滑动
if ($('.brands-swiper').find('li').length > 1) {
new Swiper('.brands-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'brands-list',
slideElement: 'li'
});
}
// 推荐搭配滑动
if ($('.recommend-swiper').find('li').length > 1) {
new Swiper('.recommend-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'recommend-list',
slideElement: 'li'
});
}
// 潮品话题轮播
if ($('.trend-topic-swiper').find('li').size() > 1) {
new Swiper('.trend-topic-swiper', {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.trend-topic-content .pagination-inner'
});
}
// 新人专享轮播
if ($('.fresh-list-swiper').find('li').size() > 1) {
new Swiper('.fresh-list-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li',
watchSlidesVisibility: true
});
}
// 潮流上装/经典裤装等轮播
$('.category-swiper').each(function (i) {
swiperClass = 'category-swiper' + i;
$(this).addClass(swiperClass);
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
new Swiper('.' + swiperClass, {
preloadImages: false,
lazyLoading: true,
lazyLoadingInPrevNext: true,
lazyLoadingOnTransitionStart: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.' + swiperClass + ' .pagination-inner'
});
}
});
});
... ...