Эх сурвалжийг харах

top.js顶边栏的时间添加

Perperon 3 сар өмнө
parent
commit
a457c47cf8

+ 13 - 1
projects/src/main/webapp/vmodules/top.jsp

@@ -72,7 +72,7 @@
 
     <div class="top-cutline"></div>
     <div class="layui-logo" style="">哈密市投资项目智慧平台</div>--%>
-    <div class="prompt"><span class="date">2024年12月20日 星期五</span></div>
+    <div class="prompt"><span class="date">{{dateWeek}}</span></div>
     <c:if test="${isShowDialog==1}">
         <div class="top-task" onClick="toTask()">
             <div class="top-dashboard-icon"></div>
@@ -125,6 +125,10 @@
         el: "#top",
         data: {
             collapse: true,
+            dateWeek: ""
+        },
+        created() {
+            this.dateWeek = this.formatDate(new Date());
         },
         methods: {
             changeSide: function () {
@@ -142,6 +146,14 @@
                         window.location.href = targetUrl;
                     }
                 });
+            },
+            formatDate(date) {
+                const weekdays = ["日", "一", "二", "三", "四", "五", "六"];
+                const year = date.getFullYear();
+                const month = date.getMonth() + 1; // JavaScript中的月份是从0开始的,所以需要加1
+                const day = date.getDate();
+                const weekday = weekdays[date.getDay()]; // JavaScript中的getDay()方法返回的是一周中的第几天,从0(星期日)到6(星期六)
+                return year+`年`+(month < 10 ? '0' + month : month)+`月`+(day < 10 ? '0' + day : day)+`日 星期`+weekday;
             }
         }
     })