You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
2.6 KiB

5 years ago
!function(){function o(){var o=$(window).scrollTop();o>=a?s.gotopShow():s.gotopHide()}function t(){var o=!0;$(window).on("touchstart",function(t){o=!1;var e=t.originalEvent.touches,n=e[0].screenY;$(this).on("touchmove",function(o){var t=o.originalEvent.touches,e=t[0].screenY,i=e-n,a=$(window).scrollTop();a>0?(i<-10&&s.gotopHide(),i>10&&s.gotopShow()):s.gotopHide()}).one("touchend",function(){$(this).off("touchmove touchend"),o=!0})}),$(window).on("scroll",function(){if(o){var t=$(window).scrollTop();0===t&&s.gotopHide()}})}var e={parentBox:$("body"),right:8,bottom:40,zindex:110,hasReport:!1,reportFun:null,isMobile:!1,hasFreeAd:!0,vipDiscount:!1};/Android|webOS|iPhone|iPod|BlackBerry/i.test(window.navigator.userAgent)?e.hasFreeAd=!1:e.hasFreeAd=!0;var n=!1,i="http"===location.protocol.substr(0,4)?"":"http:";$("<link/>",{rel:"stylesheet",type:"text/css",href:i+"//csdnimg.cn/public/common/gotop/css/goTop.min.css?v20180912133540"}).appendTo("head");var s=$('<div class="meau-gotop-box"> <a href="#" id="backtop" class="btn-meau" title="返回顶部"> <svg xmlns="http://www.w3.org/2000/svg" width="19" height="12"> <path d="M9.314 0l9.313 9.314-2.12 2.121-7.193-7.192-7.193 7.192L0 9.314z" fill="#FFF" fill-rule="evenodd" /> </svg> </a> </div>'),a=$(window).height();s.gotopShow=function(){$(this).find("a#backtop").fadeIn(200).css("display","flex")},s.gotopHide=function(){$(this).find("a#backtop").fadeOut(200)},s.find("a#backtop").click(function(o){o.preventDefault(),$("html,body").animate({scrollTop:0},200),e.isMobile&&s.gotopHide()});var r=function(i){if(n=!0,void 0!==i&&"object"==typeof i&&$.extend(e,i),e.hasReport)if(null===e.reportFun)console.warn("请设置内容举报方法");else{var r=$('<a href="#" id="reportContent" class="btn-meau" title="举报"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="22"><path d="M0 13.028V3.365L9 0l9 3.365v9.663C18 17.983 13.97 22 9 22s-9-4.017-9-8.972zm2-8.282v8.282c0 3.854 3.134 6.978 7 6.978s7-3.124 7-6.978V4.746L9 2.13 2 4.746zm6 10.276h2v1.993H8v-1.993zm0-8.973h2v6.979H8V6.049z" fill="#FFF" fill-rule="nonzero"/></svg> </a>');s.append(r),r.click(function(o){o.preventDefault(),e.reportFun()})}if(e.hasFreeAd){var d=$('<a href="https://mall.csdn.net/vip_code" id="adContent" class="btn-meau"> </a>');s.prepend(d)}e.isMobile&&s.addClass("wap"),e.parentBox.append(s),s.css({right:e.right+"px",bottom:e.bottom+"px","z-index":e.zindex}),e.isMobile?t():($(window).resize(function(){a=$(window).height(),o()}),$(window).scroll(o))};window.GoTop=r,setTimeout(function(){n||r()},200)}();