style(home): 预约卡片补充医院并允许长内容换行
首行集中日期、就诊人、服务与状态,医院单独成行;服务、医院与姓名超长时 换行展示而不是截断,详情箭头独立包裹。同步更新首页 UI 测试断言与缺省文案。
This commit is contained in:
+2
-2
@@ -212,8 +212,7 @@ Page({
|
||||
return sorted.slice(0, PENDING_PREVIEW_LIMIT).map((item) => this.formatPendingRecord(item))
|
||||
},
|
||||
|
||||
// 预约摘要只给日期、服务、就诊人与状态;时间与医院由详情页承接。
|
||||
// timeText 仍保留在数据里,供卡片 aria-label 朗读完整预约时间。
|
||||
// 首页摘要保留关键就诊安排,缺少信息时给出可读提示。
|
||||
formatPendingRecord(item) {
|
||||
const date = parseDate(item.schedule?.date)
|
||||
const whenText = date
|
||||
@@ -227,6 +226,7 @@ Page({
|
||||
timeText: item.schedule?.startTime || '时间待定',
|
||||
statusText: status.text,
|
||||
statusTone: status.tone,
|
||||
hospitalName: item.hospital?.name || '医院待定',
|
||||
patientName: item.patient?.name || '待补充',
|
||||
serviceName: item.escort?.serviceName || '陪诊服务'
|
||||
}
|
||||
|
||||
@@ -34,21 +34,20 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 预约摘要只保留日期、服务、就诊人与状态,时间与医院进详情页。 -->
|
||||
<!-- 两行预约摘要:日期、姓名、服务与状态在上,医院在下;长内容自然换行。 -->
|
||||
<view class="pending-section" wx:if="{{pendingRecords.length}}">
|
||||
<text class="pending-heading">当前预约</text>
|
||||
<view class="pending-card" wx:for="{{pendingRecords}}" wx:key="id" data-id="{{item.id}}" bindtap="goToRecordDetail" hover-class="surface-hover" aria-role="button" aria-label="{{item.whenText}} {{item.timeText}},{{item.serviceName}},{{item.statusText}},查看预约详情">
|
||||
<view class="pending-card" wx:for="{{pendingRecords}}" wx:key="id" data-id="{{item.id}}" bindtap="goToRecordDetail" hover-class="surface-hover" aria-role="button" aria-label="{{item.whenText}},就诊人:{{item.patientName}},{{item.serviceName}},{{item.statusText}},{{item.hospitalName}},查看预约详情">
|
||||
<view class="pending-content">
|
||||
<view class="pending-top">
|
||||
<view class="pending-summary">
|
||||
<text class="pending-when">{{item.whenText}}</text>
|
||||
<text class="pending-patient">{{item.patientName}}</text>
|
||||
<text class="pending-service">{{item.serviceName}}</text>
|
||||
<view class="pending-status chip-tone-{{item.statusTone}}">{{item.statusText}}</view>
|
||||
</view>
|
||||
<view class="pending-meta">
|
||||
<text class="pending-service">{{item.serviceName}}</text>
|
||||
<text class="pending-patient">就诊人:{{item.patientName}}</text>
|
||||
</view>
|
||||
<text class="pending-hospital">{{item.hospitalName}}</text>
|
||||
</view>
|
||||
<t-icon name="chevron-right" size="30rpx" color="#6F655C" />
|
||||
<view class="pending-arrow" aria-hidden="true"><t-icon name="chevron-right" size="30rpx" color="#6F655C" /></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
+17
-16
@@ -108,28 +108,29 @@ button.hero-cta.action-hover { background: var(--brand-ink); }
|
||||
}
|
||||
.trust-item { display: flex; align-items: center; gap: 10rpx; }
|
||||
.trust-check { flex-shrink: 0; width: 12rpx; height: 7rpx; margin-top: -4rpx; border-bottom: 2rpx solid var(--brand-ink); border-left: 2rpx solid var(--brand-ink); transform: rotate(-45deg); }
|
||||
.pending-section { padding: 4rpx 0; }
|
||||
.pending-heading { color: var(--muted); font-size: var(--fs-26); }
|
||||
.pending-section { padding: 20rpx 0 0; }
|
||||
.pending-heading { display: block; padding: 0 4rpx; color: var(--muted); font-size: var(--fs-26); line-height: 1.5; }
|
||||
.pending-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
gap: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
padding: 24rpx;
|
||||
box-sizing: border-box;
|
||||
min-height: 88rpx;
|
||||
border: 2rpx solid var(--line);
|
||||
border-radius: 28rpx;
|
||||
background: var(--white);
|
||||
}
|
||||
.pending-content { flex: 1; min-width: 0; }
|
||||
/* 首行:日期居左强调,状态胶囊靠右;状态色只包文字本身 */
|
||||
.pending-top {
|
||||
/* 日期与姓名便于快速识别预约;服务吸收余量,长内容换行而不截断。 */
|
||||
.pending-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 8rpx;
|
||||
gap: 12rpx 16rpx;
|
||||
}
|
||||
.pending-when { color: var(--brand-ink); font-size: var(--fs-30); font-weight: 600; white-space: nowrap; }
|
||||
.pending-when { max-width: 100%; color: var(--brand-ink); font-size: var(--fs-30); font-weight: 600; line-height: 1.5; overflow-wrap: break-word; }
|
||||
.pending-status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -144,23 +145,23 @@ button.hero-cta.action-hover { background: var(--brand-ink); }
|
||||
}
|
||||
/* 状态语气档与 recordlist / recorddetail 同一套,色值读 app.wxss 令牌 */
|
||||
.chip-tone-wait { background: var(--status-wait-bg); border-color: var(--status-wait-line); color: var(--status-wait-ink); }
|
||||
.chip-tone-doing { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-strong); }
|
||||
.chip-tone-doing { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
|
||||
.chip-tone-done { background: var(--status-done-bg); border-color: var(--status-done-line); color: var(--status-done-ink); }
|
||||
.chip-tone-cancel { background: var(--status-cancel-bg); border-color: var(--status-cancel-line); color: var(--status-cancel-ink); }
|
||||
.chip-tone-neutral { background: transparent; border-color: var(--sep); color: var(--muted); }
|
||||
/* 第二行:服务名 + 就诊人同行;服务名过长时截断,就诊人完整保留 */
|
||||
.pending-meta { display: flex; align-items: baseline; gap: 12rpx; min-width: 0; }
|
||||
.pending-service {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
.pending-patient { flex-shrink: 0; color: var(--muted); font-size: var(--fs-24); line-height: 1.5; white-space: nowrap; }
|
||||
.pending-hospital { display: block; margin-top: 12rpx; color: var(--ink-2); font-size: var(--fs-28); line-height: 1.6; word-break: break-all; }
|
||||
.pending-patient { min-width: 0; max-width: 100%; color: var(--ink); font-size: var(--fs-28); font-weight: 600; line-height: 1.5; word-break: break-all; }
|
||||
.pending-arrow { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
||||
.section { margin-top: 32rpx; }
|
||||
.section-head {
|
||||
margin-bottom: 16rpx;
|
||||
|
||||
+58
-5
@@ -5,16 +5,48 @@ const path = require('node:path')
|
||||
const vm = require('node:vm')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
|
||||
test('当前预约使用紧凑三行摘要,时间、服务及状态共用首行', () => {
|
||||
test('当前预约使用两行摘要,日期、姓名、服务及状态共用首行,不显示时间', () => {
|
||||
const wxml = fs.readFileSync(path.join(root, 'pages/home/index.wxml'), 'utf8')
|
||||
assert.match(wxml, /pending-heading">当前预约/)
|
||||
assert.doesNotMatch(wxml, /pending-service-row/)
|
||||
const summary = /<view class="pending-summary">([\s\S]*?)<\/view>/.exec(wxml)[1]
|
||||
for (const field of ['whenText', 'timeText', 'serviceName', 'statusText']) {
|
||||
const match = /<view class="pending-summary">([\s\S]*?)<\/view>/.exec(wxml)
|
||||
assert.ok(match, '预约卡片应包含首行摘要')
|
||||
const summary = match[1]
|
||||
for (const field of ['whenText', 'patientName', 'serviceName', 'statusText']) {
|
||||
assert.ok(summary.includes(`item.${field}`))
|
||||
}
|
||||
assert.match(wxml, /pending-hospital">{{item.hospitalName}}/)
|
||||
assert.match(wxml, /pending-patient">就诊人:{{item.patientName}}/)
|
||||
assert.match(summary, /pending-when">{{item.whenText}}/)
|
||||
assert.match(summary, /pending-patient">{{item.patientName}}/)
|
||||
assert.ok(summary.indexOf('item.whenText') < summary.indexOf('item.patientName'))
|
||||
assert.ok(summary.indexOf('item.patientName') < summary.indexOf('item.serviceName'))
|
||||
assert.doesNotMatch(wxml, /item\.timeText/)
|
||||
assert.equal((wxml.match(/class="pending-patient"/g) || []).length, 1)
|
||||
const afterSummary = wxml.slice(wxml.indexOf('</view>', wxml.indexOf('class="pending-summary"')))
|
||||
assert.doesNotMatch(afterSummary, /class="pending-patient"/)
|
||||
})
|
||||
|
||||
test('预约卡片长内容可换行,保留详情入口和完整无障碍摘要', () => {
|
||||
const wxml = fs.readFileSync(path.join(root, 'pages/home/index.wxml'), 'utf8')
|
||||
const wxss = fs.readFileSync(path.join(root, 'pages/home/index.wxss'), 'utf8')
|
||||
const rule = (name) => {
|
||||
const match = new RegExp(`\\.${name}\\s*\\{([^}]+)\\}`).exec(wxss)
|
||||
assert.ok(match, `缺少 ${name} 样式`)
|
||||
return match[1]
|
||||
}
|
||||
assert.match(rule('pending-summary'), /flex-wrap:\s*wrap/)
|
||||
for (const name of ['pending-service', 'pending-hospital', 'pending-patient']) {
|
||||
assert.match(rule(name), /word-break:\s*break-all/)
|
||||
assert.doesNotMatch(rule(name), /ellipsis|nowrap|overflow:\s*hidden/)
|
||||
}
|
||||
assert.match(rule('pending-content'), /min-width:\s*0/)
|
||||
assert.match(rule('pending-arrow'), /flex-shrink:\s*0/)
|
||||
const card = /<view class="pending-card"[^>]+>/.exec(wxml)[0]
|
||||
assert.match(card, /data-id="{{item.id}}" bindtap="goToRecordDetail"/)
|
||||
const label = /aria-label="([^"]+)"/.exec(card)[1]
|
||||
for (const field of ['whenText', 'serviceName', 'statusText', 'hospitalName', 'patientName']) {
|
||||
assert.ok(label.includes(`item.${field}`))
|
||||
}
|
||||
})
|
||||
|
||||
function createHome(wx = {}) {
|
||||
@@ -56,7 +88,7 @@ test('导航信息不可用时保留默认布局,视图就绪恢复深色文
|
||||
assert.equal(restored(), 1)
|
||||
})
|
||||
|
||||
test('预约预览显示具体时间、状态和完整医院名,缺值使用可读提示', () => {
|
||||
test('预约预览保留时间数据、状态和完整医院名,缺值使用可读提示', () => {
|
||||
const { page } = createHome()
|
||||
const result = page.formatPendingRecord({
|
||||
_id: '1', status: 'pending',
|
||||
@@ -69,9 +101,30 @@ test('预约预览显示具体时间、状态和完整医院名,缺值使用
|
||||
assert.equal(result.hospitalName, '中国人民解放军总医院第九医学中心')
|
||||
const empty = page.formatPendingRecord({})
|
||||
assert.equal(empty.timeText, '时间待定')
|
||||
assert.equal(empty.whenText, '日期待定')
|
||||
assert.equal(empty.hospitalName, '医院待定')
|
||||
assert.equal(empty.serviceName, '陪诊服务')
|
||||
assert.equal(empty.patientName, '待补充')
|
||||
})
|
||||
|
||||
test('预约预览保留完整长文本,取消申请状态优先展示', () => {
|
||||
const { page } = createHome()
|
||||
const item = {
|
||||
_id: 'long-record',
|
||||
status: 'confirmed',
|
||||
cancelStatus: 'requested',
|
||||
hospital: { name: '中国人民解放军总医院第九医学中心门诊部' },
|
||||
patient: { name: '阿依古丽·阿卜杜拉' },
|
||||
escort: { serviceName: '全天陪诊与出入院手续代办服务' }
|
||||
}
|
||||
const result = page.formatPendingRecord(item)
|
||||
assert.equal(result.hospitalName, item.hospital.name)
|
||||
assert.equal(result.patientName, item.patient.name)
|
||||
assert.equal(result.serviceName, item.escort.serviceName)
|
||||
assert.equal(result.statusText, '待取消')
|
||||
assert.equal(result.statusTone, 'doing')
|
||||
})
|
||||
|
||||
test('预约预览按日期时间排序、最多三条,不修改原数组', () => {
|
||||
const { page } = createHome()
|
||||
const records = ['15:00', '08:00', '13:00', '10:00'].map((startTime, index) => ({
|
||||
|
||||
Reference in New Issue
Block a user