这是一个完整的HTML代码示例,实现了一个“付费解锁文件”的交互页面。模拟了文件被锁定,需要支付(模拟)才能查看内容的过程,且无法通过常规方式跳过。
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🔒 付费解锁文件</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
min-height: 100vh;
background: linear-gradient(145deg, #0b0e1a 0%, #1a1f2f 100%);
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.card {
background: rgba(22, 28, 46, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-radius: 48px;
padding: 40px 36px;
max-width: 600px;
width: 100%;
box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
transition: transform 0.2s ease;
border: 1px solid rgba(255, 255, 255, 0.03);
}
.file-icon {
text-align: center;
font-size: 4.2rem;
margin-bottom: 8px;
filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5));
}
h2 {
color: #f0f3fa;
font-weight: 500;
font-size: 1.8rem;
text-align: center;
letter-spacing: -0.3px;
margin-bottom: 6px;
}
.filename {
text-align: center;
color: #8892b0;
font-size: 1rem;
background: rgba(255, 255, 255, 0.04);
padding: 8px 16px;
border-radius: 100px;
display: inline-block;
margin: 0 auto 20px;
border: 1px solid rgba(255, 255, 255, 0.06);
backdrop-filter: blur(4px);
font-weight: 400;
letter-spacing: 0.3px;
}
.lock-badge {
background: #e74c3c;
color: white;
padding: 6px 18px;
border-radius: 60px;
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
display: inline-block;
margin: 0 auto 16px;
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}
.price-tag {
display: flex;
justify-content: center;
align-items: baseline;
gap: 6px;
margin: 18px 0 10px;
}
.price {
font-size: 3rem;
font-weight: 700;
color: #f0f3fa;
letter-spacing: -1px;
}
.currency {
font-size: 1.2rem;
color: #8892b0;
font-weight: 400;
}
.description {
color: #a8b2d1;
text-align: center;
font-size: 0.95rem;
line-height: 1.6;
margin: 12px 0 28px;
opacity: 0.8;
padding: 0 6px;
}
.pay-btn {
background: linear-gradient(135deg, #6c5ce7, #a855f7);
border: none;
width: 100%;
padding: 18px 0;
border-radius: 60px;
color: white;
font-size: 1.2rem;
font-weight: 600;
cursor: pointer;
transition: all 0.25s ease;
box-shadow: 0 8px 24px rgba(108, 92, 231, 0.35);
letter-spacing: 0.5px;
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
margin-bottom: 14px;
}
.pay-btn:hover {
transform: scale(1.02);
box-shadow: 0 12px 32px rgba(108, 92, 231, 0.5);
background: linear-gradient(135deg, #7c6df7, #b86aff);
}
.pay-btn:active {
transform: scale(0.97);
}
.pay-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2);
}
.skip-attempt {
background: rgba(255, 255, 255, 0.02);
border: 1px dashed rgba(255, 255, 255, 0.1);
color: #6b7a9f;
padding: 12px 16px;
border-radius: 40px;
font-size: 0.9rem;
width: 100%;
text-align: center;
cursor: pointer;
transition: all 0.2s;
margin-top: 6px;
font-weight: 400;
letter-spacing: 0.2px;
}
.skip-attempt:hover {
background: rgba(255, 255, 255, 0.06);
border-color: rgba(255, 255, 255, 0.2);
color: #b0c0e0;
}
.file-content {
margin-top: 28px;
background: rgba(0, 0, 0, 0.3);
border-radius: 24px;
padding: 24px 20px;
border-left: 4px solid #6c5ce7;
backdrop-filter: blur(4px);
display: none;
animation: fadeIn 0.4s ease;
}
.file-content.show {
display: block;
}
.file-content pre {
color: #ccd6f6;
font-family: 'Fira Code', 'JetBrains Mono', monospace;
font-size: 0.9rem;
white-space: pre-wrap;
word-break: break-word;
line-height: 1.6;
margin: 0;
background: rgba(255, 255, 255, 0.02);
padding: 8px 4px;
border-radius: 12px;
}
.file-content .label {
color: #8892b0;
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 10px;
}
.file-content .label span {
background: #6c5ce7;
padding: 2px 12px;
border-radius: 40px;
color: white;
font-size: 0.7rem;
}
.toast {
background: #2ecc71;
color: #0b0e1a;
padding: 12px 18px;
border-radius: 60px;
font-weight: 600;
font-size: 0.9rem;
margin-bottom: 16px;
text-align: center;
display: none;
box-shadow: 0 6px 20px rgba(46, 204, 113, 0.3);
animation: fadeIn 0.3s ease;
}
.toast.error {
background: #e74c3c;
color: white;
box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.footer-note {
text-align: center;
font-size: 0.7rem;
color: #3d4666;
margin-top: 20px;
letter-spacing: 0.3px;
border-top: 1px solid rgba(255,255,255,0.03);
padding-top: 18px;
}
.flex-center {
display: flex;
justify-content: center;
}
</style>
</head>
<body>
<div class="card" role="main" aria-label="付费文件解锁面板">
<!– 文件图标 –>
<div class="file-icon">📄</div>
<!– 标题 & 文件名 –>
<h2>加密文件</h2>
<div class="flex-center">
<span class="filename">📎 重要报告_2026.pdf</span>
</div>
<!– 锁定状态 –>
<div class="flex-center">
<span class="lock-badge">🔒 需付费解锁</span>
</div>
<!– 价格 –>
<div class="price-tag">
<span class="currency">$</span>
<span class="price" id="priceDisplay">9.99</span>
</div>
<p class="description">
此文件已被加密保护。支付后即可查看完整内容,<br>且不支持跳过。
</p>
<!– 付费按钮 –>
<button class="pay-btn" id="payBtn">
<span>💳</span> 立即支付解锁
</button>
<!– 模拟跳过(不可用) –>
<button class="skip-attempt" id="skipBtn">
⛔ 尝试跳过 (无效)
</button>
<!– Toast 消息 –>
<div id="toastMessage" class="toast"></div>
<!– 文件内容 (解锁后显示) –>
<div class="file-content" id="fileContent">
<div class="label">
<span>📂 已解锁</span> 文件内容
</div>
<pre>
╔══════════════════════════════════════╗
║ 年度战略复盘与规划 (2026) ║
║ ──────────────────────────────── ║
║ • ║
║ • ║
║ • ║
║ • ║
║ • ║
╚══════════════════════════════════════╝
</pre>
</div>
<div class="footer-note">
⚡ 支付模拟 · 无真实交易
</div>
</div>
<script>
(function() {
"use strict";
// DOM 元素
const payBtn = document.getElementById('payBtn');
const skipBtn = document.getElementById('skipBtn');
const fileContent = document.getElementById('fileContent');
const toast = document.getElementById('toastMessage');
const priceDisplay = document.getElementById('priceDisplay');
// 状态 —— 文件是否已解锁
let isUnlocked = false;
// ———- 工具函数:显示 Toast ———-
function showToast(message, isError = false) {
toast.textContent = message;
toast.className = 'toast'; // 重置
if (isError) {
toast.classList.add('error');
}
toast.style.display = 'block';
// 3.5秒后自动隐藏
clearTimeout(window._toastTimer);
window._toastTimer = setTimeout(() => {
toast.style.display = 'none';
}, 3500);
}
// ———- 解锁文件 ———-
function unlockFile() {
if (isUnlocked) {
showToast('✅ 文件已经解锁,无需重复支付', false);
return;
}
// 模拟支付过程 (瞬间完成)
// 实际场景中可接入支付网关,这里模拟成功
const paymentSuccess = true; // 假设支付成功
if (paymentSuccess) {
// 解锁
isUnlocked = true;
fileContent.classList.add('show');
// 改变按钮状态
payBtn.disabled = true;
payBtn.innerHTML = '<span>✅</span> 已解锁 · 可查看内容';
payBtn.style.background = 'linear-gradient(135deg, #2ecc71, #27ae60)';
payBtn.style.boxShadow = '0 8px 24px rgba(46, 204, 113, 0.3)';
// 更新锁定标记
const lockBadge = document.querySelector('.lock-badge');
if (lockBadge) {
lockBadge.innerHTML = '🔓 已解锁';
lockBadge.style.background = '#2ecc71';
lockBadge.style.boxShadow = '0 4px 12px rgba(46, 204, 113, 0.3)';
}
showToast('🎉 支付成功!文件已解锁,内容已显示', false);
} else {
// 极少情况支付失败 (模拟)
showToast('❌ 支付失败,请稍后重试', true);
}
}
// ———- “跳过”处理 (绝对不可用) ———-
function handleSkip() {
if (isUnlocked) {
showToast('🔓 文件已解锁,无需跳过', false);
return;
}
// 无论点多少次,都不允许跳过
showToast('⛔ 无法跳过付费。请完成支付以查看文件。', true);
// 附加“惩罚”效果:抖动或者额外提醒 (纯UI反馈)
skipBtn.style.transform = 'scale(0.96)';
skipBtn.style.borderColor = '#e74c3c';
skipBtn.style.color = '#e74c3c';
setTimeout(() => {
skipBtn.style.transform = '';
skipBtn.style.borderColor = 'rgba(255, 255, 255, 0.1)';
skipBtn.style.color = '#6b7a9f';
}, 400);
// 再“贴心”提醒一次 (用toast再强调)
setTimeout(() => {
if (!isUnlocked) {
showToast('🔒 此文件强制付费解锁,跳过功能已被禁用', true);
}
}, 600);
}
// ———- 额外:防止控制台/右键/拖拽等绕过 (增加门槛) ———-
function preventBypass(e) {
// 阻止拖拽打开、右键菜单(仅用于演示增强)
if (e.type === 'dragstart' || e.type === 'dragover' || e.type === 'drop') {
e.preventDefault();
return false;
}
// 对右键进行轻微拦截 (但不完全阻止,避免过度干扰)
if (e.type === 'contextmenu') {
// 如果是文件内容区域或按钮,可以提示
const target = e.target;
if (target.closest('.card') || target.closest('.file-content')) {
e.preventDefault();
showToast('⛔ 右键菜单已禁用 · 请使用支付按钮', true);
return false;
}
}
return true;
}
// ———- 事件绑定 ———-
payBtn.addEventListener('click', unlockFile);
skipBtn.addEventListener('click', handleSkip);
// 额外安全措施:拦截拖拽、右键(加强不可跳过感)
document.addEventListener('dragstart', preventBypass);
document.addEventListener('dragover', preventBypass);
document.addEventListener('drop', preventBypass);
document.addEventListener('contextmenu', preventBypass);
// 键盘快捷键拦截 (比如 Ctrl+U, Ctrl+S 等常见查看源码/保存) 仅用于演示
document.addEventListener('keydown', function(e) {
// 如果文件未解锁,拦截 F12, Ctrl+Shift+I, Ctrl+U, Ctrl+S (简单模拟)
if (!isUnlocked) {
const ctrl = e.ctrlKey || e.metaKey;
const key = e.key.toLowerCase();
// F12, Ctrl+Shift+I, Ctrl+U, Ctrl+S, Ctrl+P
if (key === 'f12' ||
(ctrl && key === 'u') ||
(ctrl && key === 's') ||
(ctrl && key === 'p') ||
(ctrl && e.shiftKey && key === 'i')) {
e.preventDefault();
showToast('⛔ 快捷键已被禁用 · 请支付解锁', true);
return false;
}
}
return true;
});
// 页面加载完成后,若有任何尝试通过控制台修改的, 额外提醒 (非绝对)
console.log('%c🔒 此文件受付费保护,请通过界面支付解锁。', 'font-size: 18px; font-weight: bold; color: #e74c3c; background: #1a1f2f; padding: 12px 20px; border-radius: 30px; border: 1px solid #e74c3c;');
// 暴露变量到window 用于演示 (但不提供解锁捷径)
window.__fileLocked = true;
Object.defineProperty(window, '__fileLocked', {
get: function() { return !isUnlocked; },
set: function(val) {
// 阻止通过控制台直接修改状态 (但无法完全阻止,增加心理门槛)
if (val === false && !isUnlocked) {
showToast('⛔ 无法通过控制台绕过付费', true);
}
return false;
}
});
console.log('🔐 提示: 支付后文件自动解锁,无需额外操作。');
// 初始化状态:确保文件内容隐藏
fileContent.classList.remove('show');
// 一个小彩蛋: 如果用户双击价格,显示提示 (无实际作用)
document.querySelector('.price').addEventListener('dblclick', function() {
if (!isUnlocked) {
showToast('💡 价格: $9.99 · 支付后永久解锁', false);
}
});
})();
</script>
</body>
</html>
```
付费解锁流程与防绕过机制
可以通过点击“立即支付解锁”按钮来模拟付费流程。页面设计了多层机制来确保“不可跳过”的体验。
· 核心解锁流程:点击支付按钮会触发模拟支付(代码中预设为成功),支付成功后文件内容会立即显示,同时按钮和状态标签会更新为“已解锁”。
· 多层防绕过设计:
· “跳过”按钮:点击会触发提示,告知无法跳过,并伴有视觉反馈。
· 快捷键与右键拦截:代码拦截了常见的查看源码(Ctrl+U)、保存(Ctrl+S)等快捷键,并禁用了文件区域的右键菜单。
· 控制台防护:尝试通过浏览器控制台修改解锁状态会收到提示,增加了绕过的心理门槛。
· 清晰的视觉反馈:页面通过Toast弹窗、按钮状态变化和锁定标签的更新,让人随时了解当前所处的“付费前”或“解锁后”状态。
网硕互联帮助中心



评论前必须登录!
注册