87 lines
2.5 KiB
JavaScript
87 lines
2.5 KiB
JavaScript
/**
|
|||
|
|
* 我的婚恋状态页 U41
|
||
|
|
* 展示当前状态,提供退出服务/正在了解/成功牵手入口
|
||
|
|
*/
|
||
|
|
const api = require('../../utils/api');
|
||
|
|
|
||
|
|
Page({
|
||
|
|
data: {
|
||
|
|
relationshipStatus: 'searching', // searching, paused, getting_to_know, matched_successfully
|
||
|
|
recommendationEnabled: true,
|
||
|
|
matchCount: 0,
|
||
|
|
loading: false
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad() {
|
||
|
|
this.loadStatus();
|
||
|
|
},
|
||
|
|
|
||
|
|
onShow() {
|
||
|
|
this.loadStatus();
|
||
|
|
},
|
||
|
|
|
||
|
|
async loadStatus() {
|
||
|
|
try {
|
||
|
|
const token = wx.getStorageSync('accessToken');
|
||
|
|
const res = await api.get('/account/status', {}, { Authorization: `Bearer ${token}` });
|
||
|
|
this.setData({
|
||
|
|
relationshipStatus: res.relationshipStatus || 'searching',
|
||
|
|
recommendationEnabled: res.recommendationEnabled !== false,
|
||
|
|
matchCount: res.activeMatchCount || 0
|
||
|
|
});
|
||
|
|
} catch (err) {
|
||
|
|
console.error(err);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
async withdrawService() {
|
||
|
|
wx.showModal({
|
||
|
|
title: '退出婚恋服务',
|
||
|
|
content: '退出后您的资料将不再展示,系统不再为您推荐对象,但账号保留。是否继续?',
|
||
|
|
success: async (ret) => {
|
||
|
|
if (ret.confirm) {
|
||
|
|
try {
|
||
|
|
const token = wx.getStorageSync('accessToken');
|
||
|
|
await api.post('/account/withdraw', {}, { Authorization: `Bearer ${token}` });
|
||
|
|
this.setData({ recommendationEnabled: false, relationshipStatus: 'paused' });
|
||
|
|
wx.showToast({ title: '已退出婚恋服务', icon: 'success' });
|
||
|
|
} catch (err) {
|
||
|
|
wx.showToast({ title: err.message || '操作失败', icon: 'none' });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
async resumeService() {
|
||
|
|
try {
|
||
|
|
const token = wx.getStorageSync('accessToken');
|
||
|
|
await api.post('/account/resume', {}, { Authorization: `Bearer ${token}` });
|
||
|
|
this.setData({ recommendationEnabled: true, relationshipStatus: 'searching' });
|
||
|
|
wx.showToast({ title: '已重新开启', icon: 'success' });
|
||
|
|
} catch (err) {
|
||
|
|
wx.showToast({ title: err.message || '操作失败', icon: 'none' });
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
goSuccessConfirm() {
|
||
|
|
wx.navigateTo({ url: '/pages/success-confirm/success-confirm' });
|
||
|
|
},
|
||
|
|
|
||
|
|
goPrivacy() {
|
||
|
|
wx.navigateTo({ url: '/pages/privacy-settings/privacy-settings' });
|
||
|
|
},
|
||
|
|
|
||
|
|
goLogout() {
|
||
|
|
wx.showModal({
|
||
|
|
title: '注销账号',
|
||
|
|
content: '注销后所有数据将被删除且不可恢复,是否继续?',
|
||
|
|
success: (ret) => {
|
||
|
|
if (ret.confirm) {
|
||
|
|
wx.navigateTo({ url: '/pages/account-logout/account-logout' });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|