Authored by 陈峰

解决商品详情页单图的全屏浏览模式,和优化返回顶部按钮动画效果

@@ -25,8 +25,13 @@ @@ -25,8 +25,13 @@
25 </div> 25 </div>
26 {{^}} 26 {{^}}
27 <div class="banner-top-single"> 27 <div class="banner-top-single">
28 - <a href={{url}}> 28 + {{#if url}}
  29 + <a href="{{url}}">
29 <img class="img" src="{{image2 img w=450 h=600 q=60}}"> 30 <img class="img" src="{{image2 img w=450 h=600 q=60}}">
30 </a> 31 </a>
  32 + {{^}}
  33 + <img class="img" src="{{image2 img w=450 h=600 q=60}}">
  34 + {{/if}}
  35 +
31 </div> 36 </div>
32 {{/if}} 37 {{/if}}
@@ -37,6 +37,9 @@ setTimeout(() => { @@ -37,6 +37,9 @@ setTimeout(() => {
37 $('.banner-top').toggleClass('hover'); 37 $('.banner-top').toggleClass('hover');
38 swiper.onResize(); 38 swiper.onResize();
39 }) 39 })
  40 + $('.banner-top-single').click(function() {
  41 + $('.banner-top-single').toggleClass('hover');
  42 + })
40 }, 500); 43 }, 500);
41 44
42 45
@@ -288,14 +291,12 @@ setTimeout(() => { @@ -288,14 +291,12 @@ setTimeout(() => {
288 //加载详情页的返回顶部按钮并注册事件 291 //加载详情页的返回顶部按钮并注册事件
289 292
290 $(document).scroll(function() { 293 $(document).scroll(function() {
291 - if($(document).scrollTop() >= $(document).height() - $(window).height() - 20) {  
292 - if (!$('.float-top').hasClass('animation')) { 294 + if($(document).scrollTop() >= $(document).height() - $(window).height() - 120) {
293 var top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height()-$('.float-top').height())/2; 295 var top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height()-$('.float-top').height())/2;
294 var left = $('.back-to-top').offset().left - $('.float-top').offset().left; 296 var left = $('.back-to-top').offset().left - $('.float-top').offset().left;
295 $('.float-top').addClass('animation').css({ 297 $('.float-top').addClass('animation').css({
296 'transform': 'translate('+left+'px, '+top+'px) scale(0, 0)', 298 'transform': 'translate('+left+'px, '+top+'px) scale(0, 0)',
297 }); 299 });
298 - }  
299 } else if ($('.product-detail').length && $(document).scrollTop() >= $('.product-detail').offset().top) { 300 } else if ($('.product-detail').length && $(document).scrollTop() >= $('.product-detail').offset().top) {
300 if (!$('.float-top').hasClass('hover') || $('.float-top').hasClass('animation')) { 301 if (!$('.float-top').hasClass('hover') || $('.float-top').hasClass('animation')) {
301 $('.float-top').addClass('hover').removeClass('animation').removeAttr('style'); 302 $('.float-top').addClass('hover').removeClass('animation').removeAttr('style');
@@ -216,6 +216,29 @@ $basicBtnC: #eb0313; @@ -216,6 +216,29 @@ $basicBtnC: #eb0313;
216 margin-bottom: 30px; 216 margin-bottom: 30px;
217 width: 448px; 217 width: 448px;
218 } 218 }
  219 + &.hover {
  220 + position: fixed;
  221 + width: 100%;
  222 + background-color: black;
  223 + height: 100%;
  224 + top: 0px;
  225 + left: 0px;
  226 + right: 0px;
  227 + border: 0px;
  228 + z-index: 999;
  229 + display: -webkit-flex;
  230 + display: -moz-flex;
  231 + display: -ms-flex;
  232 + display: -o-flex;
  233 + display: flex;
  234 + -ms-align-items: center;
  235 + align-items: center;
  236 + img {
  237 + margin-top: initial;
  238 + margin-bottom: initial;
  239 + width: 100%;
  240 + }
  241 + }
219 } 242 }
220 243
221 .banner-top { 244 .banner-top {