itemdetail 预约弹窗补上与 itemorder 一致的免责协议勾选与阅读弹层,修复该页无协议确认(服务端已强制校验)导致无法下单;用户协议入口、页面与分享标题统一为「陪诊服务协议」,免责协议兜底标题同步更名。
73 lines
1.5 KiB
JavaScript
73 lines
1.5 KiB
JavaScript
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
agreement: null,
|
|
loading: true,
|
|
error: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {
|
|
this.loadAgreement()
|
|
},
|
|
|
|
loadAgreement() {
|
|
this.setData({ loading: true, error: false })
|
|
getApp().loadAgreement().then((agreement) => {
|
|
this.setData({
|
|
agreement: agreement ? this.formatAgreement(agreement) : null,
|
|
loading: false,
|
|
error: !agreement
|
|
})
|
|
})
|
|
},
|
|
|
|
// 服务端协议保留简洁文案结构,页面渲染前补稳定键,不在 WXML 使用索引或值本身作 key。
|
|
formatAgreement(agreement) {
|
|
const toItems = list => (list || []).map((text, index) => ({
|
|
id: `${index}_${text}`,
|
|
text
|
|
}))
|
|
return {
|
|
...agreement,
|
|
sections: (agreement.sections || []).map(section => ({
|
|
...section,
|
|
items: section.items ? toItems(section.items) : section.items,
|
|
table: section.table ? {
|
|
headers: toItems(section.table.headers),
|
|
rows: (section.table.rows || []).map(row => ({
|
|
id: row.join('|'),
|
|
cells: toItems(row)
|
|
}))
|
|
} : section.table
|
|
})),
|
|
footer: toItems(agreement.footer)
|
|
}
|
|
},
|
|
|
|
retry() {
|
|
this.loadAgreement()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
return {
|
|
title: '陪诊服务协议',
|
|
path: '/pages/escort/agreement'
|
|
}
|
|
},
|
|
|
|
onShareTimeline() {
|
|
return {
|
|
title: '陪诊服务协议'
|
|
}
|
|
}
|
|
})
|