社区食堂满意度评价表 - Contact Form 7
/* 保留所有原有CSS样式不变 */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}
body {
background: linear-gradient(135deg, #f5f7fa, #e4edf9);
color: #333;
line-height: 1.6;
padding: 20px;
min-height: 100vh;
}
.cf7-container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.cf7-header {
text-align: center;
padding: 30px;
background: linear-gradient(135deg, #2c3e50, #4a6491);
color: white;
}
.cf7-header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
}
.cf7-header p {
font-size: 1.2rem;
opacity: 0.9;
}
.cf7-section-card {
padding: 30px;
border-bottom: 1px solid #eaeaea;
background: #fff;
}
.cf7-section-title {
font-size: 24px;
color: #2c3e50;
margin-bottom: 25px;
padding-bottom: 12px;
border-bottom: 2px solid #3498db;
display: flex;
align-items: center;
}
.cf7-section-title i {
margin-right: 10px;
color: #3498db;
background: #e1f0fa;
padding: 8px;
border-radius: 50%;
}
.cf7-form-row {
display: flex;
flex-wrap: wrap;
margin: 0 -15px 20px;
}
.cf7-form-col {
flex: 1;
min-width: 250px;
padding: 0 15px;
margin-bottom: 20px;
}
.cf7-input-wrapper {
margin-bottom: 20px;
}
.cf7-label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #2c3e50;
font-size: 16px;
display: flex;
align-items: center;
}
.cf7-label i {
margin-right: 8px;
color: #3498db;
}
.cf7-input, .cf7-textarea {
width: 100%;
padding: 14px 15px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 16px;
transition: all 0.3s ease;
background: #f9fbfd;
}
.cf7-input:focus, .cf7-textarea:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
background: #fff;
}
.cf7-textarea {
min-height: 120px;
resize: vertical;
}
.cf7-radio {
display: flex;
gap: 15px;
margin-top: 5px;
}
.cf7-radio label {
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
padding: 8px 15px;
border-radius: 8px;
transition: all 0.3s ease;
border: 1px solid #ddd;
}
.cf7-radio label:hover {
background: #f0f7ff;
border-color: #3498db;
}
.cf7-table-wrapper {
overflow-x: auto;
margin: 20px 0;
border-radius: 8px;
border: 1px solid #eaeaea;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.cf7-score-table {
width: 100%;
border-collapse: collapse;
min-width: 800px;
}
.cf7-score-table th {
background: linear-gradient(to bottom, #f8fafc, #eef2f7);
color: #2c3e50;
font-weight: 600;
text-align: center;
padding: 14px;
border-bottom: 2px solid #eaeaea;
}
.cf7-score-table td {
padding: 14px;
text-align: center;
border-bottom: 1px solid #eaeaea;
background-color: white;
}
.cf7-score-table tr:nth-child(even) td {
background-color: #f8fafc;
}
.cf7-score-table tr:hover td {
background-color: #f0f7ff;
}
.radio-group {
display: flex;
justify-content: center;
gap: 8px;
}
.radio-option {
display: flex;
flex-direction: column;
align-items: center;
gap: 5px;
}
.radio-option input {
margin: 0;
width: 20px;
height: 20px;
cursor: pointer;
}
.radio-label {
font-size: 12px;
color: #666;
white-space: nowrap;
}
.cf7-info-card {
background: linear-gradient(to right, #f0f7ff, #e6f3ff);
border-radius: 8px;
padding: 25px;
margin: 25px 30px;
border-left: 4px solid #3498db;
box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}
.cf7-info-title {
font-size: 20px;
color: #2c3e50;
margin-bottom: 15px;
display: flex;
align-items: center;
}
.cf7-info-title i {
margin-right: 10px;
color: #3498db;
}
.cf7-info-content {
font-size: 15px;
line-height: 1.7;
color: #3a506b;
}
.cf7-info-content p {
margin-bottom: 12px;
}
.cf7-info-content ul {
padding-left: 25px;
margin-bottom: 15px;
}
.cf7-info-content li {
margin-bottom: 8px;
position: relative;
}
.cf7-info-content li:before {
content: "•";
color: #3498db;
font-weight: bold;
position: absolute;
left: -15px;
}
.cf7-info-content strong {
color: #2c3e50;
}
.cf7-submit-wrapper {
padding: 0 30px 30px;
text-align: center;
}
.cf7-submit {
background: linear-gradient(135deg, #3498db, #1a5a8d);
color: white;
border: none;
padding: 16px 45px;
font-size: 18px;
font-weight: 600;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
position: relative;
overflow: hidden;
}
.cf7-submit:hover {
background: linear-gradient(135deg, #2980b9, #144a75);
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(52, 152, 219, 0.5);
}
.cf7-submit:active {
transform: translateY(1px);
}
.cf7-submit:after {
content: "";
position: absolute;
top: -50%;
left: -60%;
width: 20px;
height: 200%;
background: rgba(255,255,255,0.3);
transform: rotate(30deg);
transition: all 0.8s;
}
.cf7-submit:hover:after {
left: 120%;
}
.score-display {
font-size: 2.2rem;
font-weight: 700;
color: #2c3e50;
text-align: center;
margin: 10px 0;
padding: 10px;
background: #f8fafc;
border-radius: 8px;
border: 1px solid #ddd;
}
.score-description {
margin-top: 5px;
font-size: 14px;
font-weight: 500;
padding: 8px 12px;
border-radius: 4px;
display: inline-block;
}
.progress-container {
height: 8px;
background: #ecf0f1;
border-radius: 4px;
margin-top: 10px;
overflow: hidden;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, #3498db, #2ecc71);
width: 0%;
transition: width 0.5s ease;
}
@media (max-width: 768px) {
.cf7-form-col {
flex: 0 0 100%;
}
.cf7-section-card {
padding: 20px;
}
.cf7-section-title {
font-size: 20px;
}
.cf7-header h1 {
font-size: 2rem;
}
.cf7-radio {
flex-wrap: wrap;
}
.cf7-radio label {
flex: 1;
min-width: 120px;
justify-content: center;
}
}
.cf7-response {
padding: 15px;
margin: 15px 30px;
border-radius: 8px;
text-align: center;
display: none;
}
.cf7-response.success {
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
display: block;
}
.cf7-response.error {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
display: block;
}
填报说明
评分规则:
- 最终得分 = 各题评分之和。
- 得分 ≥ 40 分:调查结果为满意。
- 满意率 = (得分 ≥ 40 的问卷数)/ 总问卷数 × 100%。
注意事项:
- 请如实填写,确保评分客观。
- 提交后数据将用于改进服务质量。
- 完成所有评分后,系统自动计算总分。
document.addEventListener('DOMContentLoaded', function() {
// 初始化表单
initForm();
// 监听CF7表单提交事件
document.addEventListener('wpcf7submit', function(event) {
const responseDiv = document.getElementById('form-response');
if (event.detail.status === 'mail_sent') {
responseDiv.className = 'cf7-response success';
responseDiv.innerHTML = '
评价提交成功!感谢您的反馈!';
} else {
responseDiv.className = 'cf7-response error';
responseDiv.innerHTML = '
提交失败,请检查表单后重试';
}
}, false);
// 初始化表单状态
function initForm() {
// 绑定评分单选按钮事件
const form = document.querySelector('.wpcf7-form');
if (form) {
form.addEventListener('change', function(e) {
if (e.target.type === 'radio') {
calculateTotalScore();
}
});
}
// 初始计算得分
calculateTotalScore();
}
// 计算总分
function calculateTotalScore() {
let totalScore = 0;
let answeredQuestions = 0;
// 检查每个问题是否已回答
for (let i = 1; i <= 10; i++) {
const questionName = `question${i}`;
const selectedOption = document.querySelector(`input[name="${questionName}"]:checked`);
if (selectedOption) {
totalScore += parseInt(selectedOption.value);
answeredQuestions++;
}
}
// 更新总分显示
document.getElementById('total-score').textContent = totalScore;
document.getElementById('cf7-total-score').value = totalScore;
// 更新进度条
const progressPercentage = (answeredQuestions / 10) * 100;
document.getElementById('score-progress').style.width = `${progressPercentage}%`;
// 更新进度条颜色
if (progressPercentage < 30) {
document.getElementById('score-progress').style.background = "#e74c3c";
} else if (progressPercentage = 40) {
scoreDescription.textContent = "评价结果:满意";
scoreDescription.style.background = "#e8f6ef";
scoreDescription.style.color = "#27ae60";
} else {
scoreDescription.textContent = "评价结果:不满意";
scoreDescription.style.background = "#fce8e6";
scoreDescription.style.color = "#e74c3c";
}
} else {
scoreDescription.textContent = `已完成 ${answeredQuestions}/10 题`;
scoreDescription.style.background = "#e1f0fa";
scoreDescription.style.color = "#3498db";
}
}
});