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
5ed9e1d4
Commit
5ed9e1d4
authored
Dec 28, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
恢复首页轮播图设置
parent
6378d44d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
215 additions
and
99 deletions
+215
-99
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
+215
-99
No files found.
app/design/frontend/Joshine/breeze/Magento_Cms/templates/default/home.phtml
View file @
5ed9e1d4
...
@@ -4,122 +4,238 @@
...
@@ -4,122 +4,238 @@
* See COPYING.txt for license details.
* See COPYING.txt for license details.
*/
*/
?>
?>
<?php
echo
$block
->
getLayout
()
->
createBlock
(
'Magento\Cms\Block\Block'
)
->
setBlockId
(
'homepageslider'
)
->
toHtml
();
?>
<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>
<script>
require
([
require
([
'jquery'
'jquery'
],
function
(
$
)
{
],
function
(
$
)
{
function
animation
(
obj
,
target
,
callback
)
{
//obj要实现的那个元素, target目标位置
$
.
fn
.
banner
=
function
(
options
){
clearInterval
(
obj
.
timer
);
//清除以前的定时器,只保留当前的
var
that
=
this
;
obj
.
timer
=
setInterval
(
function
()
{
options
=
options
||
{};
var
step
=
(
target
-
obj
.
offsetLeft
)
/
10
;
this
.
_obj
=
{
step
=
step
>
0
?
Math
.
ceil
(
step
)
:
Math
.
floor
(
step
);
btn
:
options
.
btn
===
false
?
false
:
true
,
if
(
obj
.
offsetLeft
==
target
)
{
list
:
options
.
list
===
false
?
false
:
true
,
clearInterval
(
obj
.
timer
);
autoPlay
:
options
.
autoPlay
===
false
?
false
:
true
,
//回调函数
delayTime
:
options
.
delayTime
||
2000
,
callback
&&
callback
();
moveTime
:
options
.
moveTime
||
200
,
}
else
{
index
:
options
.
index
||
0
,
obj
.
style
.
left
=
obj
.
offsetLeft
+
step
+
'px'
;
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>`
}
}
},
15
);
that
.
html
(
`<div class="imgbox">
${
str
}
</div>`
).
css
({
}
"width"
:
"100%"
,
"height"
:
"auto"
,
position
:
"relative"
,
overflow
:
"hidden"
}).
children
(
".imgbox"
).
css
({
"width"
:
"100%"
,
window
.
addEventListener
(
'load'
,
function
()
{
}).
children
(
"a"
).
css
({
var
banner
=
document
.
querySelector
(
'.banner'
);
position
:
"absolute"
,
var
prev
=
document
.
querySelector
(
'.prev'
);
left
:
1920
,
var
next
=
document
.
querySelector
(
'.next'
);
top
:
0
,
var
circle
=
document
.
querySelector
(
'.gd'
);
"width"
:
"100%"
,
var
bannerWidth
=
banner
.
offsetWidth
;
var
ul
=
banner
.
querySelector
(
'ul'
);
var
num
=
0
;
//鼠标移动盒子内让按钮显示
}).
eq
(
0
).
css
({
banner
.
addEventListener
(
'mouseenter'
,
function
()
{
left
:
0
prev
.
style
.
display
=
'block'
;
}).
end
().
children
(
"img"
).
css
({
next
.
style
.
display
=
'block'
;
"width"
:
"100%"
,
clearInterval
(
autoPlay
);
autoPlay
=
null
;
//清除定时器
})
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
();
});
});
}
}
this
.
_obj
.
init
();
//为按钮prev,next加事件
this
.
_obj
.
leftClick
=
function
()
{
circle
.
children
[
num
].
className
=
'current'
;
if
(
that
.
_obj
.
index
==
0
){
//判断有没有执行完动画
that
.
_obj
.
index
=
that
.
_obj
.
img
.
length
-
1
;
var
flag
=
true
;
that
.
_obj
.
iPrev
=
0
;
next
.
addEventListener
(
'click'
,
function
()
{
}
else
{
if
(
flag
)
{
that
.
_obj
.
index
--
;
flag
=
false
;
that
.
_obj
.
iPrev
=
that
.
_obj
.
index
+
1
;
if
(
num
==
nums
-
1
)
{
animation
(
ul
,
0
);
num
=
0
;
flag
=
true
;
}
else
{
num
++
;
animation
(
ul
,
-
num
*
bannerWidth
,
function
()
{
flag
=
true
;
});
}
currents
();
}
}
});
that
.
_obj
.
btnMove
(
1
);
}
prev
.
addEventListener
(
'click'
,
function
()
{
this
.
_obj
.
rightClick
=
function
(){
if
(
flag
)
{
if
(
that
.
_obj
.
index
==
that
.
_obj
.
img
.
length
-
1
){
flag
=
false
;
that
.
_obj
.
index
=
0
;
if
(
num
==
0
)
{
that
.
_obj
.
iPrev
=
that
.
_obj
.
img
.
length
-
1
;
animation
(
ul
,
-
nums
*
bannerWidth
-
1
);
}
else
{
num
=
nums
-
1
;
that
.
_obj
.
index
++
;
flag
=
true
;
that
.
_obj
.
iPrev
=
that
.
_obj
.
index
-
1
;
}
else
{
num
--
;
animation
(
ul
,
-
num
*
bannerWidth
,
function
()
{
flag
=
true
;
});
}
currents
();
}
}
});
that
.
_obj
.
btnMove
(
-
1
);
}
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"
})
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>`
;
}
$
(
"<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
)
}
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
)
function
currents
()
{
$
(
".list"
).
children
(
"li"
).
css
(
"background"
,
"rgba(200,200,200,0.6)"
)
for
(
var
a
=
0
;
a
<
nums
;
a
++
)
{
.
eq
(
iNow
).
css
(
"background"
,
"#005caf"
)
circle
.
children
[
a
].
className
=
''
;
}
}
circle
.
children
[
num
].
className
=
'current'
;
}
}
//无缝播放
if
(
this
.
_obj
.
autoPlay
){
var
li
=
ul
.
children
[
0
].
cloneNode
(
true
);
this
.
_obj
.
t
=
setInterval
(()
=>
{
ul
.
appendChild
(
li
);
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
img_arr
=
[
"/media/wysiwyg/202210281.png"
,
"/media/wysiwyg/202210282.png"
];
var
autoPlay
=
setInterval
(
function
()
{
if
(
isMobile
())
{
//手动调用点击事件
img_arr
=
[
"/media/wysiwyg/202210281-m.png"
,
"/media/wysiwyg/202210282-m.png"
];
next
.
click
();
}
},
5000
);
$
(
".banner1"
).
banner
({
})
img
:
img_arr
,
href
:
[
"/shapewear"
,
"/shapewear"
],
btn
:
true
,
list
:
true
,
autoPlay
:
true
,
delayTime
:
5000
,
moveTime
:
500
,
index
:
0
});
});
});
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_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
();
?>
...
...
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