Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
aab986ec
Commit
aab986ec
authored
Jan 16, 2023
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化首页延迟加载
parent
9817873a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
35 deletions
+4
-35
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/flashsaleproduct.phtml
+1
-1
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
+2
-33
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/homenewproduct.phtml
+1
-1
No files found.
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/flashsaleproduct.phtml
View file @
aab986ec
...
...
@@ -16,7 +16,7 @@ foreach($ids as $pid):
?>
<div
class=
"flash-sale-item"
>
<a
href=
"
<?php
echo
$product
->
getProductUrl
()
?>
"
>
<img
data-src=
"
<?php
echo
$productImage
;
?>
"
alt=
"Loading...
"
/></a>
<img
src=
"
<?php
echo
$productImage
;
?>
"
loading=
"lazy
"
/></a>
<div
class=
"flash-sale-info"
>
<a
class=
"product-name"
href=
"
<?php
echo
$product
->
getProductUrl
()
?>
"
>
<?php
echo
$product
->
getName
();
?>
</a>
<?=
$blocklist
->
getReviewsSummaryHtml
(
$product
,
$templateType
)
?>
...
...
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
View file @
aab986ec
...
...
@@ -56,7 +56,7 @@
</style>
<div
class=
"banner1"
></div>
<a
href=
"#top"
title=
"go to header"
id=
"topBtn"
style=
"display: none;"
>
<img
data-src=
"
<?php
echo
$block
->
getViewFileUrl
(
'images/goTop.png'
);
?>
"
src=
"
<?php
echo
$block
->
getViewFileUrl
(
'images/goTop.png'
);
?>
"
>
<img
loading=
"lazy
"
src=
"
<?php
echo
$block
->
getViewFileUrl
(
'images/goTop.png'
);
?>
"
>
</a>
<script>
require
([
...
...
@@ -79,7 +79,7 @@
this
.
_obj
.
init
=
function
(){
var
str
=
``
;
for
(
var
i
=
0
;
i
<
this
.
img
.
length
;
i
++
){
str
+=
`<a href="
${
this
.
href
[
i
]}
"><img
alt="Loading..." data-
src="
${
this
.
img
[
i
]}
" src="
${
this
.
img
[
i
]}
"></a>`
str
+=
`<a href="
${
this
.
href
[
i
]}
"><img
loading="lazy"
src="
${
this
.
img
[
i
]}
" src="
${
this
.
img
[
i
]}
"></a>`
}
that
.
html
(
`<div class="imgbox">
${
str
}
</div>`
).
css
({
"width"
:
"100%"
,
...
...
@@ -284,39 +284,8 @@
$
(
'.columns'
).
css
(
'margin-top'
,
headerH
);
}
});
</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_new_arrivals'
)
->
toHtml
();
?>
<?php
echo
$block
->
getLayout
()
->
createBlock
(
'Magento\Cms\Block\Block'
)
->
setBlockId
(
'flashsaleproduct'
)
->
toHtml
();
?>
<?php
echo
$block
->
getLayout
()
->
createBlock
(
'Magento\Cms\Block\Block'
)
->
setBlockId
(
'home_category_thumnail'
)
->
toHtml
();
?>
<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
);
</script>
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/homenewproduct.phtml
View file @
aab986ec
...
...
@@ -26,7 +26,7 @@ foreach($ids as $pid):
?>
<div
class=
"flash-sale-item"
>
<a
href=
"
<?php
echo
$product
->
getProductUrl
()
?>
"
>
<img
data-src=
"
<?php
echo
$productImage
;
?>
"
alt=
"Loading...
"
/></a>
<img
loading=
"lazy"
src=
"
<?php
echo
$productImage
;
?>
"
/></a>
<div
class=
"flash-sale-info"
>
<a
class=
"product-name"
href=
"
<?php
echo
$product
->
getProductUrl
()
?>
"
>
<?php
echo
$product
->
getName
();
?>
</a>
<?=
$blocklist
->
getReviewsSummaryHtml
(
$product
,
$templateType
)
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment