diff --git a/components/hospital-select/index.js b/components/hospital-select/index.js index 270fbfd..47a9665 100644 --- a/components/hospital-select/index.js +++ b/components/hospital-select/index.js @@ -1,6 +1,7 @@ -// 医院选择:列表可搜索(名称 / 主体名 / 全拼 / 拼音首字母),找不到时可手动输入 +// 医院选择:列表可搜索(名称 / 主体名 / 全拼 / 拼音首字母);列表里没有的走「其他医院」手填 const SEARCH_PLACEHOLDER = '搜索医院名称或拼音' -const OPTION_HEIGHT = 112 +// 单行选项高度:字号放大后重新核算(名称 32rpx + 地址 28rpx + 上下留白) +const OPTION_HEIGHT = 132 // 关键词去掉空白、转小写:中文原样匹配,拼音统一小写比较 const normalizeKeyword = (value) => String(value || '').trim().toLowerCase().replace(/\s+/g, '') @@ -22,14 +23,6 @@ Component({ properties: { label: { type: String, value: '就诊医院' }, value: { type: String, value: '' }, - manual: { - type: Boolean, - value: false, - observer() { - // 父级切换手动/列表模式时收起面板,避免两种形态叠在一起 - if (this.data.open) this.setData({ open: false, keyword: '', optionsHeight: 0 }) - }, - }, options: { type: Array, value: [], @@ -47,6 +40,8 @@ Component({ keyword: '', filtered: [], optionsHeight: 0, + manualEntry: false, + manualName: '', searchPlaceholder: SEARCH_PLACEHOLDER, }, @@ -67,17 +62,17 @@ Component({ }, onOpen() { - if (this.data.disabled || this.data.manual) return + if (this.data.disabled) return if (this.data.open) { this.onClose() return } - this.setData({ open: true, keyword: '' }) + this.setData({ open: true, keyword: '', manualEntry: false }) this.refreshFiltered(this.data.options, '') }, onClose() { - this.setData({ open: false, keyword: '', optionsHeight: 0 }) + this.setData({ open: false, keyword: '', optionsHeight: 0, manualEntry: false }) }, onKeywordInput(e) { @@ -100,34 +95,27 @@ Component({ }) }, - // 搜索词没有匹配时,直接把当前输入当作医院名,转入手动输入 - onUseKeyword() { - const name = String(this.data.keyword || '').trim() + // 「其他医院」:展开手填输入框;有搜索词时带入搜索词,否则带入当前已填名称 + onStartManual() { + const keyword = String(this.data.keyword || '').trim() + const current = String(this.data.value || '').trim() + this.setData({ manualEntry: true, manualName: keyword || current }) + }, + + onManualNameInput(e) { + this.setData({ manualName: e.detail.value }) + }, + + onCancelManual() { + this.setData({ manualEntry: false, manualName: '' }) + }, + + onConfirmManual() { + const name = String(this.data.manualName || '').trim() if (!name) return + this.onClose() this.triggerEvent('change', { name, manual: true, hospital: null }) }, - - onManualInput(e) { - this.triggerEvent('change', { name: e.detail.value, manual: true, hospital: null }) - }, - - onToggleManual() { - if (this.data.disabled) return - - if (!this.data.manual) { - this.onClose() - this.triggerEvent('change', { name: this.data.value || '', manual: true, hospital: null }) - return - } - - // 从手动切回列表:当前值能在列表里找到就还原选中,否则清空 - const value = String(this.data.value || '').trim() - const matched = (this.data.options || []).find((item) => item.name === value) - this.onClose() - this.triggerEvent('change', matched - ? { name: matched.name, manual: false, hospital: matched } - : { name: '', manual: false, hospital: null }) - }, }, }) diff --git a/components/hospital-select/index.wxml b/components/hospital-select/index.wxml index 11cb608..78e634d 100644 --- a/components/hospital-select/index.wxml +++ b/components/hospital-select/index.wxml @@ -1,41 +1,43 @@ - - {{label}} - {{manual ? '从列表选择' : '手动输入'}} - - - - + {{label}} + {{value || placeholder}} - + 收起 + + + + 确定 + 返回列表 + + {{keyword ? '没有找到匹配的医院' : '暂无可选医院'}} - 使用「{{keyword}}」 - 手动输入 - - 没有找到?使用「{{keyword}}」 + + + 其他医院(列表里没有?手动填写名称) diff --git a/components/hospital-select/index.wxss b/components/hospital-select/index.wxss index 0006cee..508fba3 100644 --- a/components/hospital-select/index.wxss +++ b/components/hospital-select/index.wxss @@ -16,34 +16,18 @@ opacity: 0.6; } -.hospital-label-wrap { - display: flex; - flex-direction: column; - align-items: flex-start; - flex-shrink: 0; -} - +/* 行标签与取值统一 30rpx,与页面表单(.order-label / .order-value)同档 */ .hospital-label { color: var(--muted, #6F655C); - font-size: var(--fs-28, 28rpx); + font-size: var(--fs-30, 30rpx); letter-spacing: 1rpx; } +/* compact 档用于「预约记录 · 编辑」表单,跟该页 .form-label(26) / .form-input(28) 对齐 */ .is-compact .hospital-label { font-size: var(--fs-26, 26rpx); } -.hospital-mode { - margin-top: 6rpx; - color: var(--brand-ink, #9B4508); - font-size: var(--fs-24, 24rpx); - line-height: 1.4; -} - -.hospital-mode:active { - opacity: 0.6; -} - .hospital-value { display: flex; flex: 1; @@ -57,7 +41,7 @@ min-width: 0; overflow: hidden; color: var(--ink, #2B2521); - font-size: var(--fs-28, 28rpx); + font-size: var(--fs-30, 30rpx); font-weight: 700; text-align: right; text-overflow: ellipsis; @@ -65,6 +49,7 @@ } .is-compact .hospital-value-text { + font-size: var(--fs-28, 28rpx); font-weight: 400; } @@ -73,20 +58,55 @@ font-weight: 400; } -.hospital-input { - flex: 1; - min-width: 0; - margin-left: 24rpx; - color: var(--ink, #2B2521); - font-size: var(--fs-28, 28rpx); - text-align: right; -} - .hospital-placeholder { color: var(--muted, #6F655C); font-weight: 400; } +/* 「其他医院」:面板底部常驻入口,展开手填输入框 */ +.hospital-other { + margin-top: 16rpx; + padding: 20rpx 0; + border-top: 2rpx solid var(--sep, #E5DACC); + text-align: center; +} + +.hospital-other-text { + color: var(--brand-ink, #9B4508); + font-size: var(--fs-30, 30rpx); +} + +.hospital-other:active { + opacity: 0.6; +} + +.hospital-manual-panel { + display: flex; + align-items: center; + padding: 20rpx 0 8rpx; +} + +.hospital-manual-input { + flex: 1; + min-width: 0; + color: var(--ink, #2B2521); + font-size: var(--fs-30, 30rpx); +} + +.hospital-manual-confirm { + flex-shrink: 0; + margin-left: 16rpx; + color: var(--brand-ink, #9B4508); + font-size: var(--fs-30, 30rpx); +} + +.hospital-manual-cancel { + flex-shrink: 0; + margin-left: 16rpx; + color: var(--muted, #6F655C); + font-size: var(--fs-28, 28rpx); +} + .hospital-chevron { flex-shrink: 0; width: 16rpx; @@ -102,32 +122,34 @@ transform: rotate(-135deg); } -/* 展开面板直接铺在表单卡片上:去掉嵌套边框与内缩,列表横向更宽 */ +/* 展开面板:浅橙衬底 + 2rpx 浅橙描边托形,与白卡拉开边界(不用阴影) */ .hospital-panel { - margin: 0; - padding: 0; - background: transparent; + margin: 12rpx 0 24rpx; + padding: 0 20rpx 20rpx; + border: 2rpx solid var(--brand-line, #FFE0C2); + border-radius: 20rpx; + background: var(--brand-soft, #FFF4E8); } .hospital-search { display: flex; align-items: center; padding: 8rpx 0 12rpx; - border-bottom: 2rpx solid var(--line, #ECE3D6); + border-bottom: 2rpx solid var(--sep, #E5DACC); } .hospital-search-input { flex: 1; min-width: 0; color: var(--ink, #2B2521); - font-size: var(--fs-26, 26rpx); + font-size: var(--fs-30, 30rpx); } .hospital-search-close { flex-shrink: 0; margin-left: 16rpx; color: var(--muted, #6F655C); - font-size: var(--fs-24, 24rpx); + font-size: var(--fs-28, 28rpx); } .hospital-search-close:active { @@ -143,7 +165,7 @@ align-items: center; justify-content: space-between; padding: 16rpx 0; - border-bottom: 2rpx solid var(--line, #ECE3D6); + border-bottom: 2rpx solid var(--sep, #E5DACC); } .hospital-option:last-child { @@ -151,7 +173,7 @@ } .hospital-option:active { - background: var(--brand-soft, #FFF4E8); + background: var(--white, #FFFFFF); } .hospital-option-main { @@ -162,21 +184,22 @@ .hospital-option-name { display: block; color: var(--ink, #2B2521); - font-size: var(--fs-28, 28rpx); + font-size: var(--fs-30, 30rpx); font-weight: 700; line-height: 1.4; word-break: break-all; } +/* compact 档跟该页 .form-input(28rpx) 对齐 */ .is-compact .hospital-option-name { - font-size: var(--fs-26, 26rpx); + font-size: var(--fs-28, 28rpx); } .hospital-option-sub { display: block; margin-top: 6rpx; color: var(--muted, #6F655C); - font-size: var(--fs-24, 24rpx); + font-size: var(--fs-26, 26rpx); line-height: 1.4; word-break: break-all; } @@ -185,7 +208,7 @@ flex-shrink: 0; margin-left: 16rpx; color: var(--brand-ink, #9B4508); - font-size: var(--fs-24, 24rpx); + font-size: var(--fs-26, 26rpx); } .hospital-empty { @@ -196,21 +219,6 @@ .hospital-empty-text { display: block; color: var(--muted, #6F655C); - font-size: var(--fs-26, 26rpx); + font-size: var(--fs-30, 30rpx); } -.hospital-use-input { - display: inline-block; - margin-top: 12rpx; - color: var(--brand-ink, #9B4508); - font-size: var(--fs-26, 26rpx); -} - -.hospital-use-input:active { - opacity: 0.6; -} - -.hospital-panel-footer { - padding-top: 12rpx; - text-align: center; -} diff --git a/pages/escort/itemdetail.js b/pages/escort/itemdetail.js index 1004d7f..ca17d63 100644 --- a/pages/escort/itemdetail.js +++ b/pages/escort/itemdetail.js @@ -21,7 +21,7 @@ Page({ provinces: [], hospital: '', hospitalOptions: [], - hospitalManual: false, + hospitalCustom: false, appointmentDate: '', appointmentTime: '', minAppointmentDate: '', @@ -66,12 +66,10 @@ Page({ } this.applyBookingConfig(service) - // 启动时 app 已在预取医院;这里等它落定后刷新下拉,失败则退回手动输入 + // 启动时 app 已在预取医院;这里等它落定后刷新下拉, + // 列表为空时组件内的「其他医院」入口仍可手填 getApp().loadHospitals().then(() => { this.refreshHospitalOptions() - if (!this.data.hospitalOptions.length && !this.data.hospitalManual) { - this.setData({ hospitalManual: true }) - } }) const serviceView = { ...service, @@ -129,7 +127,7 @@ Page({ province: provinces[0] || '', provinceIndex: 0, hospital: '', - hospitalManual: false, + hospitalCustom: false, requiresAddress: !!booking.requiresAddress }, () => this.refreshHospitalOptions(provinces[0] || '')) }, @@ -234,7 +232,7 @@ Page({ provinceIndex: index, province, hospital: '', - hospitalManual: false + hospitalCustom: false }, () => this.refreshHospitalOptions(province)) }, @@ -243,7 +241,8 @@ Page({ const hospitalOptions = getApp().getHospitalsByProvince(province) let hospital = '' - if (this.data.hospitalManual) { + if (this.data.hospitalCustom) { + // 「其他医院」手填的名称不在库内,刷新列表时原样保留 hospital = this.data.hospital } else { const selected = hospitalOptions.find((item) => item._id === this.selectedHospitalId) @@ -258,11 +257,11 @@ Page({ this.setData({ hospitalOptions, hospital }) }, - // 医院选择组件回传:name 为最终值,manual 表示是否手动输入,hospital 为库内记录 + // 医院选择组件回传:name 为最终值,manual 表示是否为「其他医院」手填,hospital 为库内记录 onHospitalChange(e) { const { name, manual, hospital } = e.detail this.selectedHospitalId = hospital?._id || '' - this.setData({ hospital: name, hospitalManual: manual }) + this.setData({ hospital: name, hospitalCustom: manual }) }, onDateChange(e) { @@ -295,7 +294,9 @@ Page({ validateOrder() { const data = this.data if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人' - if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院' + if (!data.hospital.trim()) { + return data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称' + } if (!data.appointmentDate) return '请选择预约日期' if (!data.appointmentTime) return '请选择预约时间' if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址' @@ -362,7 +363,7 @@ Page({ province: provinces[0] || '', provinceIndex: 0, hospital: '', - hospitalManual: false, + hospitalCustom: false, appointmentDate: '', appointmentTime: '', sessionIndex: 0, diff --git a/pages/escort/itemdetail.wxml b/pages/escort/itemdetail.wxml index 2c9297e..67a1e4d 100644 --- a/pages/escort/itemdetail.wxml +++ b/pages/escort/itemdetail.wxml @@ -115,10 +115,10 @@ {{item.name}} - {{item.mobile}} - - + 添加就诊人 + + + 增加 @@ -154,7 +154,6 @@