Compare commits

1 Commits
Author SHA1 Message Date
lik 28793e39f5 feat(escort): 预约页陪诊项目改为卡片下拉选择
点击项目卡片展开下拉列表切换服务,保留原卡片展示;下拉项名称与价格同一行,价格字号与标题一致。
2026-11-05 22:02:01 +08:00
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: '',
+23 -6
View File
@@ -8,12 +8,11 @@
</view>
<view class="booking-form">
<!-- 陪诊项目:切换后同步更新服务的预约规则 -->
<!-- 陪诊项目:保留原项目卡片展示,点击卡片展开下拉列表切换 -->
<view class="service-picker-row">
<text class="order-label">陪诊项目</text>
<picker class="service-picker" mode="selector" range="{{serviceOptions}}" value="{{serviceIndex}}"
disabled="{{submitting}}" bindchange="onServiceChange">
<view class="order-service-info">
<view class="service-picker {{submitting ? 'is-disabled' : ''}}">
<view class="order-service-info" bindtap="onToggleServicePanel">
<view class="order-service-mark">
<t-icon name="{{serviceIcon}}" size="48rpx" color="#9B4508" />
</view>
@@ -21,11 +20,29 @@
<text class="order-service-title">{{service.title}}</text>
<text class="order-service-price">¥{{service.price}}/次</text>
</view>
<view class="service-picker-arrow">
<view class="service-picker-arrow {{servicePanelOpen ? 'is-open' : ''}}">
<t-icon name="chevron-down" size="40rpx" color="#9B4508" />
</view>
</view>
</picker>
<view class="service-panel" wx:if="{{servicePanelOpen}}">
<scroll-view wx:if="{{services.length > 0}}" class="service-options" scroll-y
style="height: {{serviceOptionsHeight}}rpx;">
<view class="service-option {{index === serviceIndex ? 'active' : ''}}" wx:for="{{services}}" wx:key="id"
data-index="{{index}}" bindtap="onServiceOptionTap">
<view class="service-option-mark">
<t-icon name="{{item.icon}}" size="40rpx" color="#9B4508" />
</view>
<text class="service-option-name">{{item.title}}</text>
<text class="service-option-sub">¥{{item.price}}/次</text>
<text class="service-option-selected" wx:if="{{index === serviceIndex}}">已选</text>
</view>
</scroll-view>
<view wx:else class="service-empty">
<text class="service-empty-text">暂无可选项目</text>
</view>
</view>
</view>
</view>
<!-- 选择就诊人:订单必须关联健康档案,就诊人信息全部由此带入 -->
+105 -5
View File
@@ -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 {