-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.js
More file actions
46 lines (35 loc) · 1.42 KB
/
home.js
File metadata and controls
46 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import $ from 'jquery'
$('.home-3-action').on('mouseenter mouseleave', function(evt) {
let $elem = $(this).find('img')
let src = $elem.prop('src')
let matched = src.match(/(.*?home-3-)([\w|-]+)(.png)/)
$elem.prop('src', matched[1] +
(matched[2].length === 1 ? matched[2] + '-active' : matched[2].substr(0, matched[2].indexOf('-'))) +
matched[3])
})
$('.home-6-btn').on('click', function() {
let name = $('[name="name"]').val().trim(),
contact = $('[name="contact"]').val().trim(),
description = $('[name="description"]').val().trim()
if(!name) alert('还没有填写姓名')
else if(!contact) alert('还没有填写联系方式')
else if(!description) alert('还没有填写内容')
else
$.post('#', {
name: name,
contact: contact,
description: description
}).then(_ => { alert('提交成功') },
_ => { alert('提交失败') })
})
let carouselCurrFrame = 0
let carouselCurrLength = $('.home-carousel-frame').length
$('.home-carousel').height(screen.availHeight - 88)
$('.home-carousel').width(carouselCurrLength * 100 + '%')
$('.home-carousel-frame').width((1 / 3 * 100) + '%')
function runCarousel() {
$('.home-carousel').animate({ left: (-100 * carouselCurrFrame)+ '%' }, 1200, function() {
carouselCurrFrame = (carouselCurrFrame >= carouselCurrLength - 1 ? 0 : carouselCurrFrame + 1)
})
}
setInterval(runCarousel, 4567)