style(home): 首页首屏重排与预约卡片精简
品牌行按胶囊按钮位置计算安全区,hero 改为眉题+双行标题+装饰图形; 预约卡片压到两行:日期与状态胶囊一行、服务与就诊人一行,状态复用记录页语气档; 「联系我们」入口并入「联系客服」。
This commit is contained in:
+36
-6
@@ -1,6 +1,8 @@
|
||||
const API = require('../../utils/api.js')
|
||||
const { restoreLightNavigation } = require('../../utils/navigation.js')
|
||||
const { parseDate } = require('../../utils/date.js')
|
||||
const { ensureLogin } = require('../../utils/auth.js')
|
||||
const { STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
|
||||
// 首页未完成预约预览:服务端按预约日期倒序,这里取一页后在本地正序,
|
||||
// 让最近的一场排在最前。20 条覆盖常见未完成量;首页只展示最近三条,
|
||||
@@ -33,6 +35,8 @@ const SERVICE_ORDER = [1, 2, 7, 3, 4, 5, 8, 6]
|
||||
|
||||
Page({
|
||||
data: {
|
||||
topbarStyle: '',
|
||||
brandStyle: '',
|
||||
escortServices: [], // 陪诊服务(来自后端,按 SERVICE_ORDER 展示)
|
||||
pendingRecords: [], // 按预约时间正序的最近几条未完成预约,每条渲染成一张卡,最多 3 条
|
||||
quickEntries: [{
|
||||
@@ -58,8 +62,8 @@ Page({
|
||||
},
|
||||
{
|
||||
id: 'contact',
|
||||
name: '联系我们',
|
||||
desc: '人工客服',
|
||||
name: '联系客服',
|
||||
desc: '',
|
||||
icon: 'call',
|
||||
url: '/pages/mine/contact',
|
||||
// 第三张卡通栏排布(两列网格的 2+1),避免右下角孤零零半张卡
|
||||
@@ -69,6 +73,7 @@ Page({
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.updateNavigationLayout()
|
||||
// 先用上次成功拉取的列表渲染宫格,避免首屏出现一块空白;
|
||||
// 紧接着请求最新数据,回来后覆盖
|
||||
const cached = getApp().getCachedServices()
|
||||
@@ -78,7 +83,29 @@ Page({
|
||||
this.loadServices()
|
||||
},
|
||||
|
||||
onReady() {
|
||||
// 自定义导航在视图就绪后再恢复一次,避免首帧沿用上一页的白色系统文字。
|
||||
restoreLightNavigation()
|
||||
},
|
||||
|
||||
updateNavigationLayout() {
|
||||
try {
|
||||
const info = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync()
|
||||
const capsule = wx.getMenuButtonBoundingClientRect()
|
||||
const statusBarHeight = Number(info.statusBarHeight) || 0
|
||||
if (!(capsule.top >= statusBarHeight && capsule.height > 0 && capsule.left > 0)) return
|
||||
const gap = capsule.top - statusBarHeight
|
||||
this.setData({
|
||||
topbarStyle: `padding-top: ${statusBarHeight}px; height: ${statusBarHeight + capsule.height + gap * 2}px;`,
|
||||
brandStyle: `height: ${capsule.height + gap * 2}px; max-width: ${Math.max(0, capsule.left - 32)}px;`
|
||||
})
|
||||
} catch (err) {
|
||||
console.warn('首页导航布局使用默认值', err)
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
restoreLightNavigation()
|
||||
this.refreshPendingPreview()
|
||||
// 同步自定义 tabBar 选中态(首页为第 0 项)
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
@@ -185,19 +212,22 @@ Page({
|
||||
return sorted.slice(0, PENDING_PREVIEW_LIMIT).map((item) => this.formatPendingRecord(item))
|
||||
},
|
||||
|
||||
// 单条只保留首页需要的四项:日期、就诊人、医院、服务项目。
|
||||
// 日期只到「月-日」:首屏扫读时用户先判断是哪一天,周几和时段交给详情
|
||||
// 预约摘要只给日期、服务、就诊人与状态;时间与医院由详情页承接。
|
||||
// timeText 仍保留在数据里,供卡片 aria-label 朗读完整预约时间。
|
||||
formatPendingRecord(item) {
|
||||
const date = parseDate(item.schedule?.date)
|
||||
const whenText = date
|
||||
? `${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
|
||||
: '日期待定'
|
||||
const status = STATUS_MAP[resolveOrderStatus(item)] || STATUS_MAP.pending
|
||||
|
||||
return {
|
||||
id: item._id,
|
||||
whenText,
|
||||
patientName: item.patient?.name || '--',
|
||||
hospitalName: item.hospital?.name || '--',
|
||||
timeText: item.schedule?.startTime || '时间待定',
|
||||
statusText: status.text,
|
||||
statusTone: status.tone,
|
||||
patientName: item.patient?.name || '待补充',
|
||||
serviceName: item.escort?.serviceName || '陪诊服务'
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user