Authored by 王水玲

星潮bug修改

@@ -12,17 +12,7 @@ @@ -12,17 +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 class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a>  
16 - </li>  
17 - {{/ starAvatar}}  
18 - {{# starAvatar}}  
19 - <li class="swiper-slide">  
20 - <a class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a>  
21 - </li>  
22 - {{/ starAvatar}}  
23 - {{# starAvatar}}  
24 - <li class="swiper-slide">  
25 - <a class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a> 15 + <span class="rank-avatar" data-url='{{url}}' data-avatar="{{image cover 180 180}}"></span>
26 </li> 16 </li>
27 {{/ starAvatar}} 17 {{/ starAvatar}}
28 </ul> 18 </ul>
@@ -31,7 +31,7 @@ var $window = $(window), @@ -31,7 +31,7 @@ var $window = $(window),
31 var mySwiper; 31 var mySwiper;
32 */ 32 */
33 33
34 -var avatarKey, bannerLen; 34 +var avatarKey, bannerLen, res;
35 35
36 require('../common'); 36 require('../common');
37 37
@@ -66,6 +66,31 @@ function setAvatar($userAvatar) { @@ -66,6 +66,31 @@ function setAvatar($userAvatar) {
66 }; 66 };
67 } 67 }
68 68
  69 +
  70 +// 明星头像点击居中显示或跳转
  71 +function bindAvatar(dom) {
  72 + avatarKey = dom.index();
  73 +
  74 + if (!dom.hasClass('swiper-slide-active')) {
  75 + if (avatarKey >= (2 * bannerLen + 1)) {
  76 + avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 200);
  77 + avatarSwiper.slideTo(bannerLen + 1, 200);
  78 + } else if (avatarKey <= (bannerLen - 1)) {
  79 + avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200);
  80 + avatarSwiper.slideTo(2 * bannerLen - 1, 200);
  81 + } else {
  82 + avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200);
  83 + avatarSwiper.slideTo(avatarKey, 200);
  84 + }
  85 +
  86 + return false;
  87 + } else if (window.queryString.app_version) {
  88 + return false;
  89 + }
  90 +
  91 + return false;
  92 +}
  93 +
69 function setIndexAction() { 94 function setIndexAction() {
70 var starIScroll; 95 var starIScroll;
71 96
@@ -106,18 +131,24 @@ function setIndexAction() { @@ -106,18 +131,24 @@ function setIndexAction() {
106 if (!avatarSwiperClone) { 131 if (!avatarSwiperClone) {
107 avatarSwiperClone = new Swiper('.avatar-0', { 132 avatarSwiperClone = new Swiper('.avatar-0', {
108 loop: true, 133 loop: true,
109 - initialSlide: $('.avatar-1').find('.swiper-slide-active').index(), 134 + initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
110 centeredSlides: true, 135 centeredSlides: true,
111 slidesPerView: 'auto', 136 slidesPerView: 'auto',
112 loopedSlides: bannerLen, 137 loopedSlides: bannerLen,
113 spaceBetween: 10, 138 spaceBetween: 10,
114 slidesOffsetBefore: -($('.swiper-num').width()), 139 slidesOffsetBefore: -($('.swiper-num').width()),
115 watchSlidesProgress: true, 140 watchSlidesProgress: true,
116 - watchSlidesVisibility: true 141 + watchSlidesVisibility: true,
  142 + onInit: function() {
  143 + $('.avatar-0 li').on('click', function() {
  144 + res = bindAvatar($(this));
  145 + return res;
  146 + });
  147 + }
117 }); 148 });
118 149
119 avatarSwiperClone.params.control = avatarSwiper; 150 avatarSwiperClone.params.control = avatarSwiper;
120 - avatarSwiper.params.control = avatarSwiperClone; 151 + avatarSwiper.params.control = avatarSwiperClone;
121 } 152 }
122 } 153 }
123 154
@@ -206,7 +237,13 @@ function setIndexAction() { @@ -206,7 +237,13 @@ function setIndexAction() {
206 spaceBetween: 10, 237 spaceBetween: 10,
207 slidesOffsetBefore: -($('.swiper-num').width()), 238 slidesOffsetBefore: -($('.swiper-num').width()),
208 watchSlidesProgress: true, 239 watchSlidesProgress: true,
209 - watchSlidesVisibility: true 240 + watchSlidesVisibility: true,
  241 + onInit: function() {
  242 + $('.avatar-1 li').on('click', function() {
  243 + res = bindAvatar($(this));
  244 + return res;
  245 + });
  246 + }
210 }); 247 });
211 } 248 }
212 249
@@ -241,29 +278,7 @@ function setIndexAction() { @@ -241,29 +278,7 @@ function setIndexAction() {
241 278
242 // articleImgAction($(item), key); 279 // articleImgAction($(item), key);
243 }); 280 });
244 - }  
245 -  
246 - // 明星头像点击居中显示或跳转  
247 - $('.avatar-swiper li').on('click', function() {  
248 - if (!$(this).hasClass('swiper-slide-active')) {  
249 - avatarKey = $(this).index();  
250 -  
251 - if (avatarKey >= (2 * bannerLen + 1)) {  
252 - avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 200);  
253 - avatarSwiper.slideTo(bannerLen + 1, 200);  
254 - } else if (avatarKey <= (bannerLen - 1)) {  
255 - avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200);  
256 - avatarSwiper.slideTo(2 * bannerLen - 1, 200);  
257 - } else {  
258 - avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200);  
259 - avatarSwiper.slideTo(avatarKey, 200);  
260 - }  
261 -  
262 - return false;  
263 - } else if (window.queryString.app_version) {  
264 - return false;  
265 - }  
266 - }); 281 + }
267 282
268 $('.rank-avatar').each(function(key, item) { 283 $('.rank-avatar').each(function(key, item) {
269 if ($(item).attr('data-avatar') !== '') { 284 if ($(item).attr('data-avatar') !== '') {
@@ -276,6 +291,8 @@ function setIndexAction() { @@ -276,6 +291,8 @@ function setIndexAction() {
276 }); 291 });
277 } 292 }
278 293
  294 +
  295 +// 首页数据请求
279 getIndexHtml = function() { 296 getIndexHtml = function() {
280 var $starMain = $('.star-main'); 297 var $starMain = $('.star-main');
281 298
@@ -123,6 +123,7 @@ @@ -123,6 +123,7 @@
123 &.avatar-clone { 123 &.avatar-clone {
124 margin-top: 0; 124 margin-top: 0;
125 position: fixed; 125 position: fixed;
  126 + width: 640px;
126 padding: 5px 0; 127 padding: 5px 0;
127 z-index: 9; 128 z-index: 9;
128 background: #000; 129 background: #000;