Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
任超
/
js.portalStaticPage
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
e623e0a0
authored
2020-11-21 14:32:11 +0800
by
田浩浩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加公示数据加载
1 parent
6208707d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
14 deletions
index.html
staticJs/common.js
staticJs/pageHome.js
index.html
View file @
e623e0a
...
...
@@ -143,7 +143,7 @@
<i>
查看全部 >
</i>
</a>
</h2>
<ul
class=
"notice_list"
>
<ul
class=
"notice_list"
id=
"ulNotice"
>
<li>
<a
href=
""
title=
"1地信中心开展外业安全生产监控系统培训工作"
>
1地信中心开展外业安全生产监控系统培训工作
...
...
staticJs/common.js
View file @
e623e0a
//设置当前页面导航栏背景色
function
addTabs
(
id
){
function
addTabs
(
id
)
{
$
(
'.layui-nav-item'
).
removeClass
(
'layui-this'
)
$
(
id
).
addClass
(
'layui-this'
)
}
//设置ajax调取服务接口
function
SetServicesPath
(){
return
"http://192.168.2.108"
function
SetServicesPath
()
{
return
"http://192.168.2.108"
}
//设置全局參數
...
...
@@ -17,10 +17,10 @@ var portal =
'name'
:
'myName'
};
function
CutDate
(
times
){
//截取日期
function
CutDate
(
times
)
{
var
timearr
=
times
.
replace
(
" "
,
":"
).
replace
(
/
\:
/g
,
"-"
).
split
(
"-"
);
var
timestr
=
""
+
timearr
[
0
]
+
"/"
+
timearr
[
1
]
+
"/"
+
timearr
[
2
]
var
timestr
=
""
+
timearr
[
0
]
+
"/"
+
timearr
[
1
]
+
"/"
+
timearr
[
2
]
//var timestr = "" + timearr[1].split("")[1] + "月" + timearr[2] + "日\t" + timearr[3] + ":" + timearr[4] + ""
return
timestr
}
...
...
staticJs/pageHome.js
View file @
e623e0a
...
...
@@ -29,17 +29,39 @@ layui.use('util', function () {
});
});
var
recentlyDay
;
function
getDate
()
{
var
date
=
new
Date
();
var
base
=
new
Date
(
date
).
getTime
();
var
oneDay
=
24
*
3600
*
1000
;
var
date
=
[];
var
data
=
[
Math
.
random
()
*
300
];
var
time
=
new
Date
(
base
);
date
.
push
([
time
.
getFullYear
(),
time
.
getMonth
()
+
1
,
time
.
getDate
()].
join
(
'/'
));
for
(
var
i
=
1
;
i
<
7
;
i
++
)
{
//控制需要的天数
var
now
=
new
Date
(
base
-=
oneDay
);
//这里控制往前一周还是往后一周
date
.
push
([
now
.
getFullYear
(),
now
.
getMonth
()
+
1
,
now
.
getDate
()].
join
(
'/'
));
data
.
push
(
Math
.
round
((
Math
.
random
()
-
0.5
)
*
20
+
data
[
i
-
1
]));
}
return
date
.
reverse
();
// var newdate = date.reverse(); //往后一周的话需要将数组倒叙
//console.log(date);
}
//初始化方法
$
(
function
()
{
// NewsData();
addTabs
(
'#index'
)
addTabs
(
'#index'
);
recentlyDay
=
getDate
();
NewsData
();
NoticeData
();
});
//加载新闻
首页
数据
//加载新闻数据
function
NewsData
()
{
var
ulNews
=
$
(
"#ulNews"
);
ulNews
.
empty
();
var
str
=
''
;
var
li
,
publishTime
;
$
.
ajax
({
type
:
"get"
,
//提交方式
url
:
portal
.
api_url
+
"/hlwj/Mh/getNewsHotArticleList"
,
//路径
...
...
@@ -49,13 +71,47 @@ function NewsData() {
if
(
result
.
code
==
200
&&
result
.
data
!=
null
)
{
for
(
var
i
=
0
;
i
<
result
.
data
.
length
;
i
++
)
{
if
(
i
==
6
)
return
;
str
=
'<li><a href="#" title="'
+
result
.
data
[
i
].
headline
+
'">'
+
result
.
data
[
i
].
headline
+
'</a>'
;
str
+=
'<span>'
+
CutDate
(
result
.
data
[
i
].
publishTime
)
+
'</span></li>'
;
ulNews
.
append
(
str
);
publishTime
=
CutDate
(
result
.
data
[
i
].
publishTime
);
li
=
'<li><a href="#" title="'
+
result
.
data
[
i
].
headline
+
'">'
;
li
+=
'<div class="news_item">'
;
if
(
recentlyDay
.
indexOf
(
publishTime
)
>
-
1
)
{
li
+=
'<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#iconzuixin"></use> </svg>'
;
}
li
+=
result
.
data
[
i
].
headline
+
'</div>'
;
li
+=
'<span>'
+
publishTime
+
'</span></a></li>'
;
ulNews
.
append
(
li
);
}
}
}
});
}
//加载公告数据
function
NoticeData
()
{
var
ulTag
=
$
(
"#ulNotice"
);
ulTag
.
empty
();
var
li
;
$
.
ajax
({
type
:
"get"
,
//提交方式
url
:
portal
.
api_url
+
"/hlwj/Mh/getMHNotice"
,
//路径
dataType
:
"json"
,
//数据,这里使用的是Json格式进行传输
success
:
function
(
result
)
{
//返回数据根据结果进行相应的处理
if
(
result
.
code
==
200
&&
result
.
data
!=
null
)
{
for
(
var
i
=
0
;
i
<
result
.
data
.
length
;
i
++
)
{
if
(
i
==
6
)
return
;
li
=
'<li><a href="#" title="'
+
result
.
data
[
i
].
title
+
'">'
+
result
.
data
[
i
].
title
;
if
(
result
.
data
[
i
].
noticeType
==
1
)
{
li
+=
'<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#icongonggao1"></use> </svg>'
;
}
else
{
li
+=
'<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#icongongshi"></use> </svg>'
;
}
li
+=
'</a></li>'
;
ulTag
.
append
(
li
);
}
}
}
});
}
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment