<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>关爱展厅</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
body {
background: #0f172a;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Inter', sans-serif;
overflow: hidden;
}
.gallery-container {
perspective: 1000px;
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.carousel {
position: relative;
width: 300px;
height: 400px;
transform-style: preserve-3d;
/* 使用更平滑的过渡函数 */
transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.carousel-item {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
/* 使用will-change优化性能 */
will-change: transform, box-shadow;
transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
box-shadow 0.5s cubic-bezier(0.23, 1, 0.32, 1);
cursor: pointer;
z-index: 5;
}
.carousel-item:hover {
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
transform: translateZ(calc(400px + 10px)); /* 悬停时向前移动 */
}
.carousel-item:active {
transform: translateZ(calc(400px)) scale(0.98);
transition-duration: 0.2s;
}
.carousel-item img {
width: 100%;
height: 100%;
object-fit: cover;
/* 使用will-change优化性能 */
will-change: transform;
transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}
.carousel-item:hover img {
transform: scale(1.05);
}
.carousel-info {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 20px;
background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
transform: translateY(20px);
opacity: 0;
/* 使用will-change优化性能 */
will-change: transform, opacity;
transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
z-index: 10;
}
.carousel-item:hover .carousel-info {
transform: translateY(0);
opacity: 1;
}
.carousel-title {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 5px;
color: white;
}
.carousel-desc {
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.8);
}
.controls {
position: fixed;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 20px;
z-index: 20;
}
.control-btn {
background: rgba(255, 255, 255, 0.1);
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
/* 使用will-change优化性能 */
will-change: background;
transition: background 0.3s ease;
}
.control-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
#activityBtn {
position: fixed;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.1);
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
/* 使用will-change优化性能 */
will-change: background;
transition: background 0.3s ease;
z-index: 20;
}
#activityBtn:hover {
background: rgba(255, 255, 255, 0.2);
}
#activityModal {
display: none;
position: fixed;
z-index: 100;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.7);
/* 使用will-change优化性能 */
will-change: opacity;
transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.modal-content {
background-color: #1e293b;
margin: 10% auto;
padding: 20px;
border-radius: 10px;
width: 80%;
max-width: 600px;
color: white;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
/* 使用will-change优化性能 */
will-change: transform, opacity;
transform: translateY(20px);
opacity: 0;
transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}
.modal-open .modal-content {
transform: translateY(0);
opacity: 1;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
/* 使用will-change优化性能 */
will-change: color;
transition: color 0.3s ease;
}
.close:hover,
.close:focus {
color: white;
text-decoration: none;
cursor: pointer;
}
.activity-list {
margin-top: 20px;
}
.activity-item {
padding: 15px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
/* 使用will-change优化性能 */
will-change: background;
transition: background 0.2s ease;
}
.activity-item:hover {
background: rgba(255, 255, 255, 0.03);
}
.activity-item:last-child {
border-bottom: none;
}
.activity-date {
font-weight: bold;
color: #94a3b8;
}
@media (max-width: 600px) {
.carousel {
width: 250px;
height: 350px;
}
.modal-content {
width: 90%;
margin: 5% auto;
}
#activityBtn {
top: 10px;
right: 10px;
padding: 8px 15px;
font-size: 0.9rem;
}
}
</style>
</head>
<body>
<div class="gallery-container">
<div id="carousel" class="carousel">
<!-- 图片将通过JS动态添加 -->
</div>
</div>
<div class="controls">
<button id="prevBtn" class="control-btn">
<i class="fa fa-arrow-left mr-2"></i>上一张
</button>
<button id="nextBtn" class="control-btn">
下一张<i class="fa fa-arrow-right ml-2"></i>
</button>
</div>
<button id="activityBtn" class="control-btn">
<i class="fa fa-calendar mr-2"></i>活动清单
</button>
<div id="activityModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2 class="text-xl font-bold mb-4">7月活动清单</h2>
<div class="activity-list">
<!-- 活动列表将通过JS动态生成 -->
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const carousel = document.getElementById('carousel');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const activityBtn = document.getElementById('activityBtn');
const activityModal = document.getElementById('activityModal');
const closeBtn = document.querySelector('.close');
const itemsCount = 5; // 更新为5个项目
const radius = 400;
let currentAngle = 0;
const angleStep = 360 / itemsCount; // 重新计算角度步长
// 优化后的主题数据,添加了"新员工融入"和"任务分派"
const communicationRecords = [
{
id: 1001,
title: "员工生病探望",
participants: ["人力资源部: 王经理", "部门主管: 张主管"],
content: "前往医院探望生病住院的员工,带去公司关怀和慰问品,了解康复情况并协调工作安排。",
time: "2023-06-15",
location: "市中心医院",
followUp: "人力资源部持续跟进员工康复进度,部门安排同事临时接手相关工作。",
topic: "生病看望",
imageId: 1005 // 医疗相关图片
},
{
id: 1003,
title: "6月员工生日会",
participants: ["行政部: 刘主管", "6月寿星: 全体成员"],
content: "举办6月员工生日会,庆祝员工生日,分享蛋糕和礼物,增强团队凝聚力。",
time: "2023-06-25",
location: "公司会议室",
followUp: "行政部收集员工反馈,持续优化生日关怀活动形式。",
topic: "生日关怀",
imageId: 1003 // 庆祝相关图片
},
{
id: 1004,
title: "端午节福利发放",
participants: ["行政部: 全体成员", "各部门代表"],
content: "为全体员工发放端午节福利,包括粽子、咸鸭蛋等传统节日礼品,表达节日问候。",
time: "2023-06-22",
location: "公司大厅",
followUp: "行政部持续关注员工福利需求,准备其他节日福利方案。",
topic: "节日福利",
imageId: 1004 // 食物相关图片
},
{
id: 1005,
title: "新员工入职欢迎会",
participants: ["人力资源部: 李主管", "新员工: 张明、王芳", "部门同事代表"],
content: "为新员工举办入职欢迎会,介绍公司文化、规章制度,帮助新员工快速融入团队。",
time: "2023-06-30",
location: "公司培训室",
followUp: "各部门安排导师指导新员工,定期跟进新员工适应情况。",
topic: "新员工融入",
imageId: 1006 // 团队合作相关图片
},
{
id: 1006,
title: "项目任务分派会议",
participants: ["项目经理: 赵经理", "开发团队: 全体成员", "测试团队: 负责人"],
content: "召开项目任务分派会议,明确各成员职责和任务,制定项目计划和时间节点。",
time: "2023-07-05",
location: "公司会议室B",
followUp: "定期召开项目进度会议,及时解决遇到的问题,确保项目顺利进行。",
topic: "任务分派",
imageId: 1008 // 商务会议相关图片
}
];
// 更新活动列表,添加新员工融入和任务分派相关活动
const currentMonthActivities = [
{
date: "2023-07-05",
title: "新一期员工入职培训",
type: "培训",
location: "公司培训室",
participants: "人力资源部、新入职员工"
},
{
date: "2023-07-10",
title: "员工户外拓展训练",
type: "团队活动",
location: "城市郊外拓展基地",
participants: "全体员工"
},
{
date: "2023-07-15",
title: "客户满意度调研分析",
type: "分析会",
location: "公司会议室A",
participants: "市场部、客服部"
},
{
date: "2023-07-20",
title: "第三季度项目任务分派",
type: "任务分配",
location: "公司大会议室",
participants: "各部门负责人、项目团队"
},
{
date: "2023-07-25",
title: "产品创新头脑风暴",
type: "研讨会",
location: "公司创意空间",
participants: "产品部、研发部、设计部"
}
];
function createCarouselItems() {
for (let i = 0; i < itemsCount; i++) {
const angle = (i * angleStep) * (Math.PI / 180);
const item = document.createElement('div');
item.className = 'carousel-item';
item.style.transform = `rotateY(${i * angleStep}deg) translateZ(${radius}px)`;
item.dataset.index = i;
item.dataset.topic = communicationRecords[i].topic;
const img = document.createElement('img');
img.src = `https://picsum.photos/id/${communicationRecords[i].imageId}/600/800`;
img.alt = communicationRecords[i].title;
const info = document.createElement('div');
info.className = 'carousel-info';
const title = document.createElement('h3');
title.className = 'carousel-title';
title.textContent = communicationRecords[i].title;
const desc = document.createElement('p');
desc.className = 'carousel-desc';
desc.textContent = communicationRecords[i].participants.join('、');
info.appendChild(title);
info.appendChild(desc);
item.appendChild(img);
item.appendChild(info);
carousel.appendChild(item);
item.addEventListener('click', () => {
const topic = encodeURIComponent(communicationRecords[i].topic);
console.log(`跳转到主题: ${topic}`);
item.style.transform = `rotateY(${i * angleStep}deg) translateZ(${radius - 10}px) scale(0.98)`;
setTimeout(() => {
item.style.transform = `rotateY(${i * angleStep}deg) translateZ(${radius}px)`;
// 注意:这里使用了相对路径,实际使用时请根据你的项目结构调整
window.location.href = `./photo-wall.html?topic=${topic}`;
}, 150);
});
}
}
function createActivityList() {
const activityList = document.querySelector('.activity-list');
activityList.innerHTML = '';
currentMonthActivities.forEach(activity => {
const activityItem = document.createElement('div');
activityItem.className = 'activity-item';
const dateElement = document.createElement('div');
dateElement.className = 'activity-date';
dateElement.textContent = activity.date;
const titleElement = document.createElement('h3');
titleElement.className = 'text-lg font-semibold mt-1';
titleElement.textContent = activity.title;
const typeElement = document.createElement('div');
typeElement.className = 'text-sm text-blue-400 mt-1';
typeElement.textContent = activity.type;
const locationElement = document.createElement('div');
locationElement.className = 'text-sm text-gray-300 mt-1';
locationElement.innerHTML = `<i class="fa fa-map-marker mr-1"></i> ${activity.location}`;
const participantsElement = document.createElement('div');
participantsElement.className = 'text-sm text-gray-300 mt-1';
participantsElement.innerHTML = `<i class="fa fa-users mr-1"></i> ${activity.participants}`;
activityItem.appendChild(dateElement);
activityItem.appendChild(titleElement);
activityItem.appendChild(typeElement);
activityItem.appendChild(locationElement);
activityItem.appendChild(participantsElement);
activityList.appendChild(activityItem);
});
}
function rotateCarousel(angle) {
// 使用requestAnimationFrame优化动画性能
requestAnimationFrame(() => {
carousel.style.transform = `rotateY(${angle}deg)`;
});
}
prevBtn.addEventListener('click', () => {
currentAngle += angleStep;
rotateCarousel(currentAngle);
});
nextBtn.addEventListener('click', () => {
currentAngle -= angleStep;
rotateCarousel(currentAngle);
});
let isDragging = false;
let startX, startRotation;
let lastAnimationFrameId = null;
document.addEventListener('mousedown', (e) => {
if (!e.target.closest('.carousel-item')) {
isDragging = true;
startX = e.clientX;
startRotation = currentAngle;
document.body.style.cursor = 'grabbing';
// 防止拖动时选择文本
document.body.style.userSelect = 'none';
}
});
document.addEventListener('mousemove', (e) => {
if (!isDragging) return;
const diffX = e.clientX - startX;
const newAngle = startRotation - diffX * 0.5;
// 使用requestAnimationFrame优化性能
if (lastAnimationFrameId) {
cancelAnimationFrame(lastAnimationFrameId);
}
lastAnimationFrameId = requestAnimationFrame(() => {
currentAngle = newAngle;
rotateCarousel(currentAngle);
});
});
document.addEventListener('mouseup', () => {
if (isDragging) {
isDragging = false;
document.body.style.cursor = 'default';
document.body.style.userSelect = '';
if (lastAnimationFrameId) {
cancelAnimationFrame(lastAnimationFrameId);
}
}
});
activityBtn.addEventListener('click', () => {
createActivityList();
activityModal.style.display = 'block';
// 添加延迟以确保过渡效果生效
setTimeout(() => {
activityModal.classList.add('modal-open');
}, 10);
});
closeBtn.addEventListener('click', () => {
activityModal.classList.remove('modal-open');
// 等待过渡完成后隐藏模态框
setTimeout(() => {
activityModal.style.display = 'none';
}, 500);
});
window.addEventListener('click', (e) => {
if (e.target === activityModal) {
activityModal.classList.remove('modal-open');
// 等待过渡完成后隐藏模态框
setTimeout(() => {
activityModal.style.display = 'none';
}, 500);
}
});
createCarouselItems();
rotateCarousel(currentAngle);
});
</script>
</body>
</html>
上述代码中“项目任务分派会议”和“6月员工生日会”这两个模块的冒泡事件异常,其他模块是正常的
最新发布