feat(hospital): 医院选择改为底部弹层并适配键盘
面板通过 root-portal 挂到页面根部,脱离父级 scroll-view 与 transform 层叠上下文, 两个预约入口共用同一选择面板;展开高度按窗口与键盘高度计算,搜索与手动填写 关闭 adjust-position,删除原先按行高推算列表高度和自动上滚页面的逻辑。
This commit is contained in:
@@ -1,73 +1,46 @@
|
||||
<view class="hospital-select {{compact ? 'is-compact' : ''}} {{disabled ? 'is-disabled' : ''}} {{open ? 'is-open' : ''}}">
|
||||
<!-- 展开时的全屏遮罩:点击任意空白处收起,强化「可开可收」的下拉感知 -->
|
||||
<view class="hospital-mask" wx:if="{{open}}" bindtap="onClose" catchtouchmove="noop"></view>
|
||||
<view class="hospital-row">
|
||||
<view class="hospital-select {{compact ? 'is-compact' : ''}} {{disabled ? 'is-disabled' : ''}}">
|
||||
<view class="hospital-row" bindtap="onOpen" aria-role="button" aria-label="{{label}}:{{value || placeholder}}" aria-expanded="{{open}}">
|
||||
<text class="hospital-label">{{label}}</text>
|
||||
<view class="hospital-value" bindtap="onOpen">
|
||||
<view class="hospital-value">
|
||||
<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}}">
|
||||
<view class="hospital-search">
|
||||
<input
|
||||
class="hospital-search-input"
|
||||
value="{{keyword}}"
|
||||
placeholder="{{searchPlaceholder}}"
|
||||
placeholder-class="hospital-placeholder"
|
||||
confirm-type="search"
|
||||
bindinput="onKeywordInput"
|
||||
/>
|
||||
<view class="hospital-search-close" bindtap="onClose" aria-role="button" aria-label="收起医院列表">
|
||||
<view class="hospital-collapse-arrow"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 填写其他医院:列表里没有的医院走这里 -->
|
||||
<view wx:if="{{manualEntry}}" class="hospital-manual-panel">
|
||||
<input
|
||||
class="hospital-manual-input"
|
||||
value="{{manualName}}"
|
||||
placeholder="请输入医院名称"
|
||||
placeholder-class="hospital-placeholder"
|
||||
focus="{{manualEntry}}"
|
||||
confirm-type="done"
|
||||
bindinput="onManualNameInput"
|
||||
bindconfirm="onConfirmManual"
|
||||
/>
|
||||
<text class="hospital-manual-confirm" catchtap="onConfirmManual">确定</text>
|
||||
<text class="hospital-manual-cancel" catchtap="onCancelManual">返回列表</text>
|
||||
</view>
|
||||
|
||||
<scroll-view
|
||||
wx:elif="{{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>
|
||||
</view>
|
||||
|
||||
<!-- 其他医院:常驻入口,不用先搜出空结果才找得到 -->
|
||||
<view wx:if="{{!manualEntry}}" class="hospital-other" bindtap="onStartManual">
|
||||
<text class="hospital-other-text">其他医院(列表里没有?手动填写名称)</text>
|
||||
<view class="hospital-chevron"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 脱离父级 scroll-view 和 transform 层叠上下文,两个预约入口共享同一选择面板。 -->
|
||||
<root-portal wx:if="{{open}}">
|
||||
<view class="hospital-overlay">
|
||||
<view class="hospital-mask" bindtap="onClose" catchtouchmove="noop"></view>
|
||||
<view class="hospital-panel {{keyboardHeight ? 'keyboard-open' : ''}}" style="height: {{panelHeight}}px; bottom: {{keyboardHeight}}px;" catchtap="noop">
|
||||
<view class="hospital-heading" catchtouchmove="noop">
|
||||
<text class="hospital-title">{{manualEntry ? '手动填写医院' : '选择医院'}}</text>
|
||||
<view class="hospital-close" bindtap="onClose" aria-role="button" aria-label="关闭医院选择"><view class="close-mark"></view></view>
|
||||
</view>
|
||||
<block wx:if="{{manualEntry}}">
|
||||
<view class="hospital-manual-panel">
|
||||
<input class="hospital-manual-input" value="{{manualName}}" placeholder="请输入医院名称" placeholder-class="hospital-placeholder" focus="{{manualEntry}}" adjust-position="{{false}}" confirm-type="done" bindinput="onManualNameInput" bindconfirm="onConfirmManual" bindkeyboardheightchange="onKeyboardHeightChange" />
|
||||
<view class="manual-actions">
|
||||
<button class="manual-back" size="default" bindtap="onCancelManual">返回列表</button>
|
||||
<button class="manual-confirm" size="default" disabled="{{!manualName}}" bindtap="onConfirmManual">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="hospital-search" catchtouchmove="noop">
|
||||
<input class="hospital-search-input" value="{{keyword}}" placeholder="{{searchPlaceholder}}" placeholder-class="hospital-placeholder" adjust-position="{{false}}" confirm-type="search" bindinput="onKeywordInput" bindkeyboardheightchange="onKeyboardHeightChange" />
|
||||
</view>
|
||||
<scroll-view class="hospital-options" scroll-y enhanced show-scrollbar="{{true}}">
|
||||
<view class="hospital-option {{item.name === value ? 'is-selected' : ''}}" wx:for="{{filtered}}" wx:key="_id" data-index="{{index}}" bindtap="onSelect" aria-role="button" aria-label="{{item.name}} {{item.address || ''}}">
|
||||
<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>
|
||||
<view class="hospital-option-selected" wx:if="{{item.name === value}}" aria-label="已选"></view>
|
||||
</view>
|
||||
<view class="hospital-empty" wx:if="{{!filtered.length}}">{{keyword ? '没有找到匹配的医院' : '暂无可选医院'}}</view>
|
||||
</scroll-view>
|
||||
<view class="hospital-other" bindtap="onStartManual" catchtouchmove="noop" aria-role="button">手动填写医院</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</root-portal>
|
||||
Reference in New Issue
Block a user