Showing
6 changed files
with
170 additions
and
25 deletions
@@ -2,15 +2,25 @@ | @@ -2,15 +2,25 @@ | ||
2 | * 自定义频道, 临时方案,暂时写死 | 2 | * 自定义频道, 临时方案,暂时写死 |
3 | */ | 3 | */ |
4 | 'use strict'; | 4 | 'use strict'; |
5 | +const customModel = require('../models/custom'); | ||
5 | 6 | ||
6 | -let index = (req, res) => { | ||
7 | - res.render('custom', { | ||
8 | - module: 'channel', | ||
9 | - page: 'custom', | ||
10 | - content_code: req.params.id, // 这是位置码,后边去调用资源位,渲染页面 | ||
11 | - title: req.query.title || 'Yoho!Buy 有货', | ||
12 | - downloadLink: 'http://union.yoho.cn/union/downapp.html?union_type=100000000000081' | ||
13 | - }); | 7 | +let index = (req, res, next) => { |
8 | + let contentCode = req.params.id; | ||
9 | + | ||
10 | + if (!contentCode) { | ||
11 | + return next(); | ||
12 | + } | ||
13 | + | ||
14 | + customModel.getResourceData(contentCode).then(result => { | ||
15 | + res.render('custom', { | ||
16 | + module: 'channel', | ||
17 | + page: 'custom', | ||
18 | + content: result, | ||
19 | + title: req.query.title || 'Yoho!Buy 有货', | ||
20 | + content_code: req.params.id, // 这是位置码,后边去调用资源位,渲染页面 | ||
21 | + downloadLink: 'http://union.yoho.cn/union/downapp.html?union_type=100000000000081' | ||
22 | + }); | ||
23 | + }).catch(next); | ||
14 | }; | 24 | }; |
15 | 25 | ||
16 | module.exports = { | 26 | module.exports = { |
apps/channel/models/custom.js
0 → 100644
1 | +/** | ||
2 | + * 自定义频道页面 model | ||
3 | + * @author: Bi Kai<kai.bi@yoho.cn> | ||
4 | + * @date: 2016/05/09 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | +const utils = '../../../utils'; | ||
9 | +const resourcesProcess = require(`${utils}/resources-process`); | ||
10 | +const service = global.yoho.ServiceAPI; | ||
11 | + | ||
12 | +const getResourceData = (code) => { | ||
13 | + return service.get('operations/api/v5/resource/get', { | ||
14 | + content_code: code | ||
15 | + }, { | ||
16 | + cache: true, | ||
17 | + code: 200 | ||
18 | + }).then(result => { | ||
19 | + return resourcesProcess(result.data); | ||
20 | + }); | ||
21 | +}; | ||
22 | + | ||
23 | +module.exports = { | ||
24 | + getResourceData | ||
25 | +} |
1 | -{{!-- 临时方案 --}} | 1 | +{{! 资源位}} |
2 | +<div class="resource-content"> | ||
3 | + {{> channel/content}} | ||
4 | +</div> | ||
2 | 5 | ||
6 | +{{!-- 临时方案 | ||
3 | <style> | 7 | <style> |
4 | html,body { | 8 | html,body { |
5 | width: 100%; | 9 | width: 100%; |
@@ -67,3 +71,4 @@ | @@ -67,3 +71,4 @@ | ||
67 | </ul> | 71 | </ul> |
68 | </div> | 72 | </div> |
69 | </div> | 73 | </div> |
74 | + --}} |
@@ -17,21 +17,21 @@ module.exports = { | @@ -17,21 +17,21 @@ module.exports = { | ||
17 | assetUrl: '//127.0.0.1:5001', | 17 | assetUrl: '//127.0.0.1:5001', |
18 | testCode: 'yoho4946abcdef#$%&!@', | 18 | testCode: 'yoho4946abcdef#$%&!@', |
19 | domains: { | 19 | domains: { |
20 | - api: 'http://api-test3.yohops.com:9999/', | ||
21 | - service: 'http://service-test3.yohops.com:9999/', | ||
22 | - liveApi: 'http://testapi.live.yohops.com:9999/', | ||
23 | - singleApi: 'http://api-test3.yohops.com:9999/', | ||
24 | - imSocket: 'ws://im.yohobuy.com:10240', | ||
25 | - imCs: 'http://im.yohobuy.com/api', | ||
26 | - imServer: 'http://im.yohobuy.com/server' | 20 | + // api: 'http://api-test3.yohops.com:9999/', |
21 | + // service: 'http://service-test3.yohops.com:9999/', | ||
22 | + // liveApi: 'http://testapi.live.yohops.com:9999/', | ||
23 | + // singleApi: 'http://api-test3.yohops.com:9999/', | ||
24 | + // imSocket: 'ws://im.yohobuy.com:10240', | ||
25 | + // imCs: 'http://im.yohobuy.com/api', | ||
26 | + // imServer: 'http://im.yohobuy.com/server' | ||
27 | 27 | ||
28 | - // api: 'http://api.yoho.cn/', | ||
29 | - // service: 'http://service.yoho.cn/', | ||
30 | - // liveApi: 'http://api.live.yoho.cn/', | ||
31 | - // singleApi: 'http://single.yoho.cn/', | ||
32 | - // imSocket: 'wss://imsocket.yohobuy.com:443', | ||
33 | - // imCs: 'https://imhttp.yohobuy.com/api', | ||
34 | - // imServer: 'https://imhttp.yohobuy.com/server' | 28 | + api: 'http://api.yoho.cn/', |
29 | + service: 'http://service.yoho.cn/', | ||
30 | + liveApi: 'http://api.live.yoho.cn/', | ||
31 | + singleApi: 'http://single.yoho.cn/', | ||
32 | + imSocket: 'wss://imsocket.yohobuy.com:443', | ||
33 | + imCs: 'https://imhttp.yohobuy.com/api', | ||
34 | + imServer: 'https://imhttp.yohobuy.com/server' | ||
35 | }, | 35 | }, |
36 | subDomains: { | 36 | subDomains: { |
37 | host: '.m.yohobuy.com', | 37 | host: '.m.yohobuy.com', |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | {{#data}} | 2 | {{#data}} |
3 | <div class="banner-list"> | 3 | <div class="banner-list"> |
4 | <a href="{{url}}"> | 4 | <a href="{{url}}"> |
5 | - <img src="{{image2 src w=640 h=200 q=60}}" alt=""> | 5 | + <img src="{{image2 src w=640 h=200 q=60 mode=3}}" alt=""> |
6 | </a> | 6 | </a> |
7 | </div> | 7 | </div> |
8 | {{/data}} | 8 | {{/data}} |
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | {{#data}} | 12 | {{#data}} |
13 | <li class="swiper-slide"> | 13 | <li class="swiper-slide"> |
14 | <a href="{{url}}"> | 14 | <a href="{{url}}"> |
15 | - <img src="{{image2 src w=640 h=200 q=60}}" alt=""> | 15 | + <img src="{{image2 src w=640 h=200 q=60 mode=3}}" alt=""> |
16 | </a> | 16 | </a> |
17 | </li> | 17 | </li> |
18 | {{/data}} | 18 | {{/data}} |
1 | +var Swiper = require('yoho-swiper2'); | ||
2 | +var lazyLoad = require('yoho-jquery-lazyload'); | ||
3 | +var fastclick = require('yoho-fastclick'); | ||
4 | +var swiperClass; | ||
5 | + | ||
1 | require('../common'); | 6 | require('../common'); |
7 | + | ||
8 | +$(function () { | ||
9 | + fastclick.attach(document.body); | ||
10 | + lazyLoad($('img.lazy')); | ||
11 | + | ||
12 | + // 头部banner轮播 | ||
13 | + if ($('.banner-swiper').find('li').size() > 1) { | ||
14 | + new Swiper('.banner-swiper', { | ||
15 | + lazyLoading: true, | ||
16 | + lazyLoadingInPrevNext: true, | ||
17 | + loop: true, | ||
18 | + autoplay: 3000, | ||
19 | + autoplayDisableOnInteraction: false, | ||
20 | + paginationClickable: true, | ||
21 | + slideElement: 'li', | ||
22 | + pagination: '.banner-top .pagination-inner' | ||
23 | + }); | ||
24 | + } | ||
25 | + | ||
26 | + // 小 banner | ||
27 | + $('.banner-center-swiper').each(function () { | ||
28 | + if ($(this).find('li').length > 1) { | ||
29 | + new Swiper(this, { | ||
30 | + preloadImages: false, | ||
31 | + lazyLoading: true, | ||
32 | + lazyLoadingInPrevNext: true, | ||
33 | + lazyLoadingOnTransitionStart: true, | ||
34 | + loop: true, | ||
35 | + autoplay: 3000, | ||
36 | + autoplayDisableOnInteraction: false, | ||
37 | + slideElement: 'li', | ||
38 | + paginationHide: true | ||
39 | + }); | ||
40 | + } | ||
41 | + }); | ||
42 | + | ||
43 | + // 热门品牌滑动 | ||
44 | + if ($('.brands-swiper').find('li').length > 1) { | ||
45 | + new Swiper('.brands-swiper', { | ||
46 | + grabCursor: true, | ||
47 | + slidesPerView: 'auto', | ||
48 | + wrapperClass: 'brands-list', | ||
49 | + slideElement: 'li' | ||
50 | + }); | ||
51 | + } | ||
52 | + | ||
53 | + // 推荐搭配滑动 | ||
54 | + if ($('.recommend-swiper').find('li').length > 1) { | ||
55 | + new Swiper('.recommend-swiper', { | ||
56 | + grabCursor: true, | ||
57 | + slidesPerView: 'auto', | ||
58 | + wrapperClass: 'recommend-list', | ||
59 | + slideElement: 'li' | ||
60 | + }); | ||
61 | + } | ||
62 | + | ||
63 | + // 潮品话题轮播 | ||
64 | + if ($('.trend-topic-swiper').find('li').size() > 1) { | ||
65 | + new Swiper('.trend-topic-swiper', { | ||
66 | + loop: true, | ||
67 | + autoplay: 3000, | ||
68 | + autoplayDisableOnInteraction: false, | ||
69 | + paginationClickable: true, | ||
70 | + slideElement: 'li', | ||
71 | + pagination: '.trend-topic-content .pagination-inner' | ||
72 | + }); | ||
73 | + } | ||
74 | + | ||
75 | + // 新人专享轮播 | ||
76 | + if ($('.fresh-list-swiper').find('li').size() > 1) { | ||
77 | + new Swiper('.fresh-list-swiper', { | ||
78 | + lazyLoading: true, | ||
79 | + lazyLoadingInPrevNext: true, | ||
80 | + grabCursor: true, | ||
81 | + slidesPerView: 'auto', | ||
82 | + slideElement: 'li', | ||
83 | + watchSlidesVisibility: true | ||
84 | + }); | ||
85 | + } | ||
86 | + | ||
87 | + // 潮流上装/经典裤装等轮播 | ||
88 | + $('.category-swiper').each(function (i) { | ||
89 | + swiperClass = 'category-swiper' + i; | ||
90 | + $(this).addClass(swiperClass); | ||
91 | + if ($('.' + swiperClass).find('.swiper-slide').size() > 1) { | ||
92 | + new Swiper('.' + swiperClass, { | ||
93 | + preloadImages: false, | ||
94 | + lazyLoading: true, | ||
95 | + lazyLoadingInPrevNext: true, | ||
96 | + lazyLoadingOnTransitionStart: true, | ||
97 | + loop: true, | ||
98 | + autoplay: 3000, | ||
99 | + autoplayDisableOnInteraction: false, | ||
100 | + paginationClickable: true, | ||
101 | + slideElement: 'li', | ||
102 | + pagination: '.' + swiperClass + ' .pagination-inner' | ||
103 | + }); | ||
104 | + } | ||
105 | + }); | ||
106 | +}); |
-
Please register or login to post a comment