代码优化

This commit is contained in:
DelLevin-Home
2026-06-30 17:51:39 +08:00
parent 9430524378
commit 622e534b84
9 changed files with 34 additions and 1233 deletions

View File

@@ -13,6 +13,16 @@ DateTime? _safeParseDate(String? str, {DateTime? fallback}) {
return DateTime.tryParse(str)?.toLocal() ?? fallback;
}
/// 安全将动态值转为 double失败时返回 fallback
double? _safeParseDouble(dynamic value, {double? fallback}) {
if (value == null) return fallback;
if (value is double) return value;
if (value is int) return value.toDouble();
if (value is num) return value.toDouble();
if (value is String) return double.tryParse(value) ?? fallback;
return fallback;
}
/// 解析字符串列表(通用工具函数,不限于 Movie
List<String> parseStringListGeneric(dynamic data) {
if (data == null) return [];
@@ -86,14 +96,14 @@ class Movie {
genres: _parseStringList(json['genres']),
alternateTitles: _parseStringList(json['alternate_titles']),
summary: json['summary'],
rating: json['rating']?.toDouble(),
rating: _safeParseDouble(json['rating']),
status: json['status'] ?? 'want_to_watch',
category: json['category'] ?? 'movie',
watchDate: _safeParseDate(json['watch_date']),
createdAt: _safeParseDate(json['created_at'], fallback: DateTime.now())!,
updatedAt: _safeParseDate(json['updated_at'], fallback: DateTime.now())!,
isDeleted: json['is_deleted'] == 1 || json['is_deleted'] == true,
coverOffset: (json['cover_offset'] ?? 0.0).toDouble(),
coverOffset: _safeParseDouble(json['cover_offset'], fallback: 0.0)!,
);
}
@@ -224,14 +234,14 @@ class Book {
publisher: json['publisher'],
genres: Movie.parseStringList(json['genres']),
summary: json['summary'],
rating: json['rating']?.toDouble(),
rating: _safeParseDouble(json['rating']),
status: json['status'] ?? 'want_to_read',
isbn: json['isbn'],
publishDate: _safeParseDate(json['publish_date']),
createdAt: _safeParseDate(json['created_at'], fallback: DateTime.now())!,
updatedAt: _safeParseDate(json['updated_at'], fallback: DateTime.now())!,
isDeleted: json['is_deleted'] == 1 || json['is_deleted'] == true,
coverOffset: (json['cover_offset'] ?? 0.0).toDouble(),
coverOffset: _safeParseDouble(json['cover_offset'], fallback: 0.0)!,
);
}

View File

