Showing
15 changed files
with
489 additions
and
44 deletions
@@ -5,52 +5,114 @@ | @@ -5,52 +5,114 @@ | ||
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | -// const library = '../../../library'; | ||
9 | -// const channelModel = require('../models/channel'); | ||
10 | const mRoot = '../models'; | 8 | const mRoot = '../models'; |
11 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
12 | - | ||
13 | -// const helpers = require(`${library}/helpers`); | ||
14 | -// const log = require(`${library}/logger`); | ||
15 | const headerModel = require('../../../doraemon/models/header'); | 10 | const headerModel = require('../../../doraemon/models/header'); |
16 | const starModel = require(`${mRoot}/star`); | 11 | const starModel = require(`${mRoot}/star`); |
17 | 12 | ||
18 | -/** | ||
19 | - * 星潮教室首页 | ||
20 | - * @param {[object]} req | ||
21 | - * @param {[object]} res | ||
22 | - * @return {[type]} | ||
23 | - */ | ||
24 | -exports.index = (req, res) => { | ||
25 | - let headerData = headerModel.setNavHeader('新潮教室'); | ||
26 | - let renderData = { | ||
27 | - // module: 'product', | ||
28 | - // page: 'sale', | ||
29 | - title: '新潮教室', | ||
30 | - pageHeader: headerData, | ||
31 | - pageFooter: true | ||
32 | - }; | ||
33 | - | ||
34 | - starModel.getIndexData().then(() => { | ||
35 | - res.render('star/index', _.assign(headerData, renderData, { | ||
36 | - content: '', | ||
37 | - headTab: [ | 13 | +const headTab = [ |
38 | { | 14 | { |
39 | - cur: true, | ||
40 | - url: '', | 15 | + cur: false, |
16 | + url: '/guang/star/index', | ||
41 | name: '全部' | 17 | name: '全部' |
42 | }, | 18 | }, |
43 | { | 19 | { |
44 | cur: false, | 20 | cur: false, |
45 | - url: '', | 21 | + url: '/guang/star/special', |
46 | name: '星专题' | 22 | name: '星专题' |
47 | }, | 23 | }, |
48 | { | 24 | { |
49 | cur: false, | 25 | cur: false, |
50 | - url: '', | 26 | + url: '/guang/star/collocation', |
51 | name: '星搭配' | 27 | name: '星搭配' |
52 | } | 28 | } |
53 | - ] | 29 | +]; |
30 | + | ||
31 | +const headerData = headerModel.setNavHeader('新潮教室'); | ||
32 | + | ||
33 | +const renderData = { | ||
34 | + module: 'guang', | ||
35 | + title: '新潮教室', | ||
36 | + pageHeader: headerData | ||
37 | +} | ||
38 | + | ||
39 | +const curHeadTab = (num) => { | ||
40 | + let i = 0; | ||
41 | + | ||
42 | + for (i; i <= 2; i++) { | ||
43 | + if (i === num) { | ||
44 | + headTab[i].cur = true; | ||
45 | + } else { | ||
46 | + headTab[i].cur = false; | ||
47 | + } | ||
48 | + } | ||
49 | +}; | ||
50 | + | ||
51 | +/** | ||
52 | + * 星潮教室首页 | ||
53 | + * @param {[object]} req | ||
54 | + * @param {[object]} res | ||
55 | + * @return {[type]} | ||
56 | + */ | ||
57 | +exports.index = (req, res) => { | ||
58 | + renderData.page = 'star'; | ||
59 | + starModel.getIndexData().then((result) => { | ||
60 | + curHeadTab(0); | ||
61 | + res.render('star/index', _.assign(renderData, { | ||
62 | + content: result, | ||
63 | + headTab: headTab | ||
54 | })); | 64 | })); |
55 | }); | 65 | }); |
56 | }; | 66 | }; |
67 | + | ||
68 | +/** | ||
69 | + * 星专题 | ||
70 | + * @param {[object]} req | ||
71 | + * @param {[object]} res | ||
72 | + * @return {[type]} | ||
73 | + */ | ||
74 | +exports.special = (req, res) => { | ||
75 | + renderData.page = 'star'; | ||
76 | + starModel.getSpecialData().then((result) => { | ||
77 | + curHeadTab(1); | ||
78 | + res.render('star/special', _.assign(renderData, { | ||
79 | + resources: result, | ||
80 | + headTab: headTab | ||
81 | + })); | ||
82 | + }); | ||
83 | +}; | ||
84 | + | ||
85 | + | ||
86 | +/** | ||
87 | + * 星搭配 | ||
88 | + * @param {[object]} req | ||
89 | + * @param {[object]} res | ||
90 | + * @return {[type]} | ||
91 | + */ | ||
92 | +exports.collocation = (req, res) => { | ||
93 | + renderData.page = 'collocation'; | ||
94 | + curHeadTab(2); | ||
95 | + res.render('star/collocation', _.assign(renderData, { | ||
96 | + headTab: headTab | ||
97 | + })); | ||
98 | +} | ||
99 | + | ||
100 | +/** | ||
101 | + * 星搭配文章请求 | ||
102 | + * @param {[object]} req | ||
103 | + * @param {[object]} res | ||
104 | + * @return {[type]} | ||
105 | + */ | ||
106 | +exports.collocationList = (req, res) => { | ||
107 | + let params = Object.assign({}, req.query); | ||
108 | + let uid = 9239279 || req.user.uid || 0; | ||
109 | + | ||
110 | + starModel.getCollocationListData(params, uid).then((result) => { | ||
111 | + res.render('star/collocation-list', _.assign({ | ||
112 | + layout: false, | ||
113 | + params: params, | ||
114 | + collocationList: result | ||
115 | + })); | ||
116 | + }); | ||
117 | + | ||
118 | +} |
@@ -19,9 +19,8 @@ const serviceAPI = new ServiceAPI(); | @@ -19,9 +19,8 @@ const serviceAPI = new ServiceAPI(); | ||
19 | */ | 19 | */ |
20 | const getResources = (page) => { | 20 | const getResources = (page) => { |
21 | const contentCode = { | 21 | const contentCode = { |
22 | - sale: '7c2b77093421efa8ae9302c91460db73', | ||
23 | - breakCode: '7c2b77093421efa8ae9302c91460db73', | ||
24 | - vip: '7c2b77093421efa8ae9302c91460db73' | 22 | + index: '8adc27fcf5676f356602889afcfd2a8e', |
23 | + special: '89cc20483ee2cbc8a716dcfe2b6c7603' | ||
25 | }; | 24 | }; |
26 | 25 | ||
27 | return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ | 26 | return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ |
@@ -36,10 +35,36 @@ const getResources = (page) => { | @@ -36,10 +35,36 @@ const getResources = (page) => { | ||
36 | }); | 35 | }); |
37 | }; | 36 | }; |
38 | 37 | ||
39 | - | ||
40 | /** | 38 | /** |
41 | * 星潮首页 | 39 | * 星潮首页 |
42 | */ | 40 | */ |
43 | exports.getIndexData = () => { | 41 | exports.getIndexData = () => { |
44 | - getResources('index'); | ||
45 | -}; | 42 | + return getResources('index'); |
43 | +} | ||
44 | + | ||
45 | +/** | ||
46 | + * 星专题 | ||
47 | + */ | ||
48 | +exports.getSpecialData = () => { | ||
49 | + return getResources('special'); | ||
50 | +} | ||
51 | + | ||
52 | +/** | ||
53 | + * 星搭配 | ||
54 | + */ | ||
55 | +exports.getCollocationListData = (params, uid) => { | ||
56 | + | ||
57 | + return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', sign.apiSign(Object.assign({ | ||
58 | + limit: '20', | ||
59 | + uid: uid | ||
60 | + }, params))).then((result) => { | ||
61 | + if (result && result.code === 200) { | ||
62 | + return res; | ||
63 | + } else { | ||
64 | + logger.error('获取星搭配文章列表返回 code 不是 200'); | ||
65 | + return []; | ||
66 | + } | ||
67 | + }); | ||
68 | +} | ||
69 | + | ||
70 | +// guang/api/v5/article/getStarClassroomArticleList |
@@ -12,6 +12,9 @@ const star = require(cRoot + '/star'); | @@ -12,6 +12,9 @@ const star = require(cRoot + '/star'); | ||
12 | 12 | ||
13 | const router = express.Router(); // eslint-disable-line | 13 | const router = express.Router(); // eslint-disable-line |
14 | 14 | ||
15 | -router.get('/star', star.index); // 星潮教室首页 | 15 | +router.get('/star/index', star.index); // 星潮教室首页 |
16 | +router.get('/star/special', star.special); // 星潮教室星专题 | ||
17 | +router.get('/star/collocation', star.collocation); // 星潮教室星搭配 | ||
18 | +router.get('/star/collocation/list', star.collocationList); // 星潮教室星搭配文章请求 | ||
16 | 19 | ||
17 | module.exports = router; | 20 | module.exports = router; |
1 | +{{#each collocationList}} | ||
2 | + <li articleId="{{articleId}}" data-bp-id="guang_collocationList_{{title}}_false" class="buriedpoint"> | ||
3 | + | ||
4 | + {{#if img}} | ||
5 | + <a href="{{url}}"><img class="lazy" src ="" data-original="{{img}}" /></a> | ||
6 | + {{/if}} | ||
7 | + | ||
8 | + <div class="cont-area "> | ||
9 | + <a href="{{url}}"><h2 class="title">{{title}}</h2></a> | ||
10 | + <p class="cont-txt">{{content}}</p> | ||
11 | + <div class="count-area"> | ||
12 | + <span class="time"><i class="iconfont time-ico"></i>{{time}}</span> | ||
13 | + <span class="see"><i class="iconfont see-ico"></i>{{seeNum}}</span> | ||
14 | + <span class="collection"><i class="iconfont collected-ico {{#isCollected}} collected {{/isCollected}}"></i></span> | ||
15 | + | ||
16 | + {{# share}} | ||
17 | + <a href="{{this}}" class="iconfont forward"></a> | ||
18 | + {{/ share}} | ||
19 | + | ||
20 | + </div> | ||
21 | + </div> | ||
22 | + </li> | ||
23 | +{{/each}} |
apps/guang/views/action/star/collocation.hbs
0 → 100644
apps/guang/views/action/star/special.hbs
0 → 100644
1 | +{{log this}} | ||
2 | +<div class="star-page yoho-page"> | ||
3 | + {{> star/head-tab}} | ||
4 | + <ul class="special-list"> | ||
5 | + {{#each resources}} | ||
6 | + {{# data}} | ||
7 | + <li data-bp-id="guang_subjectList_{{title}}_false" class="buriedpoint"> | ||
8 | + <a href="{{url}}"> | ||
9 | + <img class="lazy" data-original="{{image src 640 310}}" alt="{{alt}}"/> | ||
10 | + <p>{{title}}</p> | ||
11 | + </a> | ||
12 | + </li> | ||
13 | + {{/ data}} | ||
14 | + {{/each}} | ||
15 | + </ul> | ||
16 | +</div> |
@@ -29,7 +29,7 @@ exports.setNavHeader = (title, navBack, backUrl, navBtn) => { | @@ -29,7 +29,7 @@ exports.setNavHeader = (title, navBack, backUrl, navBtn) => { | ||
29 | 29 | ||
30 | return _.merge({ | 30 | return _.merge({ |
31 | navTitle: '', | 31 | navTitle: '', |
32 | - backUrl: true, | 32 | + backUrl: 'history.go(-1);', |
33 | navBack: true, | 33 | navBack: true, |
34 | navBtn: true, | 34 | navBtn: true, |
35 | boys: true | 35 | boys: true |
public/js/guang/collocation.page.js
0 → 100644
1 | +/** | ||
2 | + * 星潮教室-星搭配分页加载 | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/4/12 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + tip = require('../plugin/tip'), | ||
9 | + loading = require('../plugin/loading'), | ||
10 | + lazyLoad = require('yoho-jquery-lazyload'), | ||
11 | + ellipsis = require('yoho-mlellipsis'), | ||
12 | + stopLoading = false; | ||
13 | + | ||
14 | +var page = 1; | ||
15 | + | ||
16 | +ellipsis.init(); | ||
17 | + | ||
18 | +$('body').addClass('star-class-body'); | ||
19 | + | ||
20 | +function massageAJAX(page) { | ||
21 | + var $this, $title, $cont; | ||
22 | + | ||
23 | + loading.showLoadingMask(); | ||
24 | + $.ajax({ | ||
25 | + type: 'GET', | ||
26 | + url: '/guang/star/collocation/list', | ||
27 | + data: { | ||
28 | + page: page | ||
29 | + }, | ||
30 | + dataType: 'html', | ||
31 | + success: function(data) { | ||
32 | + stopLoading = false; | ||
33 | + | ||
34 | + if (data === '') { | ||
35 | + stopLoading = true; | ||
36 | + tip.show('没有更多内容了'); | ||
37 | + } | ||
38 | + | ||
39 | + $('.collocation-list').append(data); | ||
40 | + | ||
41 | + // 限制标题字数 | ||
42 | + $('.cont-area').each(function() { | ||
43 | + $this = $(this); | ||
44 | + $title = $this.find('.title'); | ||
45 | + $cont = $this.find('.cont-txt'); | ||
46 | + | ||
47 | + $title[0].mlellipsis(2); | ||
48 | + $cont[0].mlellipsis(2); | ||
49 | + }); | ||
50 | + | ||
51 | + loading.hideLoadingMask(); | ||
52 | + lazyLoad($('img.lazy')); | ||
53 | + }, | ||
54 | + error: function() { | ||
55 | + tip.show('网络断开连接了~'); | ||
56 | + } | ||
57 | + }); | ||
58 | +} | ||
59 | + | ||
60 | +function scrollHandler() { | ||
61 | + if (!stopLoading && ($(window).scrollTop() + $(window).height() > $('body').height() - 100)) { | ||
62 | + stopLoading = true; | ||
63 | + page++; | ||
64 | + massageAJAX(page); | ||
65 | + } | ||
66 | +} | ||
67 | + | ||
68 | +// 分享成功 | ||
69 | +window.successShare = function() { | ||
70 | + $.ajax({ | ||
71 | + type: 'POST', | ||
72 | + url: '/guang/starclass/forward', | ||
73 | + success: function(data) { | ||
74 | + var code = data.code; | ||
75 | + | ||
76 | + if (code === 200 && data.data > 0) { | ||
77 | + tip.show('分享成功,亲密度+10'); | ||
78 | + } | ||
79 | + }, | ||
80 | + error: function() { | ||
81 | + tip.show('网络断开连接了~'); | ||
82 | + } | ||
83 | + }); | ||
84 | +}; | ||
85 | + | ||
86 | +$(window).scroll(function() { | ||
87 | + scrollHandler(); | ||
88 | +}); | ||
89 | + | ||
90 | +if ($('.collocation-list').find('li').length === 0) { | ||
91 | + massageAJAX(1); | ||
92 | +} | ||
93 | + | ||
94 | +// 星搭配收藏请求 | ||
95 | +$(document).on('touchstart', '.collection', function(event) { | ||
96 | + var $that = $(this), | ||
97 | + $icon = $that.find('.collected-ico'); | ||
98 | + | ||
99 | + var type; | ||
100 | + | ||
101 | + event.stopPropagation(); | ||
102 | + | ||
103 | + if ($icon.hasClass('collected')) { | ||
104 | + type = 'del'; | ||
105 | + } else { | ||
106 | + type = 'fav'; | ||
107 | + } | ||
108 | + | ||
109 | + | ||
110 | + $.ajax({ | ||
111 | + type: 'POST', | ||
112 | + url: '/guang/starclass/setFavorite', | ||
113 | + data: { | ||
114 | + articleId: $that.parents('li').attr('articleId'), | ||
115 | + type: type | ||
116 | + }, | ||
117 | + success: function(data) { | ||
118 | + var code = data.code; | ||
119 | + | ||
120 | + if (code === 200) { | ||
121 | + if ($icon.hasClass('collected')) { | ||
122 | + $icon.removeClass('collected'); | ||
123 | + } else { | ||
124 | + $icon.addClass('collected'); | ||
125 | + } | ||
126 | + | ||
127 | + } | ||
128 | + | ||
129 | + if (code === 201) { | ||
130 | + if ($('#collocation-link').length <= 0) { | ||
131 | + $('body').append('<a href=\'' + data.data + '\' style="display:none;" id="collocation-link">' + | ||
132 | + '<span class="collocation-link"></span></a>'); | ||
133 | + } | ||
134 | + | ||
135 | + $('.collocation-link').click(); | ||
136 | + } | ||
137 | + }, | ||
138 | + error: function() { | ||
139 | + tip.show('网络断开连接了~'); | ||
140 | + } | ||
141 | + }); | ||
142 | +}); |
public/js/guang/star.page.js
0 → 100644
1 | +/** | ||
2 | + * 星潮教室首页 | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/5/31 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + Swiper = require('yoho-swiper'), | ||
9 | + lazyLoad = require('yoho-jquery-lazyload'); | ||
10 | + | ||
11 | +lazyLoad($('img.lazy')); | ||
12 | + | ||
13 | +if ($('.swiper-container .swiper-slide').length > 1) { | ||
14 | + new Swiper('.swiper-container', { | ||
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 | + |
public/scss/guang/star/_collocation.css
0 → 100644
1 | +.star-page { | ||
2 | + .collocation-list { | ||
3 | + width: 100%; | ||
4 | + float: left; | ||
5 | + | ||
6 | + li { | ||
7 | + float: left; | ||
8 | + width: 100%; | ||
9 | + margin-top: 30px; | ||
10 | + background: #000; | ||
11 | + | ||
12 | + .cont-area { | ||
13 | + width: 100%; | ||
14 | + box-sizing: border-box; | ||
15 | + padding: 30px; | ||
16 | + } | ||
17 | + | ||
18 | + .cont-txt { | ||
19 | + font-size: 28px; | ||
20 | + line-height: 46px; | ||
21 | + color: #b0b0b0; | ||
22 | + margin-top: 10px; | ||
23 | + } | ||
24 | + | ||
25 | + img { | ||
26 | + width: 100%; | ||
27 | + } | ||
28 | + | ||
29 | + .title { | ||
30 | + font-size: 40px; | ||
31 | + line-height: 48px; | ||
32 | + color: #fff; | ||
33 | + width: 100%; | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + .count-area { | ||
39 | + position: relative; | ||
40 | + width: 100%; | ||
41 | + height: 32px; | ||
42 | + | ||
43 | + span { | ||
44 | + font-size: 24px; | ||
45 | + color: #b0b0b0; | ||
46 | + height: 32px; | ||
47 | + line-height: 32px; | ||
48 | + | ||
49 | + i { | ||
50 | + display: inline-block; | ||
51 | + margin-right: 5px; | ||
52 | + font-size: 24px; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + .time { | ||
57 | + float: left; | ||
58 | + } | ||
59 | + | ||
60 | + .see { | ||
61 | + float: left; | ||
62 | + margin-left: 20px; | ||
63 | + } | ||
64 | + | ||
65 | + .time-ico { | ||
66 | + width: 24px; | ||
67 | + height: 24px; | ||
68 | + } | ||
69 | + | ||
70 | + .see-ico { | ||
71 | + width: 31px; | ||
72 | + height: 24px; | ||
73 | + } | ||
74 | + | ||
75 | + .collection { | ||
76 | + position: absolute; | ||
77 | + right: 122px; | ||
78 | + } | ||
79 | + | ||
80 | + .collected-ico { | ||
81 | + width: 34px; | ||
82 | + height: 32px; | ||
83 | + vertical-align: text-bottom; | ||
84 | + } | ||
85 | + | ||
86 | + .collected { | ||
87 | + color: #D62927; | ||
88 | + } | ||
89 | + | ||
90 | + .forward { | ||
91 | + width: 40px; | ||
92 | + height: 28px; | ||
93 | + position: absolute; | ||
94 | + right: 23px; | ||
95 | + margin-left: 45px; | ||
96 | + font-size: 24px; | ||
97 | + color: #b0b0b0; | ||
98 | + height: 32px; | ||
99 | + line-height: 32px; | ||
100 | + } | ||
101 | + } | ||
102 | +} | ||
103 | + | ||
104 | +.star-class-body { | ||
105 | + background: #333; | ||
106 | + width: 100%; | ||
107 | + font: 12px/1.5 Arial,'黑体'; | ||
108 | + float: left; | ||
109 | +} |
public/scss/guang/star/_special.css
0 → 100644
1 | +.star-page { | ||
2 | + .special-list { | ||
3 | + width: 100%; | ||
4 | + height: auto; | ||
5 | + overflow: hidden; | ||
6 | + | ||
7 | + li { | ||
8 | + width: 100%; | ||
9 | + float: left; | ||
10 | + background: #000; | ||
11 | + margin-top: 30px; | ||
12 | + | ||
13 | + img { | ||
14 | + width: 100%; | ||
15 | + } | ||
16 | + | ||
17 | + p { | ||
18 | + width: 100%; | ||
19 | + height: 88px; | ||
20 | + box-sizing: border-box; | ||
21 | + overflow: hidden; | ||
22 | + white-space: nowrap; | ||
23 | + text-overflow: ellipsis; | ||
24 | + padding: 0 34px; | ||
25 | + font-size: 34px; | ||
26 | + line-height: 88px; | ||
27 | + } | ||
28 | + | ||
29 | + a { | ||
30 | + color: #fff; | ||
31 | + } | ||
32 | + } | ||
33 | + } | ||
34 | +} | ||
35 | + | ||
36 | + |
-
Please register or login to post a comment