chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 隐私设置页 U43
|
||||
*/
|
||||
const api = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
visibleInRecommendations: true,
|
||||
allowActivityInvitation: true,
|
||||
showLastOnline: false,
|
||||
saving: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadSettings();
|
||||
},
|
||||
|
||||
async loadSettings() {
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
const res = await api.get('/account/privacy-settings', {}, { Authorization: `Bearer ${token}` });
|
||||
this.setData({
|
||||
visibleInRecommendations: res.visibleInRecommendations !== false,
|
||||
allowActivityInvitation: res.allowActivityInvitation !== false,
|
||||
showLastOnline: res.showLastOnline === true
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
|
||||
onVisibleChange(e) {
|
||||
this.setData({ visibleInRecommendations: e.detail.value });
|
||||
},
|
||||
|
||||
onActivityInvitationChange(e) {
|
||||
this.setData({ allowActivityInvitation: e.detail.value });
|
||||
},
|
||||
|
||||
onShowLastOnlineChange(e) {
|
||||
this.setData({ showLastOnline: e.detail.value });
|
||||
},
|
||||
|
||||
async saveSettings() {
|
||||
this.setData({ saving: true });
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
await api.put('/account/privacy-settings', {
|
||||
visibleInRecommendations: this.data.visibleInRecommendations,
|
||||
allowActivityInvitation: this.data.allowActivityInvitation,
|
||||
showLastOnline: this.data.showLastOnline
|
||||
}, { Authorization: `Bearer ${token}` });
|
||||
wx.showToast({ title: '保存成功', icon: 'success' });
|
||||
} catch (err) {
|
||||
wx.showToast({ title: '保存失败', icon: 'none' });
|
||||
} finally {
|
||||
this.setData({ saving: false });
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user