69db53a9 by 任超

style:日期

1 parent 918a5e1e
...@@ -30,7 +30,6 @@ layui.use('util', function () { ...@@ -30,7 +30,6 @@ layui.use('util', function () {
30 }); 30 });
31 31
32 var recentlyDay; 32 var recentlyDay;
33
34 function getDate() { 33 function getDate() {
35 var date = new Date(); 34 var date = new Date();
36 var base = new Date(date).getTime(); 35 var base = new Date(date).getTime();
...@@ -38,13 +37,17 @@ function getDate() { ...@@ -38,13 +37,17 @@ function getDate() {
38 var date = []; 37 var date = [];
39 var data = [Math.random() * 300]; 38 var data = [Math.random() * 300];
40 var time = new Date(base); 39 var time = new Date(base);
41 date.push([time.getFullYear(), time.getMonth() + 1, time.getDate()].join('/')); 40 var mon = (time.getMonth() + 1) >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
41 var day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
42 date.push([time.getFullYear(), mon, day].join('/'));
42 for (var i = 1; i < 7; i++) {//控制需要的天数 43 for (var i = 1; i < 7; i++) {//控制需要的天数
43 var now = new Date(base -= oneDay); //这里控制往前一周还是往后一周 44 var now = new Date(base -= oneDay); //这里控制往前一周还是往后一周
44 date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/')); 45 var nowMon = (now.getMonth() + 1) >= 10 ? now.getMonth() + 1 : '0' + (now.getMonth() + 1);
46 var nowDay = now.getDate() >= 10 ? now.getDate() : '0' + now.getDate();
47 date.push([now.getFullYear(), nowMon, nowDay].join('/'));
45 data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1])); 48 data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
46 } 49 }
47 return date.reverse(); 50 return date.reverse();
48 } 51 }
49 52
50 //初始化方法 53 //初始化方法
...@@ -59,14 +62,14 @@ $(function () { ...@@ -59,14 +62,14 @@ $(function () {
59 policiesData(); 62 policiesData();
60 }); 63 });
61 function initData() { 64 function initData() {
62 $('#appointment_inquiry').click (function(){ 65 $('#appointment_inquiry').click(function () {
63 if (isLogin()) { 66 if (isLogin()) {
64 window.open('./staticViews/wdyy.html','_self') 67 window.open('./staticViews/wdyy.html', '_self')
65 } 68 }
66 }) 69 })
67 $('#onlineBooking').click (function(){ 70 $('#onlineBooking').click(function () {
68 if (isLogin()) { 71 if (isLogin()) {
69 window.open('./staticViews/wdyy.html','_self') 72 window.open('./staticViews/wdyy.html', '_self')
70 } 73 }
71 }) 74 })
72 } 75 }
...@@ -82,18 +85,18 @@ function NewsData() { ...@@ -82,18 +85,18 @@ function NewsData() {
82 //数据,这里使用的是Json格式进行传输 85 //数据,这里使用的是Json格式进行传输
83 success: function (result) {//返回数据根据结果进行相应的处理 86 success: function (result) {//返回数据根据结果进行相应的处理
84 if (result.code == 200 && result.data != null) { 87 if (result.code == 200 && result.data != null) {
85 if(result.data[0].preViewUrl) { 88 if (result.data[0].preViewUrl) {
86 $('.news-img img').attr('src',result.data[0].preViewUrl); 89 $('.news-img img').attr('src', result.data[0].preViewUrl);
87 }else { 90 } else {
88 $('.news-img img').attr('src','./staticImages/news_demo.jpg'); 91 $('.news-img img').attr('src', './staticImages/news_demo.jpg');
89 } 92 }
90 for (var i = 0; i < result.data.length; i++) { 93 for (var i = 0; i < result.data.length; i++) {
91 if (i == 6) return; 94 if (i == 6) return;
92 publishTime = CutDate(result.data[i].publishTime); 95 publishTime = CutDate(result.data[i].publishTime);
93 if (result.data[i].preViewUrl) { 96 if (result.data[i].preViewUrl) {
94 li = '<li url="'+result.data[i].preViewUrl+'"><a href="./staticViews/news/'+result.data[i].id+'.html" title="' + result.data[i].headline + '" target="_blank">'; 97 li = '<li url="' + result.data[i].preViewUrl + '"><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
95 }else { 98 } else {
96 li = '<li><a href="./staticViews/news/'+result.data[i].id+'.html" title="' + result.data[i].headline + '" target="_blank">'; 99 li = '<li><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
97 } 100 }
98 li += '<div class="news_item">'; 101 li += '<div class="news_item">';
99 if (recentlyDay.indexOf(publishTime) > -1) { 102 if (recentlyDay.indexOf(publishTime) > -1) {
...@@ -108,10 +111,10 @@ function NewsData() { ...@@ -108,10 +111,10 @@ function NewsData() {
108 }); 111 });
109 112
110 $(document).on("mouseover", "#ulNews li", function (e) { 113 $(document).on("mouseover", "#ulNews li", function (e) {
111 if($(this).attr('url')) { 114 if ($(this).attr('url')) {
112 $('.news-img img').attr('src',$(this).attr('url')); 115 $('.news-img img').attr('src', $(this).attr('url'));
113 }else { 116 } else {
114 $('.news-img img').attr('src','./staticImages/news_demo.jpg'); 117 $('.news-img img').attr('src', './staticImages/news_demo.jpg');
115 } 118 }
116 }) 119 })
117 } 120 }
...@@ -130,7 +133,7 @@ function NoticeData() { ...@@ -130,7 +133,7 @@ function NoticeData() {
130 if (result.code == 200 && result.data != null) { 133 if (result.code == 200 && result.data != null) {
131 for (var i = 0; i < result.data.length; i++) { 134 for (var i = 0; i < result.data.length; i++) {
132 if (i == 6) return; 135 if (i == 6) return;
133 li = '<li class="item_notice"><a href="./staticViews/notice/'+result.data[i].id+'.html" title="' + result.data[i].title + '" target="_blank">'; 136 li = '<li class="item_notice"><a href="./staticViews/notice/' + result.data[i].id + '.html" title="' + result.data[i].title + '" target="_blank">';
134 li += '<p>' + result.data[i].title + '</P>'; 137 li += '<p>' + result.data[i].title + '</P>';
135 if (result.data[i].noticeType == 1) { 138 if (result.data[i].noticeType == 1) {
136 li += '<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#icongongshi"></use> </svg>'; 139 li += '<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#icongongshi"></use> </svg>';
...@@ -161,7 +164,7 @@ function LawsData() { ...@@ -161,7 +164,7 @@ function LawsData() {
161 if (result.code == 200 && result.data != null) { 164 if (result.code == 200 && result.data != null) {
162 for (var i = 0; i < result.data.length; i++) { 165 for (var i = 0; i < result.data.length; i++) {
163 if (i == 6) return; 166 if (i == 6) return;
164 li = '<li><a href="./staticViews/law/'+result.data[i].id+'.html" title="' + result.data[i].headline + '" target="_blank">'+ result.data[i].headline; 167 li = '<li><a href="./staticViews/law/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">' + result.data[i].headline;
165 li += '</a></li>'; 168 li += '</a></li>';
166 ulTag.append(li); 169 ulTag.append(li);
167 } 170 }
...@@ -183,7 +186,7 @@ function policiesData() { ...@@ -183,7 +186,7 @@ function policiesData() {
183 if (result.code == 200 && result.data != null) { 186 if (result.code == 200 && result.data != null) {
184 for (var i = 0; i < result.data.length; i++) { 187 for (var i = 0; i < result.data.length; i++) {
185 if (i == 6) return; 188 if (i == 6) return;
186 li = '<li><a href="./staticViews/policy/'+result.data[i].id+'.html" title="' + result.data[i].headline + '" target="_blank">'+ result.data[i].headline; 189 li = '<li><a href="./staticViews/policy/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">' + result.data[i].headline;
187 li += '</a></li>'; 190 li += '</a></li>';
188 policies.append(li); 191 policies.append(li);
189 } 192 }
......