feat: 完善双端演示注册与红娘服务闭环
This commit is contained in:
@@ -4,10 +4,13 @@ Page({
|
||||
data: {
|
||||
serviceId: '',
|
||||
detail: null,
|
||||
source: 'assignment',
|
||||
statusLabel: '',
|
||||
followups: [],
|
||||
followupTypes: ['followup', '需求了解', '候选建议', '活动协助', '其他'],
|
||||
loading: true,
|
||||
submitting: false,
|
||||
changingStatus: false,
|
||||
form: { followupType: 'followup', content: '', nextFollowupAt: '' },
|
||||
},
|
||||
|
||||
@@ -18,7 +21,7 @@ Page({
|
||||
wx.navigateBack();
|
||||
return;
|
||||
}
|
||||
this.setData({ serviceId });
|
||||
this.setData({ serviceId, source: options.source === 'management' ? 'management' : 'assignment' });
|
||||
this.loadDetail();
|
||||
},
|
||||
|
||||
@@ -34,8 +37,10 @@ Page({
|
||||
async loadDetail() {
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const detail = await api.get(`/operator/matchmaker/services/${this.data.serviceId}`, {}, this.tokenHeaders());
|
||||
this.setData({ detail: detail || null, followups: (detail && detail.followups) || [] });
|
||||
const path = this.data.source === 'management' ? '/operator/matchmaker/management/services/' : '/operator/matchmaker/services/';
|
||||
const detail = await api.get(`${path}${encodeURIComponent(this.data.serviceId)}`, {}, this.tokenHeaders());
|
||||
const labels = { submitted: '待处理', assigned: '已接单', in_service: '服务中', waiting_user: '待用户确认', completed: '已完成' };
|
||||
this.setData({ detail: detail || null, statusLabel: labels[detail && detail.status] || (detail && detail.status) || '', followups: (detail && detail.followups) || [] });
|
||||
} catch (error) {
|
||||
if (error && (error.code === 'FORBIDDEN' || error.code === 'NOT_FOUND' || error.code === 'DATA_SCOPE_DENIED')) {
|
||||
wx.showModal({ title: '服务权限已变更', content: '该服务对象已结束或不再属于当前服务范围。', showCancel: false,
|
||||
@@ -48,6 +53,21 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async changeStatus(e) {
|
||||
const action = e.currentTarget.dataset.action;
|
||||
if (this.data.changingStatus || this.data.source === 'management') return;
|
||||
this.setData({ changingStatus: true });
|
||||
try {
|
||||
await api.post(`/operator/matchmaker/services/${encodeURIComponent(this.data.serviceId)}/${action}`, {}, this.tokenHeaders());
|
||||
wx.showToast({ title: action === 'start' ? '服务已开始' : '服务已完成', icon: 'success' });
|
||||
await this.loadDetail();
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '操作失败', icon: 'none' });
|
||||
} finally {
|
||||
this.setData({ changingStatus: false });
|
||||
}
|
||||
},
|
||||
|
||||
onTypeChange(e) { this.setData({ 'form.followupType': this.data.followupTypes[Number(e.detail.value)] || 'followup' }); },
|
||||
onContentInput(e) { this.setData({ 'form.content': e.detail.value }); },
|
||||
onNextFollowupInput(e) { this.setData({ 'form.nextFollowupAt': e.detail.value }); },
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
<text>地区:{{detail.userProfile.regionName || '未设置'}}</text>
|
||||
<text>婚姻状态:{{detail.userProfile.maritalStatus || '未设置'}}</text>
|
||||
</view>
|
||||
<view class="status">服务状态:{{detail.status}}</view>
|
||||
<view class="status">服务状态:{{statusLabel}}</view>
|
||||
<view wx:if="{{detail.description}}" class="description">服务需求:{{detail.description}}</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card" wx:if="{{source === 'assignment' && detail.status !== 'completed'}}">
|
||||
<view class="title">记录服务</view>
|
||||
<picker mode="selector" range="{{followupTypes}}" value="0" bindchange="onTypeChange">
|
||||
<view class="picker">服务类型:{{form.followupType}}</view>
|
||||
@@ -25,6 +25,13 @@
|
||||
<button type="primary" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submitFollowup">保存服务记录</button>
|
||||
</view>
|
||||
|
||||
<view class="card" wx:if="{{source === 'assignment' && detail.status === 'assigned'}}">
|
||||
<button type="primary" loading="{{changingStatus}}" disabled="{{changingStatus}}" bindtap="changeStatus" data-action="start">开始服务</button>
|
||||
</view>
|
||||
<view class="card" wx:if="{{source === 'assignment' && (detail.status === 'in_service' || detail.status === 'waiting_user')}}">
|
||||
<button loading="{{changingStatus}}" disabled="{{changingStatus}}" bindtap="changeStatus" data-action="complete">完成服务</button>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="title">服务历史</view>
|
||||
<view wx:if="{{followups.length}}">
|
||||
|
||||
Reference in New Issue
Block a user