committed by
trae-solo-agent
co-authored by
Kimi-K3.1-Pro noreply@moonshot.cn
parent
1181d598b4
commit
df96cb3b07
@@ -20,13 +20,36 @@ Page({
|
||||
this.setData({ loading: true, error: false })
|
||||
getApp().loadAgreement().then((agreement) => {
|
||||
this.setData({
|
||||
agreement: agreement || null,
|
||||
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()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user