feat(escort): 预约页补齐免责协议并统一协议口径
itemdetail 预约弹窗补上与 itemorder 一致的免责协议勾选与阅读弹层,修复该页无协议确认(服务端已强制校验)导致无法下单;用户协议入口、页面与分享标题统一为「陪诊服务协议」,免责协议兜底标题同步更名。
This commit is contained in:
@@ -2,6 +2,9 @@ const API = require('../../utils/api.js')
|
||||
const { formatDate, LATEST_APPOINTMENT_TIME, buildTimeSlots } = require('../../utils/date.js')
|
||||
const { ensureLogin } = require('../../utils/auth.js')
|
||||
|
||||
// 免责协议标题兜底:接口未返回时也能在勾选行展示协议名称
|
||||
const DEFAULT_DISCLAIMER_TITLE = '陪诊服务免责协议'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
service: {},
|
||||
@@ -39,7 +42,15 @@ Page({
|
||||
// 医院下拉展开时,把医院行滚到弹窗滚动容器顶部,避免列表被裁掉
|
||||
popupScrollIntoView: '',
|
||||
// 点击「提交预约」后弹出支付方式选择,默认线下支付
|
||||
showPayPopup: false
|
||||
showPayPopup: false,
|
||||
// 下单前必须勾选确认《陪诊服务免责协议》
|
||||
agreementAgreed: false,
|
||||
agreementHint: false,
|
||||
agreementTitle: DEFAULT_DISCLAIMER_TITLE,
|
||||
showAgreementPopup: false,
|
||||
disclaimer: null,
|
||||
disclaimerLoading: false,
|
||||
disclaimerError: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -58,6 +69,8 @@ Page({
|
||||
|
||||
async initializePage() {
|
||||
this.setData({ pageLoading: true, pageError: '' })
|
||||
// 免责协议与表单并行预加载,避免用户点开协议时再空等
|
||||
this.loadDisclaimer()
|
||||
const services = await getApp().loadServices()
|
||||
if (!services) {
|
||||
this.setData({ pageLoading: false, pageError: '服务加载失败,请重试' })
|
||||
@@ -96,6 +109,51 @@ Page({
|
||||
this.initializePage()
|
||||
},
|
||||
|
||||
/**
|
||||
* 免责协议:与表单并行预加载,用户点开弹层或直接提交时都能立即展示
|
||||
*/
|
||||
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()
|
||||
},
|
||||
|
||||
onTabChange(e) {
|
||||
const tab = e.currentTarget.dataset.tab
|
||||
if (!tab || tab === this.data.activeTab) return
|
||||
@@ -307,6 +365,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: 'offline' })
|
||||
},
|
||||
@@ -349,6 +413,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 })
|
||||
@@ -375,7 +445,9 @@ Page({
|
||||
},
|
||||
shippingAddress: { address: data.shippingAddress.trim() },
|
||||
notes: { patientNote: data.remark.trim() },
|
||||
payment: { payChannel: data.payChannel }
|
||||
payment: { payChannel: data.payChannel },
|
||||
// 协议确认快照:回传用户实际阅读的协议版本,服务端与当前版本比对,不一致则拒绝
|
||||
agreement: { accepted: true, version: data.disclaimer?.version || '' }
|
||||
}
|
||||
},
|
||||
|
||||
@@ -446,7 +518,11 @@ Page({
|
||||
gender: '不限',
|
||||
genderIndex: 0,
|
||||
remark: '',
|
||||
shippingAddress: ''
|
||||
shippingAddress: '',
|
||||
// 协议按单次服务确认,重置表单后需重新勾选
|
||||
agreementAgreed: false,
|
||||
agreementHint: false,
|
||||
showAgreementPopup: false
|
||||
}, () => this.refreshHospitalOptions(provinces[0] || ''))
|
||||
// 重置后仍默认选中第一个就诊人,方便连续预约
|
||||
const first = this.data.profiles[0]
|
||||
|
||||
Reference in New Issue
Block a user