diff --git a/pages/escort/itemorder.js b/pages/escort/itemorder.js index 8e7ab3b..4a0957c 100644 --- a/pages/escort/itemorder.js +++ b/pages/escort/itemorder.js @@ -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: '', diff --git a/pages/escort/itemorder.wxml b/pages/escort/itemorder.wxml index 24bdf71..533f05f 100644 --- a/pages/escort/itemorder.wxml +++ b/pages/escort/itemorder.wxml @@ -8,12 +8,11 @@ - + 陪诊项目 - - + + @@ -21,11 +20,29 @@ {{service.title}} ¥{{service.price}}/次 - + - + + + + + + + + {{item.title}} + ¥{{item.price}}/次 + 已选 + + + + 暂无可选项目 + + + @@ -180,4 +197,4 @@ - \ No newline at end of file + diff --git a/pages/escort/itemorder.wxss b/pages/escort/itemorder.wxss index e4a8cf6..11c1fe6 100644 --- a/pages/escort/itemorder.wxss +++ b/pages/escort/itemorder.wxss @@ -50,6 +50,7 @@ page { box-shadow: var(--shadow-card); } +/* 陪诊项目:展示沿用原项目卡片,点击卡片展开下拉列表 */ .service-picker-row { padding: 24rpx 0; border-bottom: 2rpx solid var(--line); @@ -60,6 +61,10 @@ page { margin-top: 16rpx; } +.service-picker.is-disabled { + opacity: 0.6; +} + .order-service-info { display: flex; align-items: center; @@ -78,26 +83,34 @@ page { height: 80rpx; } +/* 项目名称与价格同一行,价格靠右,右侧留出更大间距 */ .order-service-text { + display: flex; flex: 1; min-width: 0; - margin: 0 16rpx 0 12rpx; + align-items: center; + margin: 0 56rpx 0 12rpx; } .order-service-title { - display: block; + flex: 1; + min-width: 0; + overflow: hidden; color: var(--ink); font-size: var(--fs-32); font-weight: 700; line-height: 1.4; + text-overflow: ellipsis; + white-space: nowrap; } .order-service-price { - display: block; - margin-top: 6rpx; + flex-shrink: 0; + margin-left: 16rpx; color: var(--brand-ink); - font-size: var(--fs-28); + font-size: var(--fs-32); font-weight: 700; + line-height: 1.4; } .service-picker-arrow { @@ -110,6 +123,93 @@ page { border: 2rpx solid var(--brand-line); border-radius: 50%; background: var(--white); + transition: transform 0.2s ease; +} + +.service-picker-arrow.is-open { + transform: rotate(180deg); +} + +/* 展开面板:浅橙衬底 + 浅橙描边,与「就诊医院」下拉同款 */ +.service-panel { + margin: 12rpx 0 24rpx; + padding: 0 20rpx 8rpx; + border: 2rpx solid var(--brand-line); + border-radius: 20rpx; + background: var(--brand-soft); +} + +.service-options { + margin-top: 4rpx; +} + +.service-option { + display: flex; + align-items: center; + padding: 16rpx 0; + border-bottom: 2rpx solid var(--sep); +} + +.service-option:last-child { + border-bottom: none; +} + +.service-option:active { + background: var(--white); +} + +.service-option-mark { + display: flex; + flex-shrink: 0; + align-items: center; + justify-content: center; + width: 72rpx; + height: 72rpx; +} + +/* 名称与价格同一行:名称左对齐并自适应截断,价格靠右 */ +.service-option-name { + flex: 1; + min-width: 0; + margin-left: 12rpx; + overflow: hidden; + color: var(--ink); + font-size: var(--fs-30); + font-weight: 700; + line-height: 1.4; + text-overflow: ellipsis; + white-space: nowrap; +} + +.service-option.active .service-option-name { + color: var(--brand-ink); +} + +.service-option-sub { + flex-shrink: 0; + margin-left: 16rpx; + color: var(--brand-ink); + font-size: var(--fs-26); + font-weight: 700; + line-height: 1.4; +} + +.service-option-selected { + flex-shrink: 0; + margin-left: 16rpx; + color: var(--brand-ink); + font-size: var(--fs-26); +} + +.service-empty { + padding: 32rpx 0; + text-align: center; +} + +.service-empty-text { + display: block; + color: var(--muted); + font-size: var(--fs-30); } .order-row {