521 lines
17 KiB
JavaScript
521 lines
17 KiB
JavaScript
/* =========================================================
|
|
暖橙陪诊 · 官网交互
|
|
========================================================= */
|
|
|
|
(function () {
|
|
'use strict';
|
|
|
|
document.documentElement.classList.add('js');
|
|
|
|
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
|
|
/* ---------- 服务说明数据 ---------- */
|
|
|
|
var serviceData = {
|
|
1: {
|
|
title: '全天陪诊',
|
|
icon: 'sun',
|
|
tag: '陪同就医 · 8小时/次',
|
|
price: '498',
|
|
unit: '8小时/次',
|
|
desc: '八小时服务(早8点—中午12点、下午1点—晚上5点),专业陪诊师全程陪同就医。适合就诊项目较多、耗时较长,或行动、认知、沟通不便及异地就医的用户。',
|
|
includes: [
|
|
'协助取号、缴费、就诊、检查、取药',
|
|
'全程陪同当日就诊流程',
|
|
'清点病历、检查报告与药品',
|
|
'提醒复诊时间与注意事项'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'服务时长8小时,超出按80元/小时计费',
|
|
'服务费不含挂号费、检查费、药费等医疗费用',
|
|
'不提供医疗建议,不代签具有法律效力的医疗文书'
|
|
]
|
|
},
|
|
2: {
|
|
title: '半天陪诊',
|
|
icon: 'clock',
|
|
tag: '陪同就医 · 4小时/次',
|
|
price: '298',
|
|
unit: '4小时/次',
|
|
desc: '四小时服务(上午8点—中午12点 或 下午1点—晚上5点),专业陪诊师全程陪同就医。适合就诊项目较少、预计半天内完成的情况。',
|
|
includes: [
|
|
'协助取号、缴费、就诊、检查、取药',
|
|
'全程陪同当日就诊流程',
|
|
'清点病历、检查报告与药品',
|
|
'提醒复诊时间与注意事项'
|
|
],
|
|
notes: [
|
|
'请提前1天预约,紧急订单请联系客服确认',
|
|
'服务时长4小时,超出按80元/小时计费',
|
|
'服务费不含挂号费、检查费、药费等医疗费用',
|
|
'不提供医疗建议,不代签具有法律效力的医疗文书'
|
|
]
|
|
},
|
|
3: {
|
|
title: '夜间陪诊',
|
|
icon: 'moon',
|
|
tag: '陪同就医 · 夜间时段',
|
|
price: '568',
|
|
unit: '4小时/次',
|
|
desc: '四小时夜间陪诊,适合夜间就诊、不便独自前往或家属不便陪同的情况。陪诊师按约定时间在医院指定地点会合,协助完成就诊流程。',
|
|
includes: [
|
|
'夜间时段医院集合',
|
|
'协助取号、就诊、检查、取药',
|
|
'全程陪同并协助沟通',
|
|
'清点材料,提醒后续安排'
|
|
],
|
|
notes: [
|
|
'夜间就诊请提前1天预约',
|
|
'服务时长4小时,超出按100元/小时计费',
|
|
'服务费不含挂号费、检查费、药费等医疗费用',
|
|
'不提供医疗建议,不代签具有法律效力的医疗文书'
|
|
]
|
|
},
|
|
4: {
|
|
title: '代问诊',
|
|
icon: 'chat',
|
|
tag: '就医代办 · 本人可不到场',
|
|
price: '280',
|
|
unit: '次',
|
|
desc: '经您同意并授权后,陪诊师携带病历资料,代您向医生陈述病情、转达就诊诉求,如实记录医嘱并完整转达。涉及检查、用药与治疗方案的选择,由医生直接与您或家人沟通。',
|
|
includes: [
|
|
'代您向医生陈述病情与就诊诉求',
|
|
'如实记录医嘱并完整转达',
|
|
'需要时协助安排电话沟通',
|
|
'检查、取药可另行预约对应服务'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'需经您同意并授权后,陪诊师方可代您与医生沟通',
|
|
'陪诊师不提供医疗建议,不代为选择检查、用药或治疗方案',
|
|
'部分医院要求患者本人到场,请提前确认'
|
|
]
|
|
},
|
|
5: {
|
|
title: '检查预约',
|
|
icon: 'calendar',
|
|
tag: '就医代办 · 检查预约',
|
|
price: '199',
|
|
unit: '次',
|
|
desc: '陪诊师代为联系医院预约磁共振(MRI)、CT、彩超等检查时间,并把预约到的具体时间通知您,交代检查前准备与注意事项。',
|
|
includes: [
|
|
'确认检查项目与期望时间',
|
|
'代为联系医院预约检查',
|
|
'通知具体检查时间',
|
|
'交代检查前准备与注意事项'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'检查申请单需由医生开具,尚未开单的请先挂号',
|
|
'服务费不含挂号费、检查费用',
|
|
'检查知情同意书需本人或家属签署,陪诊师不代签'
|
|
]
|
|
},
|
|
6: {
|
|
title: '出入院代办',
|
|
icon: 'building',
|
|
tag: '就医代办 · 出入院手续',
|
|
price: '258',
|
|
unit: '次',
|
|
desc: '经您授权同意后,陪诊师代您办理入院登记、医保手续、出院结算等出入院手续,并将办理结果、出院小结及相关单据交付给您。',
|
|
includes: [
|
|
'入院登记、医保手续代办',
|
|
'出院结算手续代办',
|
|
'办理结果与单据交付',
|
|
'确认本次代办完成'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'需经您授权同意,并提供身份证、医保卡等证件',
|
|
'入院代办需提前确认医院床位情况',
|
|
'服务费不含住院押金和医疗费用',
|
|
'具有法律效力的医疗文书需本人或家属签署'
|
|
]
|
|
},
|
|
7: {
|
|
title: '跑腿服务',
|
|
icon: 'route',
|
|
tag: '就医代办 · 1小时/次',
|
|
price: '148',
|
|
unit: '1小时/次',
|
|
desc: '适合工作繁忙不便请假或行动不便的用户。可代办代排队、代取药品、代取报告、样本送检等医院相关事项,本人不必到场。',
|
|
includes: [
|
|
'代排队、送资料',
|
|
'代取药品、代取报告',
|
|
'样本送检',
|
|
'结果或物品交付'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'服务时长1小时,超出按80元/小时计费',
|
|
'需经您同意并授权后,陪诊师方可持您的证件和材料代办',
|
|
'服务费不含药品费、检查费等医疗费用'
|
|
]
|
|
},
|
|
8: {
|
|
title: '取药快递',
|
|
icon: 'pill',
|
|
tag: '就医代办 · 代取药品',
|
|
price: '180',
|
|
unit: '次',
|
|
desc: '经您同意并授权后,陪诊师携带您的取药凭证代取药品,核对药品名称与数量,妥善包装后通过快递寄送到家。',
|
|
includes: [
|
|
'确认取药医院或药店与药品信息',
|
|
'持取药凭证代取药品',
|
|
'核对药品名称与数量',
|
|
'妥善包装并快递寄出'
|
|
],
|
|
notes: [
|
|
'请提前1天预约',
|
|
'需提供就诊卡、处方或取药单等取药凭证',
|
|
'服务费不含药品费用,快递费按实际收取',
|
|
'寄出前会与您确认快递费用'
|
|
]
|
|
}
|
|
};
|
|
|
|
/* ---------- 工具 ---------- */
|
|
|
|
function $(selector, scope) {
|
|
return (scope || document).querySelector(selector);
|
|
}
|
|
|
|
function $all(selector, scope) {
|
|
return Array.prototype.slice.call((scope || document).querySelectorAll(selector));
|
|
}
|
|
|
|
function closestTarget(event, selector) {
|
|
var target = event.target;
|
|
if (!target || typeof target.closest !== 'function') return null;
|
|
return target.closest(selector);
|
|
}
|
|
|
|
var toastTimer = null;
|
|
|
|
function showToast(message) {
|
|
var toast = $('#toast');
|
|
if (!toast) return;
|
|
toast.textContent = message;
|
|
toast.classList.add('is-visible');
|
|
window.clearTimeout(toastTimer);
|
|
toastTimer = window.setTimeout(function () {
|
|
toast.classList.remove('is-visible');
|
|
}, 2300);
|
|
}
|
|
|
|
async function copyText(text) {
|
|
if (navigator.clipboard && window.isSecureContext) {
|
|
try {
|
|
await navigator.clipboard.writeText(text);
|
|
return true;
|
|
} catch (error) {
|
|
/* 继续使用兜底方案 */
|
|
}
|
|
}
|
|
|
|
var input = document.createElement('textarea');
|
|
input.value = text;
|
|
input.setAttribute('readonly', '');
|
|
input.style.position = 'fixed';
|
|
input.style.opacity = '0';
|
|
input.style.top = '0';
|
|
document.body.appendChild(input);
|
|
input.select();
|
|
|
|
var copied = false;
|
|
try {
|
|
copied = document.execCommand('copy');
|
|
} catch (error) {
|
|
copied = false;
|
|
}
|
|
input.remove();
|
|
return copied;
|
|
}
|
|
|
|
/* ---------- 头部滚动状态 ---------- */
|
|
|
|
var header = $('#siteHeader');
|
|
var backToTop = $('#backToTop');
|
|
|
|
function updateScrollState() {
|
|
var y = window.scrollY || window.pageYOffset;
|
|
if (header) header.classList.toggle('is-scrolled', y > 30);
|
|
if (backToTop) backToTop.classList.toggle('is-visible', y > 620);
|
|
}
|
|
|
|
updateScrollState();
|
|
window.addEventListener('scroll', updateScrollState, { passive: true });
|
|
|
|
/* ---------- 移动端导航 ---------- */
|
|
|
|
var nav = $('#siteNav');
|
|
var navToggle = $('#navToggle');
|
|
|
|
function setNav(open) {
|
|
if (!nav || !navToggle) return;
|
|
nav.classList.toggle('is-open', open);
|
|
navToggle.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
navToggle.setAttribute('aria-label', open ? '关闭菜单' : '打开菜单');
|
|
}
|
|
|
|
function closeNav() {
|
|
setNav(false);
|
|
}
|
|
|
|
if (navToggle && nav) {
|
|
navToggle.addEventListener('click', function (event) {
|
|
event.stopPropagation();
|
|
setNav(!nav.classList.contains('is-open'));
|
|
});
|
|
|
|
$all('.nav-link', nav).forEach(function (link) {
|
|
link.addEventListener('click', closeNav);
|
|
});
|
|
|
|
document.addEventListener('click', function (event) {
|
|
if (!nav.classList.contains('is-open')) return;
|
|
if (nav.contains(event.target) || navToggle.contains(event.target)) return;
|
|
closeNav();
|
|
});
|
|
|
|
document.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Escape') closeNav();
|
|
});
|
|
|
|
window.addEventListener('resize', function () {
|
|
if (window.innerWidth > 1024) closeNav();
|
|
});
|
|
}
|
|
|
|
/* ---------- 导航高亮 ---------- */
|
|
|
|
var navLinks = $all('.nav-link');
|
|
var sections = $all('main section[id]');
|
|
|
|
if ('IntersectionObserver' in window && navLinks.length && sections.length) {
|
|
var navObserver = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (!entry.isIntersecting) return;
|
|
var id = '#' + entry.target.id;
|
|
navLinks.forEach(function (link) {
|
|
link.classList.toggle('is-active', link.getAttribute('href') === id);
|
|
});
|
|
});
|
|
}, { rootMargin: '-42% 0px -52% 0px', threshold: 0 });
|
|
|
|
sections.forEach(function (section) {
|
|
navObserver.observe(section);
|
|
});
|
|
}
|
|
|
|
/* ---------- 滚动进入动画 ---------- */
|
|
|
|
var revealItems = $all('[data-reveal]');
|
|
|
|
if (!('IntersectionObserver' in window) || reduceMotion) {
|
|
revealItems.forEach(function (item) {
|
|
item.classList.add('is-visible');
|
|
});
|
|
} else {
|
|
var revealObserver = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (!entry.isIntersecting) return;
|
|
entry.target.classList.add('is-visible');
|
|
revealObserver.unobserve(entry.target);
|
|
});
|
|
}, { rootMargin: '0px 0px -8% 0px', threshold: 0.1 });
|
|
|
|
revealItems.forEach(function (item) {
|
|
revealObserver.observe(item);
|
|
});
|
|
}
|
|
|
|
/* ---------- 数字滚动 ---------- */
|
|
|
|
function animateCount(element) {
|
|
if (!element || element.dataset.counted === 'true') return;
|
|
element.dataset.counted = 'true';
|
|
|
|
var target = Number(element.dataset.count || 0);
|
|
if (!Number.isFinite(target)) return;
|
|
|
|
if (reduceMotion) {
|
|
element.textContent = String(target);
|
|
return;
|
|
}
|
|
|
|
var duration = 1100;
|
|
var start = null;
|
|
|
|
function step(timestamp) {
|
|
if (!start) start = timestamp;
|
|
var progress = Math.min((timestamp - start) / duration, 1);
|
|
var eased = 1 - Math.pow(1 - progress, 3);
|
|
element.textContent = String(Math.round(target * eased));
|
|
if (progress < 1) window.requestAnimationFrame(step);
|
|
}
|
|
|
|
window.requestAnimationFrame(step);
|
|
}
|
|
|
|
var counters = $all('[data-count]');
|
|
if ('IntersectionObserver' in window) {
|
|
var countObserver = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (entry.isIntersecting) {
|
|
animateCount(entry.target);
|
|
countObserver.unobserve(entry.target);
|
|
}
|
|
});
|
|
}, { threshold: 0.4 });
|
|
|
|
counters.forEach(function (counter) {
|
|
countObserver.observe(counter);
|
|
});
|
|
} else {
|
|
counters.forEach(animateCount);
|
|
}
|
|
|
|
/* ---------- 服务说明弹窗 ---------- */
|
|
|
|
var dialog = $('#serviceDialog');
|
|
var dialogTitle = $('#serviceDialogTitle');
|
|
var dialogTag = $('#dialogTag');
|
|
var dialogDesc = $('#dialogDesc');
|
|
var dialogPrice = $('#dialogPrice');
|
|
var dialogIncludes = $('#dialogIncludes');
|
|
var dialogNotes = $('#dialogNotes');
|
|
var dialogIconUse = dialog ? $('.dialog-icon use', dialog) : null;
|
|
|
|
function fillList(list, items) {
|
|
if (!list) return;
|
|
list.innerHTML = '';
|
|
items.forEach(function (item) {
|
|
var li = document.createElement('li');
|
|
li.textContent = item;
|
|
list.appendChild(li);
|
|
});
|
|
}
|
|
|
|
function openService(id) {
|
|
var service = serviceData[id];
|
|
if (!service || !dialog) return;
|
|
|
|
if (dialogTitle) dialogTitle.textContent = service.title;
|
|
if (dialogTag) dialogTag.textContent = service.tag;
|
|
if (dialogDesc) dialogDesc.textContent = service.desc;
|
|
if (dialogPrice) {
|
|
dialogPrice.innerHTML = '<small>¥</small>' + service.price + '<em>/' + service.unit + '</em>';
|
|
}
|
|
fillList(dialogIncludes, service.includes);
|
|
fillList(dialogNotes, service.notes);
|
|
|
|
if (dialogIconUse) {
|
|
dialogIconUse.setAttribute('href', '#i-' + service.icon);
|
|
}
|
|
|
|
if (typeof dialog.showModal === 'function') {
|
|
if (!dialog.open) dialog.showModal();
|
|
} else {
|
|
dialog.setAttribute('open', '');
|
|
}
|
|
document.body.classList.add('is-locked');
|
|
var closeButton = $('#dialogClose');
|
|
if (closeButton) closeButton.focus();
|
|
}
|
|
|
|
function closeService() {
|
|
if (!dialog) return;
|
|
if (typeof dialog.close === 'function' && dialog.open) {
|
|
dialog.close();
|
|
} else {
|
|
dialog.removeAttribute('open');
|
|
document.body.classList.remove('is-locked');
|
|
}
|
|
}
|
|
|
|
document.addEventListener('click', function (event) {
|
|
var trigger = closestTarget(event, '[data-service]');
|
|
if (!trigger) return;
|
|
event.preventDefault();
|
|
openService(trigger.getAttribute('data-service'));
|
|
});
|
|
|
|
if (dialog) {
|
|
var dialogClose = $('#dialogClose');
|
|
if (dialogClose) {
|
|
dialogClose.addEventListener('click', closeService);
|
|
}
|
|
|
|
dialog.addEventListener('close', function () {
|
|
document.body.classList.remove('is-locked');
|
|
});
|
|
|
|
dialog.addEventListener('click', function (event) {
|
|
if (event.target !== dialog) return;
|
|
var rect = dialog.getBoundingClientRect();
|
|
var inside = event.clientX >= rect.left && event.clientX <= rect.right &&
|
|
event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
if (!inside) closeService();
|
|
});
|
|
|
|
var dialogQr = $('#dialogQr');
|
|
if (dialogQr) {
|
|
dialogQr.addEventListener('click', function () {
|
|
closeService();
|
|
var contact = $('#contact');
|
|
var qrPanel = $('#qrPanel');
|
|
if (contact) {
|
|
contact.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'start' });
|
|
}
|
|
if (qrPanel) {
|
|
qrPanel.classList.remove('is-highlight');
|
|
void qrPanel.offsetWidth;
|
|
qrPanel.classList.add('is-highlight');
|
|
window.setTimeout(function () {
|
|
qrPanel.classList.remove('is-highlight');
|
|
}, 1600);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* ---------- 复制微信号 ---------- */
|
|
|
|
document.addEventListener('click', async function (event) {
|
|
var button = closestTarget(event, '[data-copy]');
|
|
if (!button) return;
|
|
var value = button.getAttribute('data-copy');
|
|
if (!value) return;
|
|
var copied = await copyText(value);
|
|
if (copied) {
|
|
showToast('微信号已复制:' + value);
|
|
} else {
|
|
showToast('复制失败,请手动复制:' + value);
|
|
}
|
|
});
|
|
|
|
/* ---------- 返回顶部 / 电话按钮 ---------- */
|
|
|
|
if (backToTop) {
|
|
backToTop.addEventListener('click', function (event) {
|
|
event.preventDefault();
|
|
window.scrollTo({ top: 0, behavior: reduceMotion ? 'auto' : 'smooth' });
|
|
});
|
|
}
|
|
|
|
/* ---------- 常见问题:一次只展开一项 ---------- */
|
|
|
|
var faqItems = $all('.faq-item');
|
|
faqItems.forEach(function (item) {
|
|
item.addEventListener('toggle', function () {
|
|
if (!item.open) return;
|
|
faqItems.forEach(function (other) {
|
|
if (other !== item) other.open = false;
|
|
});
|
|
});
|
|
});
|
|
|
|
})();
|