diff --git a/common/mock-data.js b/common/mock-data.js index 2ae4572..c445b7e 100644 --- a/common/mock-data.js +++ b/common/mock-data.js @@ -113,7 +113,7 @@ export function generateMockRecords() { } // 初始化并缓存Mock数据 -export function initMockData() { +export function initMockData() {自己看 const records = generateMockRecords() uni.setStorageSync('drink_records', JSON.stringify(records)) uni.setStorageSync('user_info', JSON.stringify(MOCK_USER)) diff --git a/components/DrinkCard.vue b/components/DrinkCard.vue index 3d92f8c..6c34828 100644 --- a/components/DrinkCard.vue +++ b/components/DrinkCard.vue @@ -6,17 +6,14 @@ - + - - {{ record.date }} - + {{ record.date }} {{ getFeelingEmoji() }} {{ getFeelingName() }} - @@ -29,7 +26,6 @@ - {{ record.standardCupsTotal }} @@ -41,36 +37,29 @@ {{ getFoodName() }} - " {{ quote }} - + - + - - - {{ record.date }} - + {{ record.date }} - {{ getCatEmoji(drink.category) }} {{ drink.brand }} {{ drink.standardCups }}杯 - {{ record.standardCupsTotal }} 标准杯 {{ getFeelingEmoji() }} {{ getFeelingName() }} - " {{ quote }} @@ -78,82 +67,112 @@ - + - - - {{ record.date }} - + {{ record.date }} {{ record.standardCupsTotal }} 标准杯 - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ getCatEmoji(drink.category) }} {{ drink.brand }} · {{ drink.standardCups }}杯 - 🍲 {{ getFoodName() }} {{ getFeelingEmoji() }} {{ getFeelingName() }} - " {{ quote }} @@ -161,11 +180,15 @@ - + - 🍻 喝酒了么 - - 记录每一杯的故事 + + 🍻 喝酒了么 + 记录每一杯的故事 + + + 扫码 + @@ -191,9 +214,7 @@ export default { const len = this.photos.length if (len === 0) return 'none' if (len === 1) return 'one' - if (len === 2) return 'two' - if (len === 3) return 'three' - if (len === 4) return 'four' + if (len <= 4) return 'few' return 'many' } }, @@ -223,7 +244,7 @@ export default { /* ========== 根容器 ========== */ .card-root { position: relative; - width: 100%; + width: 650rpx; border-radius: $radius-xl; overflow: hidden; padding: $sp-lg; @@ -237,531 +258,235 @@ export default { background: linear-gradient(160deg, #1A1308 0%, #0F0B06 40%, #1A1308 100%); border: 2rpx solid rgba(232, 168, 56, 0.25); } -.tpl-amber .bg-circle-1 { - background: radial-gradient(circle, rgba(232, 168, 56, 0.12), transparent 70%); -} -.tpl-amber .bg-circle-2 { - background: radial-gradient(circle, rgba(245, 197, 99, 0.08), transparent 70%); -} +.tpl-amber .bg-circle-1 { background: radial-gradient(circle, rgba(232, 168, 56, 0.12), transparent 70%); } +.tpl-amber .bg-circle-2 { background: radial-gradient(circle, rgba(245, 197, 99, 0.08), transparent 70%); } /* --- 模板: 暗夜极光 --- */ .tpl-aurora { background: linear-gradient(160deg, #0A0E1A 0%, #0B0B14 40%, #0E0A1A 100%); border: 2rpx solid rgba(139, 133, 184, 0.2); } -.tpl-aurora .bg-circle-1 { - background: radial-gradient(circle, rgba(94, 198, 160, 0.1), transparent 70%); -} -.tpl-aurora .bg-circle-2 { - background: radial-gradient(circle, rgba(139, 133, 184, 0.1), transparent 70%); -} -.tpl-aurora .date-badge { - background: rgba(139, 133, 184, 0.15); - border-color: rgba(139, 133, 184, 0.2); -} +.tpl-aurora .bg-circle-1 { background: radial-gradient(circle, rgba(94, 198, 160, 0.1), transparent 70%); } +.tpl-aurora .bg-circle-2 { background: radial-gradient(circle, rgba(139, 133, 184, 0.1), transparent 70%); } +.tpl-aurora .date-badge { background: rgba(139, 133, 184, 0.15); border-color: rgba(139, 133, 184, 0.2); } .tpl-aurora .stat-pill .stat-num, .tpl-aurora .cups-badge-num, .tpl-aurora .hero-cups, -.tpl-aurora .photo-total-cups { - color: $mint; -} +.tpl-aurora .photo-total-cups { color: $mint; } /* --- 模板: 胶片记忆 --- */ .tpl-film { background: linear-gradient(160deg, #141210 0%, #0D0C0A 40%, #141210 100%); border: 2rpx solid rgba(200, 180, 140, 0.15); } -.tpl-film .bg-circle-1 { - background: radial-gradient(circle, rgba(200, 180, 140, 0.08), transparent 70%); -} -.tpl-film .bg-circle-2 { - background: radial-gradient(circle, rgba(180, 160, 120, 0.06), transparent 70%); -} -.tpl-film .date-badge { - background: rgba(200, 180, 140, 0.1); - border-color: rgba(200, 180, 140, 0.15); -} +.tpl-film .bg-circle-1 { background: radial-gradient(circle, rgba(200, 180, 140, 0.08), transparent 70%); } +.tpl-film .bg-circle-2 { background: radial-gradient(circle, rgba(180, 160, 120, 0.06), transparent 70%); } +.tpl-film .date-badge { background: rgba(200, 180, 140, 0.1); border-color: rgba(200, 180, 140, 0.15); } /* 装饰背景 */ -.card-bg-deco { - position: absolute; - top: 0; left: 0; right: 0; bottom: 0; - pointer-events: none; - z-index: 0; -} -.bg-circle { - position: absolute; - border-radius: 50%; -} -.bg-circle-1 { - width: 400rpx; - height: 400rpx; - top: -100rpx; - right: -100rpx; -} -.bg-circle-2 { - width: 300rpx; - height: 300rpx; - bottom: 100rpx; - left: -80rpx; -} +.card-bg-deco { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0; } +.bg-circle { position: absolute; border-radius: 50%; } +.bg-circle-1 { width: 400rpx; height: 400rpx; top: -100rpx; right: -100rpx; } +.bg-circle-2 { width: 300rpx; height: 300rpx; bottom: 100rpx; left: -80rpx; } /* ========== 公共元素 ========== */ .date-badge { - display: inline-flex; - align-items: center; + display: inline-flex; align-items: center; padding: $sp-xs $sp-md; background: rgba(232, 168, 56, 0.1); border: 1rpx solid rgba(232, 168, 56, 0.15); border-radius: $radius-full; } -.date-badge.light { - background: rgba(255, 255, 255, 0.15); - border-color: rgba(255, 255, 255, 0.2); -} -.date-text { - font-size: $fs-xs; - color: $text-secondary; - font-family: $font-num; -} -.date-badge.light .date-text { - color: rgba(255, 255, 255, 0.85); -} +.date-badge.light { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.2); } +.date-text { font-size: $fs-xs; color: $text-secondary; font-family: $font-num; } +.date-badge.light .date-text { color: rgba(255, 255, 255, 0.85); } .feeling-tag { - display: inline-flex; - align-items: center; + display: inline-flex; align-items: center; padding: $sp-xs $sp-md; background: rgba(255, 255, 255, 0.05); border-radius: $radius-full; - font-size: $fs-xs; - color: $text-secondary; + font-size: $fs-xs; color: $text-secondary; } -.quote-mark { - font-size: $fs-3xl; - color: $amber; - opacity: 0.3; - line-height: 1; - margin-right: $sp-xs; -} -.quote-mark.light { - color: rgba(255, 255, 255, 0.4); -} -.quote-text { - font-size: $fs-sm; - color: $text-secondary; - font-style: italic; - flex: 1; - line-height: $lh-loose; -} -.quote-text.light { - color: rgba(255, 255, 255, 0.7); -} +.quote-mark { font-size: $fs-3xl; color: $amber; opacity: 0.3; line-height: 1; margin-right: $sp-xs; } +.quote-mark.light { color: rgba(255, 255, 255, 0.4); } +.quote-text { font-size: $fs-sm; color: $text-secondary; font-style: italic; flex: 1; line-height: $lh-loose; } +.quote-text.light { color: rgba(255, 255, 255, 0.7); } /* 品牌底栏 */ .card-brand-bar { - position: relative; - z-index: 1; - display: flex; - align-items: center; - justify-content: center; - gap: $sp-sm; - padding-top: $sp-lg; - margin-top: auto; + position: relative; z-index: 1; + display: flex; align-items: center; justify-content: space-between; + padding-top: $sp-lg; margin-top: auto; + border-top: 2rpx solid rgba(255, 255, 255, 0.04); } -.brand-name { - font-size: $fs-xs; - color: $text-tertiary; +.brand-left { + display: flex; flex-direction: column; gap: 4rpx; } -.brand-dot { - width: 4rpx; - height: 4rpx; - border-radius: $radius-full; - background: $text-tertiary; +.brand-name { font-size: $fs-xs; color: $text-tertiary; font-weight: $fw-medium; } +.brand-slogan { font-size: 18rpx; color: $text-tertiary; } +.brand-qr { + width: 80rpx; height: 80rpx; + background: rgba(255, 255, 255, 0.06); + border: 2rpx solid rgba(255, 255, 255, 0.08); + border-radius: $radius-md; + display: flex; align-items: center; justify-content: center; + flex-shrink: 0; } -.brand-slogan { - font-size: $fs-xs; - color: $text-tertiary; +.brand-qr-text { + font-size: 18rpx; color: $text-tertiary; } -/* ========== 无照片布局 ========== */ +/* ========== 0张: 纯文字 ========== */ .card-no-photo { - position: relative; - z-index: 1; - flex: 1; - display: flex; - flex-direction: column; - gap: $sp-lg; + position: relative; z-index: 1; flex: 1; + display: flex; flex-direction: column; gap: $sp-lg; } - -.no-photo-header { - display: flex; - justify-content: space-between; - align-items: center; -} - -.no-photo-hero { - padding: $sp-md 0; -} - -.hero-drink-list { - display: flex; - flex-direction: column; - gap: $sp-md; -} - +.no-photo-header { display: flex; justify-content: space-between; align-items: center; } +.no-photo-hero { padding: $sp-md 0; } +.hero-drink-list { display: flex; flex-direction: column; gap: $sp-md; } .hero-drink-item { - display: flex; - align-items: center; - gap: $sp-md; + display: flex; align-items: center; gap: $sp-md; padding: $sp-md; background: rgba(255, 255, 255, 0.03); border-radius: $radius-lg; border: 1rpx solid rgba(255, 255, 255, 0.04); } - -.hero-emoji { - font-size: 56rpx; - flex-shrink: 0; -} - -.hero-drink-info { - flex: 1; -} - -.hero-brand { - display: block; - font-size: $fs-base; - font-weight: $fw-bold; - color: $text-primary; -} - -.hero-product { - display: block; - font-size: $fs-xs; - color: $text-secondary; - margin-top: 4rpx; -} - -.hero-cups { - font-size: $fs-lg; - font-weight: $fw-black; - color: $amber; - font-family: $font-num; - flex-shrink: 0; -} - +.hero-emoji { font-size: 56rpx; flex-shrink: 0; } +.hero-drink-info { flex: 1; } +.hero-brand { display: block; font-size: $fs-base; font-weight: $fw-bold; color: $text-primary; } +.hero-product { display: block; font-size: $fs-xs; color: $text-secondary; margin-top: 4rpx; } +.hero-cups { font-size: $fs-lg; font-weight: $fw-black; color: $amber; font-family: $font-num; flex-shrink: 0; } .no-photo-stats { - display: flex; - align-items: center; - gap: $sp-lg; - padding: $sp-md; - background: rgba(255, 255, 255, 0.03); - border-radius: $radius-lg; + display: flex; align-items: center; gap: $sp-lg; + padding: $sp-md; background: rgba(255, 255, 255, 0.03); border-radius: $radius-lg; } +.stat-pill { display: flex; align-items: center; gap: $sp-xs; } +.stat-num { font-size: $fs-2xl; font-weight: $fw-black; color: $amber; font-family: $font-num; } +.stat-label { font-size: $fs-xs; color: $text-secondary; } +.stat-icon { font-size: $fs-base; } +.stat-divider { width: 2rpx; height: 40rpx; background: rgba(255, 255, 255, 0.08); } +.no-photo-quote { display: flex; align-items: flex-start; padding: $sp-sm 0; } -.stat-pill { - display: flex; - align-items: center; - gap: $sp-xs; -} - -.stat-num { - font-size: $fs-2xl; - font-weight: $fw-black; - color: $amber; - font-family: $font-num; -} - -.stat-label { - font-size: $fs-xs; - color: $text-secondary; -} - -.stat-icon { - font-size: $fs-base; -} - -.stat-divider { - width: 2rpx; - height: 40rpx; - background: rgba(255, 255, 255, 0.08); -} - -.no-photo-quote { - display: flex; - align-items: flex-start; - padding: $sp-sm 0; -} - -/* ========== 1张照片布局 ========== */ +/* ========== 1张: 沉浸式 ========== */ .card-one-photo { - position: relative; - z-index: 1; - flex: 1; - min-height: 600rpx; - border-radius: $radius-lg; + position: relative; z-index: 1; flex: 1; + min-height: 600rpx; border-radius: $radius-lg; overflow: hidden; margin: -#{$sp-lg}; - /* 把 padding 加回来让品牌栏有空间 */ - padding: $sp-lg; - padding-bottom: 0; - display: flex; - flex-direction: column; - justify-content: space-between; + padding: $sp-lg; padding-bottom: 0; + display: flex; flex-direction: column; justify-content: space-between; } - -.one-photo-bg { - position: absolute; - top: 0; left: 0; right: 0; bottom: 0; - width: 100%; - height: 100%; - z-index: 0; -} - +.one-photo-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; } .one-photo-overlay { - position: absolute; - top: 0; left: 0; right: 0; bottom: 0; - background: linear-gradient( - 180deg, - rgba(0, 0, 0, 0.3) 0%, - transparent 30%, - transparent 50%, - rgba(0, 0, 0, 0.75) 100% - ); + position: absolute; top: 0; left: 0; right: 0; bottom: 0; + background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 30%, transparent 50%, rgba(0,0,0,0.75) 100%); z-index: 1; } - -.one-photo-top { - position: relative; - z-index: 2; - display: flex; - justify-content: flex-start; - padding-top: $sp-sm; -} - -.one-photo-bottom { - position: relative; - z-index: 2; - display: flex; - flex-direction: column; - gap: $sp-md; - padding-bottom: $sp-md; -} - -.photo-drink-chips { - display: flex; - flex-wrap: wrap; - gap: $sp-sm; -} - +.one-photo-top { position: relative; z-index: 2; display: flex; justify-content: flex-start; padding-top: $sp-sm; } +.one-photo-bottom { position: relative; z-index: 2; display: flex; flex-direction: column; gap: $sp-md; padding-bottom: $sp-md; } +.photo-drink-chips { display: flex; flex-wrap: wrap; gap: $sp-sm; } .drink-chip { - display: inline-flex; - align-items: center; + display: inline-flex; align-items: center; padding: $sp-xs $sp-md; background: rgba(0, 0, 0, 0.45); - backdrop-filter: blur(10px); border-radius: $radius-full; border: 1rpx solid rgba(255, 255, 255, 0.1); - font-size: $fs-xs; - color: rgba(255, 255, 255, 0.9); + font-size: $fs-xs; color: rgba(255, 255, 255, 0.9); } +.photo-stats-row { display: flex; align-items: center; gap: $sp-lg; } +.photo-total-cups { font-size: $fs-xl; font-weight: $fw-black; color: $amber-light; font-family: $font-num; } +.photo-feeling { font-size: $fs-sm; color: rgba(255, 255, 255, 0.7); } +.photo-quote-line { display: flex; align-items: flex-start; } -.photo-stats-row { - display: flex; - align-items: center; - gap: $sp-lg; -} - -.photo-total-cups { - font-size: $fs-xl; - font-weight: $fw-black; - color: $amber-light; - font-family: $font-num; -} - -.photo-feeling { - font-size: $fs-sm; - color: rgba(255, 255, 255, 0.7); -} - -.photo-quote-line { - display: flex; - align-items: flex-start; -} - -/* ========== 多张照片布局 ========== */ +/* ========== 多张: 公共 ========== */ .card-multi-photo { - position: relative; - z-index: 1; - flex: 1; - display: flex; - flex-direction: column; - gap: $sp-lg; + position: relative; z-index: 1; flex: 1; + display: flex; flex-direction: column; gap: $sp-lg; } - -.multi-top { - display: flex; - justify-content: space-between; - align-items: center; -} - +.multi-top { display: flex; justify-content: space-between; align-items: center; } .multi-cups-badge { - display: flex; - align-items: baseline; - gap: $sp-xs; + display: flex; align-items: baseline; gap: $sp-xs; padding: $sp-xs $sp-md; background: rgba(232, 168, 56, 0.1); border: 1rpx solid rgba(232, 168, 56, 0.2); border-radius: $radius-full; } +.cups-badge-num { font-size: $fs-lg; font-weight: $fw-black; color: $amber; font-family: $font-num; } +.cups-badge-label { font-size: $fs-xs; color: $text-secondary; } -.cups-badge-num { - font-size: $fs-lg; - font-weight: $fw-black; - color: $amber; - font-family: $font-num; -} - -.cups-badge-label { - font-size: $fs-xs; - color: $text-secondary; -} - -/* 照片拼贴 */ -.photo-collage { - border-radius: $radius-lg; - overflow: hidden; -} - -/* 2张: 左大右小 */ -.collage-two { - display: flex; - gap: 6rpx; - height: 420rpx; -} -.collage-two .collage-large { - flex: 3; -} -.collage-two .collage-small { - flex: 2; -} - -/* 3张: 左大右两小 */ -.collage-three { - display: flex; - gap: 8rpx; - height: 440rpx; -} -.collage-three .c3-left { - flex: 1; - height: 100%; - border-radius: $radius-md; -} -.collage-three .c3-right { - width: 45%; - display: flex; - flex-direction: column; - gap: 8rpx; -} -.collage-three .c3-right-top, -.collage-three .c3-right-bottom { - flex: 1; - border-radius: $radius-md; -} - -/* 4张: 田字格 */ -.collage-four { - display: flex; - flex-wrap: wrap; - gap: 6rpx; - height: 460rpx; -} -.collage-four .collage-quarter { - width: calc(50% - 3rpx); - height: calc(50% - 3rpx); -} - -/* 5+张: 瀑布流 */ -.collage-many { - display: flex; - flex-direction: column; - gap: 6rpx; -} -.collage-many .collage-hero { - height: 320rpx; - border-radius: $radius-md; - overflow: hidden; -} -.collage-strip { - display: flex; - gap: 6rpx; - height: 160rpx; -} -.collage-strip-item { - flex: 1; - border-radius: $radius-sm; - overflow: hidden; -} -.collage-more { - width: 100rpx; - flex-shrink: 0; - background: rgba(255, 255, 255, 0.05); - border-radius: $radius-sm; - display: flex; - align-items: center; - justify-content: center; - font-size: $fs-sm; - color: $text-secondary; - font-weight: $fw-bold; -} - -.collage-item { +/* 照片网格公共 */ +.photo-grid { border-radius: $radius-lg; overflow: hidden; } +.grid-item { overflow: hidden; border-radius: $radius-sm; + position: relative; } - -.collage-img { +.grid-img { width: 100%; height: 100%; + object-fit: cover; + display: block; +} +.grid-row { display: flex; gap: 6rpx; } + +/* --- 2张: 左6右4 --- */ +.grid-2 { + display: flex; gap: 8rpx; height: 420rpx; +} +.grid-2 .gi-large { flex: 6; } +.grid-2 .gi-medium { flex: 4; } + +/* --- 3张: 左大右两小 --- */ +.grid-3 { + display: flex; gap: 8rpx; height: 440rpx; +} +.grid-3 .gi-hero-left { flex: 1; } +.grid-3 .gi-right-col { + width: 45%; display: flex; flex-direction: column; gap: 8rpx; +} +.grid-3 .gi-half { flex: 1; border-radius: $radius-md; } + +/* --- 4张: 2×2 --- */ +.grid-2x2 { + display: flex; flex-wrap: wrap; gap: 6rpx; height: 460rpx; +} +.grid-2x2 .gi-quarter { + width: calc(50% - 3rpx); height: calc(50% - 3rpx); +} + +/* --- 行式网格 (5-8张) --- */ +.grid-rows { + display: flex; flex-direction: column; gap: 6rpx; +} +.grid-row-3 { display: flex; gap: 6rpx; height: 210rpx; } +.grid-row-2 { display: flex; gap: 6rpx; height: 210rpx; } +.grid-row-4 { display: flex; gap: 6rpx; height: 170rpx; } + +.gi-third { flex: 1; } +.gi-half-row { flex: 1; } +.gi-quarter-row { flex: 1; } + +/* --- 9张: 3×3 --- */ +.grid-3x3 { + display: flex; flex-wrap: wrap; gap: 6rpx; +} +.grid-3x3 .gi-ninth { + width: calc(33.33% - 4rpx); height: 190rpx; } /* 底部信息 */ -.multi-bottom { - display: flex; - flex-direction: column; - gap: $sp-md; -} - -.multi-drinks-row { - display: flex; - flex-wrap: wrap; - gap: $sp-sm; -} - +.multi-bottom { display: flex; flex-direction: column; gap: $sp-md; } +.multi-drinks-row { display: flex; flex-wrap: wrap; gap: $sp-sm; } .multi-drink-tag { - display: inline-flex; - padding: $sp-xs $sp-md; + display: inline-flex; padding: $sp-xs $sp-md; background: rgba(255, 255, 255, 0.04); border: 1rpx solid rgba(255, 255, 255, 0.06); border-radius: $radius-full; - font-size: $fs-xs; - color: $text-secondary; -} - -.multi-meta-row { - display: flex; - gap: $sp-lg; -} - -.multi-meta-item { - font-size: $fs-sm; - color: $text-secondary; -} - -.multi-quote { - display: flex; - align-items: flex-start; + font-size: $fs-xs; color: $text-secondary; } +.multi-meta-row { display: flex; gap: $sp-lg; } +.multi-meta-item { font-size: $fs-sm; color: $text-secondary; } +.multi-quote { display: flex; align-items: flex-start; } diff --git a/pages/card/card.vue b/pages/card/card.vue index 5339331..ac22bcc 100644 --- a/pages/card/card.vue +++ b/pages/card/card.vue @@ -1,6 +1,5 @@ @@ -150,142 +381,43 @@ export default { .card-page { padding: $sp-lg; padding-bottom: calc(env(safe-area-inset-bottom) + $sp-xl); - display: flex; - flex-direction: column; - min-height: 100vh; + display: flex; flex-direction: column; min-height: 100vh; } - -/* 导航 */ .card-nav { - display: flex; - align-items: center; - gap: $sp-md; - padding: $sp-md 0 $sp-lg; + display: flex; align-items: center; gap: $sp-md; padding: $sp-md 0 $sp-lg; } - .step-back { - width: 64rpx; - height: 64rpx; - display: flex; - align-items: center; - justify-content: center; - border-radius: $radius-full; - background: $bg-card; + width: 64rpx; height: 64rpx; + display: flex; align-items: center; justify-content: center; + border-radius: $radius-full; background: $bg-card; } - -.step-back-arrow { - font-size: $fs-xl; - color: $text-secondary; - font-weight: $fw-bold; -} - -.card-nav-title { - font-size: $fs-lg; - font-weight: $fw-bold; -} - -/* 照片数量提示 */ -.photo-hint { - text-align: center; - margin-bottom: $sp-md; -} - -.photo-hint-text { - font-size: $fs-xs; - color: $text-tertiary; -} - -/* 模板切换 - 横排卡片选择 */ -.template-switcher { - display: flex; - gap: $sp-md; - margin-bottom: $sp-xl; - justify-content: center; -} - +.step-back-arrow { font-size: $fs-xl; color: $text-secondary; font-weight: $fw-bold; } +.card-nav-title { font-size: $fs-lg; font-weight: $fw-bold; } +.photo-hint { text-align: center; margin-bottom: $sp-md; } +.photo-hint-text { font-size: $fs-xs; color: $text-tertiary; } +.template-switcher { display: flex; gap: $sp-md; margin-bottom: $sp-xl; justify-content: center; } .template-option { - display: flex; - flex-direction: column; - align-items: center; - gap: $sp-xs; - padding: $sp-sm $sp-md; - border-radius: $radius-lg; - border: 2rpx solid rgba(255, 255, 255, 0.05); - background: rgba(255, 255, 255, 0.02); - transition: all $duration-fast $ease-out; - flex: 1; - max-width: 220rpx; - - &.template-active { - border-color: $amber; - background: rgba(232, 168, 56, 0.05); - } + display: flex; flex-direction: column; align-items: center; + gap: $sp-xs; padding: $sp-sm $sp-md; border-radius: $radius-lg; + border: 2rpx solid rgba(255,255,255,0.05); + background: rgba(255,255,255,0.02); + transition: all $duration-fast $ease-out; flex: 1; max-width: 220rpx; + &.template-active { border-color: $amber; background: rgba(232,168,56,0.05); } } - .template-swatch { - width: 64rpx; - height: 80rpx; - border-radius: $radius-md; - border: 2rpx solid rgba(255, 255, 255, 0.1); - position: relative; - display: flex; - align-items: center; - justify-content: center; + width: 64rpx; height: 80rpx; border-radius: $radius-md; + border: 2rpx solid rgba(255,255,255,0.1); position: relative; + display: flex; align-items: center; justify-content: center; } - -.swatch-dot { - width: 12rpx; - height: 12rpx; - border-radius: $radius-full; - background: $amber; -} - -.template-label { - font-size: $fs-xs; - color: $text-primary; - font-weight: $fw-medium; -} - -.template-desc { - font-size: 18rpx; - color: $text-tertiary; -} - -/* 卡片预览 */ +.swatch-dot { width: 12rpx; height: 12rpx; border-radius: $radius-full; background: $amber; } +.template-label { font-size: $fs-xs; color: $text-primary; font-weight: $fw-medium; } +.template-desc { font-size: 18rpx; color: $text-tertiary; } .card-preview-area { - flex: 1; - display: flex; - align-items: flex-start; - justify-content: center; - margin-bottom: $sp-xl; - width: 100%; -} - -/* 操作按钮 */ -.card-actions { - padding-bottom: $sp-xl; -} - -.action-row { - display: flex; - gap: $sp-md; - margin-top: $sp-md; -} - -.action-btn { - flex: 1; -} - -.success-toast { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - background: rgba(0, 0, 0, 0.8); - color: #fff; - padding: $sp-lg $sp-xl; - border-radius: $radius-lg; - font-size: $fs-base; - z-index: 100; + flex: 1; display: flex; align-items: flex-start; + justify-content: center; margin-bottom: $sp-xl; width: 100%; } +.card-actions { padding-bottom: $sp-xl; } +.action-row { display: flex; gap: $sp-md; margin-top: $sp-md; } +.action-btn { flex: 1; } +.export-canvas { position: fixed; left: -9999px; top: -9999px; } diff --git a/pages/record/record.vue b/pages/record/record.vue index 62191a4..c544d97 100644 --- a/pages/record/record.vue +++ b/pages/record/record.vue @@ -420,6 +420,23 @@ export default { this.backfillDate = options.date } }, + onBackPress() { + if (this.currentStep > 1 || this.hasFormData()) { + uni.showModal({ + title: '放弃记录?', + content: '当前填写的内容将不会保存', + confirmText: '继续填写', + cancelText: '放弃', + success: (res) => { + if (res.cancel) { + uni.navigateBack() + } + } + }) + return true // 阻止默认返回 + } + return false + }, methods: { selectCategory(cat) { this.currentDrink.category = cat.id @@ -484,10 +501,30 @@ export default { handleBack() { if (this.currentStep > 1) { this.prevStep() + } else if (this.hasFormData()) { + uni.showModal({ + title: '放弃记录?', + content: '当前填写的内容将不会保存', + confirmText: '继续填写', + cancelText: '放弃', + success: (res) => { + if (res.cancel) { + uni.navigateBack() + } + } + }) } else { uni.navigateBack() } }, + hasFormData() { + return this.drinks.length > 0 || + this.currentDrink.brand || + this.currentDrink.category || + this.selectedFood || + this.selectedFeeling || + this.photos.length > 0 + }, prevStep() { if (this.currentStep > 1) this.currentStep-- },