Compare commits
6
Commits
e3692043c1
...
67157fa919
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67157fa919 | ||
|
|
14b38f1ff1 | ||
|
|
4ae376204d | ||
|
|
8aebbccc58 | ||
|
|
e3c4c14720 | ||
|
|
6536abb240 |
@@ -4,6 +4,57 @@ const request = require('./utils/request.js')
|
|||||||
|
|
||||||
// 服务列表缓存:只服务首屏秒开,命中后仍会请求最新数据覆盖
|
// 服务列表缓存:只服务首屏秒开,命中后仍会请求最新数据覆盖
|
||||||
const SERVICES_CACHE_KEY = 'servicesCacheV1'
|
const SERVICES_CACHE_KEY = 'servicesCacheV1'
|
||||||
|
// 医院列表缓存:全量裁剪后落本地,冷启动先用缓存,网络成功后再覆盖
|
||||||
|
const HOSPITALS_CACHE_KEY = 'hospitalsCacheV1'
|
||||||
|
const HOSPITAL_PAGE_SIZE = 200
|
||||||
|
const HOSPITAL_MAX_PAGES = 20
|
||||||
|
|
||||||
|
// 省份归一:兼容医院库「北京」与服务目录「北京市」等不同写法
|
||||||
|
function normalizeProvince(value) {
|
||||||
|
return String(value || '')
|
||||||
|
.trim()
|
||||||
|
.replace(/(特别行政区|自治区|省|市)$/, '')
|
||||||
|
.replace(/(壮族|回族|维吾尔)$/, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复旦榜默认档位/顺序:与后端 schema 保持一致,未上榜排最后
|
||||||
|
const DEFAULT_FUDAN_RANK = 999
|
||||||
|
const DEFAULT_FUDAN_ORDER = 9999
|
||||||
|
|
||||||
|
// 兼容新嵌套对象与旧扁平接口,统一成 { rank, grade, order }
|
||||||
|
function normalizeFudanRank(item) {
|
||||||
|
const fudan = item?.fudanRank
|
||||||
|
if (fudan && typeof fudan === 'object') {
|
||||||
|
return {
|
||||||
|
rank: Number(fudan.rank) || DEFAULT_FUDAN_RANK,
|
||||||
|
grade: String(fudan.grade || '').trim(),
|
||||||
|
order: Number(fudan.order) || DEFAULT_FUDAN_ORDER,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
rank: Number(fudan) || DEFAULT_FUDAN_RANK,
|
||||||
|
grade: String(item?.fudanGrade || '').trim(),
|
||||||
|
order: Number(item?.fudanOrder) || DEFAULT_FUDAN_ORDER,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 医院下拉排序:复旦档位 → 同档榜单顺序 → 拼音 → 名称
|
||||||
|
function compareHospitals(a, b) {
|
||||||
|
const rankDiff = (a.fudanRank?.rank || DEFAULT_FUDAN_RANK) - (b.fudanRank?.rank || DEFAULT_FUDAN_RANK)
|
||||||
|
if (rankDiff) return rankDiff
|
||||||
|
|
||||||
|
const orderDiff = (a.fudanRank?.order || DEFAULT_FUDAN_ORDER) - (b.fudanRank?.order || DEFAULT_FUDAN_ORDER)
|
||||||
|
if (orderDiff) return orderDiff
|
||||||
|
|
||||||
|
const leftPinyin = a.pinyin || ''
|
||||||
|
const rightPinyin = b.pinyin || ''
|
||||||
|
if (leftPinyin !== rightPinyin) return leftPinyin < rightPinyin ? -1 : 1
|
||||||
|
|
||||||
|
const leftName = a.name || ''
|
||||||
|
const rightName = b.name || ''
|
||||||
|
if (leftName === rightName) return 0
|
||||||
|
return leftName < rightName ? -1 : 1
|
||||||
|
}
|
||||||
|
|
||||||
App({
|
App({
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
@@ -11,7 +62,9 @@ App({
|
|||||||
// 登录逻辑只在 app 里有一份,request 层不碰
|
// 登录逻辑只在 app 里有一份,request 层不碰
|
||||||
request.setUnauthorizedHandler(() => this.silentSignin())
|
request.setUnauthorizedHandler(() => this.silentSignin())
|
||||||
|
|
||||||
|
this.globalData.hospitals = this.getCachedHospitals()
|
||||||
this.loadServices()
|
this.loadServices()
|
||||||
|
this.loadHospitals()
|
||||||
// 服务协议只有协议页用,改成该页首次进入时再拉(页面里已有 loadAgreement),
|
// 服务协议只有协议页用,改成该页首次进入时再拉(页面里已有 loadAgreement),
|
||||||
// 启动期少一次并发请求
|
// 启动期少一次并发请求
|
||||||
|
|
||||||
@@ -67,6 +120,92 @@ App({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 医院列表:启动异步预取,页面下拉直接复用;失败时保留缓存并允许重试
|
||||||
|
loadHospitals() {
|
||||||
|
if (this.globalData.hospitalsReady) return this.globalData.hospitalsReady
|
||||||
|
this.globalData.hospitalsReady = this.fetchHospitals()
|
||||||
|
.then((hospitals) => {
|
||||||
|
this.globalData.hospitals = hospitals
|
||||||
|
this.cacheHospitals(hospitals)
|
||||||
|
return hospitals
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('获取医院列表失败', err)
|
||||||
|
this.globalData.hospitalsReady = null
|
||||||
|
return this.globalData.hospitals
|
||||||
|
})
|
||||||
|
return this.globalData.hospitalsReady
|
||||||
|
},
|
||||||
|
|
||||||
|
// 接口单页上限 200:按 total 逐页拉全量,避免下拉只看到第一页
|
||||||
|
async fetchHospitals() {
|
||||||
|
const hospitals = []
|
||||||
|
let page = 1
|
||||||
|
let total = 0
|
||||||
|
|
||||||
|
while (page <= HOSPITAL_MAX_PAGES) {
|
||||||
|
const res = await API.hospital.getHospitals({ page, pageSize: HOSPITAL_PAGE_SIZE })
|
||||||
|
if (res.code !== 0) throw new Error(res.msg || '医院列表加载失败')
|
||||||
|
const list = Array.isArray(res.data?.list) ? res.data.list : []
|
||||||
|
total = Number(res.data?.total) || 0
|
||||||
|
hospitals.push(...list)
|
||||||
|
if (list.length === 0 || hospitals.length >= total) break
|
||||||
|
page += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return hospitals
|
||||||
|
.map((item) => ({
|
||||||
|
_id: item?._id ? String(item._id) : '',
|
||||||
|
name: String(item?.name || '').trim(),
|
||||||
|
entityName: String(item?.entityName || '').trim(),
|
||||||
|
nicknames: Array.isArray(item?.nicknames)
|
||||||
|
? item.nicknames.map((name) => String(name || '').trim()).filter(Boolean)
|
||||||
|
: [],
|
||||||
|
pinyin: String(item?.pinyin || '').trim(),
|
||||||
|
pinyinFL: String(item?.pinyinFL || '').trim(),
|
||||||
|
province: String(item?.province || '').trim(),
|
||||||
|
address: String(item?.address || '').trim(),
|
||||||
|
fudanRank: normalizeFudanRank(item),
|
||||||
|
}))
|
||||||
|
.filter((item) => item.name)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 缓存只存下拉需要的字段,避免整份医院文档占满本地存储
|
||||||
|
cacheHospitals(hospitals) {
|
||||||
|
try {
|
||||||
|
wx.setStorageSync(HOSPITALS_CACHE_KEY, hospitals)
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('缓存医院列表失败', err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 冷启动先用缓存占位,网络成功后覆盖;缓存异常时不阻塞页面
|
||||||
|
getCachedHospitals() {
|
||||||
|
try {
|
||||||
|
const cached = wx.getStorageSync(HOSPITALS_CACHE_KEY)
|
||||||
|
if (!Array.isArray(cached)) return []
|
||||||
|
return cached.filter((item) => item && item.name)
|
||||||
|
} catch (err) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 省份是否同口径:医院库可能写「北京」,服务目录写「北京市」
|
||||||
|
isSameProvince(a, b) {
|
||||||
|
const left = normalizeProvince(a)
|
||||||
|
const right = normalizeProvince(b)
|
||||||
|
return !!left && left === right
|
||||||
|
},
|
||||||
|
|
||||||
|
// 按服务目录里的省份筛医院;返回副本后统一按复旦顺序重排
|
||||||
|
getHospitalsByProvince(province) {
|
||||||
|
const hospitals = this.globalData.hospitals || []
|
||||||
|
const list = province
|
||||||
|
? hospitals.filter((item) => this.isSameProvince(item.province, province))
|
||||||
|
: hospitals.slice()
|
||||||
|
return list.sort(compareHospitals)
|
||||||
|
},
|
||||||
|
|
||||||
loadAgreement() {
|
loadAgreement() {
|
||||||
if (this.globalData.agreementReady) return this.globalData.agreementReady
|
if (this.globalData.agreementReady) return this.globalData.agreementReady
|
||||||
this.globalData.agreementReady = API.resource.getAgreement()
|
this.globalData.agreementReady = API.resource.getAgreement()
|
||||||
@@ -210,6 +349,8 @@ App({
|
|||||||
chatSocket: null,
|
chatSocket: null,
|
||||||
services: [],
|
services: [],
|
||||||
servicesReady: null,
|
servicesReady: null,
|
||||||
|
hospitals: [],
|
||||||
|
hospitalsReady: null,
|
||||||
agreement: null,
|
agreement: null,
|
||||||
agreementReady: null,
|
agreementReady: null,
|
||||||
authReady: null,
|
authReady: null,
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// 医院选择:列表可搜索(名称 / 主体名 / 全拼 / 拼音首字母),找不到时可手动输入
|
||||||
|
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,
|
||||||
|
...(Array.isArray(item.nicknames) ? item.nicknames : []),
|
||||||
|
].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 })
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<view class="hospital-select {{compact ? 'is-compact' : ''}} {{disabled ? 'is-disabled' : ''}}">
|
||||||
|
<view class="hospital-row">
|
||||||
|
<view class="hospital-label-wrap">
|
||||||
|
<text class="hospital-label">{{label}}</text>
|
||||||
|
<text class="hospital-mode" catchtap="onToggleManual">{{manual ? '从列表选择' : '手动输入'}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<input
|
||||||
|
wx:if="{{manual}}"
|
||||||
|
class="hospital-input"
|
||||||
|
value="{{value}}"
|
||||||
|
placeholder="{{placeholder}}"
|
||||||
|
placeholder-class="hospital-placeholder"
|
||||||
|
disabled="{{disabled}}"
|
||||||
|
bindinput="onManualInput"
|
||||||
|
/>
|
||||||
|
<view wx:else class="hospital-value" bindtap="onOpen">
|
||||||
|
<text class="hospital-value-text {{value ? '' : 'is-placeholder'}}">{{value || placeholder}}</text>
|
||||||
|
<view class="hospital-chevron {{open ? 'is-open' : ''}}"></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="hospital-panel" wx:if="{{open && !manual}}">
|
||||||
|
<view class="hospital-search">
|
||||||
|
<input
|
||||||
|
class="hospital-search-input"
|
||||||
|
value="{{keyword}}"
|
||||||
|
placeholder="{{searchPlaceholder}}"
|
||||||
|
placeholder-class="hospital-placeholder"
|
||||||
|
focus="{{open}}"
|
||||||
|
confirm-type="search"
|
||||||
|
bindinput="onKeywordInput"
|
||||||
|
/>
|
||||||
|
<text class="hospital-search-close" bindtap="onClose">收起</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view
|
||||||
|
wx:if="{{filtered.length > 0}}"
|
||||||
|
class="hospital-options"
|
||||||
|
scroll-y
|
||||||
|
style="height: {{optionsHeight}}rpx;"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
wx:for="{{filtered}}"
|
||||||
|
wx:key="_id"
|
||||||
|
class="hospital-option"
|
||||||
|
data-index="{{index}}"
|
||||||
|
bindtap="onSelect"
|
||||||
|
>
|
||||||
|
<view class="hospital-option-main">
|
||||||
|
<text class="hospital-option-name">{{item.name}}</text>
|
||||||
|
<text class="hospital-option-sub" wx:if="{{item.address}}">{{item.address}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="hospital-option-selected" wx:if="{{item.name === value}}">已选</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
|
||||||
|
<view wx:else class="hospital-empty">
|
||||||
|
<text class="hospital-empty-text">{{keyword ? '没有找到匹配的医院' : '暂无可选医院'}}</text>
|
||||||
|
<text class="hospital-use-input" wx:if="{{keyword}}" bindtap="onUseKeyword">使用「{{keyword}}」</text>
|
||||||
|
<text class="hospital-use-input" wx:else bindtap="onToggleManual">手动输入</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="hospital-panel-footer" wx:if="{{keyword && filtered.length > 0}}">
|
||||||
|
<text class="hospital-use-input" bindtap="onUseKeyword">没有找到?使用「{{keyword}}」</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
/* 医院选择:行结构与页面表单保持一致,展开面板作为行内下拉 */
|
||||||
|
.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: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hospital-search {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8rpx 0 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: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hospital-option {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16rpx 0;
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ Page({
|
|||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
provinces: [],
|
provinces: [],
|
||||||
hospital: '',
|
hospital: '',
|
||||||
|
hospitalOptions: [],
|
||||||
|
hospitalManual: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
@@ -64,6 +66,13 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.applyBookingConfig(service)
|
this.applyBookingConfig(service)
|
||||||
|
// 启动时 app 已在预取医院;这里等它落定后刷新下拉,失败则退回手动输入
|
||||||
|
getApp().loadHospitals().then(() => {
|
||||||
|
this.refreshHospitalOptions()
|
||||||
|
if (!this.data.hospitalOptions.length && !this.data.hospitalManual) {
|
||||||
|
this.setData({ hospitalManual: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
const serviceView = {
|
const serviceView = {
|
||||||
...service,
|
...service,
|
||||||
notices: (service.notices || []).map(text => ({ id: text, text }))
|
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')}`
|
timeEnd = `${String(Math.floor(latest / 60)).padStart(2, '0')}:${String(latest % 60).padStart(2, '0')}`
|
||||||
}
|
}
|
||||||
const provinces = service.areas || []
|
const provinces = service.areas || []
|
||||||
|
this.selectedHospitalId = ''
|
||||||
this.setData({
|
this.setData({
|
||||||
minAppointmentDate,
|
minAppointmentDate,
|
||||||
fixedTime,
|
fixedTime,
|
||||||
@@ -118,8 +128,10 @@ Page({
|
|||||||
provinces,
|
provinces,
|
||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
|
hospital: '',
|
||||||
|
hospitalManual: false,
|
||||||
requiresAddress: !!booking.requiresAddress
|
requiresAddress: !!booking.requiresAddress
|
||||||
})
|
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||||
},
|
},
|
||||||
|
|
||||||
getServiceIcon(title) {
|
getServiceIcon(title) {
|
||||||
@@ -170,6 +182,7 @@ Page({
|
|||||||
selectedPatient: null,
|
selectedPatient: null,
|
||||||
showOrderPopup: true
|
showOrderPopup: true
|
||||||
})
|
})
|
||||||
|
this.refreshHospitalOptions()
|
||||||
this.loadProfiles()
|
this.loadProfiles()
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -214,11 +227,42 @@ Page({
|
|||||||
|
|
||||||
onProvinceChange(e) {
|
onProvinceChange(e) {
|
||||||
const index = Number(e.detail.value)
|
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) {
|
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) {
|
onDateChange(e) {
|
||||||
@@ -251,7 +295,7 @@ Page({
|
|||||||
validateOrder() {
|
validateOrder() {
|
||||||
const data = this.data
|
const data = this.data
|
||||||
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
||||||
if (!data.hospital.trim()) return '请输入就诊医院'
|
if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院'
|
||||||
if (!data.appointmentDate) return '请选择预约日期'
|
if (!data.appointmentDate) return '请选择预约日期'
|
||||||
if (!data.appointmentTime) return '请选择预约时间'
|
if (!data.appointmentTime) return '请选择预约时间'
|
||||||
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
||||||
@@ -309,6 +353,7 @@ Page({
|
|||||||
|
|
||||||
resetForm() {
|
resetForm() {
|
||||||
const provinces = this.data.provinces
|
const provinces = this.data.provinces
|
||||||
|
this.selectedHospitalId = ''
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedProfileId: '',
|
selectedProfileId: '',
|
||||||
patientName: '',
|
patientName: '',
|
||||||
@@ -317,6 +362,7 @@ Page({
|
|||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
hospital: '',
|
hospital: '',
|
||||||
|
hospitalManual: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
sessionIndex: 0,
|
sessionIndex: 0,
|
||||||
@@ -324,7 +370,7 @@ Page({
|
|||||||
genderIndex: 0,
|
genderIndex: 0,
|
||||||
remark: '',
|
remark: '',
|
||||||
shippingAddress: ''
|
shippingAddress: ''
|
||||||
})
|
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||||
this.idempotencyKey = ''
|
this.idempotencyKey = ''
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
|
"hospital-select": "/components/hospital-select/index"
|
||||||
},
|
},
|
||||||
"navigationBarTitleText": "服务详情"
|
"navigationBarTitleText": "服务详情"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,11 +150,16 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 就诊医院 -->
|
<!-- 就诊医院:自定义搜索选择,支持中文/拼音搜索与手动输入 -->
|
||||||
<view class="order-row">
|
<hospital-select
|
||||||
<text class="order-label">就诊医院</text>
|
label="就诊医院"
|
||||||
<input class="order-input" value="{{hospital}}" placeholder="请输入就诊医院" placeholder-class="input-placeholder" bindinput="onHospitalChange" />
|
value="{{hospital}}"
|
||||||
</view>
|
manual="{{hospitalManual}}"
|
||||||
|
options="{{hospitalOptions}}"
|
||||||
|
placeholder="请选择就诊医院"
|
||||||
|
disabled="{{submitting}}"
|
||||||
|
bindchange="onHospitalChange"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- 陪诊师性别要求 -->
|
<!-- 陪诊师性别要求 -->
|
||||||
<view class="order-row">
|
<view class="order-row">
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Page({
|
|||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
provinces: [],
|
provinces: [],
|
||||||
hospital: '',
|
hospital: '',
|
||||||
|
hospitalOptions: [],
|
||||||
|
hospitalManual: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
@@ -69,6 +71,14 @@ Page({
|
|||||||
this.pageReady = true
|
this.pageReady = true
|
||||||
|
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
// 启动时 app 已在预取,这里只等它落定后用最新列表刷新下拉;
|
||||||
|
// 没有可用医院时退回手动输入,避免下拉是空的还阻断下单
|
||||||
|
app.loadHospitals().then(() => {
|
||||||
|
this.refreshHospitalOptions()
|
||||||
|
if (!this.data.hospitalOptions.length && !this.data.hospitalManual) {
|
||||||
|
this.setData({ hospitalManual: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
await app.waitForAuth()
|
await app.waitForAuth()
|
||||||
if (app.globalData.user?._id) this.loadProfiles()
|
if (app.globalData.user?._id) this.loadProfiles()
|
||||||
},
|
},
|
||||||
@@ -96,6 +106,7 @@ Page({
|
|||||||
}
|
}
|
||||||
const provinces = service.areas || []
|
const provinces = service.areas || []
|
||||||
|
|
||||||
|
this.selectedHospitalId = ''
|
||||||
this.setData({
|
this.setData({
|
||||||
service,
|
service,
|
||||||
serviceIndex,
|
serviceIndex,
|
||||||
@@ -110,11 +121,13 @@ Page({
|
|||||||
provinces,
|
provinces,
|
||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
|
hospital: '',
|
||||||
|
hospitalManual: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
shippingAddress: '',
|
shippingAddress: '',
|
||||||
requiresAddress: !!booking.requiresAddress
|
requiresAddress: !!booking.requiresAddress
|
||||||
})
|
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||||
},
|
},
|
||||||
|
|
||||||
onServiceChange(e) {
|
onServiceChange(e) {
|
||||||
@@ -189,11 +202,42 @@ Page({
|
|||||||
|
|
||||||
onProvinceChange(e) {
|
onProvinceChange(e) {
|
||||||
const index = Number(e.detail.value)
|
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) {
|
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) {
|
onDateChange(e) {
|
||||||
@@ -226,7 +270,7 @@ Page({
|
|||||||
validateOrder() {
|
validateOrder() {
|
||||||
const data = this.data
|
const data = this.data
|
||||||
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
||||||
if (!data.hospital.trim()) return '请输入就诊医院'
|
if (!data.hospital.trim()) return data.hospitalManual ? '请输入就诊医院' : '请选择就诊医院'
|
||||||
if (!data.appointmentDate) return '请选择预约日期'
|
if (!data.appointmentDate) return '请选择预约日期'
|
||||||
if (!data.appointmentTime) return '请选择预约时间'
|
if (!data.appointmentTime) return '请选择预约时间'
|
||||||
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
||||||
@@ -291,6 +335,7 @@ Page({
|
|||||||
|
|
||||||
resetForm() {
|
resetForm() {
|
||||||
const provinces = this.data.provinces
|
const provinces = this.data.provinces
|
||||||
|
this.selectedHospitalId = ''
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedProfileId: '',
|
selectedProfileId: '',
|
||||||
patientName: '',
|
patientName: '',
|
||||||
@@ -299,6 +344,7 @@ Page({
|
|||||||
province: provinces[0] || '',
|
province: provinces[0] || '',
|
||||||
provinceIndex: 0,
|
provinceIndex: 0,
|
||||||
hospital: '',
|
hospital: '',
|
||||||
|
hospitalManual: false,
|
||||||
appointmentDate: '',
|
appointmentDate: '',
|
||||||
appointmentTime: '',
|
appointmentTime: '',
|
||||||
sessionIndex: 0,
|
sessionIndex: 0,
|
||||||
@@ -306,7 +352,7 @@ Page({
|
|||||||
genderIndex: 0,
|
genderIndex: 0,
|
||||||
remark: '',
|
remark: '',
|
||||||
shippingAddress: ''
|
shippingAddress: ''
|
||||||
})
|
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||||
this.idempotencyKey = this.createIdempotencyKey()
|
this.idempotencyKey = this.createIdempotencyKey()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
"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": "立即预约"
|
"navigationBarTitleText": "立即预约"
|
||||||
}
|
}
|
||||||
@@ -67,10 +67,15 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="order-row">
|
<hospital-select
|
||||||
<text class="order-label">就诊医院</text>
|
label="就诊医院"
|
||||||
<input class="order-input" value="{{hospital}}" placeholder="请输入就诊医院" placeholder-class="input-placeholder" bindinput="onHospitalChange" />
|
value="{{hospital}}"
|
||||||
</view>
|
manual="{{hospitalManual}}"
|
||||||
|
options="{{hospitalOptions}}"
|
||||||
|
placeholder="请选择就诊医院"
|
||||||
|
disabled="{{submitting}}"
|
||||||
|
bindchange="onHospitalChange"
|
||||||
|
/>
|
||||||
|
|
||||||
<view class="order-row">
|
<view class="order-row">
|
||||||
<text class="order-label">陪诊师性别</text>
|
<text class="order-label">陪诊师性别</text>
|
||||||
|
|||||||
+11
-11
@@ -87,7 +87,7 @@ page {
|
|||||||
.order-service-title {
|
.order-service-title {
|
||||||
display: block;
|
display: block;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: var(--fs-30);
|
font-size: var(--fs-32);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ page {
|
|||||||
display: block;
|
display: block;
|
||||||
margin-top: 6rpx;
|
margin-top: 6rpx;
|
||||||
color: var(--brand-ink);
|
color: var(--brand-ink);
|
||||||
font-size: var(--fs-26);
|
font-size: var(--fs-28);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ page {
|
|||||||
.order-label {
|
.order-label {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: var(--fs-28);
|
font-size: var(--fs-30);
|
||||||
letter-spacing: 1rpx;
|
letter-spacing: 1rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ page {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
margin-left: 24rpx;
|
margin-left: 24rpx;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: var(--fs-28);
|
font-size: var(--fs-30);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ page {
|
|||||||
.picker-value {
|
.picker-value {
|
||||||
display: block;
|
display: block;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: var(--fs-28);
|
font-size: var(--fs-30);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ page {
|
|||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
background: var(--paper);
|
background: var(--paper);
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: var(--fs-28);
|
font-size: var(--fs-30);
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,14 +187,14 @@ page {
|
|||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
margin-top: 10rpx;
|
margin-top: 10rpx;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: var(--fs-24);
|
font-size: var(--fs-26);
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-tip {
|
.address-tip {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
margin-top: 10rpx;
|
margin-top: 10rpx;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: var(--fs-24);
|
font-size: var(--fs-26);
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ page {
|
|||||||
|
|
||||||
.patient-chip-name {
|
.patient-chip-name {
|
||||||
color: var(--ink-2);
|
color: var(--ink-2);
|
||||||
font-size: var(--fs-26);
|
font-size: var(--fs-28);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ page {
|
|||||||
.patient-chip-phone {
|
.patient-chip-phone {
|
||||||
margin-top: 6rpx;
|
margin-top: 6rpx;
|
||||||
color: var(--ink-2);
|
color: var(--ink-2);
|
||||||
font-size: var(--fs-26);
|
font-size: var(--fs-28);
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-chip-add {
|
.patient-chip-add {
|
||||||
@@ -270,7 +270,7 @@ page {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
margin-right: 8rpx;
|
margin-right: 8rpx;
|
||||||
color: var(--brand-ink);
|
color: var(--brand-ink);
|
||||||
font-size: var(--fs-24);
|
font-size: var(--fs-26);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ Page({
|
|||||||
// 医院预约规则与下单页一致,均由订单关联的服务目录下发
|
// 医院预约规则与下单页一致,均由订单关联的服务目录下发
|
||||||
showHospitalPopup: false,
|
showHospitalPopup: false,
|
||||||
provinces: [],
|
provinces: [],
|
||||||
|
hospitalOptions: [],
|
||||||
minAppointmentDate: '',
|
minAppointmentDate: '',
|
||||||
fixedTime: false,
|
fixedTime: false,
|
||||||
timeOptions: [],
|
timeOptions: [],
|
||||||
@@ -356,24 +357,39 @@ Page({
|
|||||||
// ===== 医院预约信息编辑(底部弹窗) =====
|
// ===== 医院预约信息编辑(底部弹窗) =====
|
||||||
|
|
||||||
// 打开弹窗:用当前展示值填充表单(scheduleDate 已是 YYYY-MM-DD,可直接喂给 date picker)
|
// 打开弹窗:用当前展示值填充表单(scheduleDate 已是 YYYY-MM-DD,可直接喂给 date picker)
|
||||||
onEditHospital() {
|
async onEditHospital() {
|
||||||
|
await getApp().loadHospitals()
|
||||||
const r = this.data.record
|
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 sessions = this.data.service?.booking?.sessions || []
|
||||||
const sessionIndex = Math.max(0, sessions.findIndex(item => item.start === r.scheduleStartTime))
|
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({
|
this.setData({
|
||||||
showHospitalPopup: true,
|
showHospitalPopup: true,
|
||||||
|
hospitalOptions,
|
||||||
editHospital: {
|
editHospital: {
|
||||||
province: r.hospitalProvince || this.data.provinces[0] || '',
|
province,
|
||||||
provinceIndex,
|
provinceIndex,
|
||||||
name: r.hospitalName || '',
|
name,
|
||||||
address: r.hospitalAddress || '',
|
address: r.hospitalAddress || '',
|
||||||
department: r.hospitalDepartment || '',
|
department: r.hospitalDepartment || '',
|
||||||
doctor: r.hospitalDoctor || '',
|
doctor: r.hospitalDoctor || '',
|
||||||
medicalRecordNo: r.medicalRecordNo || '',
|
medicalRecordNo: r.medicalRecordNo || '',
|
||||||
scheduleDate: r.scheduleDate || '',
|
scheduleDate: r.scheduleDate || '',
|
||||||
startTime: r.scheduleStartTime || '',
|
startTime: r.scheduleStartTime || '',
|
||||||
sessionIndex
|
sessionIndex,
|
||||||
|
hospitalManual
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -386,12 +402,29 @@ Page({
|
|||||||
|
|
||||||
onProvinceChange(e) {
|
onProvinceChange(e) {
|
||||||
const index = Number(e.detail.value)
|
const index = Number(e.detail.value)
|
||||||
|
const province = this.data.provinces[index]
|
||||||
|
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||||
|
// 省份变了,已选医院可能不在新省份内,先清空再按新省份重建列表
|
||||||
this.setData({
|
this.setData({
|
||||||
'editHospital.provinceIndex': index,
|
'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) {
|
onScheduleDateChange(e) {
|
||||||
this.setData({ 'editHospital.scheduleDate': e.detail.value })
|
this.setData({ 'editHospital.scheduleDate': e.detail.value })
|
||||||
},
|
},
|
||||||
@@ -416,7 +449,7 @@ Page({
|
|||||||
onSaveHospital() {
|
onSaveHospital() {
|
||||||
const form = this.data.editHospital
|
const form = this.data.editHospital
|
||||||
if (!form.name || !form.name.trim()) {
|
if (!form.name || !form.name.trim()) {
|
||||||
wx.showToast({ title: '请输入就诊医院', icon: 'none' })
|
wx.showToast({ title: form.hospitalManual ? '请输入就诊医院' : '请选择就诊医院', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!form.scheduleDate) {
|
if (!form.scheduleDate) {
|
||||||
@@ -428,8 +461,10 @@ Page({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提交前再对齐一次服务目录口径,避免历史数据里的「北京」被后端判为未开通
|
||||||
|
const serviceProvince = this.data.provinces.find(item => getApp().isSameProvince(item, form.province))
|
||||||
const update = {
|
const update = {
|
||||||
'hospital.province': form.province || '',
|
'hospital.province': serviceProvince || form.province || '',
|
||||||
'hospital.name': form.name.trim(),
|
'hospital.name': form.name.trim(),
|
||||||
'hospital.address': (form.address || '').trim(),
|
'hospital.address': (form.address || '').trim(),
|
||||||
'hospital.department': (form.department || '').trim(),
|
'hospital.department': (form.department || '').trim(),
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"navigationBarTitleText": "预约记录详情",
|
"navigationBarTitleText": "预约记录详情",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
|
"hospital-select": "/components/hospital-select/index"
|
||||||
},
|
},
|
||||||
"enablePullDownRefresh": true,
|
"enablePullDownRefresh": true,
|
||||||
"backgroundTextStyle": "dark"
|
"backgroundTextStyle": "dark"
|
||||||
|
|||||||
@@ -283,17 +283,15 @@
|
|||||||
<view class="form-picker-value">{{editHospital.province || '请选择省份'}}</view>
|
<view class="form-picker-value">{{editHospital.province || '请选择省份'}}</view>
|
||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
<view class="form-row">
|
<hospital-select
|
||||||
<text class="form-label">就诊医院</text>
|
label="就诊医院"
|
||||||
<input
|
|
||||||
class="form-input"
|
|
||||||
value="{{editHospital.name}}"
|
value="{{editHospital.name}}"
|
||||||
placeholder="请输入医院名称"
|
manual="{{editHospital.hospitalManual}}"
|
||||||
placeholder-class="input-placeholder"
|
options="{{hospitalOptions}}"
|
||||||
bindinput="onHospitalFieldInput"
|
placeholder="请选择医院"
|
||||||
data-field="name"
|
compact="{{true}}"
|
||||||
|
bindchange="onHospitalSelectChange"
|
||||||
/>
|
/>
|
||||||
</view>
|
|
||||||
<view class="form-row">
|
<view class="form-row">
|
||||||
<text class="form-label">医院地址</text>
|
<text class="form-label">医院地址</text>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ const API = {
|
|||||||
update: (data) => requestUser.post('/user/update', data),
|
update: (data) => requestUser.post('/user/update', data),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 医院基础信息(公开接口):启动预取与下单页医院下拉共用
|
||||||
|
hospital: {
|
||||||
|
getHospitals: (params) => request.get('/health/hospital', params),
|
||||||
|
},
|
||||||
|
|
||||||
escort: {
|
escort: {
|
||||||
getMyRecords: (params) => request.get('/health/escort-record/my', params),
|
getMyRecords: (params) => request.get('/health/escort-record/my', params),
|
||||||
getAttendantRecords: (params) => request.get('/health/escort-record/attendant', params),
|
getAttendantRecords: (params) => request.get('/health/escort-record/attendant', params),
|
||||||
|
|||||||
Reference in New Issue
Block a user