Authored by 王水玲

星潮优化

@@ -3,7 +3,10 @@ @@ -3,7 +3,10 @@
3 <div class="swiper-num swiper-num1"></div> 3 <div class="swiper-num swiper-num1"></div>
4 <div class="swiper-num swiper-num2"></div> 4 <div class="swiper-num swiper-num2"></div>
5 <div class="swiper-num swiper-num3"></div> 5 <div class="swiper-num swiper-num3"></div>
  6 + <div class="loading-tip">下拉刷新</div>
6 <div class="star-main"> 7 <div class="star-main">
7 - {{> star/index-html}} 8 + <div class="main-content">
  9 + {{> star/index-html}}
  10 + </div>
8 </div> 11 </div>
9 </div> 12 </div>
1 -<div class="loading-tip">下拉刷新</div>  
2 <div class="star-wrap"> 1 <div class="star-wrap">
3 <div class="star-content"> 2 <div class="star-content">
4 {{#content}} 3 {{#content}}
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 (function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window); 18 (function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
19 </script> 19 </script>
20 {{#if devEnv}} 20 {{#if devEnv}}
21 - <link rel="stylesheet" href="//localhost:5001/css/index.css"> 21 + <link rel="stylesheet" href="//172.16.6.210:5001/css/index.css">
22 {{^}} 22 {{^}}
23 <link rel="stylesheet" href="//cdn.yoho.cn/m-yohobuy-node/{{version}}/index.css"> 23 <link rel="stylesheet" href="//cdn.yoho.cn/m-yohobuy-node/{{version}}/index.css">
24 {{/if}} 24 {{/if}}
@@ -41,8 +41,8 @@ @@ -41,8 +41,8 @@
41 <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script> 41 <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
42 {{/wechatShare}} 42 {{/wechatShare}}
43 {{#if devEnv}} 43 {{#if devEnv}}
44 - <script src="//localhost:5001/libs.js"></script>  
45 - <script src="//localhost:5001/{{module}}.{{page}}.js"></script> 44 + <script src="//172.16.6.210:5001/libs.js"></script>
  45 + <script src="//172.16.6.210:5001/{{module}}.{{page}}.js"></script>
46 {{^}} 46 {{^}}
47 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js"></script> 47 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js"></script>
48 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script> 48 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
@@ -59,7 +59,7 @@ function massageAJAX(pageData) { @@ -59,7 +59,7 @@ function massageAJAX(pageData) {
59 } 59 }
60 60
61 function scrollHandler() { 61 function scrollHandler() {
62 - if (!stopLoading && ($(window).scrollTop() + $(window).height() > $('body').height() - 100)) { 62 + if (!stopLoading && ($(window).scrollTop() + $(window).height() > $('body').height() * 0.75)) {
63 stopLoading = true; 63 stopLoading = true;
64 page++; 64 page++;
65 massageAJAX(page); 65 massageAJAX(page);
@@ -14,10 +14,11 @@ var $ = require('yoho-jquery'), @@ -14,10 +14,11 @@ var $ = require('yoho-jquery'),
14 14
15 var $window = $(window), 15 var $window = $(window),
16 stopLoading = false, 16 stopLoading = false,
17 - $starMain = $('.star-main'), 17 + $mainContent = $('.main-content'),
18 $headTab = $('.head-tab'), 18 $headTab = $('.head-tab'),
19 headTabH = $headTab.height(), 19 headTabH = $headTab.height(),
20 - scrollH = $(window).height() - headTabH; 20 + scrollH = $(window).height() - headTabH,
  21 + $loadingTip = $('.loading-tip');
21 22
22 /* 23 /*
23 $swiperView = $('.swiper-view'), 24 $swiperView = $('.swiper-view'),
@@ -29,7 +30,8 @@ var $window = $(window), @@ -29,7 +30,8 @@ var $window = $(window),
29 var mySwiper; 30 var mySwiper;
30 */ 31 */
31 32
32 -var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $starArticle; 33 +var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
  34 + $avatarClone, $starArticle, $avatarWrap, starIScroll;
33 35
34 var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) + 36 var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
35 ($('.swiper-num3').width() - $('.swiper-num1').width()) / 2; 37 ($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
@@ -91,66 +93,6 @@ function bindAvatar(dom) { @@ -91,66 +93,6 @@ function bindAvatar(dom) {
91 } 93 }
92 94
93 function setIndexAction() { 95 function setIndexAction() {
94 - var starIScroll;  
95 -  
96 - var $loadingTip = $('.loading-tip'),  
97 - $avatarWrap = $('.avatar-wrap:not(.avatar-clone)');  
98 -  
99 - // 下拉刷新,上拉加载  
100 - starIScroll = new PullRefresh('.star-wrap', {  
101 - height: scrollH,  
102 - pullDown: function() {  
103 - if (!stopLoading) {  
104 - stopLoading = true;  
105 - getIndexHtml();  
106 - }  
107 - }  
108 - });  
109 -  
110 - starIScroll.iScroll.on('scrollStart', function() {  
111 - // 下拉  
112 - if (this.directionY === -1) {  
113 - $loadingTip.slideDown();  
114 - }  
115 - });  
116 -  
117 - starIScroll.iScroll.on('scroll', function() {  
118 - if ($avatarWrap.offset().top <= headTabH) {  
119 - $avatarClone.show();  
120 -  
121 - if (!avatarSwiperClone) {  
122 - avatarSwiperClone = new Swiper('.avatar-0', {  
123 - loop: true,  
124 - initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,  
125 - centeredSlides: true,  
126 - slidesPerView: 'auto',  
127 - loopedSlides: bannerLen,  
128 - spaceBetween: 10,  
129 - slidesOffsetBefore: -swiperNum,  
130 - watchSlidesProgress: true,  
131 - watchSlidesVisibility: true,  
132 - onInit: function() {  
133 - $('.avatar-0 li').on('click', function() {  
134 - res = bindAvatar($(this));  
135 - return res;  
136 - });  
137 - }  
138 - });  
139 -  
140 - avatarSwiperClone.params.control = avatarSwiper;  
141 - avatarSwiper.params.control = avatarSwiperClone;  
142 - }  
143 - }  
144 -  
145 - if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {  
146 - $avatarClone.hide();  
147 - }  
148 - });  
149 -  
150 - starIScroll.iScroll.on('scrollEnd', function() {  
151 - $loadingTip.slideUp();  
152 - });  
153 -  
154 $('.avatar').each(function(key, item) { 96 $('.avatar').each(function(key, item) {
155 $(item).addClass('avatar-' + key); 97 $(item).addClass('avatar-' + key);
156 }); 98 });
@@ -229,13 +171,14 @@ function setIndexAction() { @@ -229,13 +171,14 @@ function setIndexAction() {
229 171
230 function initAction() { 172 function initAction() {
231 $starArticle = $('.star-article'); 173 $starArticle = $('.star-article');
  174 + $avatarWrap = $('.avatar-wrap');
232 bannerLen = $('.avatar-wrap').find('.swiper-slide').length; 175 bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
233 176
234 if ($avatarClone) { 177 if ($avatarClone) {
235 $avatarClone.remove(); 178 $avatarClone.remove();
236 } 179 }
237 180
238 - $starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide()); 181 + $loadingTip.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
239 182
240 $avatarClone = $('.avatar-clone'); 183 $avatarClone = $('.avatar-clone');
241 184
@@ -265,7 +208,7 @@ getIndexHtml = function() { @@ -265,7 +208,7 @@ getIndexHtml = function() {
265 avatarSwiperClone = ''; 208 avatarSwiperClone = '';
266 } 209 }
267 210
268 - $starMain.html(data); 211 + $mainContent.html(data);
269 212
270 initAction(); 213 initAction();
271 } 214 }
@@ -280,6 +223,61 @@ getIndexHtml = function() { @@ -280,6 +223,61 @@ getIndexHtml = function() {
280 223
281 initAction(); 224 initAction();
282 225
  226 +// 下拉刷新,上拉加载
  227 +starIScroll = new PullRefresh('.star-main', {
  228 + height: scrollH,
  229 + pullDown: function() {
  230 + if (!stopLoading) {
  231 + stopLoading = true;
  232 + getIndexHtml();
  233 + }
  234 + }
  235 +});
  236 +
  237 +starIScroll.iScroll.on('scrollStart', function() {
  238 + // 下拉
  239 + if (this.directionY === -1) {
  240 + $loadingTip.slideDown();
  241 + }
  242 +});
  243 +
  244 +starIScroll.iScroll.on('scroll', function() {
  245 + if ($avatarWrap.offset().top <= headTabH) {
  246 + $avatarClone.show();
  247 +
  248 + if (!avatarSwiperClone) {
  249 + avatarSwiperClone = new Swiper('.avatar-0', {
  250 + loop: true,
  251 + initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
  252 + centeredSlides: true,
  253 + slidesPerView: 'auto',
  254 + loopedSlides: bannerLen,
  255 + spaceBetween: 10,
  256 + slidesOffsetBefore: -swiperNum,
  257 + watchSlidesProgress: true,
  258 + watchSlidesVisibility: true,
  259 + onInit: function() {
  260 + $('.avatar-0 li').on('click', function() {
  261 + res = bindAvatar($(this));
  262 + return res;
  263 + });
  264 + }
  265 + });
  266 +
  267 + avatarSwiperClone.params.control = avatarSwiper;
  268 + avatarSwiper.params.control = avatarSwiperClone;
  269 + }
  270 + }
  271 +
  272 + if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
  273 + $avatarClone.hide();
  274 + }
  275 +});
  276 +
  277 +starIScroll.iScroll.on('scrollEnd', function() {
  278 + $loadingTip.slideUp();
  279 +});
  280 +
283 window.setCookie('guangStarUid', window.queryString.uid); 281 window.setCookie('guangStarUid', window.queryString.uid);
284 282
285 // 明星动态文章图片相关操作 283 // 明星动态文章图片相关操作
1 .star-page { 1 .star-page {
2 background: #333; 2 background: #333;
  3 + position: relative;
3 4
4 a { 5 a {
5 text-decoration: none; 6 text-decoration: none;
@@ -121,7 +122,6 @@ @@ -121,7 +122,6 @@
121 } 122 }
122 123
123 .star-main { 124 .star-main {
124 - position: relative;  
125 margin-top: 88px; 125 margin-top: 88px;
126 } 126 }
127 127