diff --git a/components/hospital-select/index.js b/components/hospital-select/index.js
new file mode 100644
index 0000000..33214e2
--- /dev/null
+++ b/components/hospital-select/index.js
@@ -0,0 +1,132 @@
+// 医院选择:列表可搜索(名称 / 主体名 / 全拼 / 拼音首字母),找不到时可手动输入
+const SEARCH_PLACEHOLDER = '搜索医院名称或拼音'
+const OPTION_HEIGHT = 112
+
+// 关键词去掉空白、转小写:中文原样匹配,拼音统一小写比较
+const normalizeKeyword = (value) => String(value || '').trim().toLowerCase().replace(/\s+/g, '')
+
+function filterHospitals(options, keyword) {
+ const kw = normalizeKeyword(keyword)
+ if (!kw) return options || []
+
+ return (options || []).filter((item) => [
+ item.name,
+ item.entityName,
+ item.pinyin,
+ item.pinyinFL,
+ ].some((field) => normalizeKeyword(field).includes(kw)))
+}
+
+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: [],
+ observer(newValue) {
+ this.refreshFiltered(newValue, this.data.keyword)
+ },
+ },
+ placeholder: { type: String, value: '请选择就诊医院' },
+ disabled: { type: Boolean, value: false },
+ compact: { type: Boolean, value: false },
+ },
+
+ data: {
+ open: false,
+ keyword: '',
+ filtered: [],
+ optionsHeight: 0,
+ searchPlaceholder: SEARCH_PLACEHOLDER,
+ },
+
+ lifetimes: {
+ attached() {
+ this.refreshFiltered(this.data.options, '')
+ },
+ },
+
+ methods: {
+ refreshFiltered(options = this.data.options, keyword = this.data.keyword) {
+ const filtered = filterHospitals(options, keyword)
+ const visibleRows = Math.min(filtered.length, 4)
+ this.setData({
+ filtered,
+ optionsHeight: visibleRows * OPTION_HEIGHT,
+ })
+ },
+
+ onOpen() {
+ if (this.data.disabled || this.data.manual) return
+ if (this.data.open) {
+ this.onClose()
+ return
+ }
+ this.setData({ open: true, keyword: '' })
+ this.refreshFiltered(this.data.options, '')
+ },
+
+ onClose() {
+ this.setData({ open: false, keyword: '', optionsHeight: 0 })
+ },
+
+ onKeywordInput(e) {
+ const keyword = e.detail.value
+ this.setData({ keyword })
+ this.refreshFiltered(this.data.options, keyword)
+ },
+
+ onSelect(e) {
+ if (this.data.disabled) return
+ const index = Number(e.currentTarget.dataset.index)
+ const hospital = this.data.filtered[index]
+ if (!hospital) return
+
+ this.onClose()
+ this.triggerEvent('change', {
+ name: hospital.name,
+ manual: false,
+ hospital,
+ })
+ },
+
+ // 搜索词没有匹配时,直接把当前输入当作医院名,转入手动输入
+ onUseKeyword() {
+ const name = String(this.data.keyword || '').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.json b/components/hospital-select/index.json
new file mode 100644
index 0000000..a89ef4d
--- /dev/null
+++ b/components/hospital-select/index.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
diff --git a/components/hospital-select/index.wxml b/components/hospital-select/index.wxml
new file mode 100644
index 0000000..11cb608
--- /dev/null
+++ b/components/hospital-select/index.wxml
@@ -0,0 +1,68 @@
+
+
+
+ {{label}}
+ {{manual ? '从列表选择' : '手动输入'}}
+
+
+
+
+ {{value || placeholder}}
+
+
+
+
+
+
+
+ 收起
+
+
+
+
+
+ {{item.name}}
+ {{item.address}}
+
+ 已选
+
+
+
+
+ {{keyword ? '没有找到匹配的医院' : '暂无可选医院'}}
+ 使用「{{keyword}}」
+ 手动输入
+
+
+
+
+
diff --git a/components/hospital-select/index.wxss b/components/hospital-select/index.wxss
new file mode 100644
index 0000000..2e98fd7
--- /dev/null
+++ b/components/hospital-select/index.wxss
@@ -0,0 +1,218 @@
+/* 医院选择:行结构与页面表单保持一致,展开面板作为行内下拉 */
+.hospital-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 24rpx 0;
+ border-bottom: 2rpx solid var(--line, #ECE3D6);
+}
+
+.is-compact .hospital-row {
+ min-height: 72rpx;
+ padding: 12rpx 0;
+}
+
+.is-disabled {
+ opacity: 0.6;
+}
+
+.hospital-label-wrap {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ flex-shrink: 0;
+}
+
+.hospital-label {
+ color: var(--muted, #6F655C);
+ font-size: var(--fs-28, 28rpx);
+ letter-spacing: 1rpx;
+}
+
+.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;
+ min-width: 0;
+ align-items: center;
+ justify-content: flex-end;
+ margin-left: 24rpx;
+}
+
+.hospital-value-text {
+ min-width: 0;
+ overflow: hidden;
+ color: var(--ink, #2B2521);
+ font-size: var(--fs-28, 28rpx);
+ font-weight: 700;
+ text-align: right;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.is-compact .hospital-value-text {
+ font-weight: 400;
+}
+
+.hospital-value-text.is-placeholder {
+ color: var(--muted, #6F655C);
+ 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-chevron {
+ flex-shrink: 0;
+ width: 16rpx;
+ height: 16rpx;
+ margin-left: 16rpx;
+ border-right: 2rpx solid var(--muted, #6F655C);
+ border-bottom: 2rpx solid var(--muted, #6F655C);
+ transform: rotate(45deg);
+ transition: transform 0.2s ease;
+}
+
+.hospital-chevron.is-open {
+ transform: rotate(-135deg);
+}
+
+/* 展开面板:暖白纸面 + 浅橙描边,与全站二级信息块一致 */
+.hospital-panel {
+ margin: 12rpx 0 8rpx;
+ padding: 16rpx;
+ border: 2rpx solid var(--brand-line, #FFE0C2);
+ border-radius: 20rpx;
+ background: var(--paper, #FAF8F5);
+}
+
+.hospital-search {
+ display: flex;
+ align-items: center;
+ padding-bottom: 12rpx;
+ border-bottom: 2rpx solid var(--line, #ECE3D6);
+}
+
+.hospital-search-input {
+ flex: 1;
+ min-width: 0;
+ color: var(--ink, #2B2521);
+ font-size: var(--fs-26, 26rpx);
+}
+
+.hospital-search-close {
+ flex-shrink: 0;
+ margin-left: 16rpx;
+ color: var(--muted, #6F655C);
+ font-size: var(--fs-24, 24rpx);
+}
+
+.hospital-search-close:active {
+ opacity: 0.6;
+}
+
+.hospital-options {
+ margin-top: 4rpx;
+}
+
+.hospital-option {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16rpx 4rpx;
+ border-bottom: 2rpx solid var(--line, #ECE3D6);
+}
+
+.hospital-option:last-child {
+ border-bottom: none;
+}
+
+.hospital-option:active {
+ background: var(--brand-soft, #FFF4E8);
+}
+
+.hospital-option-main {
+ flex: 1;
+ min-width: 0;
+}
+
+.hospital-option-name {
+ display: block;
+ color: var(--ink, #2B2521);
+ font-size: var(--fs-28, 28rpx);
+ font-weight: 700;
+ line-height: 1.4;
+ word-break: break-all;
+}
+
+.is-compact .hospital-option-name {
+ font-size: var(--fs-26, 26rpx);
+}
+
+.hospital-option-sub {
+ display: block;
+ margin-top: 6rpx;
+ color: var(--muted, #6F655C);
+ font-size: var(--fs-24, 24rpx);
+ line-height: 1.4;
+ word-break: break-all;
+}
+
+.hospital-option-selected {
+ flex-shrink: 0;
+ margin-left: 16rpx;
+ color: var(--brand-ink, #9B4508);
+ font-size: var(--fs-24, 24rpx);
+}
+
+.hospital-empty {
+ padding: 32rpx 0;
+ text-align: center;
+}
+
+.hospital-empty-text {
+ display: block;
+ color: var(--muted, #6F655C);
+ font-size: var(--fs-26, 26rpx);
+}
+
+.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 df20396..1004d7f 100644
--- a/pages/escort/itemdetail.js
+++ b/pages/escort/itemdetail.js
@@ -20,6 +20,8 @@ Page({
provinceIndex: 0,
provinces: [],
hospital: '',
+ hospitalOptions: [],
+ hospitalManual: false,
appointmentDate: '',
appointmentTime: '',
minAppointmentDate: '',
@@ -64,6 +66,13 @@ Page({
}
this.applyBookingConfig(service)
+ // 启动时 app 已在预取医院;这里等它落定后刷新下拉,失败则退回手动输入
+ getApp().loadHospitals().then(() => {
+ this.refreshHospitalOptions()
+ if (!this.data.hospitalOptions.length && !this.data.hospitalManual) {
+ this.setData({ hospitalManual: true })
+ }
+ })
const serviceView = {
...service,
notices: (service.notices || []).map(text => ({ id: text, text }))
@@ -108,6 +117,7 @@ Page({
timeEnd = `${String(Math.floor(latest / 60)).padStart(2, '0')}:${String(latest % 60).padStart(2, '0')}`
}
const provinces = service.areas || []
+ this.selectedHospitalId = ''
this.setData({
minAppointmentDate,
fixedTime,
@@ -118,8 +128,10 @@ Page({
provinces,
province: provinces[0] || '',
provinceIndex: 0,
+ hospital: '',
+ hospitalManual: false,
requiresAddress: !!booking.requiresAddress
- })
+ }, () => this.refreshHospitalOptions(provinces[0] || ''))
},
getServiceIcon(title) {
@@ -170,6 +182,7 @@ Page({
selectedPatient: null,
showOrderPopup: true
})
+ this.refreshHospitalOptions()
this.loadProfiles()
},
@@ -214,11 +227,42 @@ Page({
onProvinceChange(e) {
const index = Number(e.detail.value)
- this.setData({ provinceIndex: index, province: this.data.provinces[index] })
+ const province = this.data.provinces[index]
+ // 省份变了,已选医院可能不在新省份内,先清空再按新省份重建列表
+ this.selectedHospitalId = ''
+ this.setData({
+ provinceIndex: index,
+ province,
+ hospital: '',
+ hospitalManual: false
+ }, () => this.refreshHospitalOptions(province))
},
+ // 按当前省份重建医院列表;已选医院按 _id 保留,避免网络刷新后选中值丢失
+ refreshHospitalOptions(province = this.data.province) {
+ const hospitalOptions = getApp().getHospitalsByProvince(province)
+ let hospital = ''
+
+ if (this.data.hospitalManual) {
+ hospital = this.data.hospital
+ } else {
+ const selected = hospitalOptions.find((item) => item._id === this.selectedHospitalId)
+ if (selected) {
+ hospital = selected.name
+ } else if (this.selectedHospitalId) {
+ // 已选医院在刷新后已不存在,退回未选状态
+ this.selectedHospitalId = ''
+ }
+ }
+
+ this.setData({ hospitalOptions, hospital })
+ },
+
+ // 医院选择组件回传:name 为最终值,manual 表示是否手动输入,hospital 为库内记录
onHospitalChange(e) {
- this.setData({ hospital: e.detail.value })
+ const { name, manual, hospital } = e.detail
+ this.selectedHospitalId = hospital?._id || ''
+ this.setData({ hospital: name, hospitalManual: manual })
},
onDateChange(e) {
@@ -251,7 +295,7 @@ Page({
validateOrder() {
const data = this.data
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
- if (!data.hospital.trim()) return '请输入就诊医院'
+ if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院'
if (!data.appointmentDate) return '请选择预约日期'
if (!data.appointmentTime) return '请选择预约时间'
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
@@ -309,6 +353,7 @@ Page({
resetForm() {
const provinces = this.data.provinces
+ this.selectedHospitalId = ''
this.setData({
selectedProfileId: '',
patientName: '',
@@ -317,6 +362,7 @@ Page({
province: provinces[0] || '',
provinceIndex: 0,
hospital: '',
+ hospitalManual: false,
appointmentDate: '',
appointmentTime: '',
sessionIndex: 0,
@@ -324,7 +370,7 @@ Page({
genderIndex: 0,
remark: '',
shippingAddress: ''
- })
+ }, () => this.refreshHospitalOptions(provinces[0] || ''))
this.idempotencyKey = ''
},
diff --git a/pages/escort/itemdetail.json b/pages/escort/itemdetail.json
index 8dbc89c..6d34ea6 100644
--- a/pages/escort/itemdetail.json
+++ b/pages/escort/itemdetail.json
@@ -1,6 +1,7 @@
{
"usingComponents": {
- "t-icon": "tdesign-miniprogram/icon/icon"
+ "t-icon": "tdesign-miniprogram/icon/icon",
+ "hospital-select": "/components/hospital-select/index"
},
"navigationBarTitleText": "服务详情"
}
diff --git a/pages/escort/itemdetail.wxml b/pages/escort/itemdetail.wxml
index ca0da21..2c9297e 100644
--- a/pages/escort/itemdetail.wxml
+++ b/pages/escort/itemdetail.wxml
@@ -150,11 +150,16 @@
-
-
- 就诊医院
-
-
+
+
diff --git a/pages/escort/itemorder.js b/pages/escort/itemorder.js
index 555a152..7ba8b38 100644
--- a/pages/escort/itemorder.js
+++ b/pages/escort/itemorder.js
@@ -21,6 +21,8 @@ Page({
provinceIndex: 0,
provinces: [],
hospital: '',
+ hospitalOptions: [],
+ hospitalManual: false,
appointmentDate: '',
appointmentTime: '',
minAppointmentDate: '',
@@ -69,6 +71,14 @@ Page({
this.pageReady = true
const app = getApp()
+ // 启动时 app 已在预取,这里只等它落定后用最新列表刷新下拉;
+ // 没有可用医院时退回手动输入,避免下拉是空的还阻断下单
+ app.loadHospitals().then(() => {
+ this.refreshHospitalOptions()
+ if (!this.data.hospitalOptions.length && !this.data.hospitalManual) {
+ this.setData({ hospitalManual: true })
+ }
+ })
await app.waitForAuth()
if (app.globalData.user?._id) this.loadProfiles()
},
@@ -96,6 +106,7 @@ Page({
}
const provinces = service.areas || []
+ this.selectedHospitalId = ''
this.setData({
service,
serviceIndex,
@@ -110,11 +121,13 @@ Page({
provinces,
province: provinces[0] || '',
provinceIndex: 0,
+ hospital: '',
+ hospitalManual: false,
appointmentDate: '',
appointmentTime: '',
shippingAddress: '',
requiresAddress: !!booking.requiresAddress
- })
+ }, () => this.refreshHospitalOptions(provinces[0] || ''))
},
onServiceChange(e) {
@@ -189,11 +202,42 @@ Page({
onProvinceChange(e) {
const index = Number(e.detail.value)
- this.setData({ provinceIndex: index, province: this.data.provinces[index] })
+ const province = this.data.provinces[index]
+ // 省份变了,已选医院可能不在新省份内,先清空再按新省份重建列表
+ this.selectedHospitalId = ''
+ this.setData({
+ provinceIndex: index,
+ province,
+ hospital: '',
+ hospitalManual: false
+ }, () => this.refreshHospitalOptions(province))
},
+ // 按当前省份重建医院列表;已选医院按 _id 保留,避免网络刷新后选中值丢失
+ refreshHospitalOptions(province = this.data.province) {
+ const hospitalOptions = getApp().getHospitalsByProvince(province)
+ let hospital = ''
+
+ if (this.data.hospitalManual) {
+ hospital = this.data.hospital
+ } else {
+ const selected = hospitalOptions.find((item) => item._id === this.selectedHospitalId)
+ if (selected) {
+ hospital = selected.name
+ } else if (this.selectedHospitalId) {
+ // 已选医院在刷新后已不存在,退回未选状态
+ this.selectedHospitalId = ''
+ }
+ }
+
+ this.setData({ hospitalOptions, hospital })
+ },
+
+ // 医院选择组件回传:name 为最终值,manual 表示是否手动输入,hospital 为库内记录
onHospitalChange(e) {
- this.setData({ hospital: e.detail.value })
+ const { name, manual, hospital } = e.detail
+ this.selectedHospitalId = hospital?._id || ''
+ this.setData({ hospital: name, hospitalManual: manual })
},
onDateChange(e) {
@@ -226,7 +270,7 @@ Page({
validateOrder() {
const data = this.data
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
- if (!data.hospital.trim()) return '请输入就诊医院'
+ if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院'
if (!data.appointmentDate) return '请选择预约日期'
if (!data.appointmentTime) return '请选择预约时间'
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
@@ -291,6 +335,7 @@ Page({
resetForm() {
const provinces = this.data.provinces
+ this.selectedHospitalId = ''
this.setData({
selectedProfileId: '',
patientName: '',
@@ -299,6 +344,7 @@ Page({
province: provinces[0] || '',
provinceIndex: 0,
hospital: '',
+ hospitalManual: false,
appointmentDate: '',
appointmentTime: '',
sessionIndex: 0,
@@ -306,7 +352,7 @@ Page({
genderIndex: 0,
remark: '',
shippingAddress: ''
- })
+ }, () => this.refreshHospitalOptions(provinces[0] || ''))
this.idempotencyKey = this.createIdempotencyKey()
}
})
\ No newline at end of file
diff --git a/pages/escort/itemorder.json b/pages/escort/itemorder.json
index 76287ca..3750dc5 100644
--- a/pages/escort/itemorder.json
+++ b/pages/escort/itemorder.json
@@ -1,7 +1,8 @@
{
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
- "t-loading": "tdesign-miniprogram/loading/loading"
+ "t-loading": "tdesign-miniprogram/loading/loading",
+ "hospital-select": "/components/hospital-select/index"
},
"navigationBarTitleText": "立即预约"
}
\ No newline at end of file
diff --git a/pages/escort/itemorder.wxml b/pages/escort/itemorder.wxml
index f3a930d..b24901d 100644
--- a/pages/escort/itemorder.wxml
+++ b/pages/escort/itemorder.wxml
@@ -67,10 +67,15 @@
-
- 就诊医院
-
-
+
陪诊师性别
diff --git a/pages/escort/recorddetail.js b/pages/escort/recorddetail.js
index d152648..6f86f59 100644
--- a/pages/escort/recorddetail.js
+++ b/pages/escort/recorddetail.js
@@ -38,6 +38,7 @@ Page({
// 医院预约规则与下单页一致,均由订单关联的服务目录下发
showHospitalPopup: false,
provinces: [],
+ hospitalOptions: [],
minAppointmentDate: '',
fixedTime: false,
timeOptions: [],
@@ -356,24 +357,39 @@ Page({
// ===== 医院预约信息编辑(底部弹窗) =====
// 打开弹窗:用当前展示值填充表单(scheduleDate 已是 YYYY-MM-DD,可直接喂给 date picker)
- onEditHospital() {
+ async onEditHospital() {
+ await getApp().loadHospitals()
const r = this.data.record
- const provinceIndex = Math.max(0, this.data.provinces.indexOf(r.hospitalProvince))
+ // 历史订单的省份若与目录写法不同(北京 / 北京市),落回目录里的标准值
+ const matchedProvinceIndex = this.data.provinces.findIndex(item => getApp().isSameProvince(item, r.hospitalProvince))
+ const province = matchedProvinceIndex >= 0
+ ? this.data.provinces[matchedProvinceIndex]
+ : (r.hospitalProvince || this.data.provinces[0] || '')
+ const provinceIndex = Math.max(0, matchedProvinceIndex)
const sessions = this.data.service?.booking?.sessions || []
const sessionIndex = Math.max(0, sessions.findIndex(item => item.start === r.scheduleStartTime))
+
+ const hospitalOptions = getApp().getHospitalsByProvince(province)
+ const name = r.hospitalName || ''
+ const matched = hospitalOptions.find(item => item.name === name)
+ // 历史订单的医院可能已不在库中:自动退回手动输入并保留原值,保证仍能保存
+ const hospitalManual = !hospitalOptions.length || (!!name.trim() && !matched)
+
this.setData({
showHospitalPopup: true,
+ hospitalOptions,
editHospital: {
- province: r.hospitalProvince || this.data.provinces[0] || '',
+ province,
provinceIndex,
- name: r.hospitalName || '',
+ name,
address: r.hospitalAddress || '',
department: r.hospitalDepartment || '',
doctor: r.hospitalDoctor || '',
medicalRecordNo: r.medicalRecordNo || '',
scheduleDate: r.scheduleDate || '',
startTime: r.scheduleStartTime || '',
- sessionIndex
+ sessionIndex,
+ hospitalManual
}
})
},
@@ -386,12 +402,29 @@ Page({
onProvinceChange(e) {
const index = Number(e.detail.value)
+ const province = this.data.provinces[index]
+ const hospitalOptions = getApp().getHospitalsByProvince(province)
+ // 省份变了,已选医院可能不在新省份内,先清空再按新省份重建列表
this.setData({
'editHospital.provinceIndex': index,
- 'editHospital.province': this.data.provinces[index]
+ 'editHospital.province': province,
+ 'editHospital.name': '',
+ 'editHospital.hospitalManual': false,
+ hospitalOptions
})
},
+ // 医院选择组件回传:库内医院同时带出地址,手动输入保持用户填写
+ onHospitalSelectChange(e) {
+ const { name, manual, hospital } = e.detail
+ const patch = {
+ 'editHospital.name': name,
+ 'editHospital.hospitalManual': manual
+ }
+ if (hospital?.address) patch['editHospital.address'] = hospital.address
+ this.setData(patch)
+ },
+
onScheduleDateChange(e) {
this.setData({ 'editHospital.scheduleDate': e.detail.value })
},
@@ -416,7 +449,7 @@ Page({
onSaveHospital() {
const form = this.data.editHospital
if (!form.name || !form.name.trim()) {
- wx.showToast({ title: '请输入就诊医院', icon: 'none' })
+ wx.showToast({ title: form.hospitalManual ? '请输入就诊医院' : '请选择就诊医院', icon: 'none' })
return
}
if (!form.scheduleDate) {
@@ -428,8 +461,10 @@ Page({
return
}
+ // 提交前再对齐一次服务目录口径,避免历史数据里的「北京」被后端判为未开通
+ const serviceProvince = this.data.provinces.find(item => getApp().isSameProvince(item, form.province))
const update = {
- 'hospital.province': form.province || '',
+ 'hospital.province': serviceProvince || form.province || '',
'hospital.name': form.name.trim(),
'hospital.address': (form.address || '').trim(),
'hospital.department': (form.department || '').trim(),
diff --git a/pages/escort/recorddetail.json b/pages/escort/recorddetail.json
index e240546..2117076 100644
--- a/pages/escort/recorddetail.json
+++ b/pages/escort/recorddetail.json
@@ -1,7 +1,8 @@
{
"navigationBarTitleText": "预约记录详情",
"usingComponents": {
- "t-icon": "tdesign-miniprogram/icon/icon"
+ "t-icon": "tdesign-miniprogram/icon/icon",
+ "hospital-select": "/components/hospital-select/index"
},
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
diff --git a/pages/escort/recorddetail.wxml b/pages/escort/recorddetail.wxml
index 838a2fc..7662d72 100644
--- a/pages/escort/recorddetail.wxml
+++ b/pages/escort/recorddetail.wxml
@@ -283,17 +283,15 @@
{{editHospital.province || '请选择省份'}}
-
- 就诊医院
-
-
+
医院地址