fix(mp): T40 UI 审查全量修复 + 设计体系一致性优化
Phase 0 基础设施:
- statusTag.ts: getStatusInlineStyle() 移除内联 borderRadius/padding/fontSize,仅返回 {background, color}
- 新增 SEVERITY_COLORS + getSeverityStyle() + getSeverityLabel() 统一告警严重程度样式
- variables.scss: 新增 9 个语义颜色别名 ($success/$danger/$warning/$info 等)
- mixins.scss: 新增 status-inline mixin 统一状态标签样式
- 7 个消费者页面添加 @include status-inline CSS 补偿
Phase 1 HIGH 修复 (4 页面):
- P46 随访管理: 移除 getTypeStyle() 硬编码 fontSize,替换文字 Loading 为组件
- P45 咨询详情医护: 添加 Loading/ErrorState 三态模板 + error ref
- P02 健康数据: 添加 loading ref + Loading 组件 + 错误 toast 提示
- P48 告警中心: 替换本地 SEVERITY_COLORS/SEVERITY_LABELS 为 statusTag.ts 导出
Phase 2 全局一致性:
- 2.1 触控补全: 17 页面为可点击元素添加 min-height: $touch-min
- 2.2 字号替换: 19 文件 31 处硬编码 px → Design Token CSS 变量
- 2.3 颜色替换: 18 文件 ~50 处硬编码十六进制 → SCSS 语义变量
- 2.4 elder-mode.scss: 新增 9 个选择器到触控放大清单
Phase 3 LOW 修复:
- 3.1 统一 Loading: 21 页面旧式文字加载 → <Loading> 组件
- 3.2 useElderClass: 8 页面补全长者模式 class 绑定
- 3.3 零散修复: 按钮 44px→48px,诊断记录添加 scroll-view 无限加载
同时新增 UniApp (Vue 3 + Vite) 小程序完整代码库 (146 文件)
This commit is contained in:
156
apps/miniprogram-uniapp/src/pages/health/index.vue
Normal file
156
apps/miniprogram-uniapp/src/pages/health/index.vue
Normal file
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="health-scroll">
|
||||
<view :class="['health-page', elderClass]">
|
||||
<GuestGuard>
|
||||
<!-- 健康数据页 -->
|
||||
<text class="page-title">健康数据</text>
|
||||
|
||||
<Loading v-if="loading" text="加载中..." />
|
||||
|
||||
<!-- 体征录入卡片 -->
|
||||
<view v-if="!loading" class="card input-card">
|
||||
<text class="section-title">今日体征</text>
|
||||
<view class="vital-grid">
|
||||
<view v-for="item in vitalItems" :key="item.key" class="vital-item" @tap="goInput(item.key)">
|
||||
<text class="vital-icon">{{ item.icon }}</text>
|
||||
<text class="vital-name">{{ item.name }}</text>
|
||||
<text class="vital-value">{{ latestVitals[item.key] || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 健康趋势入口 -->
|
||||
<view v-if="!loading" class="card" @tap="navigateTo('/pages-sub/pkg-health/trend/index')">
|
||||
<view class="trend-entry">
|
||||
<text class="trend-label">查看健康趋势</text>
|
||||
<text class="trend-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</GuestGuard>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useElderClass } from '@/composables/useElderClass'
|
||||
import { getTodaySummary } from '@/services/health'
|
||||
import GuestGuard from '@/components/GuestGuard.vue'
|
||||
import Loading from '@/components/Loading.vue'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const { elderClass } = useElderClass()
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const vitalItems = [
|
||||
{ key: 'heart_rate', name: '心率', icon: '❤️' },
|
||||
{ key: 'blood_pressure', name: '血压', icon: '🩸' },
|
||||
{ key: 'blood_sugar', name: '血糖', icon: '🍬' },
|
||||
{ key: 'temperature', name: '体温', icon: '🌡️' },
|
||||
{ key: 'weight', name: '体重', icon: '⚖️' },
|
||||
{ key: 'oxygen', name: '血氧', icon: '🫁' },
|
||||
]
|
||||
|
||||
const latestVitals = reactive<Record<string, string>>({})
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function goInput(key: string) {
|
||||
uni.navigateTo({ url: `/pages-sub/pkg-health/input/index?type=${key}` })
|
||||
}
|
||||
|
||||
async function fetchLatestVitals() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await getTodaySummary()
|
||||
if (data) {
|
||||
Object.assign(latestVitals, data)
|
||||
}
|
||||
} catch {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(fetchLatestVitals)
|
||||
onShow(() => { authStore.restore() })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.health-scroll {
|
||||
height: 100vh;
|
||||
background: $bg;
|
||||
}
|
||||
|
||||
.health-page {
|
||||
padding: 28px 24px 120px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.card {
|
||||
@include card;
|
||||
}
|
||||
|
||||
.input-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.vital-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.vital-item {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
background: $pri-surface;
|
||||
border-radius: $r-sm;
|
||||
padding: 16px 8px;
|
||||
}
|
||||
|
||||
.vital-icon {
|
||||
font-size: var(--tk-font-h2);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.vital-name {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.vital-value {
|
||||
font-size: var(--tk-font-num);
|
||||
font-weight: bold;
|
||||
color: $pri;
|
||||
@include serif-number;
|
||||
}
|
||||
|
||||
.trend-entry {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
min-height: $touch-min;
|
||||
}
|
||||
|
||||
.trend-label {
|
||||
font-size: var(--tk-font-body);
|
||||
font-weight: 500;
|
||||
color: $tx;
|
||||
}
|
||||
|
||||
.trend-arrow {
|
||||
font-size: var(--tk-font-h1);
|
||||
color: $tx3;
|
||||
}
|
||||
</style>
|
||||
317
apps/miniprogram-uniapp/src/pages/index/index.vue
Normal file
317
apps/miniprogram-uniapp/src/pages/index/index.vue
Normal file
@@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="home-scroll" @scrolltolower="onLoadMore">
|
||||
<view :class="['home-page', elderClass]">
|
||||
<!-- 已登录模式 -->
|
||||
<template v-if="authStore.user">
|
||||
<!-- 用户问候 -->
|
||||
<view class="greeting-section">
|
||||
<text class="greeting-text">{{ greeting }},{{ authStore.user.display_name || authStore.user.username }}</text>
|
||||
<text class="greeting-date">{{ today }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 快捷功能 -->
|
||||
<view class="quick-actions">
|
||||
<view class="action-item" @tap="navigateTo('/pages-sub/appointment/create/index')">
|
||||
<text class="action-icon">📅</text>
|
||||
<text class="action-label">预约</text>
|
||||
</view>
|
||||
<view class="action-item" @tap="navigateTo('/pages-sub/consultation/index')">
|
||||
<text class="action-icon">💬</text>
|
||||
<text class="action-label">咨询</text>
|
||||
</view>
|
||||
<view class="action-item" @tap="navigateTo('/pages-sub/pkg-health/trend/index')">
|
||||
<text class="action-icon">📊</text>
|
||||
<text class="action-label">趋势</text>
|
||||
</view>
|
||||
<view class="action-item" @tap="navigateTo('/pages-sub/article/index')">
|
||||
<text class="action-icon">📰</text>
|
||||
<text class="action-label">文章</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 健康概览卡片 -->
|
||||
<view class="health-summary card">
|
||||
<text class="section-title">健康概览</text>
|
||||
<view v-if="healthSummary" class="summary-grid">
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ healthSummary.heart_rate || '--' }}</text>
|
||||
<text class="summary-label">心率</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ healthSummary.blood_pressure || '--' }}</text>
|
||||
<text class="summary-label">血压</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ healthSummary.blood_sugar || '--' }}</text>
|
||||
<text class="summary-label">血糖</text>
|
||||
</view>
|
||||
</view>
|
||||
<Loading v-else-if="summaryLoading" text="加载中..." />
|
||||
<EmptyState v-else icon="📋" title="暂无健康数据" action-text="录入数据" @action="switchTab('/pages/health/index')" />
|
||||
</view>
|
||||
|
||||
<!-- 最近文章 -->
|
||||
<view class="articles-section card">
|
||||
<text class="section-title">健康文章</text>
|
||||
<Loading v-if="articlesLoading" text="加载中..." />
|
||||
<template v-else-if="articles.length > 0">
|
||||
<view v-for="article in articles" :key="article.id" class="article-entry" @tap="goArticle(article.id)">
|
||||
<text class="article-title">{{ article.title }}</text>
|
||||
<text class="article-date">{{ formatDate(article.created_at) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<EmptyState v-else icon="📰" title="暂无文章" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<!-- 访客模式 -->
|
||||
<template v-else>
|
||||
<view class="guest-page">
|
||||
<text class="guest-hero-icon">🏥</text>
|
||||
<text class="guest-hero-title">健康管理</text>
|
||||
<text class="guest-hero-desc">您的专属健康管家</text>
|
||||
<view class="guest-login-btn" @tap="navigateTo('/pages/login/index')">
|
||||
登录 / 注册
|
||||
</view>
|
||||
<text class="guest-browse">浏览健康资讯</text>
|
||||
|
||||
<!-- 访客也展示文章 -->
|
||||
<view class="articles-section card">
|
||||
<text class="section-title">健康文章</text>
|
||||
<Loading v-if="articlesLoading" text="加载中..." />
|
||||
<template v-else-if="articles.length > 0">
|
||||
<view v-for="article in articles" :key="article.id" class="article-entry" @tap="goArticle(article.id)">
|
||||
<text class="article-title">{{ article.title }}</text>
|
||||
<text class="article-date">{{ formatDate(article.created_at) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useElderClass } from '@/composables/useElderClass'
|
||||
import { getArticles } from '@/services/article'
|
||||
import { getTodaySummary } from '@/services/health'
|
||||
import { formatDate } from '@/utils/date'
|
||||
import Loading from '@/components/Loading.vue'
|
||||
import EmptyState from '@/components/EmptyState.vue'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const { elderClass } = useElderClass()
|
||||
|
||||
const articlesLoading = ref(false)
|
||||
const summaryLoading = ref(false)
|
||||
const articles = ref<any[]>([])
|
||||
const healthSummary = ref<any>(null)
|
||||
|
||||
const greeting = computed(() => {
|
||||
const h = new Date().getHours()
|
||||
if (h < 6) return '夜深了'
|
||||
if (h < 12) return '早上好'
|
||||
if (h < 14) return '中午好'
|
||||
if (h < 18) return '下午好'
|
||||
return '晚上好'
|
||||
})
|
||||
|
||||
const today = computed(() => formatDate(new Date(), 'YYYY年MM月DD日'))
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function switchTab(url: string) {
|
||||
uni.switchTab({ url })
|
||||
}
|
||||
|
||||
function goArticle(id: string) {
|
||||
uni.navigateTo({ url: `/pages-sub/article/detail/index?id=${id}` })
|
||||
}
|
||||
|
||||
function onLoadMore() {
|
||||
// 分页加载预留
|
||||
}
|
||||
|
||||
async function fetchArticles() {
|
||||
articlesLoading.value = true
|
||||
try {
|
||||
const res = await getArticles({ limit: 5 })
|
||||
articles.value = res || []
|
||||
} catch {
|
||||
articles.value = []
|
||||
}
|
||||
articlesLoading.value = false
|
||||
}
|
||||
|
||||
async function fetchHealthSummary() {
|
||||
if (!authStore.user) return
|
||||
summaryLoading.value = true
|
||||
try {
|
||||
healthSummary.value = await getTodaySummary()
|
||||
} catch {
|
||||
healthSummary.value = null
|
||||
}
|
||||
summaryLoading.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchArticles()
|
||||
fetchHealthSummary()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
authStore.restore()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.home-scroll {
|
||||
height: 100vh;
|
||||
background: $bg;
|
||||
}
|
||||
|
||||
.home-page {
|
||||
padding: 28px 24px 120px;
|
||||
}
|
||||
|
||||
.greeting-section {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.greeting-text {
|
||||
display: block;
|
||||
font-size: var(--tk-font-h1);
|
||||
font-weight: bold;
|
||||
color: $tx;
|
||||
}
|
||||
|
||||
.greeting-date {
|
||||
display: block;
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
background: $card;
|
||||
border-radius: $r-sm;
|
||||
padding: 20px 0;
|
||||
box-shadow: $shadow-sm;
|
||||
}
|
||||
|
||||
.action-icon {
|
||||
font-size: var(--tk-font-hero);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.action-label {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx2;
|
||||
}
|
||||
|
||||
.card {
|
||||
@include card;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: var(--tk-font-num);
|
||||
font-weight: bold;
|
||||
color: $pri;
|
||||
@include serif-number;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.article-entry {
|
||||
padding: 16px 0;
|
||||
min-height: $touch-min;
|
||||
border-bottom: 1px solid $bd-l;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
.article-title {
|
||||
display: block;
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.article-date {
|
||||
display: block;
|
||||
font-size: var(--tk-font-cap);
|
||||
color: $tx3;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
// 访客模式
|
||||
.guest-page {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.guest-hero-icon {
|
||||
font-size: var(--tk-font-display);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.guest-hero-title {
|
||||
font-size: var(--tk-font-h1);
|
||||
font-weight: bold;
|
||||
color: $tx;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.guest-hero-desc {
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx3;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.guest-login-btn {
|
||||
@include btn-primary;
|
||||
width: 280px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.guest-browse {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $pri;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
41
apps/miniprogram-uniapp/src/pages/legal/privacy-policy.vue
Normal file
41
apps/miniprogram-uniapp/src/pages/legal/privacy-policy.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="legal-page">
|
||||
<rich-text class="legal-content" :nodes="PRIVACY_CONTENT" />
|
||||
<view class="legal-footer">
|
||||
<text class="legal-footer-text">如有疑问,请联系客服</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const PRIVACY_CONTENT = `
|
||||
<h3>隐私政策</h3>
|
||||
<p>更新日期:2026年4月24日</p>
|
||||
<p>生效日期:2026年4月24日</p>
|
||||
<h4>一、我们收集的信息</h4>
|
||||
<p>1. <b>注册信息</b>:微信授权获取的 openid、手机号码</p>
|
||||
<p>2. <b>健康数据</b>:您主动录入的血压、血糖、心率、体重等健康指标</p>
|
||||
<p>3. <b>就诊信息</b>:预约记录、就诊人信息、体检报告</p>
|
||||
<p>4. <b>设备信息</b>:设备型号、操作系统版本</p>
|
||||
<h4>二、信息使用目的</h4>
|
||||
<p>1. 提供健康数据记录和趋势分析</p>
|
||||
<p>2. 预约挂号和就诊管理</p>
|
||||
<p>3. 个性化健康建议</p>
|
||||
<p>4. 改进服务质量</p>
|
||||
<h4>三、信息保护</h4>
|
||||
<p>我们采用 AES-256 加密存储敏感数据,严格限制数据访问权限。</p>
|
||||
<h4>四、信息共享</h4>
|
||||
<p>未经您的同意,我们不会与第三方共享您的个人信息,法律法规要求除外。</p>
|
||||
<h4>五、您的权利</h4>
|
||||
<p>您有权查询、更正、删除您的个人信息。</p>
|
||||
<h4>六、隐私政策更新</h4>
|
||||
<p>我们可能会不时更新本隐私政策。更新后的政策将在平台上公布。</p>
|
||||
`
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.legal-page { height: 100vh; background: $bg; padding: 24px; box-sizing: border-box; }
|
||||
.legal-content { font-size: var(--tk-font-body); line-height: var(--tk-line-height); color: $tx; }
|
||||
.legal-footer { margin-top: 40px; text-align: center; }
|
||||
.legal-footer-text { font-size: var(--tk-font-cap); color: $tx3; }
|
||||
</style>
|
||||
42
apps/miniprogram-uniapp/src/pages/legal/user-agreement.vue
Normal file
42
apps/miniprogram-uniapp/src/pages/legal/user-agreement.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="legal-page">
|
||||
<rich-text class="legal-content" :nodes="AGREEMENT_CONTENT" />
|
||||
<view class="legal-footer">
|
||||
<text class="legal-footer-text">如有疑问,请联系客服</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const AGREEMENT_CONTENT = `
|
||||
<h3>用户服务协议</h3>
|
||||
<p>更新日期:2026年4月24日</p>
|
||||
<p>生效日期:2026年4月24日</p>
|
||||
<h4>一、服务条款的确认和接纳</h4>
|
||||
<p>本平台由健康管理平台运营。用户在注册及使用本平台服务前,请务必仔细阅读并充分理解本协议。</p>
|
||||
<h4>二、服务内容</h4>
|
||||
<p>本平台为用户提供以下健康管理服务:</p>
|
||||
<p>1. 健康数据记录与查看(血压、血糖、心率等)</p>
|
||||
<p>2. 在线预约挂号</p>
|
||||
<p>3. 体检报告查看</p>
|
||||
<p>4. 随访管理</p>
|
||||
<p>5. 健康资讯阅读</p>
|
||||
<p>6. 用药提醒</p>
|
||||
<h4>三、用户账号</h4>
|
||||
<p>用户通过微信授权方式注册账号。用户应妥善保管账号信息,因用户保管不善造成的损失由用户自行承担。</p>
|
||||
<h4>四、隐私保护</h4>
|
||||
<p>我们重视用户隐私保护,具体隐私政策请参阅《隐私政策》。</p>
|
||||
<h4>五、免责声明</h4>
|
||||
<p>1. 本平台提供的健康数据仅供参考,不构成医疗诊断建议。如有健康问题,请及时就医。</p>
|
||||
<p>2. 因不可抗力导致的服务中断,本平台不承担责任。</p>
|
||||
<h4>六、协议修改</h4>
|
||||
<p>本平台有权根据需要修改本协议条款,修改后的协议一经公布即替代原协议。</p>
|
||||
`
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.legal-page { height: 100vh; background: $bg; padding: 24px; box-sizing: border-box; }
|
||||
.legal-content { font-size: var(--tk-font-body); line-height: var(--tk-line-height); color: $tx; }
|
||||
.legal-footer { margin-top: 40px; text-align: center; }
|
||||
.legal-footer-text { font-size: var(--tk-font-cap); color: $tx3; }
|
||||
</style>
|
||||
240
apps/miniprogram-uniapp/src/pages/login/index.vue
Normal file
240
apps/miniprogram-uniapp/src/pages/login/index.vue
Normal file
@@ -0,0 +1,240 @@
|
||||
<template>
|
||||
<scroll-view scroll-y :class="['login-scroll', elderClass]">
|
||||
<view class="login-page">
|
||||
<!-- 品牌区 -->
|
||||
<view class="login-brand">
|
||||
<view class="login-logo">
|
||||
<text class="login-logo-mark">+</text>
|
||||
</view>
|
||||
<text class="login-title">健康管理</text>
|
||||
<text class="login-subtitle">您的专属健康管家</text>
|
||||
</view>
|
||||
|
||||
<!-- 装饰线 -->
|
||||
<view class="login-divider">
|
||||
<view class="login-divider-line" />
|
||||
</view>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<view class="login-body">
|
||||
<button v-if="!needBind" class="login-btn" :loading="authStore.loading" @tap="handleWechatLogin">
|
||||
微信一键登录
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="login-btn"
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="handleGetPhone"
|
||||
>
|
||||
授权手机号完成绑定
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 协议 -->
|
||||
<view class="agreement-row">
|
||||
<view :class="['agreement-check', { checked: agreed }]" @tap="agreed = !agreed">
|
||||
<text v-if="agreed" class="agreement-check-mark">✓</text>
|
||||
</view>
|
||||
<text class="agreement-text">
|
||||
我已阅读并同意
|
||||
<text class="agreement-link" @tap="navigateTo('/pages/legal/user-agreement')">《用户服务协议》</text>
|
||||
和
|
||||
<text class="agreement-link" @tap="navigateTo('/pages/legal/privacy-policy')">《隐私政策》</text>
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<!-- 暂不登录 -->
|
||||
<view class="skip-row">
|
||||
<text class="skip-btn" @tap="uni.reLaunch({ url: '/pages/index/index' })">
|
||||
暂不登录,先看看
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useElderClass } from '@/composables/useElderClass'
|
||||
|
||||
const { elderClass } = useElderClass()
|
||||
const authStore = useAuthStore()
|
||||
const needBind = ref(false)
|
||||
const agreed = ref(false)
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function navigateAfterLogin() {
|
||||
if (authStore.isMedicalStaff) {
|
||||
uni.reLaunch({ url: '/pages-sub/doctor/index' })
|
||||
} else {
|
||||
uni.switchTab({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
|
||||
async function handleWechatLogin() {
|
||||
if (!agreed.value) {
|
||||
uni.showToast({ title: '请先阅读并同意用户协议', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await uni.login()
|
||||
const result = await authStore.login(res.code)
|
||||
if (result) {
|
||||
navigateAfterLogin()
|
||||
} else {
|
||||
needBind.value = true
|
||||
uni.showToast({ title: '请授权手机号完成绑定', icon: 'none' })
|
||||
}
|
||||
} catch (err: any) {
|
||||
const msg = err?.message || '登录失败,请重试'
|
||||
uni.showToast({ title: msg.substring(0, 20), icon: 'none', duration: 3000 })
|
||||
}
|
||||
}
|
||||
|
||||
async function handleGetPhone(e: any) {
|
||||
if (!agreed.value) {
|
||||
uni.showToast({ title: '请先阅读并同意用户协议', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
|
||||
uni.showToast({ title: '需要授权手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const { encryptedData, iv } = e.detail
|
||||
try {
|
||||
const success = await authStore.bindPhone(encryptedData, iv)
|
||||
if (success) navigateAfterLogin()
|
||||
} catch (err: any) {
|
||||
const msg = err?.message || '绑定失败'
|
||||
uni.showModal({
|
||||
title: '绑定手机号失败',
|
||||
content: msg,
|
||||
confirmText: '重新登录',
|
||||
success: (res: any) => {
|
||||
if (res.confirm) needBind.value = false
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.login-scroll {
|
||||
height: 100vh;
|
||||
background: $bg;
|
||||
}
|
||||
|
||||
.login-page {
|
||||
padding: 80px 48px 60px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.login-brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.login-logo {
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
border-radius: 50%;
|
||||
background: $pri;
|
||||
@include flex-center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.login-logo-mark {
|
||||
font-size: var(--tk-font-hero);
|
||||
color: $white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: var(--tk-font-h1);
|
||||
font-weight: bold;
|
||||
color: $tx;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.login-subtitle {
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx3;
|
||||
}
|
||||
|
||||
.login-divider {
|
||||
width: 60%;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.login-divider-line {
|
||||
height: 1px;
|
||||
background: $bd;
|
||||
}
|
||||
|
||||
.login-body {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
@include btn-primary;
|
||||
}
|
||||
|
||||
.agreement-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-top: 32px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.agreement-check {
|
||||
width: $touch-min;
|
||||
height: $touch-min;
|
||||
border-radius: 50%;
|
||||
border: 2px solid $bd;
|
||||
@include flex-center;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
|
||||
&.checked {
|
||||
background: $pri;
|
||||
border-color: $pri;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-check-mark {
|
||||
color: $white;
|
||||
font-size: var(--tk-font-body-sm);
|
||||
}
|
||||
|
||||
.agreement-text {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: $pri;
|
||||
}
|
||||
|
||||
.skip-row {
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
.skip-btn {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
padding: 12px 24px;
|
||||
min-height: $touch-min;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
108
apps/miniprogram-uniapp/src/pages/messages/index.vue
Normal file
108
apps/miniprogram-uniapp/src/pages/messages/index.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="messages-scroll" @scrolltolower="loadMore">
|
||||
<view :class="['messages-page', elderClass]">
|
||||
<GuestGuard>
|
||||
<text class="page-title">消息</text>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
<Loading v-if="loading && messages.length === 0" text="加载中..." />
|
||||
<EmptyState v-else-if="messages.length === 0" icon="📭" title="暂无消息" />
|
||||
<template v-else>
|
||||
<view v-for="msg in messages" :key="msg.id" class="msg-card" @tap="goDetail(msg)">
|
||||
<text class="msg-title">{{ msg.title }}</text>
|
||||
<text class="msg-content">{{ msg.content }}</text>
|
||||
<text class="msg-time">{{ getRelativeTime(msg.created_at) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
</GuestGuard>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useElderClass } from '@/composables/useElderClass'
|
||||
import { notificationService } from '@/services/notification'
|
||||
import { getRelativeTime } from '@/utils/date'
|
||||
import Loading from '@/components/Loading.vue'
|
||||
import EmptyState from '@/components/EmptyState.vue'
|
||||
import GuestGuard from '@/components/GuestGuard.vue'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const { elderClass } = useElderClass()
|
||||
|
||||
const loading = ref(false)
|
||||
const messages = ref<any[]>([])
|
||||
const page = ref(1)
|
||||
|
||||
async function fetchMessages() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await notificationService.list({ page: page.value, page_size: 20 })
|
||||
messages.value = res || []
|
||||
} catch {
|
||||
messages.value = []
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
page.value++
|
||||
fetchMessages()
|
||||
}
|
||||
|
||||
function goDetail(msg: any) {
|
||||
if (msg.type === 'consultation') {
|
||||
uni.navigateTo({ url: `/pages-sub/consultation/detail/index?id=${msg.ref_id}` })
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(fetchMessages)
|
||||
onShow(() => { authStore.restore() })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.messages-scroll {
|
||||
height: 100vh;
|
||||
background: $bg;
|
||||
}
|
||||
|
||||
.messages-page {
|
||||
padding: 28px 24px 120px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.msg-card {
|
||||
background: $card;
|
||||
border-radius: $r;
|
||||
padding: 20px 24px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: $shadow-sm;
|
||||
}
|
||||
|
||||
.msg-title {
|
||||
display: block;
|
||||
font-size: var(--tk-font-body);
|
||||
font-weight: 600;
|
||||
color: $tx;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.msg-content {
|
||||
display: block;
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx2;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.msg-time {
|
||||
display: block;
|
||||
font-size: var(--tk-font-cap);
|
||||
color: $tx3;
|
||||
}
|
||||
</style>
|
||||
231
apps/miniprogram-uniapp/src/pages/profile/index.vue
Normal file
231
apps/miniprogram-uniapp/src/pages/profile/index.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<template>
|
||||
<scroll-view scroll-y class="profile-scroll">
|
||||
<view :class="['profile-page', elderClass]">
|
||||
<!-- 已登录 -->
|
||||
<template v-if="authStore.user">
|
||||
<!-- 用户信息卡片 -->
|
||||
<view class="profile-card">
|
||||
<view class="avatar">
|
||||
<text class="avatar-text">{{ (authStore.user.display_name || authStore.user.username || '?')[0] }}</text>
|
||||
</view>
|
||||
<text class="profile-name">{{ authStore.user.display_name || authStore.user.username }}</text>
|
||||
<text class="profile-phone">{{ authStore.user.phone || '' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 患者切换 -->
|
||||
<view v-if="authStore.patients.length > 0" class="card patient-card">
|
||||
<text class="section-title">就诊人</text>
|
||||
<view v-for="p in authStore.patients" :key="p.id"
|
||||
:class="['patient-item', { active: authStore.currentPatient?.id === p.id }]"
|
||||
@tap="authStore.setCurrentPatient(p)"
|
||||
>
|
||||
<text class="patient-name">{{ p.name }}</text>
|
||||
<text class="patient-relation">{{ p.relation }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 菜单 -->
|
||||
<view class="card menu-card">
|
||||
<view class="menu-item" @tap="navigateTo('/pages-sub/appointment/index')">
|
||||
<text class="menu-label">我的预约</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @tap="navigateTo('/pages-sub/consultation/index')">
|
||||
<text class="menu-label">我的咨询</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @tap="navigateTo('/pages-sub/mall/index')">
|
||||
<text class="menu-label">积分商城</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @tap="navigateTo('/pages-sub/article/index')">
|
||||
<text class="menu-label">健康文章</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @tap="uiStore.toggleElderMode()">
|
||||
<text class="menu-label">{{ uiStore.elderMode ? '退出关怀模式' : '关怀模式' }}</text>
|
||||
<text class="menu-arrow">{{ uiStore.elderMode ? '✓' : '›' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<view class="logout-btn" @tap="handleLogout">
|
||||
退出登录
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<!-- 未登录 -->
|
||||
<template v-else>
|
||||
<view class="guest-profile">
|
||||
<view class="avatar avatar-placeholder">
|
||||
<text class="avatar-text">?</text>
|
||||
</view>
|
||||
<text class="guest-text">未登录</text>
|
||||
<view class="guest-login-btn" @tap="navigateTo('/pages/login/index')">
|
||||
去登录
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useElderClass } from '@/composables/useElderClass'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const uiStore = useUIStore()
|
||||
const { elderClass } = useElderClass()
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function handleLogout() {
|
||||
uni.showModal({
|
||||
title: '确认退出',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res: any) => {
|
||||
if (res.confirm) authStore.logout()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
authStore.restore()
|
||||
if (authStore.user) authStore.loadPatients()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.profile-scroll {
|
||||
height: 100vh;
|
||||
background: $bg;
|
||||
}
|
||||
|
||||
.profile-page {
|
||||
padding: 28px 24px 120px;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
background: $card;
|
||||
border-radius: $r-lg;
|
||||
padding: 36px 24px;
|
||||
margin-bottom: 24px;
|
||||
box-shadow: $shadow-md;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
border-radius: 50%;
|
||||
background: $pri;
|
||||
@include flex-center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.avatar-text {
|
||||
font-size: var(--tk-font-h1);
|
||||
color: $white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.avatar-placeholder {
|
||||
background: $bd;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: var(--tk-font-h2);
|
||||
font-weight: bold;
|
||||
color: $tx;
|
||||
}
|
||||
|
||||
.profile-phone {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.card {
|
||||
@include card;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.patient-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 14px 0;
|
||||
min-height: $touch-min;
|
||||
border-bottom: 1px solid $bd-l;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
|
||||
&.active {
|
||||
.patient-name { color: $pri; font-weight: 600; }
|
||||
}
|
||||
}
|
||||
|
||||
.patient-name {
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx;
|
||||
}
|
||||
|
||||
.patient-relation {
|
||||
font-size: var(--tk-font-body-sm);
|
||||
color: $tx3;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 18px 0;
|
||||
border-bottom: 1px solid $bd-l;
|
||||
min-height: $menu-item-h;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
.menu-label {
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx;
|
||||
}
|
||||
|
||||
.menu-arrow {
|
||||
font-size: var(--tk-font-h2);
|
||||
color: $tx3;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
@include btn-outline;
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
// 未登录
|
||||
.guest-profile {
|
||||
@include flex-center;
|
||||
flex-direction: column;
|
||||
padding: 80px 0 40px;
|
||||
}
|
||||
|
||||
.guest-text {
|
||||
font-size: var(--tk-font-body);
|
||||
color: $tx3;
|
||||
margin: 16px 0 32px;
|
||||
}
|
||||
|
||||
.guest-login-btn {
|
||||
@include btn-primary;
|
||||
width: 200px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user