9a8cd042 by 田浩浩

门户首页数据读取

1 parent 3508e58d
...@@ -486,5 +486,5 @@ ...@@ -486,5 +486,5 @@
486 </body> 486 </body>
487 <script type="text/javascript" src="./staticJs/down.js"></script> 487 <script type="text/javascript" src="./staticJs/down.js"></script>
488 <script type="text/javascript" src="./staticJs/common.js"></script> 488 <script type="text/javascript" src="./staticJs/common.js"></script>
489 <script type="text/javascript" src="./staticJs/staticIndex.js"></script> 489 <script type="text/javascript" src="./staticJs/pageHome.js"></script>
490 </html> 490 </html>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -12,6 +12,8 @@ div.banner, div.c_one, div.c_two, div.c_three, div.c_four, div.c_five, div.foote ...@@ -12,6 +12,8 @@ div.banner, div.c_one, div.c_two, div.c_three, div.c_four, div.c_five, div.foote
12 text-align: center; 12 text-align: center;
13 } 13 }
14 14
15
16
15 div.banner { 17 div.banner {
16 height: 500px; 18 height: 500px;
17 position: relative; 19 position: relative;
...@@ -380,16 +382,20 @@ div.c_one ul li:not(:last-child) { ...@@ -380,16 +382,20 @@ div.c_one ul li:not(:last-child) {
380 } 382 }
381 383
382 div.c_one ul li a { 384 div.c_one ul li a {
383 width: 100%; 385 width: 75%;
384 display: block; 386 display: block;
385 color: #000000; 387 color: #000000;
386 text-align: left; 388 float:left;
389 white-space:nowrap; /*文本不换行*/
390 text-overflow:ellipsis;/*设置超出部分显示...*/
391 -o-text-overflow:ellipsis;
392 overflow: hidden;
387 } 393 }
388 div.c_one ul li a:hover { 394 div.c_one ul li a:hover {
389 color: #0091FF; 395 color: #0091FF;
390 } 396 }
391 397
392 div.c_one ul li a span { 398 div.c_one ul li span {
393 float: right; 399 float: right;
394 color: #9b9b9b; 400 color: #9b9b9b;
395 } 401 }
......
1 //设置当前页面导航栏背景色
1 function addTabs(id){ 2 function addTabs(id){
2 $('.layui-nav-item').removeClass('layui-this') 3 $('.layui-nav-item').removeClass('layui-this')
3 $(id).addClass('layui-this') 4 $(id).addClass('layui-this')
5 }
6
7 //设置ajax调取服务接口
8
9 function SetServicesPath(){
10 return "http://192.168.2.108"
11 }
12
13 //设置全局參數
14 var portal =
15 {
16 'api_url': "http://192.168.2.108:81/api", //属性名用引号括起来,属性间由逗号隔开
17 'name': 'myName'
18 };
19
20
21 function CutDate(times){
22 var timearr = times.replace(" ", ":").replace(/\:/g, "-").split("-");
23 var timestr = ""+timearr[0]+"/" + timearr[1] + "/" + timearr[2]
24 //var timestr = "" + timearr[1].split("")[1] + "月" + timearr[2] + "日\t" + timearr[3] + ":" + timearr[4] + ""
25 return timestr
4 } 26 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,7 +2,7 @@ layui.use('carousel', function () { ...@@ -2,7 +2,7 @@ layui.use('carousel', function () {
2 var carousel = layui.carousel; 2 var carousel = layui.carousel;
3 //建造实例 3 //建造实例
4 carousel.render({ 4 carousel.render({
5 elem: '#banner_swiper' 5 elem: '# '
6 , width: '100%' //设置容器宽度 6 , width: '100%' //设置容器宽度
7 , arrow: 'always' //始终显示箭头 7 , arrow: 'always' //始终显示箭头
8 , autoplay: true 8 , autoplay: true
...@@ -34,17 +34,31 @@ layui.use('util', function () { ...@@ -34,17 +34,31 @@ layui.use('util', function () {
34 //初始化方法 34 //初始化方法
35 $(function () { 35 $(function () {
36 NewsData(); 36 NewsData();
37 37
38 addTabs('#index') 38 addTabs('#index')
39 }); 39 });
40 40
41 //加载新闻首页数据
41 function NewsData() { 42 function NewsData() {
42 //$.ajax()
43 var ulNews = $("#ulNews"); 43 var ulNews = $("#ulNews");
44 ulNews.empty(); 44 ulNews.empty();
45 var str = ''; 45 var str = '';
46 for (var i = 0; i < 6; i++) { 46 $.ajax({
47 str = '<li><a href="#" title="创新技术体系 引领事业发展"><i>最新</i>创新技术体系 引领事业发展<span>2020-06-19</span></a></li>'; 47 type: "get", //提交方式
48 ulNews.append(str); 48 url: portal.api_url + "/hlwj/Mh/getNewsHotArticleList",//路径
49 } 49 dataType: "json",
50 //数据,这里使用的是Json格式进行传输
51 success: function (result) {//返回数据根据结果进行相应的处理
52 if (result.code == 200 && result.data != null) {
53 for (var i = 0; i < result.data.length; i++) {
54 if (i == 6) return;
55 str = '<li><a href="#" title="' + result.data[i].headline + '"' + result.data[i].headline + '</a>';
56 str+='<span>' + CutDate(result.data[i].publishTime) + '</span>></li>';
57 ulNews.append(str);
58 }
59
60 }
61 }
62 });
63
50 } 64 }
...\ No newline at end of file ...\ No newline at end of file
......