Compare commits
14
Commits
fde150c8c0
...
37ef98e12b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37ef98e12b | ||
|
|
3052ac6ceb | ||
|
|
5dd94255f5 | ||
|
|
511d5d6cd2 | ||
|
|
cac0aaf47a | ||
|
|
8eb7bc9e7a | ||
|
|
f70a8f8b72 | ||
|
|
67157fa919 | ||
|
|
14b38f1ff1 | ||
|
|
4ae376204d | ||
|
|
8aebbccc58 | ||
|
|
e3c4c14720 | ||
|
|
6536abb240 | ||
|
|
e3692043c1 |
@@ -4,6 +4,57 @@ const request = require('./utils/request.js')
|
||||
|
||||
// 服务列表缓存:只服务首屏秒开,命中后仍会请求最新数据覆盖
|
||||
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({
|
||||
onLaunch() {
|
||||
@@ -11,7 +62,9 @@ App({
|
||||
// 登录逻辑只在 app 里有一份,request 层不碰
|
||||
request.setUnauthorizedHandler(() => this.silentSignin())
|
||||
|
||||
this.globalData.hospitals = this.getCachedHospitals()
|
||||
this.loadServices()
|
||||
this.loadHospitals()
|
||||
// 服务协议只有协议页用,改成该页首次进入时再拉(页面里已有 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() {
|
||||
if (this.globalData.agreementReady) return this.globalData.agreementReady
|
||||
this.globalData.agreementReady = API.resource.getAgreement()
|
||||
@@ -210,6 +349,8 @@ App({
|
||||
chatSocket: null,
|
||||
services: [],
|
||||
servicesReady: null,
|
||||
hospitals: [],
|
||||
hospitalsReady: null,
|
||||
agreement: null,
|
||||
agreementReady: null,
|
||||
authReady: null,
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// 医院选择:列表可搜索(名称 / 主体名 / 全拼 / 拼音首字母);列表里没有的走「其他医院」手填
|
||||
const SEARCH_PLACEHOLDER = '搜索医院名称或拼音'
|
||||
// 单行选项高度:字号放大后重新核算(名称 32rpx + 地址 28rpx + 上下留白)
|
||||
const OPTION_HEIGHT = 132
|
||||
|
||||
// 关键词去掉空白、转小写:中文原样匹配,拼音统一小写比较
|
||||
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: '' },
|
||||
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,
|
||||
manualEntry: false,
|
||||
manualName: '',
|
||||
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) return
|
||||
if (this.data.open) {
|
||||
this.onClose()
|
||||
return
|
||||
}
|
||||
this.setData({ open: true, keyword: '', manualEntry: false })
|
||||
this.refreshFiltered(this.data.options, '')
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.setData({ open: false, keyword: '', optionsHeight: 0, manualEntry: false })
|
||||
},
|
||||
|
||||
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,
|
||||
})
|
||||
},
|
||||
|
||||
// 「其他医院」:展开手填输入框;有搜索词时带入搜索词,否则带入当前已填名称
|
||||
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 })
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<view class="hospital-select {{compact ? 'is-compact' : ''}} {{disabled ? 'is-disabled' : ''}}">
|
||||
<view class="hospital-row">
|
||||
<text class="hospital-label">{{label}}</text>
|
||||
<view 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}}">
|
||||
<view class="hospital-search">
|
||||
<input
|
||||
class="hospital-search-input"
|
||||
value="{{keyword}}"
|
||||
placeholder="{{searchPlaceholder}}"
|
||||
placeholder-class="hospital-placeholder"
|
||||
confirm-type="search"
|
||||
bindinput="onKeywordInput"
|
||||
/>
|
||||
<text class="hospital-search-close" bindtap="onClose">收起</text>
|
||||
</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>
|
||||
</view>
|
||||
</view>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/* 行标签与取值统一 30rpx,与页面表单(.order-label / .order-value)同档 */
|
||||
.hospital-label {
|
||||
color: var(--muted, #6F655C);
|
||||
font-size: var(--fs-30, 30rpx);
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
/* compact 档用于「预约记录 · 编辑」表单,跟该页 .form-label(28) / .form-input(30) 对齐 */
|
||||
.is-compact .hospital-label {
|
||||
font-size: var(--fs-28, 28rpx);
|
||||
}
|
||||
|
||||
.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-30, 30rpx);
|
||||
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-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;
|
||||
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);
|
||||
}
|
||||
|
||||
/* 展开面板:浅橙衬底 + 2rpx 浅橙描边托形,与白卡拉开边界(不用阴影) */
|
||||
.hospital-panel {
|
||||
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(--sep, #E5DACC);
|
||||
}
|
||||
|
||||
.hospital-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: var(--ink, #2B2521);
|
||||
font-size: var(--fs-30, 30rpx);
|
||||
}
|
||||
|
||||
.hospital-search-close {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
color: var(--muted, #6F655C);
|
||||
font-size: var(--fs-28, 28rpx);
|
||||
}
|
||||
|
||||
.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(--sep, #E5DACC);
|
||||
}
|
||||
|
||||
.hospital-option:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.hospital-option:active {
|
||||
background: var(--white, #FFFFFF);
|
||||
}
|
||||
|
||||
.hospital-option-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hospital-option-name {
|
||||
display: block;
|
||||
color: var(--ink, #2B2521);
|
||||
font-size: var(--fs-30, 30rpx);
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.hospital-option-sub {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: var(--muted, #6F655C);
|
||||
font-size: var(--fs-26, 26rpx);
|
||||
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-26, 26rpx);
|
||||
}
|
||||
|
||||
.hospital-empty {
|
||||
padding: 32rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hospital-empty-text {
|
||||
display: block;
|
||||
color: var(--muted, #6F655C);
|
||||
font-size: var(--fs-30, 30rpx);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ Page({
|
||||
provinceIndex: 0,
|
||||
provinces: [],
|
||||
hospital: '',
|
||||
hospitalOptions: [],
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
minAppointmentDate: '',
|
||||
@@ -64,6 +66,11 @@ Page({
|
||||
}
|
||||
|
||||
this.applyBookingConfig(service)
|
||||
// 启动时 app 已在预取医院;这里等它落定后刷新下拉,
|
||||
// 列表为空时组件内的「其他医院」入口仍可手填
|
||||
getApp().loadHospitals().then(() => {
|
||||
this.refreshHospitalOptions()
|
||||
})
|
||||
const serviceView = {
|
||||
...service,
|
||||
notices: (service.notices || []).map(text => ({ id: text, text }))
|
||||
@@ -108,6 +115,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 +126,10 @@ Page({
|
||||
provinces,
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
hospital: '',
|
||||
hospitalCustom: false,
|
||||
requiresAddress: !!booking.requiresAddress
|
||||
})
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
},
|
||||
|
||||
getServiceIcon(title) {
|
||||
@@ -170,6 +180,7 @@ Page({
|
||||
selectedPatient: null,
|
||||
showOrderPopup: true
|
||||
})
|
||||
this.refreshHospitalOptions()
|
||||
this.loadProfiles()
|
||||
},
|
||||
|
||||
@@ -214,11 +225,43 @@ 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: '',
|
||||
hospitalCustom: false
|
||||
}, () => this.refreshHospitalOptions(province))
|
||||
},
|
||||
|
||||
// 按当前省份重建医院列表;已选医院按 _id 保留,避免网络刷新后选中值丢失
|
||||
refreshHospitalOptions(province = this.data.province) {
|
||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||
let hospital = ''
|
||||
|
||||
if (this.data.hospitalCustom) {
|
||||
// 「其他医院」手填的名称不在库内,刷新列表时原样保留
|
||||
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, hospitalCustom: manual })
|
||||
},
|
||||
|
||||
onDateChange(e) {
|
||||
@@ -251,7 +294,9 @@ Page({
|
||||
validateOrder() {
|
||||
const data = this.data
|
||||
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
||||
if (!data.hospital.trim()) return '请输入就诊医院'
|
||||
if (!data.hospital.trim()) {
|
||||
return data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称'
|
||||
}
|
||||
if (!data.appointmentDate) return '请选择预约日期'
|
||||
if (!data.appointmentTime) return '请选择预约时间'
|
||||
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
||||
@@ -309,6 +354,7 @@ Page({
|
||||
|
||||
resetForm() {
|
||||
const provinces = this.data.provinces
|
||||
this.selectedHospitalId = ''
|
||||
this.setData({
|
||||
selectedProfileId: '',
|
||||
patientName: '',
|
||||
@@ -317,6 +363,7 @@ Page({
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
hospital: '',
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
sessionIndex: 0,
|
||||
@@ -324,7 +371,7 @@ Page({
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: ''
|
||||
})
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
this.idempotencyKey = ''
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"hospital-select": "/components/hospital-select/index"
|
||||
},
|
||||
"navigationBarTitleText": "服务详情"
|
||||
}
|
||||
|
||||
@@ -115,10 +115,10 @@
|
||||
<view class="patient-chip {{selectedProfileId === item._id ? 'active' : ''}}" wx:for="{{profiles}}" wx:key="_id"
|
||||
data-id="{{item._id}}" bindtap="onSelectProfile">
|
||||
<text class="patient-chip-name">{{item.name}}</text>
|
||||
<text class="patient-chip-phone">{{item.mobile}}</text>
|
||||
</view>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile">
|
||||
<text class="patient-chip-name">+ 添加就诊人</text>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile" aria-role="button" aria-label="增加就诊人">
|
||||
<t-icon name="add" size="28rpx" color="#9B4508" />
|
||||
<text class="patient-chip-name">增加</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -150,11 +150,15 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<!-- 就诊医院 -->
|
||||
<view class="order-row">
|
||||
<text class="order-label">就诊医院</text>
|
||||
<input class="order-input" value="{{hospital}}" placeholder="请输入就诊医院" placeholder-class="input-placeholder" bindinput="onHospitalChange" />
|
||||
</view>
|
||||
<!-- 就诊医院:自定义搜索选择,支持中文/拼音搜索与手动输入 -->
|
||||
<hospital-select
|
||||
label="就诊医院"
|
||||
value="{{hospital}}"
|
||||
options="{{hospitalOptions}}"
|
||||
placeholder="请选择就诊医院"
|
||||
disabled="{{submitting}}"
|
||||
bindchange="onHospitalChange"
|
||||
/>
|
||||
|
||||
<!-- 陪诊师性别要求 -->
|
||||
<view class="order-row">
|
||||
|
||||
@@ -463,7 +463,7 @@ page {
|
||||
|
||||
.order-service-title {
|
||||
display: block;
|
||||
font-size: var(--fs-30);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
line-height: 1.4;
|
||||
@@ -499,7 +499,7 @@ page {
|
||||
|
||||
.order-label {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
@@ -509,7 +509,7 @@ page {
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -525,7 +525,7 @@ page {
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -545,7 +545,7 @@ page {
|
||||
.picker-value {
|
||||
display: block;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ page {
|
||||
border-radius: 12rpx;
|
||||
background: var(--paper);
|
||||
border: 2rpx solid var(--line);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -573,14 +573,14 @@ page {
|
||||
.textarea-count {
|
||||
align-self: flex-end;
|
||||
margin-top: 10rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.address-tip {
|
||||
align-self: flex-start;
|
||||
margin-top: 10rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -600,7 +600,9 @@ page {
|
||||
.patient-chip {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
min-width: 180rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 140rpx;
|
||||
padding: 16rpx 24rpx;
|
||||
border-radius: 16rpx;
|
||||
background: var(--paper);
|
||||
@@ -620,7 +622,7 @@ page {
|
||||
}
|
||||
|
||||
.patient-chip-name {
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
@@ -629,14 +631,15 @@ page {
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
.patient-chip-phone {
|
||||
margin-top: 6rpx;
|
||||
font-size: var(--fs-26);
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
.patient-chip-add {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4rpx;
|
||||
/* 虚线描边 + 白底:与「已选就诊人」的实心浅橙底区分开,
|
||||
一眼看出这是动作入口而不是某个就诊人 */
|
||||
background: var(--white);
|
||||
border: 2rpx dashed var(--brand-line);
|
||||
}
|
||||
|
||||
.patient-chip-add .patient-chip-name {
|
||||
@@ -665,7 +668,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-right: 8rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
font-weight: 700;
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
+167
-28
@@ -21,6 +21,8 @@ Page({
|
||||
provinceIndex: 0,
|
||||
provinces: [],
|
||||
hospital: '',
|
||||
hospitalOptions: [],
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
minAppointmentDate: '',
|
||||
@@ -32,6 +34,9 @@ Page({
|
||||
remark: '',
|
||||
shippingAddress: '',
|
||||
requiresAddress: false,
|
||||
payChannel: 'online_wechat',
|
||||
// 点击「提交预约」后弹出支付方式选择,默认微信支付
|
||||
showPayPopup: false,
|
||||
gender: '不限',
|
||||
genderIndex: 0,
|
||||
genderOptions: ['不限', '男', '女']
|
||||
@@ -69,6 +74,11 @@ Page({
|
||||
this.pageReady = true
|
||||
|
||||
const app = getApp()
|
||||
// 启动时 app 已在预取,这里只等它落定后用最新列表刷新下拉;
|
||||
// 列表为空时组件内的「其他医院」入口仍可手填,不会阻断下单
|
||||
app.loadHospitals().then(() => {
|
||||
this.refreshHospitalOptions()
|
||||
})
|
||||
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: '',
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
shippingAddress: '',
|
||||
requiresAddress: !!booking.requiresAddress
|
||||
})
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
},
|
||||
|
||||
onServiceChange(e) {
|
||||
@@ -189,11 +202,43 @@ 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: '',
|
||||
hospitalCustom: false
|
||||
}, () => this.refreshHospitalOptions(province))
|
||||
},
|
||||
|
||||
// 按当前省份重建医院列表;已选医院按 _id 保留,避免网络刷新后选中值丢失
|
||||
refreshHospitalOptions(province = this.data.province) {
|
||||
const hospitalOptions = getApp().getHospitalsByProvince(province)
|
||||
let hospital = ''
|
||||
|
||||
if (this.data.hospitalCustom) {
|
||||
// 「其他医院」手填的名称不在库内,刷新列表时原样保留
|
||||
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, hospitalCustom: manual })
|
||||
},
|
||||
|
||||
onDateChange(e) {
|
||||
@@ -219,6 +264,13 @@ Page({
|
||||
this.setData({ remark: e.detail.value })
|
||||
},
|
||||
|
||||
onPayChannelChange(e) {
|
||||
const channel = e.currentTarget.dataset.channel
|
||||
if (!['online_wechat', 'offline'].includes(channel)) return
|
||||
if (this.data.submitting) return
|
||||
this.setData({ payChannel: channel })
|
||||
},
|
||||
|
||||
onShippingAddressChange(e) {
|
||||
this.setData({ shippingAddress: e.detail.value })
|
||||
},
|
||||
@@ -226,7 +278,9 @@ Page({
|
||||
validateOrder() {
|
||||
const data = this.data
|
||||
if (!data.selectedProfileId || !data.selectedPatient) return '请选择就诊人'
|
||||
if (!data.hospital.trim()) return '请输入就诊医院'
|
||||
if (!data.hospital.trim()) {
|
||||
return data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称'
|
||||
}
|
||||
if (!data.appointmentDate) return '请选择预约日期'
|
||||
if (!data.appointmentTime) return '请选择预约时间'
|
||||
if (data.requiresAddress && !data.shippingAddress.trim()) return '请填写完整收货地址'
|
||||
@@ -238,7 +292,26 @@ Page({
|
||||
|
||||
async submitOrder() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ submitting: true })
|
||||
// 先做一次表单校验,避免用户选完支付方式才发现信息没填全
|
||||
const error = this.validateOrder()
|
||||
if (error) {
|
||||
wx.showToast({ title: error, icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ showPayPopup: true, payChannel: 'online_wechat' })
|
||||
},
|
||||
|
||||
onClosePayPopup() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ showPayPopup: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认支付方式后真正提交订单
|
||||
*/
|
||||
async onConfirmPay() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({ submitting: true, showPayPopup: false })
|
||||
try {
|
||||
const loggedIn = await this.ensureLogin()
|
||||
if (loggedIn === null) return
|
||||
@@ -254,33 +327,24 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
const data = this.data
|
||||
const sexMap = { 男: 'male', 女: 'female' }
|
||||
const orderData = {
|
||||
idempotencyKey: this.idempotencyKey,
|
||||
healthProfileId: data.selectedProfileId,
|
||||
escort: {
|
||||
serviceId: data.service.id,
|
||||
sexRequirement: sexMap[data.gender] || 'none'
|
||||
},
|
||||
hospital: {
|
||||
province: data.province,
|
||||
name: data.hospital.trim()
|
||||
},
|
||||
schedule: {
|
||||
date: data.appointmentDate,
|
||||
startTime: data.appointmentTime
|
||||
},
|
||||
shippingAddress: { address: data.shippingAddress.trim() },
|
||||
notes: { patientNote: data.remark.trim() }
|
||||
}
|
||||
const payChannel = this.data.payChannel
|
||||
const orderData = this.buildOrderData()
|
||||
|
||||
// 网络重试沿用同一幂等键,服务端只创建一笔订单。
|
||||
const res = await API.escort.createRecord(orderData)
|
||||
if (res.code !== 0) throw new Error(res.msg || '下单失败')
|
||||
wx.showToast({ title: '下单成功', icon: 'success' })
|
||||
const record = res.data?.record
|
||||
this.resetForm()
|
||||
wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
|
||||
if (payChannel === 'offline') {
|
||||
wx.showToast({ title: '线下支付,请联系平台收款', icon: 'none' })
|
||||
wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
return
|
||||
}
|
||||
|
||||
// 选微信支付:下单成功后立即拉起收银台,支付结果以后端查单为准
|
||||
if (record?._id) await this.startWechatPay(record._id)
|
||||
else wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
} catch (err) {
|
||||
console.log('下单失败', err)
|
||||
wx.showToast({ title: err.message || '网络请求失败,请重试', icon: 'none' })
|
||||
@@ -289,8 +353,82 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
buildOrderData() {
|
||||
const data = this.data
|
||||
const sexMap = { 男: 'male', 女: 'female' }
|
||||
return {
|
||||
idempotencyKey: this.idempotencyKey,
|
||||
healthProfileId: data.selectedProfileId,
|
||||
escort: {
|
||||
serviceId: data.service.id,
|
||||
sexRequirement: sexMap[data.gender] || 'none'
|
||||
},
|
||||
hospital: {
|
||||
province: data.province,
|
||||
name: data.hospital.trim()
|
||||
},
|
||||
schedule: {
|
||||
date: data.appointmentDate,
|
||||
startTime: data.appointmentTime
|
||||
},
|
||||
shippingAddress: { address: data.shippingAddress.trim() },
|
||||
notes: { patientNote: data.remark.trim() },
|
||||
payment: { payChannel: data.payChannel }
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 发起微信支付:payOrder → requestPayment → 查单确认
|
||||
* 支付按钮防抖(this.paying),前端回调只作提示,最终状态以 getPayStatus 为准
|
||||
*/
|
||||
async startWechatPay(recordId) {
|
||||
if (this.paying) return
|
||||
this.paying = true
|
||||
let paid = false
|
||||
try {
|
||||
const res = await API.escort.payOrder(recordId)
|
||||
if (res.code !== 0 || !res.data?.payParams) {
|
||||
wx.showToast({ title: res.msg || '支付发起失败,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const payResult = await new Promise((resolve) => {
|
||||
wx.requestPayment({
|
||||
...res.data.payParams,
|
||||
success: () => resolve({ ok: true }),
|
||||
fail: (err) => resolve({ ok: false, err })
|
||||
})
|
||||
})
|
||||
|
||||
if (!payResult.ok) {
|
||||
const errMsg = payResult.err?.errMsg || ''
|
||||
if (/cancel/i.test(errMsg)) {
|
||||
wx.showToast({ title: '已取消支付', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 非取消失败可能是网络中断但支付已成功:先查单兜底
|
||||
}
|
||||
|
||||
const statusRes = await API.escort.getPayStatus(recordId).catch(() => null)
|
||||
paid = statusRes?.code === 0 && statusRes.data?.paymentStatus === 'paid'
|
||||
wx.showToast({
|
||||
title: paid ? '支付成功' : '支付结果确认中',
|
||||
icon: paid ? 'success' : 'none'
|
||||
})
|
||||
} catch (err) {
|
||||
console.log('发起支付失败', err)
|
||||
wx.showToast({ title: '支付发起失败,请稍后重试', icon: 'none' })
|
||||
} finally {
|
||||
this.paying = false
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${recordId}` })
|
||||
}, paid ? 600 : 0)
|
||||
}
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
const provinces = this.data.provinces
|
||||
this.selectedHospitalId = ''
|
||||
this.setData({
|
||||
selectedProfileId: '',
|
||||
patientName: '',
|
||||
@@ -299,6 +437,7 @@ Page({
|
||||
province: provinces[0] || '',
|
||||
provinceIndex: 0,
|
||||
hospital: '',
|
||||
hospitalCustom: false,
|
||||
appointmentDate: '',
|
||||
appointmentTime: '',
|
||||
sessionIndex: 0,
|
||||
@@ -306,7 +445,7 @@ Page({
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: ''
|
||||
})
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
this.idempotencyKey = this.createIdempotencyKey()
|
||||
}
|
||||
})
|
||||
@@ -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": "立即预约"
|
||||
}
|
||||
@@ -36,10 +36,10 @@
|
||||
<view class="patient-chip {{selectedProfileId === item._id ? 'active' : ''}}" wx:for="{{profiles}}" wx:key="_id"
|
||||
data-id="{{item._id}}" bindtap="onSelectProfile">
|
||||
<text class="patient-chip-name">{{item.name}}</text>
|
||||
<text class="patient-chip-phone">{{item.mobile}}</text>
|
||||
</view>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile">
|
||||
<text class="patient-chip-name">+ 添加就诊人</text>
|
||||
<view class="patient-chip patient-chip-add" bindtap="goToAddProfile" aria-role="button" aria-label="增加就诊人">
|
||||
<t-icon name="add" size="28rpx" color="#9B4508" />
|
||||
<text class="patient-chip-name">增加</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -67,10 +67,14 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="order-row">
|
||||
<text class="order-label">就诊医院</text>
|
||||
<input class="order-input" value="{{hospital}}" placeholder="请输入就诊医院" placeholder-class="input-placeholder" bindinput="onHospitalChange" />
|
||||
</view>
|
||||
<hospital-select
|
||||
label="就诊医院"
|
||||
value="{{hospital}}"
|
||||
options="{{hospitalOptions}}"
|
||||
placeholder="请选择就诊医院"
|
||||
disabled="{{submitting}}"
|
||||
bindchange="onHospitalChange"
|
||||
/>
|
||||
|
||||
<view class="order-row">
|
||||
<text class="order-label">陪诊师性别</text>
|
||||
@@ -131,4 +135,48 @@
|
||||
<text class="page-state-text">{{pageError}}</text>
|
||||
<button class="page-retry" bindtap="retryLoad">重新加载</button>
|
||||
</view>
|
||||
|
||||
<!-- 支付方式选择弹窗:点击「提交预约」后出现,默认微信支付 -->
|
||||
<view class="popup-mask {{showPayPopup ? 'show' : ''}}" bindtap="onClosePayPopup"></view>
|
||||
<view class="popup-content {{showPayPopup ? 'show' : ''}}">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">选择支付方式</text>
|
||||
<view class="popup-close" aria-role="button" aria-label="关闭弹窗" bindtap="onClosePayPopup">
|
||||
<t-icon name="close" size="40rpx" color="#6F655C" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="popup-body">
|
||||
<view class="pay-channel-options">
|
||||
<view
|
||||
class="pay-channel-option {{payChannel === 'online_wechat' ? 'active' : ''}}"
|
||||
data-channel="online_wechat"
|
||||
bindtap="onPayChannelChange"
|
||||
>
|
||||
<view class="pay-channel-text">
|
||||
<text class="pay-channel-title">微信支付</text>
|
||||
<text class="pay-channel-desc">提交后立即拉起收银台</text>
|
||||
</view>
|
||||
<view class="pay-channel-radio {{payChannel === 'online_wechat' ? 'checked' : ''}}"></view>
|
||||
</view>
|
||||
<view
|
||||
class="pay-channel-option {{payChannel === 'offline' ? 'active' : ''}}"
|
||||
data-channel="offline"
|
||||
bindtap="onPayChannelChange"
|
||||
>
|
||||
<view class="pay-channel-text">
|
||||
<text class="pay-channel-title">线下支付</text>
|
||||
<text class="pay-channel-desc">平台收款后确认订单</text>
|
||||
</view>
|
||||
<view class="pay-channel-radio {{payChannel === 'offline' ? 'checked' : ''}}"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="pay-popup-tip">微信支付可立即完成付款;线下支付由平台收款后再确认订单。</text>
|
||||
</view>
|
||||
<view class="popup-footer">
|
||||
<view class="popup-btn popup-btn-ghost" bindtap="onClosePayPopup">取消</view>
|
||||
<view class="popup-btn popup-btn-primary" bindtap="onConfirmPay">
|
||||
{{submitting ? '提交中...' : '确认提交'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
+186
-17
@@ -87,7 +87,7 @@ page {
|
||||
.order-service-title {
|
||||
display: block;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-30);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ page {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ page {
|
||||
.order-label {
|
||||
flex-shrink: 0;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ page {
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ page {
|
||||
.picker-value {
|
||||
display: block;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ page {
|
||||
border-radius: 12rpx;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@@ -187,14 +187,14 @@ page {
|
||||
align-self: flex-end;
|
||||
margin-top: 10rpx;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
}
|
||||
|
||||
.address-tip {
|
||||
align-self: flex-start;
|
||||
margin-top: 10rpx;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@@ -212,8 +212,11 @@ page {
|
||||
.patient-chip {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
min-width: 180rpx;
|
||||
/* 140rpx:只显示姓名,胶囊按名字长度收紧,不再为手机号预留宽度 */
|
||||
min-width: 140rpx;
|
||||
padding: 16rpx 24rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 16rpx;
|
||||
@@ -233,7 +236,7 @@ page {
|
||||
|
||||
.patient-chip-name {
|
||||
color: var(--ink-2);
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -242,14 +245,15 @@ page {
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
.patient-chip-phone {
|
||||
margin-top: 6rpx;
|
||||
color: var(--ink-2);
|
||||
font-size: var(--fs-26);
|
||||
}
|
||||
|
||||
.patient-chip-add {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4rpx;
|
||||
/* 虚线描边 + 白底:与「已选就诊人」的实心浅橙底区分开,
|
||||
一眼看出这是动作入口而不是某个就诊人 */
|
||||
background: var(--white);
|
||||
border: 2rpx dashed var(--brand-line);
|
||||
}
|
||||
|
||||
.add-profile-tip {
|
||||
@@ -270,7 +274,7 @@ page {
|
||||
min-width: 0;
|
||||
margin-right: 8rpx;
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -375,6 +379,171 @@ page {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 支付方式:两张可选卡片,选中态沿用品牌橙 */
|
||||
.pay-channel-options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.pay-channel-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 24rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 18rpx;
|
||||
background: var(--paper);
|
||||
}
|
||||
|
||||
.pay-channel-option.active {
|
||||
border-color: var(--brand-line);
|
||||
background: var(--brand-soft);
|
||||
}
|
||||
|
||||
.pay-channel-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.pay-channel-title {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pay-channel-desc {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
}
|
||||
|
||||
.pay-channel-radio {
|
||||
flex-shrink: 0;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 50%;
|
||||
background: var(--white);
|
||||
}
|
||||
|
||||
.pay-channel-radio.checked {
|
||||
border-color: var(--brand-strong);
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
.pay-popup-tip {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* ===== 支付方式底部弹窗 ===== */
|
||||
.popup-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 200;
|
||||
background: rgba(43, 37, 33, 0.45);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s ease, visibility 0.3s ease;
|
||||
}
|
||||
|
||||
.popup-mask.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 201;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 70vh;
|
||||
background: var(--white);
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.3s ease-out;
|
||||
}
|
||||
|
||||
.popup-content.show {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-shrink: 0;
|
||||
padding: 28rpx 32rpx;
|
||||
border-bottom: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
padding: 8rpx;
|
||||
margin: -8rpx;
|
||||
}
|
||||
|
||||
.popup-close:active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20rpx 32rpx 28rpx;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
flex-shrink: 0;
|
||||
padding: 20rpx 32rpx;
|
||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
||||
border-top: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.popup-btn {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 22rpx 0;
|
||||
border-radius: 999rpx;
|
||||
font-size: var(--fs-30);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.popup-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.popup-btn-ghost {
|
||||
border: 3rpx solid var(--sep);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.popup-btn-primary {
|
||||
background: var(--brand-strong);
|
||||
color: var(--white);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.patient-chip,
|
||||
.add-profile-tip,
|
||||
|
||||
+174
-50
@@ -1,7 +1,7 @@
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
const { parseDate, formatDate, formatDateTime, calcAge } = require('../../utils/date.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP } = require('../../utils/order.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
const { maskIdNumber, maskOrderId } = require('../../utils/privacy.js')
|
||||
|
||||
const SEX_MAP = {
|
||||
@@ -38,6 +38,7 @@ Page({
|
||||
// 医院预约规则与下单页一致,均由订单关联的服务目录下发
|
||||
showHospitalPopup: false,
|
||||
provinces: [],
|
||||
hospitalOptions: [],
|
||||
minAppointmentDate: '',
|
||||
fixedTime: false,
|
||||
timeOptions: [],
|
||||
@@ -177,20 +178,44 @@ Page({
|
||||
|
||||
formatRecord(item) {
|
||||
const status = item.status
|
||||
const cancelStatus = item.cancelStatus || 'none'
|
||||
// 展示状态:取消状态优先于服务状态(后端 status 不再包含取消值)
|
||||
const displayStatus = resolveOrderStatus(item)
|
||||
const paymentStatus = item.payment?.status || 'unpaid'
|
||||
const statusInfo = STATUS_MAP[status] || STATUS_MAP.pending
|
||||
const statusInfo = STATUS_MAP[displayStatus] || STATUS_MAP.pending
|
||||
const paymentInfo = PAYMENT_STATUS_MAP[paymentStatus] || PAYMENT_STATUS_MAP.unpaid
|
||||
|
||||
// 未支付按渠道与支付窗口区分:线上可去支付、超时仅可改线下或取消、线下等平台收款
|
||||
const payChannel = item.payment?.payChannel || 'offline'
|
||||
const windowEnd = item.paymentWindowEnd ? new Date(item.paymentWindowEnd) : null
|
||||
const paymentExpired = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& windowEnd instanceof Date
|
||||
&& !Number.isNaN(windowEnd.getTime())
|
||||
&& Date.now() > windowEnd.getTime()
|
||||
let paymentStatusText = paymentInfo.text
|
||||
if (paymentStatus === 'unpaid') {
|
||||
if (payChannel === 'offline') paymentStatusText = '待收款'
|
||||
else if (paymentExpired) paymentStatusText = '支付已超时'
|
||||
else paymentStatusText = '待支付'
|
||||
} else if (paymentStatus === 'paid' && item.payment?.method === 'online_wechat') {
|
||||
paymentStatusText = '已支付(微信)'
|
||||
}
|
||||
|
||||
// 底栏与「修改」入口的口径在这里算一次,WXML 只读结果,不再重复一串状态判断。
|
||||
// 删除收窄为「未支付 且 未进入服务阶段」:进行中的订单已产生服务成本,不允许直接删
|
||||
const canCancel = status === 'pending' || status === 'confirmed'
|
||||
const canDelete = paymentStatus === 'unpaid'
|
||||
&& (status === 'pending' || status === 'confirmed' || status === 'cancelled')
|
||||
const canRebook = (status === 'completed' || status === 'cancelled') && item.escort?.serviceId > 0
|
||||
// 用户只能取消:未确认且未收款的取消后订单即被删除;已确认/已收款的转为取消申请
|
||||
const canCancel = cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')
|
||||
const canRebook = (displayStatus === 'completed' || displayStatus === 'cancelled') && item.escort?.serviceId > 0
|
||||
// 终态单据只读:医院预约与陪诊需求不允许回改(就诊人「档案」跳的是档案页,不在此列)
|
||||
// 进行中服务已开始:排期与医院不允许用户单方变更,仅保留就诊人备注(与后端字段白名单一致)
|
||||
const canEditBooking = status === 'pending' || status === 'confirmed'
|
||||
const canEditBooking = cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')
|
||||
const canEditNote = canEditBooking || status === 'in_progress'
|
||||
// 待支付且未超时才能去支付;支付方式仅待支付期间可切换
|
||||
const canPay = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& !paymentExpired
|
||||
&& canEditBooking
|
||||
const canSwitchPayChannel = paymentStatus === 'unpaid' && canEditBooking
|
||||
|
||||
// 就诊人字段先落到局部变量:摘要姓名与展开区资料都从同一批值派生,
|
||||
// 口径不在 WXML 与 JS 两处各写一份
|
||||
@@ -243,27 +268,31 @@ Page({
|
||||
paidFee: (item.payment?.paidFee || 0).toFixed(2),
|
||||
showPaidFee: Number(item.payment?.paidFee) > 0,
|
||||
paymentStatus,
|
||||
paymentStatusText: paymentInfo.text,
|
||||
paymentStatusText,
|
||||
paymentStatusColor: paymentInfo.color,
|
||||
paymentStatusBg: paymentInfo.bg,
|
||||
paymentStatusBorder: paymentInfo.border,
|
||||
paymentMethodText: PAYMENT_METHOD_MAP[item.payment?.method] || '',
|
||||
payChannel,
|
||||
payChannelText: payChannel === 'online_wechat' ? '微信支付' : '线下支付',
|
||||
paymentExpired,
|
||||
canPay,
|
||||
canSwitchPayChannel,
|
||||
patientNote: item.notes?.patientNote || '',
|
||||
escortNote: item.notes?.escortNote || '',
|
||||
medicalSummary: item.notes?.medicalSummary || '',
|
||||
status,
|
||||
status: displayStatus,
|
||||
statusText: statusInfo.text,
|
||||
statusColor: statusInfo.color,
|
||||
statusBg: statusInfo.bg,
|
||||
statusBorder: statusInfo.border,
|
||||
statusDesc: statusInfo.desc,
|
||||
canCancel,
|
||||
canDelete,
|
||||
canRebook,
|
||||
canEditBooking,
|
||||
canEditNote,
|
||||
// 底栏只在确实有按钮时出现,避免无动作状态空留一条白栏
|
||||
showBottomBar: canCancel || canDelete || canRebook,
|
||||
showBottomBar: canCancel || canRebook || canPay,
|
||||
createTime: item.meta?.createtime ? formatDateTime(item.meta.createtime) : '',
|
||||
updateTime: item.meta?.updatetime ? formatDateTime(item.meta.updatetime) : ''
|
||||
}
|
||||
@@ -315,6 +344,98 @@ Page({
|
||||
this.setData({ showAllDetails: !this.data.showAllDetails })
|
||||
},
|
||||
|
||||
// ===== 微信支付 =====
|
||||
|
||||
onPayOrder() {
|
||||
if (this.paying) return
|
||||
this.paying = true
|
||||
this.startWechatPay(this.data.recordId)
|
||||
},
|
||||
|
||||
/**
|
||||
* 发起微信支付:payOrder → requestPayment → 查单确认
|
||||
* 前端回调只作提示,最终状态以后端 getPayStatus / 支付回调为准
|
||||
*/
|
||||
async startWechatPay(recordId) {
|
||||
let paid = false
|
||||
try {
|
||||
const res = await API.escort.payOrder(recordId)
|
||||
if (res.code !== 0 || !res.data?.payParams) {
|
||||
wx.showToast({ title: res.msg || '支付发起失败,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const payResult = await new Promise((resolve) => {
|
||||
wx.requestPayment({
|
||||
...res.data.payParams,
|
||||
success: () => resolve({ ok: true }),
|
||||
fail: (err) => resolve({ ok: false, err })
|
||||
})
|
||||
})
|
||||
|
||||
if (!payResult.ok && /cancel/i.test(payResult.err?.errMsg || '')) {
|
||||
wx.showToast({ title: '已取消支付', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 支付成功或非取消失败都查单兜底(可能已支付但前端网络中断)
|
||||
const statusRes = await API.escort.getPayStatus(recordId).catch(() => null)
|
||||
paid = statusRes?.code === 0 && statusRes.data?.paymentStatus === 'paid'
|
||||
wx.showToast({
|
||||
title: paid ? '支付成功' : '支付结果确认中',
|
||||
icon: paid ? 'success' : 'none'
|
||||
})
|
||||
} catch (err) {
|
||||
console.log('发起支付失败', err)
|
||||
wx.showToast({ title: '支付发起失败,请稍后重试', icon: 'none' })
|
||||
} finally {
|
||||
this.paying = false
|
||||
setTimeout(() => {
|
||||
if (recordId) this.loadRecord(recordId)
|
||||
}, paid ? 600 : 0)
|
||||
}
|
||||
},
|
||||
|
||||
// ===== 修改支付方式(仅待支付) =====
|
||||
|
||||
onSwitchPayChannel() {
|
||||
if (this.switchingPayChannel) return
|
||||
const current = this.data.record.payChannel
|
||||
wx.showActionSheet({
|
||||
itemList: ['微信支付', '线下支付'],
|
||||
success: (res) => {
|
||||
const channel = res.tapIndex === 0 ? 'online_wechat' : 'offline'
|
||||
if (channel === current) return
|
||||
this.updatePayChannel(channel)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
updatePayChannel(channel) {
|
||||
if (this.switchingPayChannel) return
|
||||
this.switchingPayChannel = true
|
||||
wx.showLoading({ title: '保存中...' })
|
||||
API.escort.updateRecord(this.data.recordId, {
|
||||
'payment.payChannel': channel
|
||||
})
|
||||
.then((res) => {
|
||||
wx.hideLoading()
|
||||
if (res.code === 0) {
|
||||
wx.showToast({ title: '支付方式已更新', icon: 'success' })
|
||||
this.loadRecord(this.data.recordId)
|
||||
} else {
|
||||
wx.showToast({ title: res.msg || '修改失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '网络请求失败,请重试', icon: 'none' })
|
||||
})
|
||||
.finally(() => {
|
||||
this.switchingPayChannel = false
|
||||
})
|
||||
},
|
||||
|
||||
// ===== 陪诊需求编辑(底部弹窗) =====
|
||||
|
||||
onEditPatientNote() {
|
||||
@@ -359,17 +480,28 @@ 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 || ''
|
||||
|
||||
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 || '',
|
||||
@@ -389,12 +521,25 @@ 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': '',
|
||||
hospitalOptions
|
||||
})
|
||||
},
|
||||
|
||||
// 医院选择组件回传:库内医院同时带出地址,手动填写的保持用户填写
|
||||
onHospitalSelectChange(e) {
|
||||
const { name, hospital } = e.detail
|
||||
const patch = { 'editHospital.name': name }
|
||||
if (hospital?.address) patch['editHospital.address'] = hospital.address
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
onScheduleDateChange(e) {
|
||||
this.setData({ 'editHospital.scheduleDate': e.detail.value })
|
||||
},
|
||||
@@ -419,7 +564,8 @@ Page({
|
||||
onSaveHospital() {
|
||||
const form = this.data.editHospital
|
||||
if (!form.name || !form.name.trim()) {
|
||||
wx.showToast({ title: '请输入就诊医院', icon: 'none' })
|
||||
const tip = this.data.hospitalOptions.length ? '请选择就诊医院' : '请填写就诊医院名称'
|
||||
wx.showToast({ title: tip, icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.scheduleDate) {
|
||||
@@ -431,8 +577,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(),
|
||||
@@ -502,9 +650,14 @@ Page({
|
||||
.then((res) => {
|
||||
wx.hideLoading()
|
||||
if (res.code === 0) {
|
||||
wx.showToast({ title: '订单已取消', icon: 'success' })
|
||||
this.setData({ showCancelPopup: false })
|
||||
this.loadRecord(this.data.recordId)
|
||||
wx.showToast({ title: res.msg || '操作成功', icon: 'success' })
|
||||
// 未确认且未收款的订单取消后已被删除,直接退回列表;其余刷新展示「待取消」
|
||||
if (res.data?.deleted) {
|
||||
setTimeout(() => wx.navigateBack(), 1200)
|
||||
} else {
|
||||
this.loadRecord(this.data.recordId)
|
||||
}
|
||||
} else {
|
||||
wx.showToast({ title: res.msg || '操作失败', icon: 'none' })
|
||||
}
|
||||
@@ -515,35 +668,6 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onDeleteOrder() {
|
||||
wx.showModal({
|
||||
title: '删除订单',
|
||||
content: '确定要删除该订单吗?删除后不可恢复。',
|
||||
confirmColor: '#B4231A',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({ title: '删除中...' })
|
||||
API.escort.deleteRecord(this.data.recordId)
|
||||
.then((res) => {
|
||||
wx.hideLoading()
|
||||
if (res.code === 0) {
|
||||
wx.showToast({ title: '删除成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
wx.showToast({ title: res.msg || '删除失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '网络请求失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onRebook() {
|
||||
const serviceId = this.data.record.serviceId
|
||||
if (!serviceId) return
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -119,6 +119,20 @@
|
||||
不再在卡内挂一行「请联系客服…」:那句话只对未支付状态成立,
|
||||
却长期占着卡内一条常驻行位 -->
|
||||
|
||||
<!-- 支付渠道:仅待支付期间可切换;线下支付由平台收款后补记实际方式 -->
|
||||
<view
|
||||
class="pay-switch"
|
||||
wx:if="{{record.canSwitchPayChannel}}"
|
||||
aria-role="button"
|
||||
aria-label="切换支付方式"
|
||||
bindtap="onSwitchPayChannel"
|
||||
>
|
||||
<text class="pay-switch-label">支付方式</text>
|
||||
<text class="pay-switch-value">{{record.payChannelText}}</text>
|
||||
<text class="pay-switch-action">切换</text>
|
||||
<t-icon name="chevron-right" size="24rpx" color="#6F655C" />
|
||||
</view>
|
||||
|
||||
<view class="cancel-summary" wx:if="{{record.status === 'cancelled' && record.cancelReason}}">
|
||||
<text class="cancel-summary-label">取消原因</text>
|
||||
<text class="cancel-summary-value">{{record.cancelReason}}</text>
|
||||
@@ -248,16 +262,16 @@
|
||||
>
|
||||
<view class="home-icon"></view>
|
||||
</view>
|
||||
<view
|
||||
class="action-btn action-primary"
|
||||
wx:if="{{record.canPay}}"
|
||||
bindtap="onPayOrder"
|
||||
>去支付</view>
|
||||
<view
|
||||
class="action-btn action-ghost"
|
||||
wx:if="{{record.canCancel}}"
|
||||
bindtap="onCancelOrder"
|
||||
>取消订单</view>
|
||||
<view
|
||||
class="action-btn action-ghost action-danger"
|
||||
wx:if="{{record.canDelete}}"
|
||||
bindtap="onDeleteOrder"
|
||||
>删除订单</view>
|
||||
<view
|
||||
class="action-btn {{record.status === 'cancelled' ? 'action-primary' : 'action-ghost'}}"
|
||||
wx:if="{{record.canRebook}}"
|
||||
@@ -288,17 +302,14 @@
|
||||
<view class="form-picker-value">{{editHospital.province || '请选择省份'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">就诊医院</text>
|
||||
<input
|
||||
class="form-input"
|
||||
value="{{editHospital.name}}"
|
||||
placeholder="请输入医院名称"
|
||||
placeholder-class="input-placeholder"
|
||||
bindinput="onHospitalFieldInput"
|
||||
data-field="name"
|
||||
/>
|
||||
</view>
|
||||
<hospital-select
|
||||
label="就诊医院"
|
||||
value="{{editHospital.name}}"
|
||||
options="{{hospitalOptions}}"
|
||||
placeholder="请选择医院"
|
||||
compact="{{true}}"
|
||||
bindchange="onHospitalSelectChange"
|
||||
/>
|
||||
<view class="form-row">
|
||||
<text class="form-label">医院地址</text>
|
||||
<input
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
- 陪诊需求、陪诊记录与就诊摘要仅在有内容时出现,已完成订单的服务结果直接展示;
|
||||
- 修改仍按就诊人、医院预约、陪诊需求分区,表单只存在于档案页或底部弹窗;
|
||||
- 配色沿用 app.wxss 暖橙令牌,状态文字与颜色共同传达信息;
|
||||
- 字号阶梯:36 日期 / 34 金额 / 32 姓名 · 陪诊师名 / 28 行值(医院 · 服务 · 时段 · 电话)
|
||||
/ 24 标签 · 地址 · 辅助说明,最小 24rpx(12px) */
|
||||
- 字号阶梯:36 日期 / 34 金额 · 分区标题 · 姓名 · 弹窗标题 / 30 行值(医院 · 服务 · 电话 · 正文)
|
||||
/ 26-28 标签 · 地址 · 辅助说明,最小 26rpx */
|
||||
page {
|
||||
background-color: var(--paper);
|
||||
|
||||
@@ -39,7 +39,7 @@ page {
|
||||
}
|
||||
|
||||
.page-state-text {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ page {
|
||||
border-radius: 999rpx;
|
||||
background: transparent;
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 500;
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -130,9 +130,8 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 20rpx;
|
||||
/* 28rpx 降到 26rpx:说明退到「次强」档,与 32rpx 的胶囊拉开一档差,
|
||||
抬头内部才有焦点;此前两者同为 28rpx,只靠字重区分,谁都不是主角 */
|
||||
font-size: var(--fs-26);
|
||||
/* 说明保持比 32rpx 的胶囊低一档,抬头内部才有焦点 */
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
letter-spacing: 1rpx;
|
||||
@@ -152,16 +151,15 @@ page {
|
||||
flex-shrink: 0;
|
||||
width: 8rpx;
|
||||
/* 色标高度跟随标题字号,缩字号时同步收,保持「短横 + 标题」的等高一档 */
|
||||
height: 32rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 4rpx;
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
/* 34rpx 降一档到 32rpx:与 attendantdetail / agreement / about 的分区标题同一档,
|
||||
不新增字号档位(DESIGN.md 字号阶梯) */
|
||||
/* 分区标题 34rpx,色标等高跟随 */
|
||||
.section-title {
|
||||
margin-left: 16rpx;
|
||||
font-size: var(--fs-32);
|
||||
font-size: var(--fs-34);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
letter-spacing: 1rpx;
|
||||
@@ -184,9 +182,8 @@ page {
|
||||
不靠颜色——颜色留给底栏主按钮 */
|
||||
.section-link-text {
|
||||
margin-right: 4rpx;
|
||||
/* 26rpx 与图标同档:入口降为中性的同时留一点体量,
|
||||
避免和卡片正文(26rpx)拉开层级后又退到看不清 */
|
||||
font-size: var(--fs-26);
|
||||
/* 与图标同档:入口降为中性的同时留一点体量 */
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -214,7 +211,7 @@ page {
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.6;
|
||||
@@ -337,7 +334,7 @@ page {
|
||||
.appt-label {
|
||||
flex-shrink: 0;
|
||||
width: 96rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.8;
|
||||
@@ -353,7 +350,7 @@ page {
|
||||
}
|
||||
|
||||
.appt-text {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.6;
|
||||
@@ -364,10 +361,10 @@ page {
|
||||
}
|
||||
|
||||
/* 地址:医院行下的副行,换行独占。
|
||||
尺寸与颜色同主值(26rpx / --ink-2):老人靠它找到地方,不能压成浅灰小字 */
|
||||
颜色用 --ink-2:老人靠它找到地方,不能压成浅灰小字 */
|
||||
.appt-sub {
|
||||
flex-basis: 100%;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.6;
|
||||
@@ -406,14 +403,14 @@ page {
|
||||
|
||||
.cancel-summary-label {
|
||||
display: block;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.cancel-summary-value {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -447,7 +444,7 @@ page {
|
||||
|
||||
.detail-group-title {
|
||||
display: block;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -464,7 +461,7 @@ page {
|
||||
|
||||
.detail-label {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -473,7 +470,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.5;
|
||||
text-align: right;
|
||||
@@ -482,7 +479,7 @@ page {
|
||||
.shipping-recipient {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -490,7 +487,7 @@ page {
|
||||
.shipping-address {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -504,7 +501,7 @@ page {
|
||||
|
||||
/* ===== 陪诊师卡片:平台分配后才出现 =====
|
||||
就诊当天要联系的人单独成卡,只用「名 + 电话」两段,
|
||||
名字 32rpx 立住身份,电话弱一档在右侧,扫一眼就能报出是谁 */
|
||||
名字 34rpx 立住身份,电话弱一档在右侧,扫一眼就能报出是谁 */
|
||||
.attendant-section {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
@@ -518,7 +515,7 @@ page {
|
||||
|
||||
.attendant-name {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--fs-32);
|
||||
font-size: var(--fs-34);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
letter-spacing: 1rpx;
|
||||
@@ -530,17 +527,17 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink-2);
|
||||
letter-spacing: 1rpx;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 待分配占位:与姓名同档字号但退到灰字,读作「还没定」而不是「没有」 */
|
||||
/* 待分配占位:比姓名低一档并退到灰字,读作「还没定」而不是「没有」 */
|
||||
.attendant-empty {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
letter-spacing: 1rpx;
|
||||
line-height: 1.5;
|
||||
@@ -570,13 +567,13 @@ page {
|
||||
.note-label {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.note-text {
|
||||
display: block;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.7;
|
||||
letter-spacing: 1rpx;
|
||||
@@ -598,7 +595,7 @@ page {
|
||||
|
||||
.note-add-text {
|
||||
margin-left: 8rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
|
||||
@@ -619,7 +616,7 @@ page {
|
||||
|
||||
.form-label {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -627,7 +624,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-left: 24rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
text-align: right;
|
||||
}
|
||||
@@ -639,7 +636,7 @@ page {
|
||||
}
|
||||
|
||||
.form-picker-value {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
text-align: right;
|
||||
}
|
||||
@@ -652,7 +649,7 @@ page {
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 16rpx;
|
||||
background: var(--paper);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink-2);
|
||||
line-height: 1.7;
|
||||
}
|
||||
@@ -805,7 +802,7 @@ page {
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: var(--fs-32);
|
||||
font-size: var(--fs-34);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -827,7 +824,7 @@ page {
|
||||
|
||||
/* ===== 取消订单弹窗内的原因单选 ===== */
|
||||
.cancel-tip {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -875,7 +872,7 @@ page {
|
||||
|
||||
.reason-text {
|
||||
margin-left: 16rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
@@ -913,3 +910,30 @@ page {
|
||||
color: var(--white);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* 支付方式切换:待支付期间才出现,轻量一行,不额外占卡片高度 */
|
||||
.pay-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-top: 16rpx;
|
||||
padding-top: 18rpx;
|
||||
border-top: 2rpx solid var(--line);
|
||||
}
|
||||
|
||||
.pay-switch-label {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-28);
|
||||
}
|
||||
|
||||
.pay-switch-value {
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.pay-switch-action {
|
||||
margin-left: auto;
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-26);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const API = require('../../utils/api.js')
|
||||
const { formatDate } = require('../../utils/date.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP } = require('../../utils/order.js')
|
||||
const { STATUS_MAP, PAYMENT_STATUS_MAP, resolveOrderStatus } = require('../../utils/order.js')
|
||||
|
||||
// 左右滑动切换状态页的手势参数(单位 px)
|
||||
const SWIPE_THRESHOLD = 50
|
||||
@@ -58,7 +58,12 @@ Page({
|
||||
if (!app.globalData.user?._id) throw new Error('请先登录后查看预约记录')
|
||||
|
||||
const params = { page, pageSize: this.data.pageSize }
|
||||
if (this.data.statusFilter === 'ongoing') params.status = ONGOING_STATUS_QUERY
|
||||
if (this.data.statusFilter === 'ongoing') {
|
||||
params.status = ONGOING_STATUS_QUERY
|
||||
} else {
|
||||
// 全部预约需要包含已取消订单;默认列表会隐藏已取消
|
||||
params.includeCancelled = 1
|
||||
}
|
||||
|
||||
const res = await API.escort.getMyRecords(params)
|
||||
if (res.code !== 0) throw new Error(res.msg || '预约记录加载失败')
|
||||
@@ -101,13 +106,34 @@ Page({
|
||||
},
|
||||
|
||||
formatRecord(item) {
|
||||
const statusInfo = STATUS_MAP[item.status] || STATUS_MAP.pending
|
||||
const displayStatus = resolveOrderStatus(item)
|
||||
const statusInfo = STATUS_MAP[displayStatus] || STATUS_MAP.pending
|
||||
const paymentStatusInfo = PAYMENT_STATUS_MAP[item.payment?.status] || PAYMENT_STATUS_MAP.unpaid
|
||||
const fee = Number(item.payment?.totalFee) || 0
|
||||
const appointmentTime = item.schedule?.date
|
||||
? `${formatDate(item.schedule.date, '--')} ${item.schedule.startTime || ''}`.trim()
|
||||
: '--'
|
||||
|
||||
// 未支付的展示按渠道与支付窗口区分:线上可去支付、超时仅可改线下或取消、线下等平台收款
|
||||
const paymentStatus = item.payment?.status || 'unpaid'
|
||||
const payChannel = item.payment?.payChannel || 'offline'
|
||||
const windowEnd = item.paymentWindowEnd ? new Date(item.paymentWindowEnd) : null
|
||||
const paymentExpired = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& windowEnd instanceof Date
|
||||
&& !Number.isNaN(windowEnd.getTime())
|
||||
&& Date.now() > windowEnd.getTime()
|
||||
let paymentStatusText = paymentStatusInfo.text
|
||||
if (paymentStatus === 'unpaid') {
|
||||
if (payChannel === 'offline') paymentStatusText = '线下支付'
|
||||
else if (paymentExpired) paymentStatusText = '支付已超时'
|
||||
else paymentStatusText = '待支付'
|
||||
}
|
||||
const canPay = paymentStatus === 'unpaid'
|
||||
&& payChannel === 'online_wechat'
|
||||
&& !paymentExpired
|
||||
&& ['pending', 'confirmed'].includes(displayStatus)
|
||||
|
||||
return {
|
||||
_id: item._id,
|
||||
patientName: item.patient?.name || '--',
|
||||
@@ -120,7 +146,11 @@ Page({
|
||||
statusBorder: statusInfo.border,
|
||||
appointmentTime,
|
||||
fee: fee.toFixed(2),
|
||||
paymentStatusText: paymentStatusInfo.text,
|
||||
payChannel,
|
||||
payChannelText: payChannel === 'online_wechat' ? '微信支付' : '线下支付',
|
||||
paymentExpired,
|
||||
canPay,
|
||||
paymentStatusText,
|
||||
paymentStatusColor: paymentStatusInfo.color,
|
||||
paymentStatusBg: paymentStatusInfo.bg,
|
||||
paymentStatusBorder: paymentStatusInfo.border
|
||||
@@ -190,6 +220,13 @@ Page({
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${id}` })
|
||||
},
|
||||
|
||||
// 列表「去支付」只作为入口:真正发起支付在详情页,避免列表与详情两套支付逻辑
|
||||
onPayRecord(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
if (!id) return
|
||||
wx.navigateTo({ url: `/pages/escort/recorddetail?id=${id}` })
|
||||
},
|
||||
|
||||
// 回首页:首页是 tabBar 页,必须走 switchTab,navigateTo 跳不过去
|
||||
onGoHome() {
|
||||
wx.switchTab({ url: '/pages/home/index' })
|
||||
|
||||
@@ -83,6 +83,12 @@
|
||||
class="pay-chip"
|
||||
style="background: {{item.paymentStatusBg}}; color: {{item.paymentStatusColor}}; border-color: {{item.paymentStatusBorder}};"
|
||||
>{{item.paymentStatusText}}</view>
|
||||
<view
|
||||
class="pay-entry"
|
||||
wx:if="{{item.canPay}}"
|
||||
catchtap="onPayRecord"
|
||||
data-id="{{item._id}}"
|
||||
>去支付</view>
|
||||
<t-icon class="record-chevron" name="chevron-right" size="28rpx" color="#6F655C" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
- 形状锁定:卡 28rpx、状态胶囊 10rpx、分段控件 999rpx
|
||||
- 左右滑动切换状态页:记录区横向拖动时跟手平移(有阻尼与上限),
|
||||
松手弹回;拖动中关过渡保即时响应,松手后由过渡做回弹
|
||||
- 字号阶梯:费用 34 / 类型 30 / 就诊信息 28 / 时间 · 胶囊 24(rpx),
|
||||
全页最小 24rpx(12px),达可读下限 */
|
||||
- 字号阶梯:费用 34 / 类型 32 / 就诊信息 30 / 时间 · 标签 28 / 角标 · 辅助 26(rpx);
|
||||
订单状态胶囊 26 与支付状态胶囊 24 保持原档,仍以「有底色 vs 无底色」区分主次 */
|
||||
page {
|
||||
background-color: var(--paper);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ page {
|
||||
}
|
||||
|
||||
/* 两格等宽:容器内距各 32rpx 后可用宽 622rpx,一格 305rpx,
|
||||
四字标签(28rpx)+ 角标横向只占约 150rpx,居中后左右留白充足 */
|
||||
四字标签(30rpx)+ 角标横向只占约 160rpx,居中后左右留白充足 */
|
||||
.seg-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
@@ -73,13 +73,13 @@ page {
|
||||
}
|
||||
|
||||
.seg-label {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.seg-count {
|
||||
margin-left: 8rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ page {
|
||||
}
|
||||
|
||||
.record-type {
|
||||
font-size: var(--fs-30);
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
letter-spacing: 1rpx;
|
||||
@@ -158,7 +158,7 @@ page {
|
||||
|
||||
.time-text {
|
||||
margin-left: 8rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
@@ -175,14 +175,14 @@ page {
|
||||
.info-label {
|
||||
flex-shrink: 0;
|
||||
width: 130rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-28);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.info-value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ page {
|
||||
|
||||
.error-text {
|
||||
margin-top: 24rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
@@ -256,7 +256,7 @@ page {
|
||||
border-radius: 999rpx;
|
||||
background: transparent;
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 500;
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -274,13 +274,13 @@ page {
|
||||
|
||||
.empty-text {
|
||||
margin-top: 24rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.empty-subtext {
|
||||
margin-top: 10rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ page {
|
||||
}
|
||||
|
||||
.no-more-text {
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -322,6 +322,22 @@ page {
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
/* 列表「去支付」:只在待支付且未超时时出现,点击进入详情完成支付 */
|
||||
.pay-entry {
|
||||
margin-right: 12rpx;
|
||||
padding: 8rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-26);
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pay-entry:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.home-fab:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ page {
|
||||
|
||||
.page-state-text {
|
||||
margin-top: 20rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
line-height: 1.6;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
@@ -32,7 +32,7 @@ page {
|
||||
padding: 12rpx 28rpx;
|
||||
border: 2rpx solid var(--brand-strong);
|
||||
border-radius: 28rpx;
|
||||
font-size: var(--fs-26);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 500;
|
||||
color: var(--brand-strong);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ page {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
/* 行高约 87rpx(28rpx×1.4 + 上下 24rpx),贴近 iOS 44pt 触控目标 */
|
||||
/* 行高约 90rpx(30rpx×1.4 + 上下 24rpx),贴近 iOS 44pt 触控目标 */
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -67,7 +67,7 @@ page {
|
||||
.field-error {
|
||||
width: 100%;
|
||||
margin-top: 12rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
line-height: 1.5;
|
||||
color: #B4231A;
|
||||
text-align: right;
|
||||
@@ -82,7 +82,7 @@ page {
|
||||
.form-label {
|
||||
flex-shrink: 0;
|
||||
margin-right: 24rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ page {
|
||||
.picker-value {
|
||||
display: block;
|
||||
text-align: right;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ page {
|
||||
}
|
||||
|
||||
.sex-text {
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -165,15 +165,14 @@ page {
|
||||
width: 100%;
|
||||
height: 160rpx;
|
||||
margin-top: 16rpx;
|
||||
font-size: var(--fs-28);
|
||||
font-size: var(--fs-30);
|
||||
color: var(--ink);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 24rpx 是中文最小字号下限 */
|
||||
.remark-count {
|
||||
align-self: flex-end;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ page {
|
||||
|
||||
.tips-text {
|
||||
margin-left: 10rpx;
|
||||
font-size: var(--fs-24);
|
||||
font-size: var(--fs-26);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,8 +250,9 @@ page {
|
||||
|
||||
.promo-btn-text {
|
||||
margin-right: 4rpx;
|
||||
/* 28rpx / 14px:按钮字不再是"看不清的附属小字",与正文同级 */
|
||||
font-size: var(--fs-28);
|
||||
/* 24rpx / 12px:按钮字收小一档,让「了解详情」退回附属提示的层级,
|
||||
不与左侧标题争夺首屏注意力 */
|
||||
font-size: var(--fs-24);
|
||||
font-weight: 700;
|
||||
color: var(--brand-ink);
|
||||
letter-spacing: 1rpx;
|
||||
@@ -485,7 +486,7 @@ page {
|
||||
次级层级靠 --ink-2 的色阶表达,不用半档字重 */
|
||||
.assist-name {
|
||||
font-size: var(--fs-30);
|
||||
font-weight: 400;
|
||||
font-weight: 700;
|
||||
color: var(--ink-2);
|
||||
/* 行高 1.5:字号 32→30 会让这一行的盒高少 2.8rpx,
|
||||
用 1.5 把盒高补回 45rpx(≈改前 32rpx × normal),
|
||||
@@ -564,12 +565,12 @@ page {
|
||||
}
|
||||
|
||||
.quick-name {
|
||||
/* 30rpx / 15px:文字区约 179rpx,最长「预约记录」4 字 120rpx 仍单行。
|
||||
与宫格项名同档 30rpx,但这里是卡名(可点入口),走 700 与 400 拉开 */
|
||||
font-size: var(--fs-30);
|
||||
/* 32rpx / 16px:卡名放大一号,作为可点入口的主标签。
|
||||
文字区约 179rpx,最长「预约记录」4 字 128rpx 仍单行 */
|
||||
font-size: var(--fs-32);
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
/* 行高 1.5:字号 32→30 少 2.8rpx,用行高补回,卡片高度与历史版本一致 */
|
||||
/* 行高 1.5:放大后靠行高补回视觉高度,卡片整体高度与历史版本一致 */
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
--t-display: 88rpx;
|
||||
/* 72rpx:价格数字收小一号(原 88rpx),避免大号数字压过卡片信息 */
|
||||
--t-display: 72rpx;
|
||||
--t-h1: 44rpx;
|
||||
/* 36rpx 及以上不参与全局字号令牌(大字模式不放大),保持字面量 */
|
||||
--t-h2: 36rpx;
|
||||
|
||||
@@ -12,6 +12,11 @@ const API = {
|
||||
update: (data) => requestUser.post('/user/update', data),
|
||||
},
|
||||
|
||||
// 医院基础信息(公开接口):启动预取与下单页医院下拉共用
|
||||
hospital: {
|
||||
getHospitals: (params) => request.get('/health/hospital', params),
|
||||
},
|
||||
|
||||
escort: {
|
||||
getMyRecords: (params) => request.get('/health/escort-record/my', params),
|
||||
getAttendantRecords: (params) => request.get('/health/escort-record/attendant', params),
|
||||
@@ -20,6 +25,9 @@ const API = {
|
||||
updateRecord: (id, data) => request.put(`/health/escort-record/${id}`, data),
|
||||
updateStatus: (id, data) => request.patch(`/health/escort-record/${id}/status`, data),
|
||||
deleteRecord: (id) => request.delete(`/health/escort-record/${id}`),
|
||||
// 微信支付:发起支付返回调起收银台参数;支付结果以后端查单为准
|
||||
payOrder: (id) => request.post(`/health/escort-record/${id}/pay`),
|
||||
getPayStatus: (id) => request.get(`/health/escort-record/${id}/pay/status`),
|
||||
// 陪诊师公示列表(公开接口,后端已做脱敏)
|
||||
getAttendants: (params) => request.get('/health/attendant', params),
|
||||
// 单个陪诊师详情,同一份白名单数据
|
||||
|
||||
+14
-2
@@ -2,13 +2,24 @@
|
||||
const STATUS_MAP = {
|
||||
pending: { text: '待确认', color: '#0F766E', bg: '#ECF7F4', border: '#C7E5DF', desc: '订单已提交,等待陪诊师确认' },
|
||||
confirmed: { text: '已确认', color: '#0F766E', bg: '#ECF7F4', border: '#C7E5DF', desc: '订单已确认,陪诊师将准时为您服务' },
|
||||
cancel_requested: { text: '待取消', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', desc: '取消申请已提交,等待陪诊师确认' },
|
||||
in_progress: { text: '进行中', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', desc: '陪诊服务正在进行中' },
|
||||
completed: { text: '已完成', color: '#1F7A4D', bg: '#EAF6EE', border: '#CDE9D7', desc: '陪诊服务已完成,感谢您的使用' },
|
||||
cancelled: { text: '已取消', color: '#B4231A', bg: '#FCF0EE', border: '#F2D6D1', desc: '该订单已取消' }
|
||||
}
|
||||
|
||||
// 取消与 status 解耦:展示层优先按 cancelStatus 映射为「待取消/已取消」,
|
||||
// 其余情况仍按服务状态展示,status 本身不再写入取消值。
|
||||
function resolveOrderStatus(item) {
|
||||
const cancelStatus = item?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return item?.status || 'pending'
|
||||
}
|
||||
|
||||
const PAYMENT_STATUS_MAP = {
|
||||
unpaid: { text: '未支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '请联系客服完成支付' },
|
||||
// 未支付的展示文案由页面按 payChannel / 支付窗口派生,这里不再固定「联系客服」
|
||||
unpaid: { text: '未支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2' },
|
||||
partial: { text: '部分支付', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '请联系客服补齐剩余费用' },
|
||||
paid: { text: '已支付', color: '#1F7A4D', bg: '#EAF6EE', border: '#CDE9D7' },
|
||||
refunding: { text: '退款中', color: '#B8520A', bg: '#FFF4E8', border: '#FFE0C2', hint: '退款处理中,如需了解进度请联系客服' },
|
||||
@@ -17,5 +28,6 @@ const PAYMENT_STATUS_MAP = {
|
||||
|
||||
module.exports = {
|
||||
STATUS_MAP,
|
||||
PAYMENT_STATUS_MAP
|
||||
PAYMENT_STATUS_MAP,
|
||||
resolveOrderStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user