Authored by 王水玲

星潮教室修改

@@ -9,8 +9,6 @@ const mRoot = '../models'; @@ -9,8 +9,6 @@ const mRoot = '../models';
9 const _ = require('lodash'); 9 const _ = require('lodash');
10 const starModel = require(`${mRoot}/star`); 10 const starModel = require(`${mRoot}/star`);
11 11
12 -// const headerModel = require('../../../doraemon/models/header');  
13 -  
14 const headTab = [ 12 const headTab = [
15 { 13 {
16 url: '/guang/star', 14 url: '/guang/star',
@@ -21,22 +19,15 @@ const headTab = [ @@ -21,22 +19,15 @@ const headTab = [
21 name: '星专题' 19 name: '星专题'
22 }, 20 },
23 { 21 {
24 - url: '/guang/star/collocation?uid=', 22 + url: '/guang/star/collocation',
25 name: '星搭配' 23 name: '星搭配'
26 } 24 }
27 ]; 25 ];
28 26
29 const processPublicData = (req, title) => { 27 const processPublicData = (req, title) => {
30 - // let headerData = headerModel.setNav({  
31 - // navTitle: title,  
32 - // navBtn: navBtn  
33 - // });  
34 -  
35 let renderData = { 28 let renderData = {
36 module: 'guang', 29 module: 'guang',
37 title: title 30 title: title
38 -  
39 - // pageHeader: headerData  
40 }; 31 };
41 32
42 if (req.query.app_version || req.query.appVersion) { 33 if (req.query.app_version || req.query.appVersion) {
@@ -56,15 +47,8 @@ exports.index = (req, res, next) => { @@ -56,15 +47,8 @@ exports.index = (req, res, next) => {
56 const pageHeadTab = _.cloneDeep(headTab); 47 const pageHeadTab = _.cloneDeep(headTab);
57 48
58 pageHeadTab[0].cur = true; 49 pageHeadTab[0].cur = true;
59 - pageHeadTab[2].url += (req.query.uid || 0);  
60 -  
61 - // res.render('star/index', _.assign({  
62 - // page: 'star',  
63 - // isStarIndexPage: true,  
64 - // headTab: pageHeadTab  
65 - // }, processPublicData(req, '星潮教室')));  
66 50
67 - starModel.getIndexData((req.query.uid || 0)).then((result) => { 51 + starModel.getIndexData().then((result) => {
68 res.render('star/index', _.assign({ 52 res.render('star/index', _.assign({
69 page: 'star', 53 page: 'star',
70 isStarIndexPage: true, 54 isStarIndexPage: true,
@@ -73,21 +57,21 @@ exports.index = (req, res, next) => { @@ -73,21 +57,21 @@ exports.index = (req, res, next) => {
73 focus: true, 57 focus: true,
74 data: result.ads 58 data: result.ads
75 }, 59 },
76 - starAvatar: result.starAvatar.concat(result.starAvatar).concat(result.starAvatar), // 需要优化,数组重复三次 60 + starAvatar: result.starAvatar ? result.starAvatar : '',
77 articles: result.articles 61 articles: result.articles
78 }, processPublicData(req, '星潮教室'))); 62 }, processPublicData(req, '星潮教室')));
79 }).catch(next); 63 }).catch(next);
80 }; 64 };
81 65
82 exports.getIndexHtml = (req, res, next) => { 66 exports.getIndexHtml = (req, res, next) => {
83 - starModel.getIndexData((req.query.uid || 0)).then((result) => { 67 + starModel.getIndexData().then((result) => {
84 res.render('star/index-html', _.assign({ 68 res.render('star/index-html', _.assign({
85 layout: false, 69 layout: false,
86 content: { 70 content: {
87 focus: true, 71 focus: true,
88 data: result.ads 72 data: result.ads
89 }, 73 },
90 - starAvatar: result.starAvatar.concat(result.starAvatar).concat(result.starAvatar), // 需要优化,数组重复三次 74 + starAvatar: result.starAvatar ? result.starAvatar : '',
91 articles: result.articles 75 articles: result.articles
92 })); 76 }));
93 }).catch(next); 77 }).catch(next);
@@ -104,7 +88,6 @@ exports.special = (req, res, next) => { @@ -104,7 +88,6 @@ exports.special = (req, res, next) => {
104 const pageHeadTab = _.cloneDeep(headTab); 88 const pageHeadTab = _.cloneDeep(headTab);
105 89
106 pageHeadTab[1].cur = true; 90 pageHeadTab[1].cur = true;
107 - pageHeadTab[2].url += (req.query.uid || 0);  
108 res.render('star/special', _.assign({ 91 res.render('star/special', _.assign({
109 page: 'special' 92 page: 'special'
110 }, processPublicData(req, '星潮教室'), { 93 }, processPublicData(req, '星潮教室'), {
@@ -126,7 +109,6 @@ exports.collocation = (req, res) => { @@ -126,7 +109,6 @@ exports.collocation = (req, res) => {
126 const pageHeadTab = _.cloneDeep(headTab); 109 const pageHeadTab = _.cloneDeep(headTab);
127 110
128 pageHeadTab[2].cur = true; 111 pageHeadTab[2].cur = true;
129 - pageHeadTab[2].url += (req.query.uid || 0);  
130 res.render('star/collocation', _.assign({ 112 res.render('star/collocation', _.assign({
131 isStarDetailPage: true, 113 isStarDetailPage: true,
132 page: 'collocation' 114 page: 'collocation'
@@ -144,7 +126,7 @@ exports.collocation = (req, res) => { @@ -144,7 +126,7 @@ exports.collocation = (req, res) => {
144 */ 126 */
145 exports.collocationList = (req, res, next) => { 127 exports.collocationList = (req, res, next) => {
146 let params = req.query; 128 let params = req.query;
147 - let uid = req.query.uid || 0; // 客户端访问,不能使用 cookie 129 + let uid = req.cookies.guangStarUid || 0; // 客户端访问,不能使用 cookie
148 130
149 starModel.getCollocationListData(params, uid).then((result) => { 131 starModel.getCollocationListData(params, uid).then((result) => {
150 res.render('star/list', _.assign({ 132 res.render('star/list', _.assign({
@@ -163,7 +145,7 @@ exports.collocationList = (req, res, next) => { @@ -163,7 +145,7 @@ exports.collocationList = (req, res, next) => {
163 * @return {[type]} 145 * @return {[type]}
164 */ 146 */
165 exports.setFavorite = (req, res, next) => { 147 exports.setFavorite = (req, res, next) => {
166 - let uid = req.body.uid || 0; // 客户端访问,不能使用 cookie 148 + let uid = req.cookies.guangStarUid || 0;
167 let urlEncode = ''; 149 let urlEncode = '';
168 let url = ''; 150 let url = '';
169 let params = { 151 let params = {
@@ -172,10 +154,10 @@ exports.setFavorite = (req, res, next) => { @@ -172,10 +154,10 @@ exports.setFavorite = (req, res, next) => {
172 }; 154 };
173 155
174 if (req.body.pageType === '1') { 156 if (req.body.pageType === '1') {
175 - url = `/guang/star/collocation?uid=${uid}`; 157 + url = '/guang/star/collocation';
176 urlEncode = '\/guang\/star\/collocation'; 158 urlEncode = '\/guang\/star\/collocation';
177 } else { 159 } else {
178 - url = `/guang/star/detail?tag=${req.body.tag}&uid=${uid}`; 160 + url = `/guang/star/detail?tag=${req.body.tag}`;
179 urlEncode = '\/guang\/star\/detail'; 161 urlEncode = '\/guang\/star\/detail';
180 } 162 }
181 163
@@ -45,7 +45,7 @@ const _getResources = (page) => { @@ -45,7 +45,7 @@ const _getResources = (page) => {
45 * @param {[array]} list 45 * @param {[array]} list
46 * @return {[array]} 46 * @return {[array]}
47 */ 47 */
48 -const _processIndexData = (list, uid) => { 48 +const _processIndexData = (list) => {
49 const formatData = { 49 const formatData = {
50 ads: [], 50 ads: [],
51 starAvatar: [], 51 starAvatar: [],
@@ -78,8 +78,8 @@ const _processIndexData = (list, uid) => { @@ -78,8 +78,8 @@ const _processIndexData = (list, uid) => {
78 78
79 _.forEach(data.ext.tags, (tags) => { 79 _.forEach(data.ext.tags, (tags) => {
80 avatar.tags.push({ 80 avatar.tags.push({
81 - avatarUrl: `/guang/star/detail?tag=${tags.tagName}&uid=${uid}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${tags.tagName}"}}}`, // eslint-disable-line  
82 - cover: tags.cover, 81 + avatarUrl: `/guang/star/detail?tag=${tags.tagName}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${tags.tagName}"}}}`, // eslint-disable-line
  82 + cover: tags.cover ? (tags.cover + '?imageView2/2/w/104/h/104') : tags.cover,
83 tagName: tags.tagName 83 tagName: tags.tagName
84 }); 84 });
85 }); 85 });
@@ -100,11 +100,11 @@ const _processIndexData = (list, uid) => { @@ -100,11 +100,11 @@ const _processIndexData = (list, uid) => {
100 // 首页明星头像数据处理 100 // 首页明星头像数据处理
101 if (list.tags) { 101 if (list.tags) {
102 _.forEach(list.tags, (data) => { 102 _.forEach(list.tags, (data) => {
103 - let url = `/guang/star/detail?tag=${data.tagName}&uid=${uid}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${data.tagName}"}}}`; // eslint-disable-line 103 + let url = `/guang/star/detail?tag=${data.tagName}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${data.tagName}"}}}`; // eslint-disable-line
104 104
105 formatData.starAvatar.push({ 105 formatData.starAvatar.push({
106 url: url, 106 url: url,
107 - cover: data.cover 107 + cover: data.cover ? (data.cover + '?imageView2/2/w/180/h/180') : data.cover
108 }); 108 });
109 }); 109 });
110 } 110 }
@@ -164,14 +164,14 @@ const _processCollocationData = (list) => { @@ -164,14 +164,14 @@ const _processCollocationData = (list) => {
164 /** 164 /**
165 * 星潮首页 165 * 星潮首页
166 */ 166 */
167 -const getIndexData = (uid) => { 167 +const getIndexData = () => {
168 return api.get('', sign.apiSign({ 168 return api.get('', sign.apiSign({
169 method: 'app.starClass.index', 169 method: 'app.starClass.index',
170 code: '8adc27fcf5676f356602889afcfd2a8e', 170 code: '8adc27fcf5676f356602889afcfd2a8e',
171 client_type: 'iphone' 171 client_type: 'iphone'
172 })).then((result) => { 172 })).then((result) => {
173 if (result && result.code === 200) { 173 if (result && result.code === 200) {
174 - return _processIndexData(result.data, uid); 174 + return _processIndexData(result.data);
175 } else { 175 } else {
176 logger.error('星潮教室首页数据返回 code 不是 200'); 176 logger.error('星潮教室首页数据返回 code 不是 200');
177 return {}; 177 return {};
@@ -232,7 +232,6 @@ const getSpecialData = () => { @@ -232,7 +232,6 @@ const getSpecialData = () => {
232 * 星搭配 232 * 星搭配
233 */ 233 */
234 const getCollocationListData = (params, uid) => { 234 const getCollocationListData = (params, uid) => {
235 -  
236 return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', sign.apiSign(Object.assign({ 235 return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', sign.apiSign(Object.assign({
237 limit: '20', 236 limit: '20',
238 uid: uid 237 uid: uid
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 <ul class="clearfix swiper-wrapper"> 12 <ul class="clearfix swiper-wrapper">
13 {{# starAvatar}} 13 {{# starAvatar}}
14 <li class="swiper-slide"> 14 <li class="swiper-slide">
15 - <a href='{{url}}' data-avatar="{{image cover 180 180}}" class="rank-avatar"></a> 15 + <a href='{{url}}' style="background-image: url({{image cover 180 180}})" class="star"></a>
16 </li> 16 </li>
17 {{/ starAvatar}} 17 {{/ starAvatar}}
18 </ul> 18 </ul>
@@ -36,7 +36,6 @@ $('.collocation-list,.detail-list').on('click', '.collection', function() { @@ -36,7 +36,6 @@ $('.collocation-list,.detail-list').on('click', '.collection', function() {
36 data: { 36 data: {
37 articleId: $that.parents('li').attr('articleId'), 37 articleId: $that.parents('li').attr('articleId'),
38 type: type, 38 type: type,
39 - uid: window.queryString.uid,  
40 pageType: pageType, 39 pageType: pageType,
41 tag: tag 40 tag: tag
42 }, 41 },
@@ -66,21 +65,3 @@ $('.collocation-list,.detail-list').on('click', '.collection', function() { @@ -66,21 +65,3 @@ $('.collocation-list,.detail-list').on('click', '.collection', function() {
66 } 65 }
67 }); 66 });
68 }); 67 });
69 -  
70 -// 分享成功  
71 -window.successShare = function() {  
72 - $.ajax({  
73 - type: 'POST',  
74 - url: '/guang/starclass/forward',  
75 - success: function(data) {  
76 - var code = data.code;  
77 -  
78 - if (code === 200 && data.data > 0) {  
79 - tip.show('分享成功,亲密度+10');  
80 - }  
81 - },  
82 - error: function() {  
83 - tip.show('网络断开连接了~');  
84 - }  
85 - });  
86 -};  
@@ -17,7 +17,6 @@ var $window = $(window), @@ -17,7 +17,6 @@ var $window = $(window),
17 $starMain = $('.star-main'); 17 $starMain = $('.star-main');
18 18
19 /* 19 /*
20 - $headTab = $('.head-tab'),  
21 $swiperView = $('.swiper-view'), 20 $swiperView = $('.swiper-view'),
22 $viewImg = $('.view-img'), 21 $viewImg = $('.view-img'),
23 $body = $('body'), 22 $body = $('body'),
@@ -75,7 +74,7 @@ function bindAvatar(dom) { @@ -75,7 +74,7 @@ function bindAvatar(dom) {
75 avatarSwiper.slideTo(bannerLen + 1, 200); 74 avatarSwiper.slideTo(bannerLen + 1, 200);
76 } else if (avatarKey <= (bannerLen - 1)) { 75 } else if (avatarKey <= (bannerLen - 1)) {
77 avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200); 76 avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200);
78 - avatarSwiper.slideTo(2 * bannerLen - 1, 200); 77 + avatarSwiper.slideTo(2 * bannerLen - (bannerLen - avatarKey), 200);
79 } else { 78 } else {
80 avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200); 79 avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200);
81 avatarSwiper.slideTo(avatarKey, 200); 80 avatarSwiper.slideTo(avatarKey, 200);
@@ -111,8 +110,6 @@ function setIndexAction() { @@ -111,8 +110,6 @@ function setIndexAction() {
111 starIScroll.iScroll.on('scrollStart', function() { 110 starIScroll.iScroll.on('scrollStart', function() {
112 // 下拉 111 // 下拉
113 if (this.directionY === -1) { 112 if (this.directionY === -1) {
114 -  
115 - // $headTab.slideDown();  
116 $loadingTip.slideDown(); 113 $loadingTip.slideDown();
117 } 114 }
118 }); 115 });
@@ -151,11 +148,6 @@ function setIndexAction() { @@ -151,11 +148,6 @@ function setIndexAction() {
151 }); 148 });
152 149
153 starIScroll.iScroll.on('scrollEnd', function() { 150 starIScroll.iScroll.on('scrollEnd', function() {
154 - // 上滑  
155 - // if (this.directionY === 1) {  
156 - // $headTab.slideUp(600);  
157 - // }  
158 -  
159 $loadingTip.slideUp(); 151 $loadingTip.slideUp();
160 }); 152 });
161 153
@@ -220,6 +212,12 @@ function setIndexAction() { @@ -220,6 +212,12 @@ function setIndexAction() {
220 setAvatar($(item)); 212 setAvatar($(item));
221 }); 213 });
222 214
  215 + $('.star').each(function(key, item) {
  216 + if ($(item).attr('src') === '') {
  217 + $(item).addClass('default-avater');
  218 + }
  219 + });
  220 +
223 $('#yoho-header, .head-tab').on('touchmove', function() { 221 $('#yoho-header, .head-tab').on('touchmove', function() {
224 return false; 222 return false;
225 }); 223 });
@@ -279,9 +277,10 @@ getIndexHtml = function() { @@ -279,9 +277,10 @@ getIndexHtml = function() {
279 } 277 }
280 }); 278 });
281 }; 279 };
  280 +
282 initAction(); 281 initAction();
283 282
284 -// getIndexHtml(); 283 +window.setCookie('guangStarUid', window.queryString.uid);
285 284
286 // 明星动态文章图片相关操作 285 // 明星动态文章图片相关操作
287 /* 286 /*
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 12
13 img { 13 img {
14 width: 100%; 14 width: 100%;
  15 + min-height: 310px;
15 } 16 }
16 17
17 p { 18 p {
@@ -386,6 +386,15 @@ @@ -386,6 +386,15 @@
386 background-size: contain; 386 background-size: contain;
387 } 387 }
388 388
  389 + .star {
  390 + display: block;
  391 + width: 100%;
  392 + height: 100%;
  393 + background-color: #000;
  394 + background-repeat: no-repeat;
  395 + background-size: contain;
  396 + }
  397 +
389 .default-avater { 398 .default-avater {
390 background-image: resolve('guang/star/user-avatar.png'); 399 background-image: resolve('guang/star/user-avatar.png');
391 } 400 }