Kaynağa Gözat

新闻资讯

gzb
wangzhonglu 1 yıl önce
ebeveyn
işleme
2e84f94400

+ 136
- 0
css/news.css Dosyayı Görüntüle

@@ -0,0 +1,136 @@
1
+.news_banner {
2
+  position: relative;
3
+  padding-top: 0.8rem;
4
+  width: 100%;
5
+  height: 3.85rem;
6
+}
7
+.news_banner img {
8
+  width: 100%;
9
+  height: 100%;
10
+  object-fit: cover;
11
+}
12
+.news_header_info {
13
+  position: absolute;
14
+  top: 0.8rem;
15
+  left: 0;
16
+  right: 0;
17
+  bottom: 0;
18
+  margin: auto;
19
+  width: 13rem;
20
+  height: 0.84rem;
21
+  color: #333;
22
+}
23
+.news_header_title {
24
+  font-size: 0.36rem;
25
+  font-weight: 700;
26
+}
27
+.news_header_stitle {
28
+  padding-top: 0.3rem;
29
+  font-size: 0.16rem;
30
+}
31
+.news_info {
32
+  padding-top: 0.93rem;
33
+  padding-bottom: 0.5rem;
34
+  background-color: #fff;
35
+}
36
+.news_main {
37
+  position: relative;
38
+  margin: 0 auto;
39
+  width: 13rem;
40
+}
41
+.news_search {
42
+  font-size: 0.14rem;
43
+  text-align: right;
44
+}
45
+.header_content_right{
46
+  position: relative;
47
+  display: inline-block;
48
+  width: 2.5rem;
49
+  height: 0.3rem;
50
+  border: 0.01rem solid #DCDEE2;
51
+  background-color: #fff;
52
+  border-radius: 0.04rem;
53
+  overflow: hidden;
54
+}
55
+#search_help {
56
+  position: absolute;
57
+  top: 0;
58
+  bottom: 0;
59
+  left: 0;
60
+  right: 0.4rem;
61
+  line-height: 0.3rem;
62
+  padding: 0 0.08rem;
63
+  font-size: 0.14rem;
64
+  border: none;
65
+  color: #333;
66
+  background-color: #fff;
67
+  background-image: none;
68
+  cursor: text;
69
+}
70
+#search_help::-webkit-input-placeholder,
71
+#search_help:-moz-placeholder,
72
+#search_help::-moz-placeholder,
73
+#search_help:-ms-input-placeholder {
74
+  color: #c1c6cf;
75
+  font-size: 0.14rem;
76
+}
77
+#search_help:focus {
78
+  outline: none;
79
+}
80
+.search_box {
81
+  position: absolute;
82
+  top: 0;
83
+  bottom: 0;
84
+  right: 0;
85
+  padding: 0.05rem 0.1rem;
86
+  cursor: pointer;
87
+}
88
+.search_img {
89
+  width: 0.14rem;
90
+  height: 0.14rem;
91
+}
92
+.news_list {
93
+  margin: 0 auto;
94
+  font-size: 0.16rem;
95
+  background-color: #fff;
96
+}
97
+.news_list_box {
98
+  margin: 0 auto;
99
+  width: 13rem;
100
+}
101
+.news_list_item {
102
+  margin-right: 0.27rem;
103
+  margin-bottom: 0.3rem;
104
+  display: inline-block;
105
+  width: 4.1rem;
106
+  background-color: #F8F8F8;
107
+  box-shadow: 0 0 0.12rem 0 #0000001a;
108
+}
109
+.news_list_item:nth-child(3n) {
110
+  margin-right: 0;
111
+}
112
+.news_list_item .news_item_img {
113
+  width: 100%;
114
+  height: 2.7rem;
115
+  object-fit: cover;
116
+}
117
+.news_list_item .news_item_title {
118
+  margin: 0.1rem 0.16rem;
119
+  height: 0.52rem;
120
+  font-size: 0.18rem;
121
+  font-weight: 700;
122
+  line-height: 0.26rem;
123
+  color: #333;
124
+  text-overflow: -o-ellipsis-lastline;
125
+  overflow: hidden;
126
+  text-overflow: ellipsis;
127
+  display: -webkit-box;
128
+  -webkit-line-clamp: 2;
129
+  -webkit-box-orient: vertical;
130
+}
131
+.news_list_item .news_item_stitle {
132
+  margin: 0.1rem 0.16rem;
133
+  font-size: 0.16rem;
134
+  line-height: 0.32rem;
135
+  color: #666;
136
+}

+ 0
- 0
css/news_detail.css Dosyayı Görüntüle


BIN
img/news/news_banner.png Dosyayı Görüntüle


BIN
img/news/search.png Dosyayı Görüntüle


+ 56
- 1
js/news.js Dosyayı Görüntüle

