grzx.js
1.39 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
layui.use('element', function () {
let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
});
$(function(){
$('#username').text(getItem('myCookie').username)
$('#phone').text(getItem('myCookie').phone)
$('#zjhm').text(getItem('myCookie').zjhm)
$('#recordtime').text(getItem('myCookie').recordtime)
$('#hellotime').text(getTimeState())
pageData();
})
function pageData(){
$('.business_module li .cardItem').mouseover(function(){
$(this).find('.itemImg').attr('src',$(this).find('.itemImg').attr('url'))
})
$('.business_module li .cardItem').mouseout(function(){
$(this).find('.itemImg').attr('src',$(this).find('.itemImg').attr('pre'))
})
$('.center-appointment').click(function(){
window.open("./wdyy.html?title=个人中心&href="+window.location.pathname, "_self")
})
}
function getTimeState(){
// 获取当前时间
let timeNow = new Date();
// 获取当前小时
let hours = timeNow.getHours();
// 设置默认文字
let text = '';
// 判断当前时间段
if (hours >= 0 && hours <= 10) {
text = '早上好:';
} else if (hours > 10 && hours <= 14) {
text = '中午好:';
} else if (hours > 14 && hours <= 18) {
text = '下午好:';
} else if (hours > 18 && hours <= 24) {
text = `晚上好:`;
}
// 返回当前时间段对应的状态
return text;
};