|
@@ -174,3 +174,31 @@ export const goToUrl = function (toUrl, data = { skipWay: 'navigateTo', data: ''
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
+/** 日期格式化 */
|
|
|
|
|
+export const dateFormat = function (date) {
|
|
|
|
|
+ const weekArr = ['日', '一', '二', '三', '四', '五', '六'];
|
|
|
|
|
+ let year = date.getFullYear();
|
|
|
|
|
+ let month = formatNumber(date.getMonth() + 1);
|
|
|
|
|
+ let day = formatNumber(date.getDate());
|
|
|
|
|
+ let week = weekArr[date.getDay()];
|
|
|
|
|
+ let hour = formatNumber(date.getHours());
|
|
|
|
|
+ let min = formatNumber(date.getMinutes());
|
|
|
|
|
+ let sec = formatNumber(date.getSeconds());
|
|
|
|
|
+ return {
|
|
|
|
|
+ regDate: `${year}年${month}月${day}日 星期${week}`,
|
|
|
|
|
+ date: `${year}${month}${day}`,
|
|
|
|
|
+ formatYear: `${year}-${month}-${day}`,
|
|
|
|
|
+ formatMon: `${month}-${day}`,
|
|
|
|
|
+ formatMon_C: `${month}月${day}日`,
|
|
|
|
|
+ formatTime: `${year}-${month}-${day} ${hour}:${min}:${sec}`,
|
|
|
|
|
+ week: `星期${week}`,
|
|
|
|
|
+ day: day,
|
|
|
|
|
+ year: year,
|
|
|
|
|
+ time: `${hour}${min}`,
|
|
|
|
|
+ };
|
|
|
|
|
+};
|
|
|
|
|
+/** 日期补足两位 */
|
|
|
|
|
+export const formatNumber = function (n) {
|
|
|
|
|
+ n = n.toString();
|
|
|
|
|
+ return n[1] ? n : '0' + n;
|
|
|
|
|
+};
|