physical.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. <template>
  2. <CustomNav title="体格数据" leftType="back" />
  3. <view class="page">
  4. <view class="header">
  5. <view class="month-selector">
  6. <button class="btn" @click="prevPeriod">‹</button>
  7. <view class="period-controls">
  8. <picker mode="multiSelector" :value="pickerValue" :range="pickerRange" @change="onPickerChange">
  9. <view class="month-label">{{ displayPeriod }}</view>
  10. </picker>
  11. <view class="view-toggle">
  12. <button :class="['toggle-btn', { active: viewMode === 'month' }]" @click="setViewMode('month')">月</button>
  13. <button :class="['toggle-btn', { active: viewMode === 'week' }]" @click="setViewMode('week')">周</button>
  14. </view>
  15. <view class="metric-toggle" style="margin-top:8rpx; display:flex; gap:8rpx;">
  16. <button :class="['toggle-btn', { active: selectedMetric === 'all' }]" @click.prevent="selectedMetric = 'all'">全部</button>
  17. <button :class="['toggle-btn', { active: selectedMetric === 'height' }]" @click.prevent="selectedMetric = 'height'">身高</button>
  18. <button :class="['toggle-btn', { active: selectedMetric === 'weight' }]" @click.prevent="selectedMetric = 'weight'">体重</button>
  19. <button :class="['toggle-btn', { active: selectedMetric === 'bmi' }]" @click.prevent="selectedMetric = 'bmi'">BMI</button>
  20. </view>
  21. </view>
  22. <button class="btn" @click="nextPeriod">›</button>
  23. </view>
  24. </view>
  25. <!-- 趋势图 - 简化canvas设置 -->
  26. <view class="chart-wrap">
  27. <view class="chart-header">本月趋势</view>
  28. <canvas
  29. canvas-id="bpChart"
  30. id="bpChart"
  31. class="chart-canvas"
  32. :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }"
  33. ></canvas>
  34. </view>
  35. <view class="content">
  36. <view class="summary">共 {{ records.length }} 条记录,本月平均:{{ averageHeight }} cm / {{ averageWeight }} kg;平均 BMI:{{ averageBMI }}</view>
  37. <view class="list">
  38. <view v-if="records.length === 0" class="empty">暂无记录,点击右下角 + 添加</view>
  39. <view v-for="item in records" :key="item.id" class="list-item" :style="{ backgroundColor: getItemColor(item.h, item.w) }">
  40. <view class="date">{{ item.date }}</view>
  41. <view class="value">{{ item.h }} cm / {{ item.w }} kg · BMI {{ item.bmi }}</view>
  42. <button class="btn-delete" @click="confirmDeleteRecord(item.id)">✕</button>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="fab" @click="openAdd">
  47. <view class="fab-inner">+</view>
  48. </view>
  49. <view class="modal" v-if="showAdd">
  50. <view class="modal-backdrop" @click="closeAdd"></view>
  51. <view class="modal-panel">
  52. <view class="drag-handle"></view>
  53. <view class="modal-header"><text class="modal-title">添加体格数据</text></view>
  54. <view class="modal-inner">
  55. <view class="form-row">
  56. <text class="label">日期</text>
  57. <picker mode="date" :value="addDate" @change="onAddDateChange">
  58. <view class="picker-display">{{ addDateLabel }}</view>
  59. </picker>
  60. </view>
  61. <view class="form-row">
  62. <text class="label">身高 (cm)</text>
  63. <input type="number" v-model.number="addHeight" class="input" placeholder="身高 (cm)" />
  64. </view>
  65. <view class="form-row">
  66. <text class="label">体重 (kg)</text>
  67. <input type="number" v-model.number="addWeight" class="input" placeholder="体重 (kg)" />
  68. </view>
  69. </view>
  70. <!--提供滑动条(收缩压70-200,舒张压40-120)-->
  71. <view class="ruler-wrap">
  72. <view class="ruler-row">
  73. <ScaleRuler v-if="showAdd" :min="100" :max="220" :step="1" :gutter="16" :initialValue="addHeight ?? 170" @update="onHUpdate" @change="onHChange" />
  74. </view>
  75. <view class="ruler-row">
  76. <ScaleRuler v-if="showAdd" :min="30" :max="200" :step="1" :gutter="16" :initialValue="addWeight ?? 65" @update="onWUpdate" @change="onWChange" />
  77. </view>
  78. </view>
  79. <view class="fixed-footer">
  80. <button class="btn-primary btn-full" @click="confirmAdd">保存</button>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script setup lang="ts">
  87. import { ref, computed, onMounted, watch, nextTick, onBeforeUnmount, getCurrentInstance } from 'vue'
  88. import { createUChart } from '@/composables/useUChart'
  89. import CustomNav from '@/components/custom-nav.vue'
  90. import ScaleRuler from '@/components/scale-ruler.vue'
  91. import { getWeekStart, getWeekEnd, formatDisplayDate, formatPickerDate, daysInMonth } from '@/utils/date'
  92. import { getWindowWidth, rpxToPx } from '@/utils/platform'
  93. type RecordItem = { id: string; date: string; h: number; w: number; bmi: number }
  94. // 当前展示年月
  95. const current = ref(new Date())
  96. // 使用 multiSelector 的索引形式: [yearOffset从2000起, month(0-11)]
  97. const pickerValue = ref([current.value.getFullYear() - 2000, current.value.getMonth()])
  98. // 视图模式:'month' 或 'week'
  99. const viewMode = ref<'month' | 'week'>('month')
  100. // 年月选择器的选项范围(与 height/weight 保持一致)
  101. const pickerRange = ref([
  102. Array.from({ length: 50 }, (_, i) => `${2000 + i}年`),
  103. Array.from({ length: 12 }, (_, i) => `${i + 1}月`)
  104. ])
  105. // 明确的canvas尺寸(将由 getCanvasSize 初始化以匹配设备宽度)
  106. const canvasWidth = ref(700) // 初始值,会在 mounted 时覆盖
  107. const canvasHeight = ref(320)
  108. // 获取Canvas实际尺寸的函数 - 参考微信小程序示例使用固定尺寸
  109. function getCanvasSize(): Promise<{ width: number; height: number }> {
  110. return new Promise(async (resolve) => {
  111. const width = await getWindowWidth().catch(() => 375)
  112. const height = Math.round((320 / 750) * width)
  113. resolve({ width, height })
  114. })
  115. }
  116. // 使用 formatPickerDate 从 src/utils/date.ts
  117. const displayYear = computed(() => current.value.getFullYear())
  118. const displayMonth = computed(() => current.value.getMonth() + 1)
  119. // 显示周期(支持月/周)
  120. const displayPeriod = computed(() => {
  121. if (viewMode.value === 'month') {
  122. return `${displayYear.value}年 ${displayMonth.value}月`
  123. } else {
  124. const weekStart = getWeekStart(current.value)
  125. const weekEnd = getWeekEnd(current.value)
  126. return `${formatDisplayDate(weekStart)} - ${formatDisplayDate(weekEnd)}`
  127. }
  128. })
  129. const records = ref<RecordItem[]>(generateMockRecords(current.value))
  130. function generateMockRecords(d: Date): RecordItem[] {
  131. const arr: RecordItem[] = []
  132. if (viewMode.value === 'month') {
  133. const y = d.getFullYear()
  134. const m = d.getMonth()
  135. const n = Math.floor(Math.random() * Math.min(daysInMonth(y, m), 7))
  136. for (let i = 0; i < n; i++) {
  137. const day = Math.max(1, Math.floor(Math.random() * daysInMonth(y, m)) + 1)
  138. const date = new Date(y, m, day)
  139. // 随机生成身高(150-190)和体重(45-100)作为示例数据
  140. const h = 150 + Math.floor(Math.random() * 40)
  141. const w = 45 + Math.floor(Math.random() * 55)
  142. const bmi = Math.round((w / ((h / 100) * (h / 100))) * 10) / 10
  143. arr.push({ id: `${date.getTime()}-${i}`, date: formatDisplayDate(date), h, w, bmi })
  144. }
  145. } else {
  146. const weekStart = getWeekStart(d)
  147. const n = Math.floor(Math.random() * 7)
  148. for (let i = 0; i < n; i++) {
  149. const dayOffset = Math.floor(Math.random() * 7)
  150. const date = new Date(weekStart)
  151. date.setDate(weekStart.getDate() + dayOffset)
  152. const h = 150 + Math.floor(Math.random() * 40)
  153. const w = 45 + Math.floor(Math.random() * 55)
  154. const bmi = Math.round((w / ((h / 100) * (h / 100))) * 10) / 10
  155. arr.push({ id: `${date.getTime()}-${i}`, date: formatDisplayDate(date), h, w, bmi })
  156. }
  157. }
  158. return arr.sort((a, b) => (a.date < b.date ? 1 : -1))
  159. }
  160. // 将 records 聚合为每天一个点(取最新记录)
  161. function aggregateDaily(recordsArr: RecordItem[], year: number, month: number) {
  162. const map = new Map<number, RecordItem>()
  163. for (const r of recordsArr) {
  164. const parts = r.date.split('-')
  165. if (parts.length >= 3) {
  166. const y = parseInt(parts[0], 10)
  167. const m = parseInt(parts[1], 10) - 1
  168. const d = parseInt(parts[2], 10)
  169. if (y === year && m === month) {
  170. // 覆盖同一天,保留最新的(数组头部为最新)
  171. map.set(d, r)
  172. }
  173. }
  174. }
  175. // 返回按日索引的数组
  176. return map
  177. }
  178. const averageHeight = computed(() => {
  179. if (records.value.length === 0) return '--'
  180. const sum = records.value.reduce((s, r) => s + r.h, 0)
  181. return Math.round(sum / records.value.length)
  182. })
  183. const averageWeight = computed(() => {
  184. if (records.value.length === 0) return '--'
  185. const sum = records.value.reduce((s, r) => s + r.w, 0)
  186. return Math.round(sum / records.value.length)
  187. })
  188. const averageBMI = computed(() => {
  189. if (records.value.length === 0) return '--'
  190. const sum = records.value.reduce((s, r) => s + (r.bmi || 0), 0)
  191. return Math.round((sum / records.value.length) * 10) / 10
  192. })
  193. // 根据血压值获取颜色
  194. function getItemColor(h: number, w: number): string {
  195. // 根据 BMI 简单分类
  196. if (!h || !w) return '#ffffff'
  197. const bmi = w / ((h / 100) * (h / 100))
  198. if (bmi < 18.5) return '#fff3cd' // 偏瘦 - 黄
  199. if (bmi < 25) return '#e8f5e8' // 正常 - 绿
  200. if (bmi < 30) return '#fff3cd' // 超重 - 黄
  201. return '#f8d7da' // 肥胖 - 红
  202. }
  203. // 使用共享日期工具 (src/utils/date.ts)
  204. // 使用可复用的 chart composable,支持多序列
  205. const vm = getCurrentInstance()
  206. // 选择显示的指标:'all' | 'height' | 'weight' | 'bmi'
  207. const selectedMetric = ref<'all'|'height'|'weight'|'bmi'>('all')
  208. let bpChart: any = null
  209. function createChartForMetric(metric: 'all'|'height'|'weight'|'bmi') {
  210. const seriesMap: Record<string, { names: string[]; accessors: Array<(r:any)=>number>; colors: string[] }> = {
  211. all: { names: ['身高','体重','BMI'], accessors: [ (r: RecordItem) => r.h, (r: RecordItem) => r.w, (r: RecordItem) => r.bmi ], colors: ['#ff6a00', '#007aff', '#28c76f'] },
  212. height: { names: ['身高'], accessors: [ (r: RecordItem) => r.h ], colors: ['#ff6a00'] },
  213. weight: { names: ['体重'], accessors: [ (r: RecordItem) => r.w ], colors: ['#007aff'] },
  214. bmi: { names: ['BMI'], accessors: [ (r: RecordItem) => r.bmi ], colors: ['#28c76f'] }
  215. }
  216. const cfg = seriesMap[metric]
  217. return createUChart({
  218. canvasId: 'bpChart',
  219. vm,
  220. getCanvasSize,
  221. seriesNames: cfg.names,
  222. valueAccessors: cfg.accessors,
  223. colors: cfg.colors
  224. })
  225. }
  226. // 延迟创建 chart:在 mounted 时先读取路由参数(metric),然后创建 chart 并绘制
  227. function initMetricFromRoute() {
  228. try {
  229. // 在 uni-app 中,可通过 getCurrentPages 获取当前页面的 options(包含 query)
  230. const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : []
  231. const currentPage = pages[pages.length - 1] || {}
  232. const opts = (currentPage && (currentPage as any).options) ? (currentPage as any).options : {}
  233. const metricParam = opts.metric || opts?.metric
  234. if (metricParam && ['all', 'height', 'weight', 'bmi'].includes(metricParam)) {
  235. ;(selectedMetric as any).value = metricParam
  236. }
  237. } catch (e) {
  238. console.warn('initMetricFromRoute error', e)
  239. }
  240. }
  241. onMounted(() => {
  242. // 延迟确保DOM渲染完成并设置canvas尺寸
  243. setTimeout(async () => {
  244. await nextTick()
  245. try {
  246. const size = await getCanvasSize()
  247. canvasWidth.value = size.width
  248. canvasHeight.value = size.height
  249. } catch (e) {
  250. console.warn('getCanvasSize failed on mounted', e)
  251. }
  252. // 先从路由读取 metric(如果有),然后创建 chart
  253. initMetricFromRoute()
  254. try {
  255. if (!bpChart) bpChart = createChartForMetric(selectedMetric.value)
  256. } catch (e) {
  257. console.warn('createChartForMetric failed', e)
  258. }
  259. try {
  260. if (bpChart && bpChart.draw) await bpChart.draw(records, current, viewMode)
  261. } catch (e) {
  262. console.warn('bpChart draw failed', e)
  263. }
  264. }, 500)
  265. })
  266. // 监听并更新图表(轻微去抖)
  267. watch([() => current.value], async () => {
  268. setTimeout(async () => {
  269. await bpChart.update(records, current, viewMode)
  270. }, 100)
  271. })
  272. watch([() => records.value], async () => {
  273. setTimeout(async () => {
  274. // 如果图表实例已被替换,根据 current selectedMetric 的 chart 实例更新
  275. try {
  276. if (bpChart && bpChart.update) await bpChart.update(records, current, viewMode)
  277. } catch (e) {
  278. console.warn('bpChart update failed', e)
  279. }
  280. }, 100)
  281. }, { deep: true })
  282. // 监听 selectedMetric 变化,重建图表以使用不同的 series 配置
  283. watch(() => selectedMetric.value, async (val) => {
  284. try {
  285. if (bpChart && bpChart.destroy) {
  286. try { bpChart.destroy() } catch (e) { /* ignore */ }
  287. }
  288. bpChart = createChartForMetric(val)
  289. // small delay to ensure DOM/canvas availability
  290. await nextTick()
  291. try { await bpChart.draw(records, current, viewMode) } catch (e) { console.warn('draw after metric change failed', e) }
  292. } catch (e) {
  293. console.warn('selectedMetric watch error', e)
  294. }
  295. })
  296. onBeforeUnmount(() => {
  297. try { bpChart.destroy() } catch (e) { console.warn('bpChart destroy error', e) }
  298. })
  299. // 强制重建图表(用于切换月份时彻底刷新)
  300. async function rebuildChart() {
  301. try { if (bpChart && bpChart.rebuild) await bpChart.rebuild(records, current, viewMode) } catch (e) { console.warn('rebuildChart failed', e) }
  302. }
  303. // 周/月周期导航与 Picker 处理
  304. async function prevPeriod() {
  305. const d = new Date(current.value)
  306. if (viewMode.value === 'month') {
  307. d.setMonth(d.getMonth() - 1)
  308. } else {
  309. d.setDate(d.getDate() - 7)
  310. }
  311. current.value = d
  312. pickerValue.value = [d.getFullYear() - 2000, d.getMonth()]
  313. records.value = generateMockRecords(d)
  314. await rebuildChart()
  315. }
  316. async function nextPeriod() {
  317. const d = new Date(current.value)
  318. if (viewMode.value === 'month') {
  319. d.setMonth(d.getMonth() + 1)
  320. } else {
  321. d.setDate(d.getDate() + 7)
  322. }
  323. current.value = d
  324. pickerValue.value = [d.getFullYear() - 2000, d.getMonth()]
  325. records.value = generateMockRecords(d)
  326. await rebuildChart()
  327. }
  328. async function setViewMode(mode: 'month' | 'week') {
  329. if (viewMode.value !== mode) {
  330. viewMode.value = mode
  331. records.value = generateMockRecords(current.value)
  332. await rebuildChart()
  333. }
  334. }
  335. async function onPickerChange(e: any) {
  336. const val = e?.detail?.value || e
  337. if (Array.isArray(val) && val.length >= 2) {
  338. const y = 2000 + val[0]
  339. const m = val[1]
  340. const d = new Date(y, m, 1)
  341. current.value = d
  342. pickerValue.value = [val[0], val[1]]
  343. records.value = generateMockRecords(d)
  344. await rebuildChart()
  345. }
  346. }
  347. // 添加逻辑(体格数据)
  348. const showAdd = ref(false)
  349. const addDate = ref(formatPickerDate(new Date()))
  350. const addDateLabel = ref(formatDisplayDate(new Date()))
  351. const addHeight = ref<number | null>(null)
  352. const addWeight = ref<number | null>(null)
  353. function onHUpdate(v: number) { addHeight.value = Math.round(v) }
  354. function onHChange(v: number) { addHeight.value = Math.round(v) }
  355. function onWUpdate(v: number) { addWeight.value = Math.round(v) }
  356. function onWChange(v: number) { addWeight.value = Math.round(v) }
  357. function openAdd() {
  358. showAdd.value = true;
  359. if (!addHeight.value) addHeight.value = 170;
  360. if (!addWeight.value) addWeight.value = 65
  361. }
  362. function closeAdd() {
  363. showAdd.value = false;
  364. addHeight.value = null;
  365. addWeight.value = null
  366. }
  367. function onAddDateChange(e: any) {
  368. const val = e?.detail?.value || e;
  369. addDate.value = val;
  370. addDateLabel.value = val.replace(/^(.{10}).*$/, '$1')
  371. }
  372. async function confirmAdd() {
  373. if (!addHeight.value || !addWeight.value) {
  374. uni.showToast && uni.showToast({ title: '请输入身高和体重', icon: 'none' });
  375. return
  376. }
  377. // 检查 BMI 预警(简单阈值)
  378. const bmi = addWeight.value / ((addHeight.value / 100) * (addHeight.value / 100))
  379. if (bmi >= 25) {
  380. uni.showModal({
  381. title: '体重超标',
  382. content: '当前体重指数偏高,建议注意饮食与运动,必要时就医。',
  383. showCancel: false,
  384. confirmText: '知道了'
  385. })
  386. }
  387. const id = `user-${Date.now()}`
  388. const bmiVal = Math.round((Math.round(addWeight.value) / ((Math.round(addHeight.value) / 100) * (Math.round(addHeight.value) / 100))) * 10) / 10
  389. const item: RecordItem = {
  390. id,
  391. date: addDateLabel.value,
  392. h: Math.round(addHeight.value),
  393. w: Math.round(addWeight.value),
  394. bmi: bmiVal
  395. }
  396. const parts = addDate.value.split('-')
  397. const addY = parseInt(parts[0], 10)
  398. const addM = parseInt(parts[1], 10) - 1
  399. if (viewMode.value === 'month') {
  400. if (addY === current.value.getFullYear() && addM === current.value.getMonth()) {
  401. records.value = [item, ...records.value]
  402. }
  403. } else {
  404. const addDateObj = new Date(addY, addM, parseInt(parts[2] || '1', 10))
  405. const addWeekStart = getWeekStart(addDateObj)
  406. const curWeekStart = getWeekStart(current.value)
  407. if (addWeekStart.getTime() === curWeekStart.getTime()) {
  408. records.value = [item, ...records.value]
  409. }
  410. }
  411. uni.showToast && uni.showToast({ title: '已添加', icon: 'success' })
  412. closeAdd()
  413. // 新增记录后彻底重建图表,确保像退出再进入一样刷新
  414. try {
  415. await rebuildChart()
  416. } catch (e) {
  417. console.warn('rebuildChart after add failed', e)
  418. }
  419. }
  420. async function confirmDeleteRecord(id: string) {
  421. if (typeof uni !== 'undefined' && uni.showModal) {
  422. uni.showModal({
  423. title: '删除',
  424. content: '确认删除该条记录吗?',
  425. success: async (res: any) => {
  426. if (res.confirm) {
  427. records.value = records.value.filter(r => r.id !== id)
  428. try { await rebuildChart() } catch (e) { console.warn('rebuildChart after delete failed', e) }
  429. }
  430. }
  431. })
  432. } else {
  433. records.value = records.value.filter(r => r.id !== id)
  434. try { await rebuildChart() } catch (e) { console.warn('rebuildChart after delete failed', e) }
  435. }
  436. }
  437. </script>
  438. <style scoped>
  439. .page {
  440. min-height: calc(100vh);
  441. padding-top: calc(var(--status-bar-height) + 44px);
  442. background: #f5f6f8;
  443. box-sizing: border-box
  444. }
  445. .header {
  446. padding: 20rpx 40rpx
  447. }
  448. .month-selector {
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. gap: 12rpx
  453. }
  454. .period-controls {
  455. display: flex;
  456. flex-direction: column;
  457. align-items: center;
  458. gap: 8rpx;
  459. }
  460. .view-toggle {
  461. display: flex;
  462. gap: 4rpx;
  463. }
  464. .toggle-btn {
  465. padding: 4rpx 12rpx;
  466. border: 1rpx solid #ddd;
  467. background: #f5f5f5;
  468. color: #666;
  469. border-radius: 6rpx;
  470. font-size: 24rpx;
  471. min-width: 60rpx;
  472. text-align: center;
  473. }
  474. .toggle-btn.active {
  475. background: #ff6a00;
  476. color: #fff;
  477. border-color: #ff6a00;
  478. }
  479. .month-label {
  480. font-size: 34rpx;
  481. color: #333
  482. }
  483. .btn {
  484. background: transparent;
  485. border: none;
  486. font-size: 36rpx;
  487. color: #666
  488. }
  489. .content {
  490. padding: 20rpx 24rpx 100rpx 24rpx
  491. }
  492. .chart-wrap {
  493. height: 380rpx;
  494. overflow: hidden; /* 隐藏溢出内容 */
  495. background: #fff;
  496. border-radius: 12rpx;
  497. padding: 24rpx;
  498. margin: 0 24rpx 20rpx 24rpx;
  499. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03)
  500. }
  501. .chart-header {
  502. font-size: 32rpx;
  503. color: #333;
  504. margin-bottom: 20rpx;
  505. font-weight: 600
  506. }
  507. /* 关键修复:确保canvas样式正确,参考微信小程序示例 */
  508. .chart-canvas {
  509. height: 320rpx;
  510. background-color: #FFFFFF;
  511. display: block;
  512. }
  513. .summary {
  514. padding: 20rpx;
  515. color: #666;
  516. font-size: 28rpx
  517. }
  518. .list {
  519. background: #fff;
  520. border-radius: 12rpx;
  521. padding: 10rpx;
  522. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03)
  523. }
  524. .empty {
  525. padding: 40rpx;
  526. text-align: center;
  527. color: #999
  528. }
  529. .list-item {
  530. display: flex;
  531. align-items: center;
  532. padding: 20rpx;
  533. border-bottom: 1rpx solid #f0f0f0
  534. }
  535. .list-item .date {
  536. color: #666
  537. }
  538. .list-item .value {
  539. color: #333;
  540. font-weight: 600;
  541. flex: 1;
  542. text-align: right
  543. }
  544. .btn-delete {
  545. width: 80rpx;
  546. height: 60rpx;
  547. min-width: 60rpx;
  548. min-height: 60rpx;
  549. display: inline-flex;
  550. align-items: center;
  551. justify-content: center;
  552. background: #fff0f0;
  553. color: #d9534f;
  554. border: 1rpx solid rgba(217,83,79,0.15);
  555. border-radius: 8rpx;
  556. margin-left: 30rpx
  557. }
  558. .fab {
  559. position: fixed;
  560. right: 28rpx;
  561. bottom: 160rpx;
  562. width: 110rpx;
  563. height: 110rpx;
  564. border-radius: 999px;
  565. background: linear-gradient(180deg, #ff7a00, #ff4a00);
  566. display: flex;
  567. align-items: center;
  568. justify-content: center;
  569. box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.2);
  570. z-index: 1200
  571. }
  572. .fab-inner {
  573. color: #fff;
  574. font-size: 56rpx;
  575. line-height: 56rpx
  576. }
  577. .modal {
  578. position: fixed;
  579. left: 0;
  580. right: 0;
  581. top: 0;
  582. bottom: 0;
  583. display: flex;
  584. align-items: flex-end;
  585. justify-content: center;
  586. z-index: 1300
  587. }
  588. .modal-backdrop {
  589. position: absolute;
  590. left: 0;
  591. right: 0;
  592. top: 0;
  593. bottom: 0;
  594. background: rgba(0, 0, 0, 0.4)
  595. }
  596. .modal-panel {
  597. position: relative;
  598. width: 100%;
  599. background: #fff;
  600. border-top-left-radius: 18rpx;
  601. border-top-right-radius: 18rpx;
  602. padding: 28rpx 24rpx 140rpx 24rpx;
  603. box-shadow: 0 -8rpx 30rpx rgba(0,0,0,0.12)
  604. }
  605. .modal-title {
  606. font-size: 56rpx;
  607. margin-block: 60rpx;
  608. color: #222;
  609. font-weight: 700;
  610. letter-spacing: 1rpx
  611. }
  612. .modal-inner {
  613. max-width: 70%;
  614. margin: 0 auto
  615. }
  616. .form-row {
  617. display: flex;
  618. align-items: center;
  619. justify-content: space-between;
  620. margin-bottom: 34rpx;
  621. padding: 14rpx 0;
  622. font-size: 32rpx
  623. }
  624. .input {
  625. width: 150rpx;
  626. text-align: right;
  627. padding: 16rpx;
  628. border-radius: 14rpx;
  629. border: 1rpx solid #eee;
  630. background: #fff7f0
  631. }
  632. .picker-display {
  633. color: #333
  634. }
  635. .btn-primary {
  636. background: #ff6a00;
  637. color: #fff;
  638. padding: 18rpx 22rpx;
  639. border-radius: 16rpx;
  640. text-align: center;
  641. width: 50%;
  642. box-shadow: 0 10rpx 28rpx rgba(255,106,0,0.18)
  643. }
  644. .drag-handle {
  645. width: 64rpx;
  646. height: 6rpx;
  647. background: rgba(0,0,0,0.08);
  648. border-radius: 999px;
  649. margin: 10rpx auto 14rpx auto
  650. }
  651. .modal-header {
  652. display: flex;
  653. align-items: center;
  654. justify-content: center;
  655. gap: 12rpx;
  656. margin-bottom: 6rpx
  657. }
  658. .label {
  659. color: #666
  660. }
  661. .ruler-wrap {
  662. margin: 12rpx 0
  663. }
  664. .ruler-row {
  665. margin-bottom: 8rpx
  666. }
  667. .fixed-footer {
  668. position: absolute;
  669. left: 0;
  670. right: 0;
  671. bottom: 40rpx;
  672. padding: 0 24rpx
  673. }
  674. .btn-full {
  675. width: 100%;
  676. padding: 18rpx;
  677. border-radius: 12rpx;
  678. }
  679. </style>