Authored by ccbikai

整理代码

@@ -56,7 +56,7 @@ exports.index = (req, res) => { @@ -56,7 +56,7 @@ exports.index = (req, res) => {
56 }, processPublicData(req, '星潮教室'))); 56 }, processPublicData(req, '星潮教室')));
57 }; 57 };
58 58
59 -exports.ajaxIndexHtml = (req, res) => { 59 +exports.getIndexHtml = (req, res) => {
60 starModel.getIndexData().then((result) => { 60 starModel.getIndexData().then((result) => {
61 res.render('star/index-html', _.assign({ 61 res.render('star/index-html', _.assign({
62 layout: false, 62 layout: false,
@@ -13,7 +13,7 @@ const star = require(cRoot + '/star'); @@ -13,7 +13,7 @@ const star = require(cRoot + '/star');
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', star.index); // 星潮教室首页
16 -router.get('/star/ajaxIndexHtml', star.ajaxIndexHtml); // 星潮教室首页 16 +router.get('/star/getIndexHtml', star.getIndexHtml); // 星潮教室首页
17 router.get('/star/detail', star.detail); // 明星文章专区 17 router.get('/star/detail', star.detail); // 明星文章专区
18 router.get('/star/detailList', star.detailList); // 明星文章专区文章Ajax请求 18 router.get('/star/detailList', star.detailList); // 明星文章专区文章Ajax请求
19 router.get('/star/special', star.special); // 星潮教室星专题 19 router.get('/star/special', star.special); // 星潮教室星专题
1 - <div class="avatar-swiper avatar-1">  
2 - <ul class="clearfix swiper-wrapper">  
3 - {{# starAvatar}}  
4 - <li class="swiper-slide">  
5 - <img class="rank-avatar" data-url="{{url}}" src="{{image cover 180 180}}">  
6 - </li>  
7 - {{/ starAvatar}}  
8 - </ul>  
9 -</div>  
10 -<div class="loading-tip">松手开始刷新...</div> 1 +<div class="loading-tip">松手开始刷新...</div>
11 <div class="star-wrap"> 2 <div class="star-wrap">
12 <div class="star-content"> 3 <div class="star-content">
13 {{#content}} 4 {{#content}}
@@ -16,14 +7,16 @@ @@ -16,14 +7,16 @@
16 {{/if}} 7 {{/if}}
17 {{/content}} 8 {{/content}}
18 9
19 - <div class="avatar-swiper avatar-0">  
20 - <ul class="clearfix swiper-wrapper">  
21 - {{# starAvatar}}  
22 - <li class="swiper-slide">  
23 - <img class="rank-avatar" data-url="{{url}}" src="{{image cover 180 180}}">  
24 - </li>  
25 - {{/ starAvatar}}  
26 - </ul> 10 + <div class="avatar-wrap">
  11 + <div class="avatar-swiper avatar-0">
  12 + <ul class="clearfix swiper-wrapper">
  13 + {{# starAvatar}}
  14 + <li class="swiper-slide">
  15 + <img class="rank-avatar" data-url="{{url}}" src="{{image cover 180 180}}">
  16 + </li>
  17 + {{/ starAvatar}}
  18 + </ul>
  19 + </div>
27 </div> 20 </div>
28 21
29 <ul class="star-info clearfix"> 22 <ul class="star-info clearfix">
@@ -78,8 +78,6 @@ function setIndexAction() { @@ -78,8 +78,6 @@ function setIndexAction() {
78 }); 78 });
79 79
80 starIScroll.iScroll.on('scrollStart', function() { 80 starIScroll.iScroll.on('scrollStart', function() {
81 - $window.trigger('scroll');  
82 -  
83 // 下拉 81 // 下拉
84 if (this.directionY === -1) { 82 if (this.directionY === -1) {
85 $headTab.slideDown(); 83 $headTab.slideDown();
@@ -89,16 +87,14 @@ function setIndexAction() { @@ -89,16 +87,14 @@ function setIndexAction() {
89 87
90 starIScroll.iScroll.on('scroll', function() { 88 starIScroll.iScroll.on('scroll', function() {
91 if (this.startY < -180) { 89 if (this.startY < -180) {
92 - 90 + console.log('111');
93 } 91 }
94 }); 92 });
95 93
96 starIScroll.iScroll.on('scrollEnd', function() { 94 starIScroll.iScroll.on('scrollEnd', function() {
97 - $window.trigger('scroll');  
98 -  
99 // 上滑 95 // 上滑
100 if (this.directionY === 1) { 96 if (this.directionY === 1) {
101 - $headTab.slideUp(); 97 + $headTab.slideUp(1000);
102 } 98 }
103 $loadingTip.slideUp(); 99 $loadingTip.slideUp();
104 }); 100 });
@@ -253,13 +249,14 @@ function setIndexAction() { @@ -253,13 +249,14 @@ function setIndexAction() {
253 getIndexHtml = function() { 249 getIndexHtml = function() {
254 loading.showLoadingMask(); 250 loading.showLoadingMask();
255 $.ajax({ 251 $.ajax({
256 - type: 'GET',  
257 - url: '/guang/star/ajaxIndexHtml', 252 + url: '/guang/star/getIndexHtml',
258 dataType: 'html', 253 dataType: 'html',
259 success: function(data) { 254 success: function(data) {
260 stopLoading = false; 255 stopLoading = false;
261 256
262 - if (data === '') { 257 + console.log(data);
  258 +
  259 + if (!data) {
263 stopLoading = true; 260 stopLoading = true;
264 tip.show('没有更多内容了'); 261 tip.show('没有更多内容了');
265 } 262 }
@@ -48,3 +48,5 @@ function hideLoadingMask() { @@ -48,3 +48,5 @@ function hideLoadingMask() {
48 exports.init = init; 48 exports.init = init;
49 exports.showLoadingMask = showLoadingMask; 49 exports.showLoadingMask = showLoadingMask;
50 exports.hideLoadingMask = hideLoadingMask; 50 exports.hideLoadingMask = hideLoadingMask;
  51 +exports.show = showLoadingMask;
  52 +exports.hide = hideLoadingMask;
@@ -18,7 +18,8 @@ var $ = require('yoho-jquery'), @@ -18,7 +18,8 @@ var $ = require('yoho-jquery'),
18 // }); 18 // });
19 19
20 function PullRefresh(seclector, options) { 20 function PullRefresh(seclector, options) {
21 - var $em, 21 + var $window = $(window),
  22 + $em,
22 pullFormTop = false, 23 pullFormTop = false,
23 pullStart, 24 pullStart,
24 topOffset; 25 topOffset;
@@ -46,6 +47,7 @@ function PullRefresh(seclector, options) { @@ -46,6 +47,7 @@ function PullRefresh(seclector, options) {
46 } 47 }
47 48
48 pullStart = this.y; 49 pullStart = this.y;
  50 + $window.trigger('scroll');
49 }); 51 });
50 52
51 this.iScroll.on('scrollEnd', function() { 53 this.iScroll.on('scrollEnd', function() {
@@ -57,6 +59,8 @@ function PullRefresh(seclector, options) { @@ -57,6 +59,8 @@ function PullRefresh(seclector, options) {
57 if (pullStart === this.y && this.directionY === 1) { 59 if (pullStart === this.y && this.directionY === 1) {
58 options.pullUp && options.pullUp(); 60 options.pullUp && options.pullUp();
59 } 61 }
  62 +
  63 + $window.trigger('scroll');
60 }); 64 });
61 } 65 }
62 66
@@ -115,6 +115,12 @@ @@ -115,6 +115,12 @@
115 overflow: hidden; 115 overflow: hidden;
116 margin-top: 30px; 116 margin-top: 30px;
117 117
  118 + .fixed {
  119 + position: fixed;
  120 + left: 0;
  121 + top: 0;
  122 + }
  123 +
118 li { 124 li {
119 float: left; 125 float: left;
120 width: auto; 126 width: auto;
@@ -357,14 +363,6 @@ @@ -357,14 +363,6 @@
357 float: left; 363 float: left;
358 } 364 }
359 365
360 - .avatar-1 {  
361 - background: #000;  
362 - position: relative;  
363 - z-index: 9;  
364 - margin-top: 0;  
365 - display: none;  
366 - }  
367 -  
368 .loading-tip { 366 .loading-tip {
369 display: none; 367 display: none;
370 text-align: center; 368 text-align: center;