51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
/**
|
|
* 红娘服务申请页 U34
|
|
*/
|
|
const api = require('../../utils/api');
|
|
|
|
Page({
|
|
data: {
|
|
serviceTypes: [
|
|
{ code: 'recommend_partner', name: '帮我推荐合适的人', icon: '👤' },
|
|
{ code: 'review_preference', name: '帮我看看择偶条件', icon: '📋' },
|
|
{ code: 'contact_intention', name: '帮我联系意向对象', icon: '💬' },
|
|
{ code: 'join_activity', name: '想参加线下活动', icon: '🎉' },
|
|
{ code: 'no_match_help', name: '匹配很久没有结果', icon: '😟' },
|
|
{ code: 'chat_help', name: '不知道怎么开始聊天', icon: '✉️' },
|
|
{ code: 'other', name: '其他', icon: '❓' }
|
|
],
|
|
selectedType: '',
|
|
description: '',
|
|
submitting: false
|
|
},
|
|
|
|
onTypeSelect(e) {
|
|
this.setData({ selectedType: e.currentTarget.dataset.type });
|
|
},
|
|
|
|
onDescriptionInput(e) {
|
|
this.setData({ description: e.detail.value });
|
|
},
|
|
|
|
async onSubmit() {
|
|
if (!this.data.selectedType) {
|
|
wx.showToast({ title: '请选择服务类型', icon: 'none' });
|
|
return;
|
|
}
|
|
this.setData({ submitting: true });
|
|
try {
|
|
const token = wx.getStorageSync('accessToken');
|
|
const res = await api.post('/matchmaker/services', {
|
|
serviceType: this.data.selectedType,
|
|
description: this.data.description
|
|
}, { Authorization: `Bearer ${token}` });
|
|
wx.setStorageSync('lastServiceId', res.serviceId);
|
|
wx.redirectTo({ url: '/pages/matchmaker-progress/matchmaker-progress' });
|
|
} catch (err) {
|
|
wx.showToast({ title: err.message || '提交失败', icon: 'none' });
|
|
} finally {
|
|
this.setData({ submitting: false });
|
|
}
|
|
}
|
|
});
|