Authored by ccbikai(👎🏻🍜)

自定义频道支持资源位

... ... @@ -2,15 +2,25 @@
* 自定义频道, 临时方案,暂时写死
*/
'use strict';
const customModel = require('../models/custom');
let index = (req, res) => {
res.render('custom', {
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'
});
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 有货',
content_code: req.params.id, // 这是位置码,后边去调用资源位,渲染页面
downloadLink: 'http://union.yoho.cn/union/downapp.html?union_type=100000000000081'
});
}).catch(next);
};
module.exports = {
... ...
/**
* 自定义频道页面 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
}
... ...
{{!-- 临时方案 --}}
{{! 资源位}}
<div class="resource-content">
{{> channel/content}}
</div>
{{!-- 临时方案
<style>
html,body {
width: 100%;
... ... @@ -67,3 +71,4 @@
</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'
});
}
});
});
... ...