feat(escort): 下单页增加免责协议勾选与协议弹层
提交预约前须勾选《全程陪诊服务免责协议》,点击协议名弹层查看全文;提交时回传所读版本,服务端判定过期则作废缓存并重新弹层要求重新确认。
This commit is contained in:
@@ -222,6 +222,29 @@ App({
|
||||
return this.globalData.agreementReady
|
||||
},
|
||||
|
||||
// 下单页的免责协议:与「用户协议」分开缓存,正文修订后随接口即时生效
|
||||
loadDisclaimer() {
|
||||
if (this.globalData.disclaimerReady) return this.globalData.disclaimerReady
|
||||
this.globalData.disclaimerReady = API.resource.getDisclaimer()
|
||||
.then((res) => {
|
||||
if (res.code !== 0 || !res.data?.disclaimer) throw new Error(res.msg || '免责协议加载失败')
|
||||
this.globalData.disclaimer = res.data.disclaimer
|
||||
return this.globalData.disclaimer
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('获取免责协议失败', err)
|
||||
this.globalData.disclaimerReady = null
|
||||
return null
|
||||
})
|
||||
return this.globalData.disclaimerReady
|
||||
},
|
||||
|
||||
// 服务端判定协议版本不一致后调用:作废缓存,下次 loadDisclaimer 重新拉取最新版
|
||||
invalidateDisclaimer() {
|
||||
this.globalData.disclaimer = null
|
||||
this.globalData.disclaimerReady = null
|
||||
},
|
||||
|
||||
// 已经拿到用户(如「我的」页手机号授权登录成功)就直接返回成功。
|
||||
// 但若此刻有静默登录在飞(token 可能正在轮换),要先等它落定:
|
||||
// 抢跑会让页面拿旧 token 发请求、收到 401 再触发一次重登 + 重试。
|
||||
@@ -353,6 +376,8 @@ App({
|
||||
hospitalsReady: null,
|
||||
agreement: null,
|
||||
agreementReady: null,
|
||||
disclaimer: null,
|
||||
disclaimerReady: null,
|
||||
authReady: null,
|
||||
}
|
||||
})
|
||||
@@ -8,6 +8,8 @@ const SERVICE_OPTION_HEIGHT = 108
|
||||
const SERVICE_PANEL_RESERVED = 200
|
||||
// 与陪诊师列表 / 详情页共用的选择结果 key
|
||||
const SELECTED_ATTENDANT_KEY = 'escort_selected_attendant'
|
||||
// 免责协议标题兜底:接口未返回时也能在勾选行展示协议名称
|
||||
const DEFAULT_DISCLAIMER_TITLE = '全程陪诊服务免责协议'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -48,7 +50,15 @@ Page({
|
||||
genderIndex: 0,
|
||||
genderOptions: ['不限', '男', '女'],
|
||||
// 用户指定陪诊师(选填);为空则由平台抢单或管理端指派
|
||||
selectedAttendant: null
|
||||
selectedAttendant: null,
|
||||
// 下单前必须勾选确认《全程陪诊服务免责协议》
|
||||
agreementAgreed: false,
|
||||
agreementHint: false,
|
||||
agreementTitle: DEFAULT_DISCLAIMER_TITLE,
|
||||
showAgreementPopup: false,
|
||||
disclaimer: null,
|
||||
disclaimerLoading: false,
|
||||
disclaimerError: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -92,9 +102,56 @@ Page({
|
||||
this.setData({ selectedAttendant: null })
|
||||
},
|
||||
|
||||
/**
|
||||
* 免责协议:与表单并行预加载,用户点开弹层或直接提交时都能立即展示
|
||||
*/
|
||||
loadDisclaimer() {
|
||||
if (this.data.disclaimer || this.data.disclaimerLoading) return
|
||||
this.setData({ disclaimerLoading: true, disclaimerError: false })
|
||||
getApp().loadDisclaimer().then((disclaimer) => {
|
||||
this.setData({
|
||||
disclaimer,
|
||||
agreementTitle: disclaimer?.title || DEFAULT_DISCLAIMER_TITLE,
|
||||
disclaimerLoading: false,
|
||||
disclaimerError: !disclaimer
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
onToggleAgreement() {
|
||||
if (this.data.submitting) return
|
||||
this.setData({
|
||||
agreementAgreed: !this.data.agreementAgreed,
|
||||
agreementHint: false
|
||||
})
|
||||
},
|
||||
|
||||
onOpenAgreement() {
|
||||
this.setData({ showAgreementPopup: true })
|
||||
this.loadDisclaimer()
|
||||
},
|
||||
|
||||
onCloseAgreementPopup() {
|
||||
this.setData({ showAgreementPopup: false })
|
||||
},
|
||||
|
||||
onAgreeFromPopup() {
|
||||
this.setData({
|
||||
agreementAgreed: true,
|
||||
agreementHint: false,
|
||||
showAgreementPopup: false
|
||||
})
|
||||
},
|
||||
|
||||
retryLoadDisclaimer() {
|
||||
this.loadDisclaimer()
|
||||
},
|
||||
|
||||
async initializePage() {
|
||||
this.pageReady = false
|
||||
this.setData({ pageLoading: true, pageError: '' })
|
||||
// 免责协议与表单并行加载,避免用户点开协议时再空等
|
||||
this.loadDisclaimer()
|
||||
const services = await getApp().loadServices()
|
||||
if (!services || services.length === 0) {
|
||||
this.setData({ pageLoading: false, pageError: '服务加载失败,请重试' })
|
||||
@@ -360,6 +417,12 @@ Page({
|
||||
wx.showToast({ title: error, icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 免责协议是下单前置条件:未勾选时直接拉起协议弹层,读完即可勾选
|
||||
if (!this.data.agreementAgreed) {
|
||||
this.setData({ agreementHint: true, showAgreementPopup: true })
|
||||
this.loadDisclaimer()
|
||||
return
|
||||
}
|
||||
this.setData({ showPayPopup: true, payChannel: 'online_wechat' })
|
||||
},
|
||||
|
||||
@@ -409,6 +472,12 @@ Page({
|
||||
else wx.navigateTo({ url: '/pages/escort/recordlist?tab=ongoing' })
|
||||
} catch (err) {
|
||||
console.log('下单失败', err)
|
||||
// 服务端判定协议版本不一致:作废本地缓存、重新拉取并弹出协议要求重新确认
|
||||
if ((err.message || '').includes('协议已更新')) {
|
||||
getApp().invalidateDisclaimer()
|
||||
this.setData({ disclaimer: null, agreementAgreed: false, showAgreementPopup: true })
|
||||
this.loadDisclaimer()
|
||||
}
|
||||
wx.showToast({ title: err.message || '网络请求失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ submitting: false })
|
||||
@@ -436,6 +505,8 @@ Page({
|
||||
shippingAddress: { address: data.shippingAddress.trim() },
|
||||
notes: { patientNote: data.remark.trim() },
|
||||
payment: { payChannel: data.payChannel },
|
||||
// 协议确认快照:回传用户实际阅读的协议版本,服务端与当前版本比对,不一致则拒绝
|
||||
agreement: { accepted: true, version: data.disclaimer?.version || '' },
|
||||
// 只传 employeeId,姓名 / 电话由服务端按员工档案回填
|
||||
...(data.selectedAttendant
|
||||
? { attendant: { employeeId: data.selectedAttendant.id } }
|
||||
@@ -512,7 +583,11 @@ Page({
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: '',
|
||||
selectedAttendant: null
|
||||
selectedAttendant: null,
|
||||
// 协议按单次服务确认,重置表单后需重新勾选
|
||||
agreementAgreed: false,
|
||||
agreementHint: false,
|
||||
showAgreementPopup: false
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
// 重置后仍默认选中第一个就诊人,方便连续预约
|
||||
const first = this.data.profiles[0]
|
||||
|
||||
@@ -155,6 +155,20 @@
|
||||
<textarea class="order-textarea" value="{{remark}}" placeholder="请输入其他需求或备注信息" maxlength="200" placeholder-class="input-placeholder" bindinput="onRemarkChange" />
|
||||
<text class="textarea-count">{{remark.length}}/200</text>
|
||||
</view>
|
||||
|
||||
<!-- 下单前置确认:勾选后才允许提交预约 -->
|
||||
<view class="agreement-block {{agreementHint ? 'is-hint' : ''}}">
|
||||
<view class="agreement-row" bindtap="onToggleAgreement" aria-role="checkbox" aria-checked="{{agreementAgreed}}">
|
||||
<view class="agreement-check {{agreementAgreed ? 'checked' : ''}}">
|
||||
<t-icon wx:if="{{agreementAgreed}}" name="check" size="22rpx" color="#FFFFFF" />
|
||||
</view>
|
||||
<view class="agreement-consent">
|
||||
<text class="agreement-consent-text">我已阅读并同意</text>
|
||||
<text class="agreement-link" catchtap="onOpenAgreement">《{{agreementTitle}}》</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="agreement-hint" wx:if="{{agreementHint}}">请勾选同意后再提交预约</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-placeholder"></view>
|
||||
@@ -220,4 +234,47 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 免责协议弹层:下单前必须阅读并勾选同意 -->
|
||||
<view class="popup-mask {{showAgreementPopup ? 'show' : ''}}" bindtap="onCloseAgreementPopup"></view>
|
||||
<view class="popup-content agreement-popup {{showAgreementPopup ? 'show' : ''}}">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">{{agreementTitle}}</text>
|
||||
<view class="popup-close" aria-role="button" aria-label="关闭弹窗" bindtap="onCloseAgreementPopup">
|
||||
<t-icon name="close" size="40rpx" color="#6F655C" />
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="agreement-popup-body" scroll-y>
|
||||
<block wx:if="{{disclaimer}}">
|
||||
<text class="agreement-popup-subtitle" wx:if="{{disclaimer.subtitle}}">{{disclaimer.subtitle}}</text>
|
||||
<view class="agreement-section" wx:for="{{disclaimer.sections}}" wx:key="number">
|
||||
<view class="agreement-section-title">
|
||||
<view class="agreement-section-number">{{item.number}}</view>
|
||||
<text>{{item.title}}</text>
|
||||
</view>
|
||||
<block wx:if="{{item.type === 'list'}}">
|
||||
<view class="agreement-item" wx:for="{{item.items}}" wx:for-item="subItem" wx:key="*this">
|
||||
<view class="agreement-item-dot"></view>
|
||||
<text class="agreement-item-text">{{subItem}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="agreement-popup-footer" wx:if="{{disclaimer.footer.length}}">
|
||||
<text class="agreement-popup-footer-text" wx:for="{{disclaimer.footer}}" wx:for-item="footItem" wx:key="*this">{{footItem}}</text>
|
||||
</view>
|
||||
</block>
|
||||
<view class="agreement-popup-state" wx:elif="{{disclaimerLoading}}">
|
||||
<t-loading theme="circular" size="40rpx" text="加载中..." />
|
||||
</view>
|
||||
<view class="agreement-popup-state" wx:elif="{{disclaimerError}}">
|
||||
<text class="page-state-text">协议加载失败,请重试</text>
|
||||
<button class="page-retry" bindtap="retryLoadDisclaimer">重新加载</button>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="popup-footer">
|
||||
<view class="popup-btn popup-btn-ghost" bindtap="onCloseAgreementPopup">暂不</view>
|
||||
<view class="popup-btn popup-btn-primary" wx:if="{{disclaimer}}" bindtap="onAgreeFromPopup">我已阅读并同意</view>
|
||||
<view class="popup-btn popup-btn-primary" wx:else bindtap="retryLoadDisclaimer">重新加载</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
+161
-1
@@ -709,10 +709,170 @@ page {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* ===== 免责协议确认(下单前置勾选) ===== */
|
||||
.agreement-block {
|
||||
padding: 26rpx 0 30rpx;
|
||||
}
|
||||
|
||||
.agreement-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.agreement-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-top: 2rpx;
|
||||
border: 2rpx solid var(--brand-line);
|
||||
border-radius: 50%;
|
||||
background: var(--white);
|
||||
transition: background 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
/* 选中态沿用全站唯一实心主色,白色对勾直接落在主色上 */
|
||||
.agreement-check.checked {
|
||||
border-color: var(--brand-strong);
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
.agreement-consent {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-consent-text {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-26);
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-26);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.agreement-block.is-hint .agreement-consent-text {
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
.agreement-hint {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
margin-left: 52rpx;
|
||||
color: var(--brand-strong);
|
||||
font-size: var(--fs-24);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ===== 免责协议弹层:正文区可滚动,底部固定同意按钮 ===== */
|
||||
.agreement-popup {
|
||||
height: 80vh;
|
||||
max-height: 80vh;
|
||||
}
|
||||
|
||||
.agreement-popup-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 32rpx 8rpx;
|
||||
}
|
||||
|
||||
.agreement-popup-subtitle {
|
||||
display: block;
|
||||
margin-bottom: 24rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
border-radius: 14rpx;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-24);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-section {
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.agreement-section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 12rpx;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-28);
|
||||
font-weight: 700;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.agreement-section-number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 12rpx;
|
||||
border: 2rpx solid var(--brand-line);
|
||||
border-radius: 50%;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-ink);
|
||||
font-size: var(--fs-24);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.agreement-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.agreement-item-dot {
|
||||
flex-shrink: 0;
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
margin: 14rpx 12rpx 0 0;
|
||||
border-radius: 50%;
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
.agreement-item-text {
|
||||
flex: 1;
|
||||
color: var(--ink-2);
|
||||
font-size: var(--fs-26);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.agreement-popup-footer {
|
||||
margin-top: 8rpx;
|
||||
padding: 16rpx 0 24rpx;
|
||||
border-top: 2rpx dotted var(--sep);
|
||||
}
|
||||
|
||||
.agreement-popup-footer-text {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-24);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-popup-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 80rpx 0;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.patient-chip,
|
||||
.add-profile-tip,
|
||||
.submit-btn {
|
||||
.submit-btn,
|
||||
.agreement-check {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@ const API = {
|
||||
resource: {
|
||||
getServices: (params) => request.get('/health/service', params),
|
||||
getAgreement: (params) => request.get('/health/agreement', params),
|
||||
// 下单前需勾选确认的《全程陪诊服务免责协议》
|
||||
getDisclaimer: (params) => request.get('/health/disclaimer', params),
|
||||
getAiQuickQuestions: (params) => request.get('/health/ai-quick-questions', params),
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user