27 lines
660 B
JavaScript
27 lines
660 B
JavaScript
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
settings: null,
|
|
},
|
|
onShow() {
|
|
wx.request({
|
|
url: `${app.globalData.baseUrl}/api/v1/settings`,
|
|
header: { 'X-OpenID': app.globalData.openid || '' },
|
|
success: (res) => {
|
|
this.setData({ settings: res.data })
|
|
},
|
|
})
|
|
},
|
|
save() {
|
|
const settings = this.data.settings || {}
|
|
wx.request({
|
|
url: `${app.globalData.baseUrl}/api/v1/settings`,
|
|
method: 'PUT',
|
|
header: { 'Content-Type': 'application/json', 'X-OpenID': app.globalData.openid || '' },
|
|
data: settings,
|
|
success: () => wx.showToast({ title: '已保存', icon: 'success' }),
|
|
})
|
|
},
|
|
})
|