chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const app = getApp<{ globalData: { apiBase: string; token: string } }>();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name: '', phone: '', hasCompanion: false, companionName: '',
|
||||
preferredTime: '', summary: '', submitting: false
|
||||
},
|
||||
onNameInput(e: any) { this.setData({ name: e.detail.value }); },
|
||||
onPhoneInput(e: any) { this.setData({ phone: e.detail.value }); },
|
||||
onCompanionChange(e: any) { this.setData({ hasCompanion: e.detail.value }); },
|
||||
onCompanionNameInput(e: any) { this.setData({ companionName: e.detail.value }); },
|
||||
onTimeInput(e: any) { this.setData({ preferredTime: e.detail.value }); },
|
||||
onSummaryInput(e: any) { this.setData({ summary: e.detail.value }); },
|
||||
|
||||
async onSubmit() {
|
||||
const { name, phone, hasCompanion, companionName, preferredTime, summary } = this.data;
|
||||
if (!name || !phone) return wx.showToast({ title: '请填写姓名和联系方式', icon: 'none' });
|
||||
this.setData({ submitting: true });
|
||||
try {
|
||||
await wx.request({
|
||||
url: `${app.globalData.apiBase}/counseling/services`,
|
||||
method: 'POST',
|
||||
header: { 'Authorization': `Bearer ${app.globalData.token}`, 'Content-Type': 'application/json' },
|
||||
data: {
|
||||
serviceType: 'premarital_guidance',
|
||||
preferredTime,
|
||||
userRequestSummary: summary || `申请人:${name},电话:${phone}${hasCompanion ? `,伴侣:${companionName}` : ''}`,
|
||||
requestSource: 'user_self'
|
||||
}
|
||||
});
|
||||
wx.showToast({ title: '申请已提交', icon: 'success' });
|
||||
setTimeout(() => wx.redirectTo({ url: '/pages/my-counseling/my-counseling' }), 1500);
|
||||
} catch (e) {
|
||||
wx.showToast({ title: '提交失败,请重试', icon: 'none' });
|
||||
} finally {
|
||||
this.setData({ submitting: false });
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user