Commit a343cb81 by yuzhenWang

优化样式发布测试

parent 9c675edd
...@@ -49,7 +49,7 @@ function isActive(path: string): boolean { ...@@ -49,7 +49,7 @@ function isActive(path: string): boolean {
<div class="h-[3px] bg-brand-600"></div> <div class="h-[3px] bg-brand-600"></div>
<header class="sticky top-0 z-20 border-b border-silver-200/70 bg-white/80 backdrop-blur-lg"> <header class="sticky top-0 z-20 border-b border-silver-200/70 bg-white/80 backdrop-blur-lg">
<div class="mx-auto flex max-w-3xl items-center justify-between px-4 py-3"> <div class="mx-auto flex max-w-3xl items-center justify-between px-4 py-3">
<div class="text-[18px] font-semibold tracking-tight text-brand-700">{{ t('app.title') }}</div> <div class="text-lg font-semibold tracking-tight text-brand-700">{{ t('app.title') }}</div>
<LoginBadge /> <LoginBadge />
</div> </div>
</header> </header>
...@@ -69,13 +69,14 @@ function isActive(path: string): boolean { ...@@ -69,13 +69,14 @@ function isActive(path: string): boolean {
v-for="tab in tabs" v-for="tab in tabs"
:key="tab.name" :key="tab.name"
:to="tab.path" :to="tab.path"
class="flex flex-col items-center rounded-xl py-2 text-xs font-medium transition-colors" class="flex flex-col items-center rounded-xl py-2 text-sm font-medium transition-colors"
:class="isActive(tab.path) ? 'text-brand-700' : 'text-silver-500 hover:text-silver-700'" :class="isActive(tab.path) ? 'text-brand-700' : 'text-silver-500 hover:text-silver-700'"
> >
<span <span
class="rounded-full px-3 py-1 transition-colors" class="rounded-full px-3 py-1 transition-colors"
:class="isActive(tab.path) ? 'bg-brand-50' : 'bg-transparent'" :class="isActive(tab.path) ? 'bg-brand-50' : 'bg-transparent'"
>{{ t(tab.labelKey) }}</span> >{{ t(tab.labelKey) }}</span
>
</RouterLink> </RouterLink>
</div> </div>
</nav> </nav>
......
<script setup lang="ts"> <!-- <script setup lang="ts">
import { Dialog, DialogPanel, DialogTitle } from '@headlessui/vue' import { Dialog, DialogPanel, DialogTitle } from '@headlessui/vue'
defineProps<{ defineProps<{
...@@ -21,4 +21,49 @@ const emit = defineEmits<{ ...@@ -21,4 +21,49 @@ const emit = defineEmits<{
</DialogPanel> </DialogPanel>
</div> </div>
</Dialog> </Dialog>
</template> </template> -->
\ No newline at end of file
<script setup lang="ts">
import { computed } from 'vue'
import { Dialog, DialogPanel, DialogTitle } from '@headlessui/vue'
type Position = 'auto' | 'bottom' | 'center' | 'top'
const props = withDefaults(
defineProps<{
open: boolean
title?: string
/** 弹窗位置:auto = 移动端底部/桌面居中(原默认行为);其余为强制指定 */
position?: Position
}>(),
{ position: 'auto' }
)
const emit = defineEmits<{
(e: 'close'): void
}>()
const alignClass = computed(
() =>
({
auto: 'items-end sm:items-center',
bottom: 'items-end',
center: 'items-center',
top: 'items-start'
})[props.position]
)
</script>
<template>
<Dialog :open="open" class="relative z-50" @close="emit('close')">
<div class="fixed inset-0 bg-black/30" aria-hidden="true"></div>
<div class="fixed inset-0 flex justify-center p-4" :class="alignClass">
<DialogPanel class="w-full max-w-md rounded-3xl bg-white p-5 shadow-soft sm:rounded-2xl">
<DialogTitle v-if="title" class="tnum mb-3 text-lg font-semibold tracking-tight">{{
title
}}</DialogTitle>
<slot />
</DialogPanel>
</div>
</Dialog>
</template>
...@@ -3,12 +3,9 @@ import { computed } from 'vue' ...@@ -3,12 +3,9 @@ import { computed } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { formatDetailMoney, formatHkd } from '@/utils/money' import { formatDetailMoney, formatHkd } from '@/utils/money'
import { formatPercent } from '@/utils/number' import { formatPercent } from '@/utils/number'
import { calcPremiumTotals } from '@/utils/premium' // import { calcPremiumTotals } from '@/utils/premium'
import type { // PaymentFrequency,StatementItem
PaymentFrequency, import type { StatementDetail as StatementDetailType } from '@/api/types'
StatementDetail as StatementDetailType,
StatementItem
} from '@/api/types'
const props = defineProps<{ const props = defineProps<{
detail: StatementDetailType detail: StatementDetailType
...@@ -25,37 +22,41 @@ const adjustment = computed<number | null>(() => props.detail.adjustmentAmount ? ...@@ -25,37 +22,41 @@ const adjustment = computed<number | null>(() => props.detail.adjustmentAmount ?
const hasAdjustment = computed(() => adjustment.value !== null && adjustment.value !== 0) const hasAdjustment = computed(() => adjustment.value !== null && adjustment.value !== 0)
const adjustmentText = computed(() => formatHkd(adjustment.value ?? 0)) const adjustmentText = computed(() => formatHkd(adjustment.value ?? 0))
function frequencyLabel(value: PaymentFrequency): string { // function frequencyLabel(value: PaymentFrequency): string {
return t(`frequency.${value}`) // return t(`frequency.${value}`)
} // }
/** 期交保费 × 缴费年期;季缴/月缴先按每年 4/12 期年化,避免总额算少 */ /** 期交保费 × 缴费年期;季缴/月缴先按每年 4/12 期年化,避免总额算少 */
function premiumText(item: StatementItem): string { // function premiumText(item: StatementItem): string {
if (!item.periodPremium) return '' // if (!item.periodPremium) return ''
const { periods, annualized, total } = calcPremiumTotals( // const { periods, annualized, total } = calcPremiumTotals(
item.periodPremium, // item.periodPremium,
item.paymentFrequency, // item.paymentFrequency,
item.paymentTerm // item.paymentTerm
) // )
const perPeriod = `${formatDetailMoney(item.periodPremium, item.originalCurrency)} / ${frequencyLabel( // const perPeriod = `${formatDetailMoney(item.periodPremium, item.originalCurrency)} / ${frequencyLabel(
item.paymentFrequency // item.paymentFrequency
)}` // )}`
if (total === null) { // if (total === null) {
// 年期缺失或终身缴费:只给年化金额,不臆造总额 // // 年期缺失或终身缴费:只给年化金额,不臆造总额
return `${perPeriod} · ${t('statement.annualized')} ${formatDetailMoney( // return `${perPeriod} · ${t('statement.annualized')} ${formatDetailMoney(
annualized, // annualized,
item.originalCurrency // item.originalCurrency
)}` // )}`
} // }
const perYear = periods > 1 ? ` × ${periods} ${t('statement.periodsPerYear')}` : '' // const perYear = periods > 1 ? ` × ${periods} ${t('statement.periodsPerYear')}` : ''
return `${perPeriod}${perYear} × ${item.paymentTerm} ${t('statement.years')} = ${formatDetailMoney( // return `${perPeriod}${perYear} × ${item.paymentTerm} ${t('statement.years')} = ${formatDetailMoney(
total, // total,
item.originalCurrency // item.originalCurrency
)}` // )}`
} // }
// function rateText(rate: number): string {
// return rate > 0 ? rate.toFixed(4) : '—'
// }
function rateText(rate: number): string { function rateText(rate: number): string {
return rate > 0 ? rate.toFixed(4) : '—' if (!(rate > 0)) return '—'
return Number.isInteger(rate) ? rate.toFixed(2) : rate.toFixed(4)
} }
</script> </script>
...@@ -74,13 +75,13 @@ function rateText(rate: number): string { ...@@ -74,13 +75,13 @@ function rateText(rate: number): string {
<div class="mt-4 grid grid-cols-2 gap-3"> <div class="mt-4 grid grid-cols-2 gap-3">
<div class="rounded-xl bg-brand-50 px-3 py-3"> <div class="rounded-xl bg-brand-50 px-3 py-3">
<div class="text-xs text-brand-700/80">{{ t('statement.gross') }}</div> <div class="text-xs text-brand-700/80">{{ t('statement.gross') }}</div>
<div class="tnum mt-1 text-xl font-semibold leading-tight text-brand-700"> <div class="tnum mt-1 text-lg font-semibold leading-tight text-brand-700">
{{ formatHkd(detail.grossAmount) }} {{ formatHkd(detail.grossAmount) }}
</div> </div>
</div> </div>
<div class="rounded-xl bg-silver-50 px-3 py-3"> <div class="rounded-xl bg-silver-50 px-3 py-3">
<div class="text-xs text-silver-600">{{ t('statement.net') }}</div> <div class="text-xs text-silver-600">{{ t('statement.net') }}</div>
<div class="tnum mt-1 text-xl font-semibold leading-tight text-silver-700"> <div class="tnum mt-1 text-lg font-semibold leading-tight text-silver-700">
{{ formatHkd(detail.netAmount) }} {{ formatHkd(detail.netAmount) }}
</div> </div>
</div> </div>
...@@ -211,10 +212,11 @@ function rateText(rate: number): string { ...@@ -211,10 +212,11 @@ function rateText(rate: number): string {
<dt class="shrink-0 text-silver-500">{{ t('statement.policyRate') }}</dt> <dt class="shrink-0 text-silver-500">{{ t('statement.policyRate') }}</dt>
<dd class="tnum text-silver-700">{{ rateText(item.exchangeRate) }}</dd> <dd class="tnum text-silver-700">{{ rateText(item.exchangeRate) }}</dd>
</div> </div>
<div v-if="item.periodPremium" class="col-span-2 flex gap-1.5"> <!-- <div v-if="item.periodPremium" class="col-span-2 flex gap-1.5">
1111
<dt class="shrink-0 text-silver-500">{{ t('statement.premiumTerm') }}</dt> <dt class="shrink-0 text-silver-500">{{ t('statement.premiumTerm') }}</dt>
<dd class="tnum text-silver-700">{{ premiumText(item) }}</dd> <dd class="tnum text-silver-700">{{ premiumText(item) }}</dd>
</div> </div> -->
<div v-if="item.remark" class="col-span-2 flex gap-1.5"> <div v-if="item.remark" class="col-span-2 flex gap-1.5">
<dt class="shrink-0 text-silver-500">{{ t('statement.itemRemark') }}</dt> <dt class="shrink-0 text-silver-500">{{ t('statement.itemRemark') }}</dt>
......
...@@ -96,7 +96,7 @@ onMounted(load) ...@@ -96,7 +96,7 @@ onMounted(load)
</div> </div>
</ApiLoader> </ApiLoader>
<Modal :open="modalOpen" :title="selectedPolicyNo" @close="modalOpen = false"> <Modal :open="modalOpen" position="center" :title="selectedPolicyNo" @close="modalOpen = false">
<ApiLoader <ApiLoader
:loading="modalLoading" :loading="modalLoading"
:error="modalError" :error="modalError"
......
...@@ -49,9 +49,10 @@ export default { ...@@ -49,9 +49,10 @@ export default {
'2xl': '1rem' '2xl': '1rem'
}, },
fontSize: { fontSize: {
xs: ['.9375rem', { lineHeight: '1.25rem' }], // 13px + 20px 行高 xs: ['.75rem', { lineHeight: '1.25rem' }], // 13px + 20px 行高
sm: ['1.125rem'], sm: ['.875rem'],
lg: ['1.25rem', { lineHeight: '1.25rem' }] // 13px + 20px 行高 lg: ['1rem', { lineHeight: '1.25rem' }] // 13px + 20px 行高
} }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment