feat(closed-loop): complete end-to-end closed loops across miniapp, backend, and admin
这个提交包含在:
@@ -82,21 +82,29 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="author-actions">
|
||||
<button
|
||||
v-if="isPostOwner(post)"
|
||||
class="btn-delete-post btn-active"
|
||||
@click.stop="handleDeletePost(post)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
<template v-if="isPostOwner(post)">
|
||||
<button
|
||||
class="join-btn btn-active"
|
||||
style="margin-right: 12rpx;"
|
||||
@click.stop="handleManageApplies(post)"
|
||||
>
|
||||
申请({{ post.applyCount || 0 }})
|
||||
</button>
|
||||
<button
|
||||
class="btn-delete-post btn-active"
|
||||
@click.stop="handleDeletePost(post)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</template>
|
||||
<button
|
||||
v-else
|
||||
class="join-btn btn-active"
|
||||
:class="{ 'btn-applied': post.hasApplied }"
|
||||
:disabled="post.hasApplied"
|
||||
:class="{ 'btn-applied': post.hasApplied && post.myApplyStatus !== 'REJECTED' }"
|
||||
:disabled="post.hasApplied && post.myApplyStatus !== 'REJECTED'"
|
||||
@click="handleJoinParty(post)"
|
||||
>
|
||||
{{ post.hasApplied ? '已申请' : (post.actionText || '聊一聊') }}
|
||||
{{ post.myApplyStatus === 'ACCEPTED' ? '已同意上车' : (post.myApplyStatus === 'REJECTED' ? '重新申请' : (post.hasApplied ? '待房主确认' : (post.actionText || '聊一聊'))) }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -389,7 +397,7 @@ import SkeletonScreen from '@/components/SkeletonScreen.vue';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
import { getNavBarInfo } from '@/common/nav.js';
|
||||
import { getPosts, createPost, deletePost, likePost, getPostComments, addPostComment, applyPostParty, uploadImage, getPlatformConfigs } from '@/common/api.js';
|
||||
import { getPosts, createPost, deletePost, likePost, getPostComments, addPostComment, applyPostParty, getPostApplies, handlePostApply, uploadImage, getPlatformConfigs } from '@/common/api.js';
|
||||
|
||||
const isLoading = ref(true);
|
||||
const currentThemeKey = ref(getCurrentThemeKey());
|
||||
@@ -473,12 +481,14 @@ const loadRemotePosts = async () => {
|
||||
if (!Array.isArray(localAppliedIds)) localAppliedIds = [];
|
||||
|
||||
posts.value = list.map(item => {
|
||||
const isApplied = localAppliedIds.includes(String(item.id));
|
||||
const serverStatus = item.myApplyStatus || null;
|
||||
const isApplied = serverStatus ? (serverStatus !== 'REJECTED') : localAppliedIds.includes(String(item.id));
|
||||
return {
|
||||
...item,
|
||||
myApplyStatus: serverStatus || (isApplied ? 'PENDING' : null),
|
||||
liked: item.liked !== undefined ? item.liked : localLikedIds.includes(String(item.id)),
|
||||
hasApplied: isApplied,
|
||||
actionText: isApplied ? '已申请' : (item.actionText || '加入车队')
|
||||
actionText: serverStatus === 'ACCEPTED' ? '已同意上车' : (isApplied ? '待房主确认' : (item.actionText || '加入车队'))
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -763,10 +773,59 @@ const handleDeletePost = (post) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleManageApplies = async (post) => {
|
||||
uni.showLoading({ title: '加载申请列表...' });
|
||||
try {
|
||||
const list = await getPostApplies(post.id);
|
||||
uni.hideLoading();
|
||||
if (!list || list.length === 0) {
|
||||
uni.showToast({ title: '暂无搭子上车申请', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const itemList = list.slice(0, 6).map(a => {
|
||||
const name = a.applicant_name || a.applicantName || '同城搭子';
|
||||
const st = a.status === 'ACCEPTED' ? '已同意' : (a.status === 'REJECTED' ? '已婉拒' : '待确认');
|
||||
return `${name} [${st}] - 点击审批`;
|
||||
});
|
||||
uni.showActionSheet({
|
||||
itemList,
|
||||
success: (res) => {
|
||||
const target = list[res.tapIndex];
|
||||
if (!target) return;
|
||||
const name = target.applicant_name || target.applicantName || '同城搭子';
|
||||
uni.showModal({
|
||||
title: `审批搭子申请`,
|
||||
content: `申请人:${name}\n请选择是否同意该搭子加入车队/同城局:`,
|
||||
confirmText: '同意上车',
|
||||
cancelText: '婉拒申请',
|
||||
confirmColor: '#10B981',
|
||||
success: async (mRes) => {
|
||||
const newStatus = mRes.confirm ? 'ACCEPTED' : (mRes.cancel ? 'REJECTED' : null);
|
||||
if (!newStatus) return;
|
||||
try {
|
||||
await handlePostApply(target.id, newStatus);
|
||||
uni.showToast({
|
||||
title: newStatus === 'ACCEPTED' ? '已同意搭子上车' : '已婉拒该申请',
|
||||
icon: 'success'
|
||||
});
|
||||
loadRemotePosts();
|
||||
} catch (err) {
|
||||
uni.showToast({ title: err.message || '操作失败', icon: 'none' });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '加载申请列表失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
const handleJoinParty = (post) => {
|
||||
if (post.hasApplied) {
|
||||
if (post.hasApplied && post.myApplyStatus !== 'REJECTED') {
|
||||
uni.showToast({
|
||||
title: '已提交过约伴申请',
|
||||
title: post.myApplyStatus === 'ACCEPTED' ? '房主已同意您的上车申请' : '已提交过申请,请等待房主确认',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
@@ -792,7 +851,8 @@ const handleJoinParty = (post) => {
|
||||
} catch (_) {}
|
||||
|
||||
post.hasApplied = true;
|
||||
post.actionText = '已申请';
|
||||
post.myApplyStatus = 'PENDING';
|
||||
post.actionText = '待房主确认';
|
||||
let localAppliedIds = uni.getStorageSync('COMMUNITY_APPLIED_POST_IDS') || [];
|
||||
if (!Array.isArray(localAppliedIds)) localAppliedIds = [];
|
||||
const strId = String(post.id);
|
||||
|
||||
在新工单中引用
屏蔽一个用户