Commit b5078f4a by lmf

首页增加预加载功能

parents 321768f9 5db3a6fe
...@@ -15,3 +15,4 @@ generated ...@@ -15,3 +15,4 @@ generated
var var
.idea .idea
/.php_cs.cache /.php_cs.cache
/app/design/frontend/Joshine/breeze/Magento_Cms/templates/meta.phtml
...@@ -23,9 +23,6 @@ ...@@ -23,9 +23,6 @@
padding: 1px; padding: 1px;
} }
#topBtn {
width: 8% !important;
}
} }
@media (max-width: 1024px) { @media (max-width: 1024px) {
...@@ -39,25 +36,9 @@ ...@@ -39,25 +36,9 @@
p.flashsale-title{ p.flashsale-title{
font-size: 18px; font-size: 18px;
} }
#topBtn{
width: 6% !important;
}
} }
#topBtn{
bottom: 5%;
right: 2%;
position:fixed;
width: 4%;
}
</style> </style>
<div class="banner1"></div> <div class="banner1"></div>
<a href="#top" title="go to header" id="topBtn" style="display: none;">
<img loading="lazy" src="<?php echo $block->getViewFileUrl('images/goTop.png'); ?>">
</a>
<script> <script>
require([ require([
'jquery' 'jquery'
...@@ -241,32 +222,6 @@ ...@@ -241,32 +222,6 @@
index: 0 index: 0
}); });
}); });
window.onscroll = function (){
var top = document.getElementById("topBtn");
if (document.documentElement.scrollTop > 200 || document.body.scrollTop > 200){
top.style.display="block";
}else {
top.style.display="none";
}
}
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
}
require(['jquery'],function ($){
if (flag){
var imgH = $('.logo').height();
imgH= Math.ceil(imgH/3);
$('.header ').css('margin-bottom',imgH);
}else{
var headerH = $('.page-header').outerHeight(true);
$('.columns').css('margin-top',headerH);
}
});
</script> </script>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('home_top_category_thumnail')->toHtml();?> <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('home_top_category_thumnail')->toHtml();?>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('home_new_arrivals')->toHtml();?> <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('home_new_arrivals')->toHtml();?>
......
...@@ -70,7 +70,9 @@ require([ ...@@ -70,7 +70,9 @@ require([
}); });
$('#search').on('blur',function (){ $('#search').on('blur',function (){
$(this).attr("style",""); if (!$(this).val()){
$(this).attr("style","");
}
}); });
}); });
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,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();?>
<a href="#top" title="go to header" id="topBtn" style="display: none;">
<img loading="lazy" src="<?php echo $block->getViewFileUrl('images/goTop.png'); ?>">
</a>
<script> <script>
require([ require([
'jquery' 'jquery'
......
...@@ -19,6 +19,37 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight() ...@@ -19,6 +19,37 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
? $logoSizeResolver->getHeight() ? $logoSizeResolver->getHeight()
: $block->getLogoHeight(); : $block->getLogoHeight();
?> ?>
<script>
window.onscroll = function (){
var top = document.getElementById("topBtn");
if (document.documentElement.scrollTop > 200 || document.body.scrollTop > 200){
top.style.display="block";
}else {
top.style.display="none";
}
}
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
}
require(['jquery'],function ($){
if (flag){
var imgH = $('.logo').height();
imgH= Math.ceil(imgH/3);
$('.header ').css('margin-bottom',imgH);
}else{
var headerH = $('.page-header').outerHeight(true);
$('.columns').css('margin-top',headerH);
}
});
</script>
<span data-action="toggle-nav" class="action nav-toggle"><span><?= $block->escapeHtml(__('Toggle Nav')) ?></span></span> <span data-action="toggle-nav" class="action nav-toggle"><span><?= $block->escapeHtml(__('Toggle Nav')) ?></span></span>
<a <a
class="logo" class="logo"
...@@ -31,4 +62,4 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight() ...@@ -31,4 +62,4 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
<?= $logoWidth ? 'width="' . $block->escapeHtmlAttr($logoWidth) . '"' : '' ?> <?= $logoWidth ? 'width="' . $block->escapeHtmlAttr($logoWidth) . '"' : '' ?>
<?= $logoHeight ? 'height="' . $block->escapeHtmlAttr($logoHeight) . '"' : '' ?> <?= $logoHeight ? 'height="' . $block->escapeHtmlAttr($logoHeight) . '"' : '' ?>
/> />
</a> </a>
\ No newline at end of file
...@@ -142,6 +142,10 @@ ...@@ -142,6 +142,10 @@
// position: fixed; // position: fixed;
//} //}
#topBtn{
width: 6% !important;
}
} }
...@@ -608,6 +612,10 @@ ul { ...@@ -608,6 +612,10 @@ ul {
.categories_tab { .categories_tab {
height: 330px; height: 330px;
} }
#topBtn {
width: 8% !important;
}
} }
.categories_tab { .categories_tab {
...@@ -2571,3 +2579,10 @@ strong#block-related-heading,strong#block-upsell-heading{ font-weight: 600; colo ...@@ -2571,3 +2579,10 @@ strong#block-related-heading,strong#block-upsell-heading{ font-weight: 600; colo
padding:0 !important; padding:0 !important;
} }
#topBtn{
bottom: 5%;
right: 2%;
position:fixed;
width: 4%;
}
\ No newline at end of file
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