44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/** 公益红娘协助授权说明页(演示测试稿) */
|
|||
|
|
const { matchmakerService } = require('../../services');
|
||
|
|
const authorizationStatement = require('../../assets/matchmaker-authorization-test');
|
||
|
|
|
||
|
|
Page({
|
||
|
|
data: {
|
||
|
|
title: authorizationStatement.title,
|
||
|
|
content: authorizationStatement.content,
|
||
|
|
targetUserId: '',
|
||
|
|
submitting: false,
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad(options) {
|
||
|
|
this.setData({ targetUserId: options.targetUserId || '' });
|
||
|
|
},
|
||
|
|
|
||
|
|
async onAgree() {
|
||
|
|
if (!this.data.targetUserId || this.data.submitting) return;
|
||
|
|
this.setData({ submitting: true });
|
||
|
|
try {
|
||
|
|
const service = await matchmakerService.applyService({
|
||
|
|
serviceType: 'recommendation_assistance',
|
||
|
|
targetUserId: this.data.targetUserId,
|
||
|
|
description: '希望公益红娘协助了解公益活动和线下服务',
|
||
|
|
authorizationAccepted: true,
|
||
|
|
});
|
||
|
|
if (service && (service.serviceId || service.id)) {
|
||
|
|
wx.setStorageSync('lastServiceId', service.serviceId || service.id);
|
||
|
|
}
|
||
|
|
wx.showToast({ title: '申请已提交', icon: 'success' });
|
||
|
|
setTimeout(() => {
|
||
|
|
wx.redirectTo({ url: '/pages/matchmaker-progress/matchmaker-progress' });
|
||
|
|
}, 500);
|
||
|
|
} catch (err) {
|
||
|
|
wx.showToast({ title: (err && err.message) || '申请失败,请稍后重试', icon: 'none' });
|
||
|
|
this.setData({ submitting: false });
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onCancel() {
|
||
|
|
wx.navigateBack();
|
||
|
|
},
|
||
|
|
});
|