@@ -3,5 +3,60 @@ $(function () {
3 3
   $(".footer_root").load("./comm/footer.html");
4 4
   // nav传值显示下划线
5 5
   $(".header_root").data("nav_info", 5);
6
-  
6
+  // 新闻资讯搜索信息
7
+  let newsInfo = {
8
+    page: 1,
9
+    size: 9,
10
+    newstitle: "",
11
+    total: 0
12
+  };
13
+  // 加载新闻资讯列表
14
+  function loadNewsList(params) {
15
+    let newsItemHtml = "";
16
+    $.each(params.list, function(newsIndex, newsItem) {
17
+      newsItemHtml = '<div class="news_list_item"><img class="news_item_img" src="' + $.showImageUrl + newsItem.newspic + '" /><div class="news_item_title">' + newsItem.newstitle + '</div><div class="news_item_stitle">' + $.msToDateString(newsItem.createtime) + '</div></div>';
18
+    });
19
+    $(".news_list_box").html(newsItem);
20
+  }
21
+  // 搜索新闻列表
22
+  function searchList() {
23
+    let _url = $.baseUrl + "n/listc";
24
+    $.ajax({
25
+      type: 'POST',
26
+      url: _url,
27
+      dataType: "json",
28
+      contentType: "application/json; charset=utf-8",
29
+      data: JSON.stringify({
30
+        page: newsInfo.page,
31
+        size: newsInfo.size,
32
+        newstitle: newsInfo.newstitle
33
+      }),
34
+      success: function (data) {
35
+        if (data.code === 0) {
36
+          loadNewsList(data.obj);
37
+        } else {
38
+          alert(data.msg);
39
+        }
40
+      }
41
+    });
42
+  }
43
+  // 回车搜索
44
+  function enterSearch(event) {
45
+    // 兼容FF和IE和Opera
46
+    let theEvent = event || window.event;
47
+    let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
48
+    let content = theEvent.target.value;
49
+    search_helpcomm = content;
50
+    if (code == 13) {
51
+      searchList();
52
+    }
53
+  }
54
+  // 输入内容改变
55
+  function searchInputChange(event) {
56
+    let theEvent = event || window.event;
57
+    search_helpcomm = theEvent.target.value;
58
+  }
59
+  $(".news_info #search_help").on("change", searchInputChange);
60
+  $(".news_info #search_help").on("keydown", enterSearch);
61
+  $(".news_info .search_box").click(searchList);
7 62
 });

+ 11
- 8
sections/comm/header.html Dosyayı Görüntüle

@@ -181,14 +181,17 @@
181 181
             console.log("语言切换");
182 182
           }
183 183
         });
184
-        $(window).on("scroll", function() {
185
-          let top = $(window).scrollTop();
186
-          if(top > 100){
187
-            $(".header_root").addClass("bg_white");
188
-          } else {
189
-            $(".header_root").removeClass("bg_white");
190
-          }
191
-        });
184
+        let _pathname = window.location.pathname;
185
+        if (_pathname === "/index.html" || _pathname === "/") {
186
+          $(window).on("scroll", function() {
187
+            let top = $(window).scrollTop();
188
+            if(top > 100){
189
+              $(".header_root").addClass("bg_white");
190
+            } else {
191
+              $(".header_root").removeClass("bg_white");
192
+            }
193
+          });
194
+        }
192 195
       });
193 196
     </script>
194 197
   </body>

+ 39
- 0
sections/news.html Dosyayı Görüntüle

@@ -13,9 +13,48 @@
13 13
   </head>
14 14
   <body>
15 15
     <div class="header_root bg_white"></div>
16
+    <div class="news_banner">
17
+      <img src="../img/news/news_banner.png" />
18
+      <div class="news_header_info">
19
+        <div class="news_header_title">新闻资讯</div>
20
+        <div class="news_header_stitle">星火最新资讯,让一切皆有可能</div>
21
+      </div>
22
+    </div>
23
+    <div class="news_info">
24
+      <div class="news_main">
25
+        <div class="news_search">
26
+          <div class="header_content_right">
27
+            <input
28
+              type="text"
29
+              id="search_help"
30
+              placeholder="请输入关键词"
31
+            />
32
+            <div class="search_box">
33
+              <img class="search_img" src="../img/news/search.png" />
34
+            </div>
35
+          </div>
36
+        </div>
37
+      </div>
38
+    </div>
39
+    <div class="news_list">
40
+      <div class="news_list_box">
41
+        <!-- <div class="news_list_item">
42
+          <img class="news_item_img" src="" />
43
+          <div class="news_item_title"></div>
44
+          <div class="news_item_stitle"></div>
45
+        </div> -->
46
+      </div>
47
+    </div>
48
+    <div class="news_page_box">
49
+      <div></div>
50
+      <div></div>
51
+      <div></div>
52
+      <div></div>
53
+    </div>
16 54
     <div class="footer_root"></div>
17 55
     <script src="../librarys/jquery@1.12.4/jquery.min.js"></script>
18 56
     <script src="../librarys/swiper@3.4.2/swiper.jquery.min.js"></script>
57
+    <script src="../utils/index.js"></script>
19 58
     <script src="../js/news.js"></script>
20 59
   </body>
21 60
 </html>

+ 1
- 1
sections/news_detail.html Dosyayı Görüntüle

@@ -8,7 +8,7 @@
8 8
     <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
9 9
     <link rel="stylesheet" href="../librarys/swiper@3.4.2/swiper.min.css" />
10 10
     <link rel="stylesheet" href="../css/comm.css" />
11
-    <link rel="stylesheet" href="../css/news_detail.css" />
11
+    <link rel="stylesheet" href="../css/news.css" />
12 12
     <script src="../utils/rem.js"></script>
13 13
   </head>
14 14
   <body>

+ 18
- 1
utils/index.js Dosyayı Görüntüle

@@ -1 +1,18 @@
1
-jQuery.extend({});
1
+jQuery.extend({
2
+  baseUrl: "//xhwebapitest.xhkjedu.com/",
3
+  showImageUrl: "//schoolstatic.xhkjedu.com/static/",
4
+  //毫秒时间转换为yyyy-MM-dd
5
+  msToDateString: function (ms) {
6
+    let date = new Date(ms);
7
+    let year = date.getFullYear();
8
+    let month = date.getMonth() + 1;
9
+    let day = date.getDate();
10
+    if (month < 10) {
11
+      month = "0" + month;
12
+    }
13
+    if (day < 10) {
14
+      day = "0" + day;
15
+    }
16
+    return year + "-" + month + "-" + day;
17
+  },
18
+});

Loading…
İptal
Kaydet