Commit b04e3328 by lmf

优化代码

parent c91bf2cc
...@@ -7,42 +7,11 @@ ...@@ -7,42 +7,11 @@
?> ?>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('public_footer')->toHtml();?> <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('public_footer')->toHtml();?>
<script> <script>
const imgs = document.getElementsByTagName("img");
const viewHeight =
window.innerHeight || document.documentElement.clientHeight;
let num = 0;
function lazyload() {
for (let i = num; i < imgs.length; i++) {
let distance = viewHeight - imgs[i].getBoundingClientRect().top;
if (distance >= 0) {
imgs[i].src = imgs[i].getAttribute("data-src");
num = i + 1;
}
}
}
function debounce(fn, delay = 500) {
let timer = null;
return function (...args) {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
fn.call(this, args);
}, delay);
};
}
window.onload = lazyload;
window.addEventListener("scroll", debounce(lazyload, 600), false);
require([ require([
'jquery' 'jquery'
], function ($) { ], function ($) {
//footer //footer
$("h4").click(function () { $("h4").click(function () {
console.log(22222222222222222222222222)
function browserRedirect() { function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase(); var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
...@@ -55,14 +24,11 @@ ...@@ -55,14 +24,11 @@
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
// document.writeln("您的浏览设备为:"); // document.writeln("您的浏览设备为:");
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
// alert("手机浏览!");
return 1; return 1;
} else { } else {
// alert("PC浏览!");
return 2; return 2;
} }
} }
// browserRedirect();
if(browserRedirect() == 1){ if(browserRedirect() == 1){
var dis = $(this).siblings("ul").css("display"); var dis = $(this).siblings("ul").css("display");
...@@ -78,8 +44,6 @@ ...@@ -78,8 +44,6 @@
$(this).siblings("ul").css("display","block"); $(this).siblings("ul").css("display","block");
$(this).children("span").html('^') $(this).children("span").html('^')
} }
}); });
$(".page-header .actions.search-dropdown").click(function () { $(".page-header .actions.search-dropdown").click(function () {
$("#search_mini_form_input").toggle(); $("#search_mini_form_input").toggle();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment