- 添加项目配置文件(.editorconfig, .gitignore) - 创建App.vue主应用文件,包含启动时Mock数据初始化 - 添加index.html和main.js应用入口文件 - 配置manifest.json应用基本信息和权限设置 - 设置pages.json页面路由和全局样式 - 添加uni.promisify.adaptor.js适配器文件 - 创建uni.scss设计令牌系统,定义琥珀夜光主题色彩 - 新增constants.js常量定义,包含酒类分类和品牌数据
395 lines
8.6 KiB
Vue
395 lines
8.6 KiB
Vue
<template>
|
||
<view class="page-container login-page">
|
||
<!-- 顶部品牌区 -->
|
||
<view class="brand-area">
|
||
<view class="brand-glow"></view>
|
||
<view class="brand-icon">
|
||
<text class="brand-emoji">🍻</text>
|
||
</view>
|
||
<text class="brand-name">喝酒了么</text>
|
||
<text class="brand-slogan">让每一杯酒都有迹可循</text>
|
||
</view>
|
||
|
||
<!-- 登录区域 -->
|
||
<view class="login-area">
|
||
<!-- 理性饮酒须知 -->
|
||
<view v-if="showNotice" class="notice-card card">
|
||
<view class="notice-header">
|
||
<text class="notice-icon">📋</text>
|
||
<text class="notice-title">理性饮酒须知</text>
|
||
</view>
|
||
<view class="notice-content">
|
||
<text class="notice-item">• 过量饮酒有害健康,请理性记录</text>
|
||
<text class="notice-item">• 本应用不鼓励未成年人使用</text>
|
||
<text class="notice-item">• 不涉及任何酒类销售与推荐</text>
|
||
<text class="notice-item">• 您的数据仅用于个人记录</text>
|
||
</view>
|
||
<button class="btn-primary notice-btn" @click="acceptNotice">我已了解</button>
|
||
</view>
|
||
|
||
<!-- 主登录按钮 -->
|
||
<view v-else class="login-actions">
|
||
<button class="btn-cta login-btn" @click="handleLogin">
|
||
<text class="login-btn-icon">📱</text>
|
||
<text class="login-btn-text">微信一键登录</text>
|
||
</button>
|
||
|
||
<view class="login-divider">
|
||
<view class="login-divider-line"></view>
|
||
<text class="login-divider-text">或</text>
|
||
<view class="login-divider-line"></view>
|
||
</view>
|
||
|
||
<button class="btn-secondary" @click="handleGuest">
|
||
先看看再说
|
||
</button>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 饮酒偏好(登录后显示) -->
|
||
<view v-if="showPreferences" class="pref-overlay">
|
||
<view class="pref-card card-elevated">
|
||
<view class="pref-header">
|
||
<text class="text-h2">你的饮酒偏好</text>
|
||
<text class="text-caption">可跳过,稍后在设置中修改</text>
|
||
</view>
|
||
|
||
<view class="pref-section">
|
||
<text class="pref-label">常喝的酒类</text>
|
||
<view class="pref-tags">
|
||
<view
|
||
v-for="cat in drinkCategories"
|
||
:key="cat.id"
|
||
class="tag"
|
||
:class="{ 'tag-active': selectedCategories.includes(cat.id) }"
|
||
@click="toggleCategory(cat.id)"
|
||
>
|
||
<text>{{ cat.emoji }} {{ cat.name }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="pref-section">
|
||
<text class="pref-label">饮酒频率</text>
|
||
<view class="pref-options">
|
||
<view
|
||
v-for="freq in frequencies"
|
||
:key="freq.id"
|
||
class="freq-option"
|
||
:class="{ 'freq-active': selectedFrequency === freq.id }"
|
||
@click="selectedFrequency = freq.id"
|
||
>
|
||
<text>{{ freq.name }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="pref-actions">
|
||
<button class="btn-text" @click="skipPreferences">跳过</button>
|
||
<button class="btn-primary" @click="savePreferences">保存并进入</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 底部协议 -->
|
||
<view class="agreement">
|
||
<text class="text-tiny">登录即代表同意</text>
|
||
<text class="text-tiny text-amber">《用户协议》</text>
|
||
<text class="text-tiny">和</text>
|
||
<text class="text-tiny text-amber">《隐私政策》</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { DRINK_CATEGORIES } from '../../common/constants'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
showNotice: true,
|
||
showPreferences: false,
|
||
drinkCategories: DRINK_CATEGORIES,
|
||
selectedCategories: [],
|
||
selectedFrequency: '',
|
||
frequencies: [
|
||
{ id: 'daily', name: '几乎每天' },
|
||
{ id: 'often', name: '经常喝' },
|
||
{ id: 'sometimes', name: '偶尔喝' },
|
||
{ id: 'rarely', name: '很少喝' }
|
||
]
|
||
}
|
||
},
|
||
methods: {
|
||
acceptNotice() {
|
||
this.showNotice = false
|
||
},
|
||
handleLogin() {
|
||
// Mock登录,直接显示偏好设置
|
||
this.showPreferences = true
|
||
},
|
||
handleGuest() {
|
||
uni.setStorageSync('is_logged_in', 'true')
|
||
uni.setStorageSync('is_first_launch', 'false')
|
||
uni.reLaunch({ url: '/pages/index/index' })
|
||
},
|
||
toggleCategory(id) {
|
||
const idx = this.selectedCategories.indexOf(id)
|
||
if (idx > -1) {
|
||
this.selectedCategories.splice(idx, 1)
|
||
} else {
|
||
this.selectedCategories.push(id)
|
||
}
|
||
},
|
||
skipPreferences() {
|
||
this.finishLogin()
|
||
},
|
||
savePreferences() {
|
||
const user = JSON.parse(uni.getStorageSync('user_info') || '{}')
|
||
user.preferences = {
|
||
favoriteCategories: this.selectedCategories,
|
||
frequency: this.selectedFrequency
|
||
}
|
||
uni.setStorageSync('user_info', JSON.stringify(user))
|
||
this.finishLogin()
|
||
},
|
||
finishLogin() {
|
||
uni.setStorageSync('is_logged_in', 'true')
|
||
uni.setStorageSync('is_first_launch', 'false')
|
||
uni.reLaunch({ url: '/pages/index/index' })
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.login-page {
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-height: 100vh;
|
||
padding: $sp-xl;
|
||
}
|
||
|
||
.brand-area {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
padding-top: 120rpx;
|
||
}
|
||
|
||
.brand-glow {
|
||
position: absolute;
|
||
width: 400rpx;
|
||
height: 400rpx;
|
||
background: radial-gradient(circle, rgba(232,168,56,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -60%);
|
||
filter: blur(30rpx);
|
||
}
|
||
|
||
.brand-icon {
|
||
width: 200rpx;
|
||
height: 200rpx;
|
||
background: $bg-card;
|
||
border-radius: $radius-xl;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: $shadow-md;
|
||
margin-bottom: $sp-xl;
|
||
position: relative;
|
||
z-index: 2;
|
||
}
|
||
|
||
.brand-emoji {
|
||
font-size: 96rpx;
|
||
}
|
||
|
||
.brand-name {
|
||
font-size: $fs-hero;
|
||
font-weight: $fw-black;
|
||
color: $text-primary;
|
||
letter-spacing: -4rpx;
|
||
margin-bottom: $sp-sm;
|
||
}
|
||
|
||
.brand-slogan {
|
||
font-size: $fs-md;
|
||
color: $text-secondary;
|
||
}
|
||
|
||
.login-area {
|
||
padding-bottom: $sp-3xl;
|
||
}
|
||
|
||
/* 理性饮酒须知 */
|
||
.notice-card {
|
||
padding: $sp-xl;
|
||
}
|
||
|
||
.notice-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: $sp-sm;
|
||
margin-bottom: $sp-lg;
|
||
}
|
||
|
||
.notice-icon {
|
||
font-size: $fs-xl;
|
||
}
|
||
|
||
.notice-title {
|
||
font-size: $fs-lg;
|
||
font-weight: $fw-bold;
|
||
}
|
||
|
||
.notice-content {
|
||
margin-bottom: $sp-lg;
|
||
}
|
||
|
||
.notice-item {
|
||
display: block;
|
||
font-size: $fs-sm;
|
||
color: $text-secondary;
|
||
line-height: $lh-loose;
|
||
}
|
||
|
||
.notice-btn {
|
||
width: 100%;
|
||
}
|
||
|
||
/* 登录按钮 */
|
||
.login-actions {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: $sp-lg;
|
||
}
|
||
|
||
.login-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: $sp-sm;
|
||
}
|
||
|
||
.login-btn-icon {
|
||
font-size: $fs-xl;
|
||
}
|
||
|
||
.login-btn-text {
|
||
font-size: $fs-xl;
|
||
font-weight: $fw-bold;
|
||
}
|
||
|
||
.login-divider {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: $sp-md;
|
||
}
|
||
|
||
.login-divider-line {
|
||
flex: 1;
|
||
height: 2rpx;
|
||
background: rgba(255,255,255,0.06);
|
||
}
|
||
|
||
.login-divider-text {
|
||
font-size: $fs-sm;
|
||
color: $text-tertiary;
|
||
}
|
||
|
||
/* 偏好设置弹层 */
|
||
.pref-overlay {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background: rgba(0,0,0,0.7);
|
||
display: flex;
|
||
align-items: flex-end;
|
||
z-index: 100;
|
||
padding: $sp-lg;
|
||
}
|
||
|
||
.pref-card {
|
||
width: 100%;
|
||
padding: $sp-xl;
|
||
border-radius: $radius-xl $radius-xl 0 0;
|
||
}
|
||
|
||
.pref-header {
|
||
margin-bottom: $sp-xl;
|
||
|
||
.text-h2 {
|
||
display: block;
|
||
margin-bottom: $sp-xs;
|
||
}
|
||
}
|
||
|
||
.pref-section {
|
||
margin-bottom: $sp-xl;
|
||
}
|
||
|
||
.pref-label {
|
||
display: block;
|
||
font-size: $fs-sm;
|
||
font-weight: $fw-medium;
|
||
color: $text-secondary;
|
||
margin-bottom: $sp-md;
|
||
}
|
||
|
||
.pref-tags {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: $sp-sm;
|
||
}
|
||
|
||
.pref-options {
|
||
display: flex;
|
||
gap: $sp-sm;
|
||
}
|
||
|
||
.freq-option {
|
||
flex: 1;
|
||
text-align: center;
|
||
padding: $sp-md $sp-sm;
|
||
border-radius: $radius-md;
|
||
background: $bg-card;
|
||
font-size: $fs-sm;
|
||
color: $text-secondary;
|
||
border: 2rpx solid transparent;
|
||
transition: all $duration-fast $ease-out;
|
||
|
||
&.freq-active {
|
||
background: $amber-glow;
|
||
color: $amber;
|
||
border-color: rgba(232,168,56,0.3);
|
||
}
|
||
}
|
||
|
||
.pref-actions {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
gap: $sp-lg;
|
||
|
||
.btn-primary {
|
||
flex: 1;
|
||
}
|
||
}
|
||
|
||
/* 底部协议 */
|
||
.agreement {
|
||
display: flex;
|
||
justify-content: center;
|
||
gap: $sp-xs;
|
||
padding: $sp-lg 0;
|
||
}
|
||
</style>
|