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 文件)
143 lines
7.6 KiB
Vue
143 lines
7.6 KiB
Vue
<template>
|
|
<view :class="['detail-page', elderClass]">
|
|
<view class="balance-card">
|
|
<text class="balance-label">当前积分</text>
|
|
<text class="balance-value">{{ balance.toLocaleString() }}</text>
|
|
<view class="balance-stats">
|
|
<view class="stat-item">
|
|
<text class="stat-value stat-earn">{{ (pointsStore.account?.total_earned ?? 0).toLocaleString() }}</text>
|
|
<text class="stat-label">累计获得</text>
|
|
</view>
|
|
<view class="stat-divider" />
|
|
<view class="stat-item">
|
|
<text class="stat-value stat-spend">{{ (pointsStore.account?.total_spent ?? 0).toLocaleString() }}</text>
|
|
<text class="stat-label">累计消费</text>
|
|
</view>
|
|
<view class="stat-divider" />
|
|
<view class="stat-item">
|
|
<text class="stat-value stat-expired">{{ (pointsStore.account?.total_expired ?? 0).toLocaleString() }}</text>
|
|
<text class="stat-label">已过期</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="type-tabs">
|
|
<view v-for="tab in TYPE_TABS" :key="tab.key"
|
|
:class="['type-tab', activeTab === tab.key ? 'active' : '']"
|
|
@tap="handleTabChange(tab.key)">
|
|
<text class="type-tab-text">{{ tab.label }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view v-if="transactions.length === 0 && !loading" class="empty-wrap">
|
|
<EmptyState icon="" title="暂无积分记录" hint="签到或兑换后将显示记录" />
|
|
</view>
|
|
|
|
<scroll-view v-else scroll-y class="tx-scroll" @scrolltolower="loadMore">
|
|
<view class="transaction-item" v-for="tx in transactions" :key="tx.id">
|
|
<view :class="['tx-badge', `tx-badge-${getTypeClass(tx.type)}`]">
|
|
<text class="tx-badge-text">{{ getTypeLabel(tx.type) }}</text>
|
|
</view>
|
|
<view class="tx-info">
|
|
<text class="tx-desc">{{ tx.description || (tx.type === 'earn' ? '积分收入' : tx.type === 'spend' ? '积分消费' : '积分过期') }}</text>
|
|
<text class="tx-date">{{ formatDate(tx.created_at) }}</text>
|
|
</view>
|
|
<view class="tx-amount-col">
|
|
<text :class="['tx-amount', `tx-amount-${tx.type === 'earn' ? 'positive' : 'negative'}`]">{{ formatAmount(tx) }}</text>
|
|
<text class="tx-remaining">余额 {{ tx.balance_after.toLocaleString() }}</text>
|
|
</view>
|
|
</view>
|
|
<Loading v-if="loading" text="加载中..." />
|
|
<view v-if="!loading && transactions.length >= total && total > 0" class="no-more"><text class="no-more-text">没有更多了</text></view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed } from 'vue'
|
|
import { onShow, onPullDownRefresh } from '@dcloudio/uni-app'
|
|
import { listMyTransactions, type PointsTransaction } from '@/services/points'
|
|
import { usePointsStore } from '@/stores/points'
|
|
import EmptyState from '@/components/EmptyState.vue'
|
|
import Loading from '@/components/Loading.vue'
|
|
import { useElderClass } from '@/composables/useElderClass'
|
|
|
|
const TYPE_TABS = [{ key: '', label: '全部' }, { key: 'earn', label: '收入' }, { key: 'spend', label: '支出' }]
|
|
|
|
const { elderClass } = useElderClass()
|
|
const pointsStore = usePointsStore()
|
|
const transactions = ref<PointsTransaction[]>([])
|
|
const activeTab = ref('')
|
|
const page = ref(1)
|
|
const total = ref(0)
|
|
const loading = ref(false)
|
|
let loadingGuard = false
|
|
|
|
const balance = computed(() => pointsStore.account?.balance ?? 0)
|
|
const getTypeLabel = (type: string) => type === 'earn' ? '收' : type === 'spend' ? '支' : '过'
|
|
const getTypeClass = (type: string) => type === 'earn' ? 'earn' : type === 'spend' ? 'spend' : 'expired'
|
|
const formatAmount = (tx: PointsTransaction) => tx.type === 'earn' ? `+${tx.amount.toLocaleString()}` : `-${tx.amount.toLocaleString()}`
|
|
const formatDate = (dateStr: string) => {
|
|
if (!dateStr) return ''
|
|
const d = new Date(dateStr)
|
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
|
|
}
|
|
|
|
const fetchTransactions = async (pageNum: number, type: string, isRefresh = false) => {
|
|
if (loadingGuard) return
|
|
loadingGuard = true; loading.value = true
|
|
try {
|
|
const res = await listMyTransactions({ page: pageNum, page_size: 10 })
|
|
let list = res.data || []
|
|
if (type) list = list.filter(t => t.type === type)
|
|
transactions.value = isRefresh ? list : [...transactions.value, ...list]
|
|
total.value = res.total; page.value = pageNum
|
|
} catch { uni.showToast({ title: '加载失败', icon: 'none' }) }
|
|
finally { loadingGuard = false; loading.value = false }
|
|
}
|
|
|
|
const handleTabChange = (key: string) => { activeTab.value = key; fetchTransactions(1, key, true) }
|
|
const loadMore = () => { if (!loading.value && transactions.value.length < total.value) fetchTransactions(page.value + 1, activeTab.value) }
|
|
|
|
onShow(() => { uni.setNavigationBarTitle({ title: '积分明细' }); Promise.all([pointsStore.refresh(), fetchTransactions(1, activeTab.value, true)]) })
|
|
onPullDownRefresh(() => { Promise.all([pointsStore.refresh(), fetchTransactions(1, activeTab.value, true)]).finally(() => uni.stopPullDownRefresh()) })
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.detail-page { min-height: 100vh; background: $bg; }
|
|
.balance-card { background: linear-gradient(135deg, $pri, darken($pri, 10%)); padding: 24px; margin: 0; }
|
|
.balance-label { font-size: var(--tk-font-cap); color: rgba(255,255,255,0.8); display: block; }
|
|
.balance-value { font-size: var(--tk-font-num); font-weight: 700; color: $white; display: block; margin: 8px 0 20px; }
|
|
.balance-stats { display: flex; align-items: center; }
|
|
.stat-item { flex: 1; text-align: center; }
|
|
.stat-value { font-size: var(--tk-font-body); font-weight: 500; display: block; }
|
|
.stat-earn { color: rgba(255,255,255,0.95); }
|
|
.stat-spend { color: rgba(255,255,255,0.95); }
|
|
.stat-expired { color: rgba(255,255,255,0.95); }
|
|
.stat-label { font-size: var(--tk-font-cap); color: rgba(255,255,255,0.6); display: block; margin-top: 4px; }
|
|
.stat-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.2); }
|
|
.type-tabs { display: flex; padding: 12px 24px; gap: 8px; background: $card; }
|
|
.type-tab { padding: 6px 16px; min-height: $touch-min; display: flex; align-items: center; border-radius: 20px; background: rgba(0,0,0,0.04); }
|
|
.type-tab.active { background: $pri; }
|
|
.type-tab-text { font-size: var(--tk-font-cap); color: $tx2; }
|
|
.type-tab.active .type-tab-text { color: $white; }
|
|
.tx-scroll { height: calc(100vh - 200px); padding: 16px 24px; }
|
|
.transaction-item { @include card; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
|
|
.tx-badge { width: 36px; height: 36px; border-radius: 50%; @include flex-center; flex-shrink: 0; }
|
|
.tx-badge-earn { background: rgba(82,196,26,0.1); }
|
|
.tx-badge-spend { background: rgba(250,84,28,0.1); }
|
|
.tx-badge-expired { background: rgba(0,0,0,0.05); }
|
|
.tx-badge-text { font-size: var(--tk-font-micro); font-weight: 500; }
|
|
.tx-info { flex: 1; min-width: 0; }
|
|
.tx-desc { font-size: var(--tk-font-body); color: $tx; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
.tx-date { font-size: var(--tk-font-cap); color: $tx3; display: block; margin-top: 2px; }
|
|
.tx-amount-col { text-align: right; flex-shrink: 0; }
|
|
.tx-amount { font-size: var(--tk-font-body); font-weight: 500; display: block; }
|
|
.tx-amount-positive { color: $acc; }
|
|
.tx-amount-negative { color: $wrn; }
|
|
.tx-remaining { font-size: var(--tk-font-micro); color: $tx3; display: block; margin-top: 2px; }
|
|
.empty-wrap { padding-top: 60px; }
|
|
.no-more { @include flex-center; padding: 20px; }
|
|
.no-more-text { font-size: var(--tk-font-cap); color: $tx3; }
|
|
</style>
|