24 lines
722 B
JavaScript
24 lines
722 B
JavaScript
const authApi = require('../../api/auth')
|
|
|
|
Page({
|
|
data: { loading: true, agreement: null },
|
|
|
|
onLoad(options) {
|
|
this.load(options && options.type)
|
|
},
|
|
|
|
async load(type) {
|
|
const agreementType = type === 'PRIVACY_POLICY' ? 'PRIVACY_POLICY' : 'USER_TERMS'
|
|
this.setData({ loading: true })
|
|
try {
|
|
const agreements = await authApi.getCurrentAgreements()
|
|
const agreement = (Array.isArray(agreements) ? agreements : []).find(item => item.agreementType === agreementType)
|
|
this.setData({ agreement: agreement || null })
|
|
} catch (error) {
|
|
wx.showToast({ title: error.message || '协议加载失败', icon: 'none' })
|
|
} finally {
|
|
this.setData({ loading: false })
|
|
}
|
|
}
|
|
})
|