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
449d0106
Commit
449d0106
authored
Dec 26, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级首页轮播图模块
parent
565acc9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
224 deletions
+108
-224
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
+108
-224
No files found.
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
View file @
449d0106
...
...
@@ -4,239 +4,123 @@
* See COPYING.txt for license details.
*/
?>
<style>
.banner1
,
.banner1
>
.imgbox
,
.banner1
>
.imgbox
>
a
,
.banner1
>
.imgbox
>
a
>
img
{
height
:
634px
!important
;
}
input
#left
,
input
#right
{
top
:
300px
!important
;
padding-top
:
2px
;
}
@media
(
max-width
:
768px
)
{
.banner1
,
.banner1
>
.imgbox
,
.banner1
>
.imgbox
>
a
,
.banner1
>
.imgbox
>
a
>
img
{
height
:
577px
!important
;
margin-top
:
10px
;
}
input
#left
,
input
#right
{
top
:
280px
!important
;
padding
:
1px
;
}
}
@media
(
max-width
:
1024px
)
{
.rating-result
::before
,
.rating-result
>
span
::before
{
-webkit-mask-size
:
1rem
1rem
;
}
.rating-result
{
width
:
5rem
;
height
:
1rem
;
}
p
.flashsale-title
{
font-size
:
18px
;
}
}
</style>
<div
class=
"banner1"
></div>
<script>
require
([
'jquery'
],
function
(
$
)
{
$
.
fn
.
banner
=
function
(
options
){
var
that
=
this
;
options
=
options
||
{};
this
.
_obj
=
{
btn
:
options
.
btn
===
false
?
false
:
true
,
list
:
options
.
list
===
false
?
false
:
true
,
autoPlay
:
options
.
autoPlay
===
false
?
false
:
true
,
delayTime
:
options
.
delayTime
||
2000
,
moveTime
:
options
.
moveTime
||
200
,
index
:
options
.
index
||
0
,
iPrev
:
options
.
img
.
length
-
1
,
img
:
options
.
img
||
[],
href
:
options
.
href
||
[],
};
this
.
_obj
.
init
=
function
(){
var
str
=
``
;
for
(
var
i
=
0
;
i
<
this
.
img
.
length
;
i
++
){
str
+=
`<a href="
${
this
.
href
[
i
]}
"><img src="
${
this
.
img
[
i
]}
"></a>`
}
that
.
html
(
`<div class="imgbox">
${
str
}
</div>`
).
css
({
"width"
:
"100%"
,
"height"
:
"auto"
,
position
:
"relative"
,
overflow
:
"hidden"
}).
children
(
".imgbox"
).
css
({
"width"
:
"100%"
,
}).
children
(
"a"
).
css
({
position
:
"absolute"
,
left
:
1920
,
top
:
0
,
"width"
:
"100%"
,
}).
eq
(
0
).
css
({
left
:
0
}).
end
().
children
(
"img"
).
css
({
"width"
:
"100%"
,
});
}
this
.
_obj
.
init
();
this
.
_obj
.
leftClick
=
function
()
{
if
(
that
.
_obj
.
index
==
0
){
that
.
_obj
.
index
=
that
.
_obj
.
img
.
length
-
1
;
that
.
_obj
.
iPrev
=
0
;
}
else
{
that
.
_obj
.
index
--
;
that
.
_obj
.
iPrev
=
that
.
_obj
.
index
+
1
;
}
that
.
_obj
.
btnMove
(
1
);
}
this
.
_obj
.
rightClick
=
function
(){
if
(
that
.
_obj
.
index
==
that
.
_obj
.
img
.
length
-
1
){
that
.
_obj
.
index
=
0
;
that
.
_obj
.
iPrev
=
that
.
_obj
.
img
.
length
-
1
;
}
else
{
that
.
_obj
.
index
++
;
that
.
_obj
.
iPrev
=
that
.
_obj
.
index
-
1
;
}
that
.
_obj
.
btnMove
(
-
1
);
<?php
echo
$block
->
getLayout
()
->
createBlock
(
'Magento\Cms\Block\Block'
)
->
setBlockId
(
'homepageslider'
)
->
toHtml
();
?>
<script>
require
([
'jquery'
],
function
(
$
)
{
function
animation
(
obj
,
target
,
callback
)
{
//obj要实现的那个元素, target目标位置
clearInterval
(
obj
.
timer
);
//清除以前的定时器,只保留当前的
obj
.
timer
=
setInterval
(
function
()
{
var
step
=
(
target
-
obj
.
offsetLeft
)
/
10
;
step
=
step
>
0
?
Math
.
ceil
(
step
)
:
Math
.
floor
(
step
);
if
(
obj
.
offsetLeft
==
target
)
{
clearInterval
(
obj
.
timer
);
//回调函数
callback
&&
callback
();
}
else
{
obj
.
style
.
left
=
obj
.
offsetLeft
+
step
+
'px'
;
}
},
15
);
}
if
(
this
.
_obj
.
btn
){
$
(
"<input type='button' id='left' value='<'>"
).
css
(
{
left
:
0
,
}).
appendTo
(
this
).
after
(
$
(
"<input type='button' id='right' value='>'>"
).
css
({
right
:
0
,
})).
parent
()
.
children
(
"input"
).
css
({
position
:
"absolute"
,
top
:
130
,
width
:
30
,
height
:
30
,
border
:
"none"
,
background
:
"rgba(200,200,200,0.5)"
,
borderRadius
:
"50%"
,
color
:
"#ffffff"
window
.
addEventListener
(
'load'
,
function
()
{
var
banner
=
document
.
querySelector
(
'.banner'
);
var
prev
=
document
.
querySelector
(
'.prev'
);
var
next
=
document
.
querySelector
(
'.next'
);
var
circle
=
document
.
querySelector
(
'.gd'
);
var
bannerWidth
=
banner
.
offsetWidth
;
var
ul
=
banner
.
querySelector
(
'ul'
);
var
num
=
0
;
//鼠标移动盒子内让按钮显示
banner
.
addEventListener
(
'mouseenter'
,
function
()
{
prev
.
style
.
display
=
'block'
;
next
.
style
.
display
=
'block'
;
clearInterval
(
autoPlay
);
autoPlay
=
null
;
//清除定时器
})
this
.
on
(
"click"
,
"#left"
,
that
.
_obj
.
leftClick
)
this
.
on
(
"click"
,
"#right"
,
that
.
_obj
.
rightClick
)
this
.
_obj
.
btnMove
=
function
(
type
)
{
let
imgs
=
that
.
children
(
".imgbox"
).
children
(
"a"
);
imgs
.
eq
(
this
.
iPrev
).
css
({
left
:
0
}).
stop
().
animate
({
left
:
imgs
.
eq
(
0
).
width
()
*
type
},
this
.
moveTime
).
end
().
eq
(
this
.
index
).
css
({
left
:
-
imgs
.
eq
(
0
).
width
()
*
type
}).
stop
().
animate
({
left
:
0
},
this
.
moveTime
)
if
(
!
this
.
list
)
return
;
$
(
".list"
).
children
(
"li"
).
css
(
"background"
,
"rgba(200,200,200,0.6)"
)
.
eq
(
this
.
index
).
css
(
"background"
,
"#005caf"
)
}
}
if
(
this
.
_obj
.
list
){
let
str
=
""
;
for
(
var
i
=
0
;
i
<
this
.
_obj
.
img
.
length
;
i
++
){
str
+=
`<li></li>`
;
banner
.
addEventListener
(
'mouseleave'
,
function
()
{
prev
.
style
.
display
=
'none'
;
next
.
style
.
display
=
'none'
;
autoPlay
=
setInterval
(
function
()
{
//手动调用点击事件
next
.
click
();
},
5000
);
});
//设置ul的宽度
var
nums
=
ul
.
children
.
length
;
ul
.
style
.
width
=
nums
*
bannerWidth
+
'px'
;
//动态创建底部小圆点
for
(
var
k
=
0
;
k
<
nums
;
k
++
)
{
let
i
=
document
.
createElement
(
'i'
);
circle
.
appendChild
(
i
);
i
.
setAttribute
(
'index'
,
k
);
i
.
addEventListener
(
'click'
,
function
()
{
num
=
this
.
getAttribute
(
'index'
);
animation
(
ul
,
-
num
*
bannerWidth
);
currents
();
});
}
$
(
"<ul class='list'>"
).
html
(
str
).
appendTo
(
this
).
css
({
margin
:
0
,
padding
:
0
,
listStyle
:
"none"
,
width
:
"100%"
,
height
:
40
,
bottom
:
0
,
position
:
"absolute"
,
display
:
"flex"
,
justifyContent
:
"center"
,
lineHeight
:
"40px"
,
textAlign
:
"center"
}).
children
(
"li"
).
css
({
width
:
40
,
height
:
6
,
background
:
"rgba(200,200,200,0.6)"
,
margin
:
"0 5px"
,
textAlign
:
"center"
,
cursor
:
"pointer"
}).
eq
(
0
).
css
({
background
:
"#005caf"
}).
end
().
click
(
function
()
{
if
(
$
(
this
).
index
()
>
that
.
_obj
.
index
){
that
.
_obj
.
listMove
(
$
(
this
).
index
(),
-
1
)
}
if
(
$
(
this
).
index
()
<
that
.
_obj
.
index
){
that
.
_obj
.
listMove
(
$
(
this
).
index
(),
1
)
//为按钮prev,next加事件
circle
.
children
[
num
].
className
=
'current'
;
//判断有没有执行完动画
var
flag
=
true
;
next
.
addEventListener
(
'click'
,
function
()
{
if
(
flag
)
{
flag
=
false
;
if
(
num
==
nums
-
1
)
{
animation
(
ul
,
0
);
num
=
0
;
flag
=
true
;
}
else
{
num
++
;
animation
(
ul
,
-
num
*
bannerWidth
,
function
()
{
flag
=
true
;
});
}
currents
();
}
that
.
_obj
.
index
=
$
(
this
).
index
(
);
}
);
})
this
.
_obj
.
listMove
=
function
(
iNow
,
type
)
{
let
imgs
=
that
.
children
(
".imgbox"
).
children
(
"a"
);
imgs
.
eq
(
this
.
index
).
css
({
left
:
0
}).
stop
().
animate
({
left
:
imgs
.
eq
(
0
).
width
()
*
type
},
this
.
moveTime
).
end
().
eq
(
iNow
).
css
({
left
:
-
imgs
.
eq
(
0
).
width
()
*
type
}).
stop
().
animate
({
left
:
0
},
this
.
moveTime
)
prev
.
addEventListener
(
'click'
,
function
()
{
if
(
flag
)
{
flag
=
false
;
if
(
num
==
0
)
{
animation
(
ul
,
-
nums
*
bannerWidth
-
1
);
num
=
nums
-
1
;
flag
=
true
;
}
else
{
num
--
;
animation
(
ul
,
-
num
*
bannerWidth
,
function
()
{
flag
=
true
;
});
}
currents
();
}
});
$
(
".list"
).
children
(
"li"
).
css
(
"background"
,
"rgba(200,200,200,0.6)"
)
.
eq
(
iNow
).
css
(
"background"
,
"#005caf"
)
function
currents
()
{
for
(
var
a
=
0
;
a
<
nums
;
a
++
)
{
circle
.
children
[
a
].
className
=
''
;
}
circle
.
children
[
num
].
className
=
'current'
;
}
}
if
(
this
.
_obj
.
autoPlay
){
this
.
_obj
.
t
=
setInterval
(()
=>
{
this
.
_obj
.
rightClick
();
},
this
.
_obj
.
delayTime
);
this
.
hover
(
function
()
{
clearInterval
(
that
.
_obj
.
t
)
},
function
()
{
that
.
_obj
.
t
=
setInterval
(()
=>
{
that
.
_obj
.
rightClick
();
},
that
.
_obj
.
delayTime
);
})
}
}
//无缝播放
var
li
=
ul
.
children
[
0
].
cloneNode
(
true
);
ul
.
appendChild
(
li
);
var
img_arr
=
[
"/media/wysiwyg/202210281.png"
,
"/media/wysiwyg/202210282.png"
];
if
(
isMobile
())
{
img_arr
=
[
"/media/wysiwyg/202210281-m.png"
,
"/media/wysiwyg/202210282-m.png"
];
}
$
(
".banner1"
).
banner
({
img
:
img_arr
,
href
:
[
"/shapewear"
,
"/shapewear"
],
btn
:
true
,
list
:
true
,
autoPlay
:
true
,
delayTime
:
5000
,
moveTime
:
500
,
index
:
0
//自动播放
var
autoPlay
=
setInterval
(
function
()
{
//手动调用点击事件
next
.
click
();
},
5000
);
})
});
});
function
isMobile
()
{
var
userAgentInfo
=
navigator
.
userAgent
;
var
mobileAgents
=
[
"Android"
,
"iPhone"
,
"SymbianOS"
,
"Windows Phone"
,
"iPad"
,
"iPod"
];
var
mobile_flag
=
false
;
for
(
var
v
=
0
;
v
<
mobileAgents
.
length
;
v
++
)
{
if
(
userAgentInfo
.
indexOf
(
mobileAgents
[
v
])
>
0
)
{
mobile_flag
=
true
;
break
;
}
}
var
screen_width
=
window
.
screen
.
width
;
var
screen_height
=
window
.
screen
.
height
;
if
(
screen_width
<
500
&&
screen_height
<
800
){
mobile_flag
=
true
;
}
return
mobile_flag
;
}
</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_new_arrivals'
)
->
toHtml
();
?>
<?php
echo
$block
->
getLayout
()
->
createBlock
(
'Magento\Cms\Block\Block'
)
->
setBlockId
(
'flashsaleproduct'
)
->
toHtml
();
?>
...
...
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