@@ -67,7 +67,6 @@ class _ProfilePageState extends State<ProfilePage> with RouteAware {
Future<void> _loadUserData() async {
try {
await UserPrefs.init();
setState(() {
_nickname = _userPrefs.nickname;
_motto = _userPrefs.motto;

View File

@@ -194,6 +194,7 @@ class AppProvider extends ChangeNotifier {
void setThemeMode(ThemeMode mode) {
if (_themeMode != mode) {
_themeMode = mode;
UserPrefs().setThemeMode(mode.index); // 0=system, 1=light, 2=dark
notifyListeners();
}
}

View File

@@ -9,6 +9,7 @@ class DatabaseHelper {
static final DatabaseHelper instance = DatabaseHelper._init();
static Database? _database;
static Completer<void>? _reopenCompleter;
static Completer<Database>? _initCompleter;
DatabaseHelper._init();
@@ -41,13 +42,28 @@ class DatabaseHelper {
}
Future<Database> get database async {
// 如果正在重开,等待完成(无忙等待)
// 如果正在重开,等待完成
if (_reopenCompleter != null) {
await _reopenCompleter!.future;
}
if (_database != null) return _database!;
_database = await _initDB('mooknote.db');
return _database!;
// 如果已有初始化在进行,等待它完成
if (_initCompleter != null) {
return _initCompleter!.future;
}
_initCompleter = Completer<Database>();
try {
_database = await _initDB('mooknote.db');
_initCompleter!.complete(_database!);
return _database!;
} catch (e) {
_initCompleter!.completeError(e);
rethrow;
} finally {
_initCompleter = null;
}
}
Future<Database> _initDB(String filePath) async {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -1,395 +0,0 @@
<!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>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700;900&family=Noto+Serif+SC:wght@400;600;700&display=swap');
:root {
--maoyan-red: #E5342F;
--maoyan-red-dark: #C41F1A;
--ticket-bg: #FFFDF7;
--text-primary: #1A1A1A;
--text-secondary: #666666;
--text-muted: #999999;
--divider: #E8E4DA;
--bg-dark: #1E1610;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #F5F0E6;
font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
padding: 20px;
}
/* ── Ticket Wrapper ── */
.ticket-wrapper {
position: relative;
z-index: 1;
width: 100%;
max-width: 400px;
filter: drop-shadow(0 4px 24px rgba(0,0,0,0.12));
transition: transform 0.3s ease;
animation: ticketEntrance 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.ticket-wrapper:hover {
transform: translateY(-4px);
}
@keyframes ticketEntrance {
0% { opacity: 0; transform: translateY(30px) scale(0.96); }
100% { opacity: 1; transform: translateY(0) scale(1); }
}
/* ── Main Ticket ── */
.ticket {
background: var(--ticket-bg);
border-radius: 12px;
overflow: hidden;
position: relative;
box-shadow: 0 2px 0 0 rgba(255,255,255,0.06) inset;
}
/* Subtle print texture */
.ticket::after {
content: '';
position: absolute;
inset: 0;
pointer-events: none;
background: repeating-linear-gradient(
0deg,
transparent,
transparent 1px,
rgba(0,0,0,0.003) 1px,
rgba(0,0,0,0.003) 2px
);
border-radius: 12px;
z-index: 10;
}
/* ── Header (票头) ── */
.ticket-header {
padding: 18px 24px 16px;
display: flex;
align-items: center;
gap: 14px;
position: relative;
border-bottom: 1px solid #F0EDE5;
}
.maoyan-logo {
width: 42px; height: 42px;
flex-shrink: 0;
position: relative; z-index: 1;
}
.logo-text {
font-size: 24px; font-weight: 900;
color: #1A1A1A;
letter-spacing: 0.06em;
position: relative; z-index: 1;
}
/* ── Body (票身) ── */
.ticket-body {
padding: 22px 24px 18px;
position: relative;
}
/* Cinema */
.cinema-info {
margin-bottom: 20px;
padding-bottom: 0;
border-bottom: none;
}
.cinema-name {
font-size: 15px; font-weight: 600;
color: var(--text-primary);
letter-spacing: 0.02em;
margin-bottom: 4px;
}
.cinema-address {
font-size: 12px; color: var(--text-muted);
line-height: 1.5;
}
/* Movie title */
.movie-title-section {
margin-bottom: 18px;
}
.movie-title {
font-family: 'Noto Serif SC', 'STSong', 'SimSun', serif;
font-size: 28px; font-weight: 700;
color: var(--text-primary);
line-height: 1.3; letter-spacing: 0.04em;
}
.movie-subtitle {
font-size: 13px; color: var(--text-secondary);
margin-top: 3px; letter-spacing: 0.03em;
}
/* Hall & seat */
.session-info {
margin-bottom: 10px;
}
.hall-badge {
display: inline-flex;
align-items: center; gap: 6px;
color: var(--text-primary);
font-size: 14px; font-weight: 500;
letter-spacing: 0.02em;
}
.hall-badge svg {
width: 16px; height: 16px;
flex-shrink: 0;
}
.seat-datetime {
font-size: 14px; color: var(--text-primary);
font-weight: 500;
display: flex; align-items: center;
gap: 8px;
}
.separator {
color: #D0CCC0; font-weight: 300;
user-select: none;
}
.datetime-text {
color: var(--text-secondary); font-weight: 400;
}
/* ── Tear Line (撕票虚线) ── */
.tear-line {
position: relative;
height: 32px;
display: flex;
align-items: center;
margin: 0 12px;
overflow: visible;
}
.tear-line::before {
content: '';
position: absolute;
left: 18px; right: 18px;
top: 50%; transform: translateY(-50%);
height: 1px;
background: repeating-linear-gradient(
to right,
#C8C4B8 0px, #C8C4B8 6px,
transparent 6px, transparent 14px
);
}
.scissors-icon {
position: absolute;
left: 0; top: 50%;
transform: translateY(-50%);
font-size: 14px; color: #B8B4A8;
z-index: 1;
background: var(--ticket-bg);
padding-right: 6px;
user-select: none;
}
/* ── Footer (票尾) ── */
.ticket-footer {
padding: 10px 24px 16px;
display: flex;
gap: 18px;
align-items: stretch;
}
/* QR code */
.qr-section {
flex-shrink: 0;
display: flex;
align-items: stretch;
}
.qr-code {
width: 130px;
}
.qr-code img {
width: 100%;
display: block;
}
.qr-label {
font-size: 10px; color: var(--text-muted);
letter-spacing: 0.04em;
}
/* Detail rows */
.details-section {
flex: 1;
display: flex;
flex-direction: column;
gap: 6px;
min-width: 0;
justify-content: center;
}
.detail-row {
display: flex;
justify-content: space-between;
align-items: baseline;
font-size: 13px;
}
.detail-label {
color: var(--text-muted);
flex-shrink: 0;
margin-right: 8px;
font-size: 12px;
}
.detail-value {
color: var(--text-primary);
font-weight: 500;
text-align: right;
white-space: nowrap;
}
.price-value {
font-size: 18px; font-weight: 700;
color: var(--maoyan-red);
}
.price-symbol {
font-size: 12px; font-weight: 500;
}
.service-fee {
font-size: 14px; font-weight: 600;
color: var(--text-primary);
}
.platform-badge {
display: inline-flex;
align-items: center;
gap: 4px;
justify-content: flex-end;
}
.platform-text {
font-size: 11px; color: var(--text-muted);
letter-spacing: 0.05em; font-weight: 500;
}
/* ── Responsive ── */
@media (max-width: 440px) {
.ticket-wrapper { max-width: 100%; }
.ticket-header { padding: 14px 18px 12px; }
.ticket-body { padding: 16px 18px 14px; }
.ticket-footer { padding: 10px 18px 14px; gap: 12px; }
.movie-title { font-size: 24px; }
.qr-code { width: 110px; }
}
</style>
</head>
<body>
<div class="ticket-wrapper">
<div class="ticket">
<!-- ═══════════ HEADER ═══════════ -->
<div class="ticket-header">
<div class="maoyan-logo">
<img src="maoyan.png" alt="猫眼电影" style="width:100%;height:100%;object-fit:contain;">
</div>
<div class="logo-text">猫眼电影</div>
</div>
<!-- ═══════════ BODY ═══════════ -->
<div class="ticket-body">
<div class="cinema-info">
<div class="cinema-name">万达影城朝阳大悦城IMAX店</div>
</div>
<div class="movie-title-section">
<div class="movie-title">流浪地球3</div>
<div class="movie-subtitle">科幻 / 冒险 / 3D IMAX · 片长148分钟</div>
</div>
<div class="session-info">
<div class="hall-badge">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="2" width="20" height="8" rx="1"/>
<path d="M4 10v10h16V10"/>
<path d="M6 14h4v6H6z"/><path d="M14 14h4v6h-4z"/>
</svg>
3号IMAX厅
</div>
</div>
<div class="seat-datetime">
<span>8排12座</span>
<span class="separator">|</span>
<span class="datetime-text">2026年6月18日 19:30</span>
</div>
</div>
<!-- ═══════════ TEAR LINE ═══════════ -->
<div class="tear-line">
<span class="scissors-icon"></span>
</div>
<!-- ═══════════ FOOTER ═══════════ -->
<div class="ticket-footer">
<div class="qr-section">
<div class="qr-code">
<img src="mookiletter.png"
alt="验票二维码" style="width:100%;height:100%;object-fit:contain;">
</div>
<span class="qr-label"></span>
</div>
<div class="details-section">
<div class="detail-row">
<span class="detail-label">票价</span>
<span class="detail-value price-value"><span class="price-symbol">¥</span>49.90</span>
</div>
<div class="detail-row">
<span class="detail-label">服务费</span>
<span class="detail-value service-fee">¥5.00</span>
</div>
<div class="detail-row">
<span class="detail-label">出票时间</span>
<span class="detail-value">2026-06-18 10:32:15</span>
</div>
<div class="detail-row">
<span class="detail-label">淘票票</span>
<span class="detail-value platform-badge">
<span class="platform-text">已出票</span>
</span>
</div>
<div class="detail-row">
<span class="detail-label">编码</span>
<span class="detail-value" style="font-family: monospace; letter-spacing:0.05em;">8602 3100 0618 7251</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,444 +0,0 @@
<!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>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700;900&family=Noto+Serif+SC:wght@400;600;700&display=swap');
:root {
--red: #D4342E;
--gold: #C9A96E;
--bg: #F8F5F0;
--card: #FFFFFF;
--text: #1C1C1C;
--text-secondary: #6B6B6B;
--text-muted: #A0A0A0;
--border: #EBE5D9;
--divider: #EEE8DA;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(160deg, #EBE4D8 0%, #F2EDE4 40%, #EEF0EF 100%);
font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
padding: 40px 20px;
}
/* Ambient */
body::before, body::after {
content: '';
position: fixed;
border-radius: 50%;
pointer-events: none;
z-index: 0;
opacity: 0.15;
}
body::before {
width: 420px; height: 420px;
background: radial-gradient(circle, #D4342E 0%, transparent 70%);
top: -120px; right: -120px;
}
body::after {
width: 300px; height: 300px;
background: radial-gradient(circle, #C9A96E 0%, transparent 70%);
bottom: -80px; left: -80px;
}
.card {
position: relative;
z-index: 1;
width: 400px;
background: var(--card);
border-radius: 16px;
box-shadow:
0 1px 0 rgba(0,0,0,0.03),
0 2px 8px rgba(0,0,0,0.04),
0 12px 40px rgba(0,0,0,0.10);
overflow: hidden;
animation: cardIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes cardIn {
0% { opacity: 0; transform: translateY(40px) scale(0.94); }
100% { opacity: 1; transform: translateY(0) scale(1); }
}
.card::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 4px;
background: linear-gradient(90deg, var(--red) 0%, #E85D59 30%, var(--red) 60%, #C1272D 100%);
z-index: 2;
}
/* Header */
.header {
padding: 28px 28px 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.header-left {
display: flex;
align-items: center;
gap: 10px;
}
.logo {
width: 34px; height: 34px;
flex-shrink: 0;
}
.logo img {
width: 100%; height: 100%;
object-fit: contain;
}
.brand {
font-size: 20px; font-weight: 800;
color: var(--text);
letter-spacing: 0.03em;
}
.header-right {
font-size: 10px; color: var(--text-muted);
text-align: right;
letter-spacing: 0.05em;
line-height: 1.6;
}
/* Body */
.body {
padding: 24px 28px 0;
}
.cinema {
font-size: 13px; font-weight: 500;
color: var(--text-secondary);
margin-bottom: 18px;
letter-spacing: 0.03em;
display: flex;
align-items: center;
gap: 6px;
}
.cinema svg {
width: 14px; height: 14px;
flex-shrink: 0;
color: var(--red);
}
.movie-title {
font-family: 'Noto Serif SC', 'STSong', 'SimSun', serif;
font-size: 34px; font-weight: 700;
color: var(--text);
line-height: 1.15;
letter-spacing: 0.06em;
margin-bottom: 4px;
}
.movie-meta-row {
font-size: 12px; color: var(--text-muted);
letter-spacing: 0.04em;
margin-bottom: 24px;
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.movie-meta-row .tag {
display: inline-block;
padding: 3px 10px;
border: 1px solid var(--border);
border-radius: 4px;
font-size: 11px;
color: var(--text-secondary);
letter-spacing: 0.04em;
}
/* Session grid */
.session-grid {
display: flex;
gap: 20px;
padding: 16px 0;
margin-bottom: 0;
}
.session-item {
display: flex;
flex-direction: column;
gap: 4px;
}
.session-item .label {
font-size: 10px; color: var(--text-muted);
letter-spacing: 0.06em;
text-transform: uppercase;
}
.session-item .value {
font-size: 13px; font-weight: 600;
color: var(--text);
letter-spacing: 0.03em;
white-space: nowrap;
}
.session-item .value.large {
font-size: 14px;
}
/* Tear line */
.tear-section {
padding: 0 28px;
}
.tear-line {
position: relative;
height: 28px;
display: flex;
align-items: center;
}
.tear-line::before {
content: '';
position: absolute;
left: 0; right: 0;
top: 50%;
height: 1px;
background: repeating-linear-gradient(
to right,
#D5CFC0 0px, #D5CFC0 7px,
transparent 7px, transparent 15px
);
}
.tear-dot {
position: absolute;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
z-index: 1;
}
.tear-dot.left { left: -2px; }
.tear-dot.right { right: -2px; }
.tear-dot svg {
width: 12px; height: 12px;
color: #C5BFAE;
}
/* Footer */
.footer {
padding: 10px 28px 28px;
display: flex;
gap: 20px;
align-items: stretch;
}
.footer-right {
flex: 1;
display: flex;
flex-direction: column;
gap: 7px;
min-width: 0;
justify-content: center;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: baseline;
font-size: 12px;
}
.info-row .key {
color: var(--text-muted);
font-size: 11px;
letter-spacing: 0.04em;
}
.info-row .val {
color: var(--text);
font-weight: 500;
}
.info-row .val.price {
font-size: 22px; font-weight: 700;
color: var(--red);
}
.info-row .val.code {
font-family: 'SF Mono', 'Cascadia Code', 'Courier New', monospace;
font-size: 11px; letter-spacing: 0.06em;
color: var(--text-secondary);
}
/* QR */
.qr-wrap {
flex-shrink: 0;
width: 150px;
display: flex;
align-items: stretch;
}
.qr-img {
width: 100%;
height: 100%;
border-radius: 8px;
overflow: hidden;
}
.qr-img img {
width: 100%;
display: block;
}
/* Bottom strip */
.footer-strip {
margin: 0 28px;
padding: 12px 0;
border-top: 1px solid var(--divider);
display: flex;
justify-content: space-between;
align-items: center;
}
.footer-strip .left {
font-size: 10px; color: var(--text-muted);
letter-spacing: 0.05em;
}
.footer-strip .right {
font-size: 10px; color: var(--text-muted);
letter-spacing: 0.04em;
}
/* Print */
@media print {
@page { margin: 14mm; size: auto; }
body {
background: #FFF;
padding: 0;
}
body::before, body::after { display: none; }
.card {
box-shadow: none;
border: 1px solid #D8D3C5;
border-radius: 10px;
animation: none;
width: 360px;
margin: 0 auto;
}
.card::before { height: 3px; }
.header { padding: 22px 24px 0; }
.body { padding: 18px 24px 0; }
.tear-section { padding: 0 24px; }
.footer { padding: 8px 24px 24px; }
.footer-strip { margin: 0 24px; }
}
@media (max-width: 440px) {
.card { width: 100%; max-width: 400px; }
.header { padding: 22px 20px 0; }
.body { padding: 18px 20px 0; }
.tear-section { padding: 0 20px; }
.footer { padding: 8px 20px 24px; gap: 14px; }
.footer-strip { margin: 0 20px; }
.movie-title { font-size: 28px; }
.session-grid { gap: 14px; }
.qr-img { width: 120px; height: auto; }
}
</style>
</head>
<body>
<div class="card">
<div class="header">
<div class="header-left">
<div class="logo">
<img src="maoyan.png" alt="">
</div>
<span class="brand">猫眼电影</span>
</div>
<div class="header-right">收藏纪念<br>PASSENGER COPY</div>
</div>
<div class="body">
<div class="cinema">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
<circle cx="12" cy="10" r="3"/>
</svg>
万达影城朝阳大悦城IMAX店
</div>
<div class="movie-title">流浪地球3</div>
<div class="movie-meta-row">
<span class="tag">3D IMAX</span>
<span class="tag">科幻 / 冒险</span>
<span class="tag">片长148分钟</span>
</div>
<div class="session-grid">
<div class="session-item">
<span class="label">影厅</span>
<span class="value large">3号IMAX厅</span>
</div>
<div class="session-item">
<span class="label">座位</span>
<span class="value large">8排12座</span>
</div>
<div class="session-item">
<span class="label">时间</span>
<span class="value">2026/06/18 19:30</span>
</div>
</div>
</div>
<div class="tear-section">
<div class="tear-line">
<span class="tear-dot left">
<svg viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>
</span>
<span class="tear-dot right">
<svg viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>
</span>
</div>
</div>
<div class="footer">
<div class="qr-wrap">
<div class="qr-img">
<img src="mookiletter.png" alt="二维码">
</div>
</div>
<div class="footer-right">
<div class="info-row">
<span class="key">票价</span>
<span class="val price">¥49.90</span>
</div>
<div class="info-row">
<span class="key">服务费</span>
<span class="val">¥5.00</span>
</div>
<div class="divider-thin"></div>
<div class="info-row">
<span class="key">出票时间</span>
<span class="val">2026-06-18 10:32</span>
</div>
<div class="info-row">
<span class="key">淘票票</span>
<span class="val">已出票</span>
</div>
<div class="info-row">
<span class="key">编码</span>
<span class="val code">8602 3100 0618 7251</span>
</div>
</div>
</div>
<div class="footer-strip">
<span class="left">M AOYAN MOVIE · TICKET</span>
<span class="right">MY202606181930</span>
</div>
</div>
</body>
</html>

View File

@@ -1,386 +0,0 @@
<!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>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700;900&family=Noto+Serif+SC:wght@400;600;700&family=DM+Serif+Display:ital@0;1&display=swap');
:root {
--bg: #FAF7F2;
--card: #FFFFFF;
--red: #C0392B;
--red-light: #E74C3C;
--text: #1A1A1A;
--text-mid: #555555;
--text-light: #8C8C8C;
--line: #E8E2D8;
--line-light: #F2EDE5;
--stamp: #E8D5C4;
--accent: #2C5F8A;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #EBE5DB;
font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
padding: 40px 20px;
}
.ticket {
width: 420px;
background: #FFFFFB;
box-shadow:
0 0 0 1px rgba(0,0,0,0.04),
0 2px 12px rgba(0,0,0,0.05),
0 8px 40px rgba(0,0,0,0.10);
animation: in 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
position: relative;
}
@keyframes in {
0% { opacity: 0; transform: translateY(32px); }
100% { opacity: 1; transform: translateY(0); }
}
/* ── Red header strip ── */
.hdr {
background: var(--red);
padding: 14px 28px;
display: flex;
align-items: center;
gap: 10px;
}
.hdr-title {
font-size: 18px; font-weight: 700;
color: #FFF;
letter-spacing: 0.06em;
}
.hdr-sub {
margin-left: auto;
font-size: 9px; color: rgba(255,255,255,0.7);
text-align: right;
letter-spacing: 0.08em;
line-height: 1.4;
}
/* ── Main content ── */
.main {
padding: 26px 32px 0;
}
.cinema-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 22px;
}
.cinema-icon {
width: 18px; height: 18px;
flex-shrink: 0;
color: var(--red);
}
.cinema-name {
font-size: 13px; font-weight: 500;
color: var(--text-mid);
letter-spacing: 0.03em;
}
.film-title {
font-family: 'Noto Serif SC', 'STSong', 'SimSun', serif;
font-size: 38px; font-weight: 700;
color: var(--text);
line-height: 1.12;
letter-spacing: 0.06em;
margin-bottom: 8px;
}
.film-sub {
font-size: 12px; color: var(--text-light);
letter-spacing: 0.04em;
margin-bottom: 26px;
display: flex;
gap: 16px;
}
.film-sub span {
display: inline-block;
padding: 3px 0;
border-bottom: 1px solid var(--line);
}
/* ── Three-column session ── */
.sess {
display: flex;
border-top: 1px solid var(--line);
border-bottom: 1px solid var(--line);
padding: 16px 0;
margin-bottom: 0;
}
.sess-col {
flex: 1;
text-align: center;
border-right: 1px solid var(--line-light);
padding: 4px 8px;
}
.sess-col:last-child {
border-right: none;
}
.sess-col .sess-label {
font-size: 9px; color: var(--text-light);
letter-spacing: 0.1em;
text-transform: uppercase;
margin-bottom: 6px;
display: block;
}
.sess-col .sess-val {
font-size: 15px; font-weight: 600;
color: var(--text);
letter-spacing: 0.03em;
white-space: nowrap;
}
.sess-col .sess-val.hi {
color: var(--red);
}
/* ── Tear ── */
.tear {
margin: 0 32px;
height: 28px;
position: relative;
display: flex;
align-items: center;
}
.tear::before {
content: '';
position: absolute;
left: 0; right: 0;
top: 50%;
height: 1px;
background: repeating-linear-gradient(
to right,
#D8D0C0 0px, #D8D0C0 9px,
transparent 9px, transparent 18px
);
}
.tear-circle {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 13px; height: 13px;
background: #EBE5DB;
border-radius: 50%;
}
.tear-circle.l { left: -38px; }
.tear-circle.r { right: -38px; }
/* ── Footer ── */
.ftr {
padding: 14px 32px 26px;
display: flex;
gap: 28px;
align-items: center;
}
.ftr-l {
flex-shrink: 0;
display: flex;
align-items: center;
}
.qr {
width: 150px;
height: 150px;
}
.qr img {
width: 100%; height: 100%;
display: block;
object-fit: contain;
}
.ftr-r {
flex: 1;
display: flex;
flex-direction: column;
gap: 5px;
min-width: 0;
}
.row {
display: flex;
justify-content: space-between;
align-items: baseline;
}
.row .lbl {
font-size: 11px; color: var(--text-light);
letter-spacing: 0.04em;
}
.row .val {
font-size: 13px; color: var(--text);
font-weight: 500;
text-align: right;
}
.row .val.big {
font-size: 26px; font-weight: 700;
color: var(--red);
font-family: 'Noto Serif SC', serif;
}
.row .val.code {
font-family: 'SF Mono', 'Courier New', monospace;
font-size: 10px; letter-spacing: 0.06em;
color: var(--text-mid);
}
.split {
height: 1px;
background: var(--line);
margin: 4px 0;
}
.status {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 13px;
font-weight: 500;
}
.status::before {
content: '';
width: 6px; height: 6px;
background: #27AE60;
border-radius: 50%;
}
/* ── Ticket stub number ── */
.stub {
margin: 0 32px;
padding: 14px 0;
border-top: 1px solid var(--line);
display: flex;
justify-content: space-between;
}
.stub span {
font-family: 'SF Mono', 'Courier New', monospace;
font-size: 10px; color: var(--text-light);
letter-spacing: 0.08em;
}
/* ── Print ── */
@media print {
@page { margin: 12mm; size: auto; }
body { background: #FFF; padding: 0; }
.ticket {
box-shadow: none;
border: 1px solid #D0CBC0;
width: 370px;
margin: 0 auto;
animation: none;
}
.hdr { background: var(--red); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.hdr-title, .hdr-sub { color: #FFF; }
.tear-circle { background: #FFF; }
}
@media (max-width: 460px) {
.ticket { width: 100%; }
.main, .ftr, .stub { padding-left: 20px; padding-right: 20px; }
.tear { margin: 0 20px; }
.stub { margin: 0 20px; }
.film-title { font-size: 32px; }
.qr { width: 120px; height: 120px; }
}
</style>
</head>
<body>
<div class="ticket">
<!-- Header -->
<div class="hdr">
<span class="hdr-title">猫眼电影</span>
<span class="hdr-sub">收藏纪念<br>COLLECTIBLE</span>
</div>
<!-- Main -->
<div class="main">
<div class="cinema-row">
<svg class="cinema-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
<circle cx="12" cy="10" r="3"/>
</svg>
<span class="cinema-name">万达影城朝阳大悦城IMAX店</span>
</div>
<div class="film-title">流浪地球3</div>
<div class="film-sub">
<span>3D IMAX</span>
<span>科幻 / 冒险</span>
<span>片长148分钟</span>
</div>
<div class="sess">
<div class="sess-col">
<span class="sess-label">影厅</span>
<span class="sess-val hi">3号IMAX厅</span>
</div>
<div class="sess-col">
<span class="sess-label">座位</span>
<span class="sess-val">8排12座</span>
</div>
<div class="sess-col">
<span class="sess-label">时间</span>
<span class="sess-val">2026.06.18 19:30</span>
</div>
</div>
</div>
<!-- Tear line -->
<div class="tear">
<span class="tear-circle l"></span>
<span class="tear-circle r"></span>
</div>
<!-- Footer -->
<div class="ftr">
<div class="ftr-l">
<div class="qr">
<img src="mookiletter.png" alt="二维码">
</div>
</div>
<div class="ftr-r">
<div class="row">
<span class="lbl">票价</span>
<span class="val big">¥49.90</span>
</div>
<div class="row">
<span class="lbl">服务费</span>
<span class="val">¥5.00</span>
</div>
<div class="split"></div>
<div class="row">
<span class="lbl">出票时间</span>
<span class="val">2026-06-18 10:32</span>
</div>
<div class="row">
<span class="lbl">淘票票</span>
<span class="val status">已出票</span>
</div>
<div class="row">
<span class="lbl">取票码</span>
<span class="val code">8602 3100 0618 7251</span>
</div>
</div>
</div>
<!-- Stub -->
<div class="stub">
<span>TICKET · COLLECTIBLE</span>
<span>NO. MY202606181930</span>
</div>
</div>
</body>
</html>