qnloft-stock/html/calendar.html

71 lines
3.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="zh-CN">
<head>
<!-- 必须的 meta 标签 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap 的 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
crossorigin="anonymous">
<link href='https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13.1/css/all.css' rel='stylesheet'>
<title>日历</title>
</head>
<body>
<div id="head"></div>
<div class="container">
<div id="calendar"></div>
</div>
<!-- 选项 1jQuery 和 Bootstrap 集成包(集成了 Popper -->
<!-- jQuery and JavaScript Bundle with Popper -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.2/js/bootstrap.bundle.min.js"
crossorigin="anonymous"></script>
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js'></script>
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@5.10.1/locales/zh-cn.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
$.getJSON('json/events.json?nocache=' + new Date().getTime(), function(data) {
var events = data;
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
themeSystem: 'bootstrap',
locale: 'zh-cn',
selectable: true, // 允许选择日期
select: function(info) {
// 处理点击日期的事件
var clickedDate = info.start;
// 创建一个日期对象
var date = new Date(clickedDate);
// 转换为北京时间
date.setMinutes(date.getMinutes() - date.getTimezoneOffset() + 480); // 480 分钟是北京时区的偏移量
// 格式化日期
var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从 0 开始,所以要加 1
var day = date.getDate().toString().padStart(2, '0');
// 格式化后的日期字符串
var formattedDate = `${year}${month}${day}`;
console.log(formattedDate); // 输出格式化后的日期
// 进行页面跳转,例如跳转到指定日期的详情页面
window.location.href = formattedDate + '/index.html';
},
// textColor 在全天时间中才生效
events: events
});
calendar.render();
});
});
</script>
<!-- 选项 2Popper 和 Bootstrap 的 JS 插件各自独立 -->
<!--
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-Lge2E2XotzMiwH69/MXB72yLpwyENMiOKX8zS8Qo7LDCvaBIWGL+GlRQEKIpYR04" crossorigin="anonymous"></script>
-->
</body>
</html>