feat(escort): 预约页陪诊项目改为卡片下拉选择

点击项目卡片展开下拉列表切换服务,保留原卡片展示;下拉项名称与价格同一行,价格字号与标题一致。
This commit is contained in:
lik
2026-11-05 22:02:01 +08:00
parent 7b5599cd3d
commit 28793e39f5
3 changed files with 176 additions and 20 deletions
+47 -8
View File
@@ -1,13 +1,17 @@
const API = require('../../utils/api.js')
const { formatDate } = require('../../utils/date.js')
// 陪诊项目下拉单行高度:图标 72rpx + 单行文字 + 上下留白
const SERVICE_OPTION_HEIGHT = 108
Page({
data: {
services: [],
serviceOptions: [],
serviceIndex: 0,
service: {},
serviceIcon: 'user-business',
servicePanelOpen: false,
serviceOptionsHeight: 0,
totalPrice: '0.00',
pageLoading: true,
pageError: '',
@@ -65,11 +69,13 @@ Page({
const requestedIndex = services.findIndex((item) => item.id === this.requestedServiceId)
const consultationIndex = services.findIndex((item) => item.title.includes('问诊'))
const serviceIndex = requestedIndex >= 0 ? requestedIndex : (consultationIndex >= 0 ? consultationIndex : 0)
// 每个项目带上展示图标,供下拉列表逐项渲染
const serviceList = services.map((item) => ({ ...item, icon: this.getServiceIcon(item.title) }))
this.setData({
services,
serviceOptions: services.map((item) => item.title)
services: serviceList,
serviceOptionsHeight: Math.min(serviceList.length, 4) * SERVICE_OPTION_HEIGHT
})
this.applyService(services[serviceIndex], serviceIndex)
this.applyService(serviceList[serviceIndex], serviceIndex)
this.setData({ pageLoading: false })
this.pageReady = true
@@ -110,7 +116,8 @@ Page({
this.setData({
service,
serviceIndex,
serviceIcon: this.getServiceIcon(service.title),
serviceIcon: service.icon || this.getServiceIcon(service.title),
servicePanelOpen: false,
totalPrice: service.price,
minAppointmentDate: formatDate(minDate),
fixedTime,
@@ -130,10 +137,41 @@ Page({
}, () => this.refreshHospitalOptions(provinces[0] || ''))
},
onServiceChange(e) {
const index = Number(e.detail.value)
// 展开/收起陪诊项目下拉面板
onToggleServicePanel() {
if (this.data.submitting) return
const open = !this.data.servicePanelOpen
this.setData({ servicePanelOpen: open })
if (open) wx.nextTick(() => this.scrollServicePanelIntoView())
},
// 面板展开后若被底部固定操作栏遮挡,自动上滚页面,保证列表完整可见
scrollServicePanelIntoView() {
const query = this.createSelectorQuery()
query.select('.service-panel').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec((res) => {
const panelRect = res && res[0]
const scroll = res && res[1]
if (!panelRect || !scroll) return
const rpx = wx.getSystemInfoSync().windowWidth / 750
// 底部操作栏 152rpx + 留白,避免面板最后一行被压住
const reserved = 180 * rpx
const delta = panelRect.bottom + reserved - wx.getSystemInfoSync().windowHeight
if (delta < 1) return
wx.pageScrollTo({ scrollTop: scroll.scrollTop + delta, duration: 300 })
})
},
onServiceOptionTap(e) {
if (this.data.submitting) return
const index = Number(e.currentTarget.dataset.index)
if (index === this.data.serviceIndex) {
this.setData({ servicePanelOpen: false })
return
}
const service = this.data.services[index]
if (!service || index === this.data.serviceIndex) return
if (!service) return
this.applyService(service, index)
},
@@ -446,6 +484,7 @@ Page({
patientName: '',
patientPhone: '',
selectedPatient: null,
servicePanelOpen: false,
province: provinces[0] || '',
provinceIndex: 0,
hospital: '',