diff --git a/src/api/BussApi.ts b/src/api/BussApi.ts index a1fd6f3..a71430f 100644 --- a/src/api/BussApi.ts +++ b/src/api/BussApi.ts @@ -361,6 +361,23 @@ export default class BussApi { .then((res) => res.data); } + /** + * 根据ID获取用户信息 + * @param id - 用户ID + * @returns Promise 返回用户信息 + */ + static getUserById(id: number): Promise { + const user = useUser(); + return http + .server() + .get(`users/${id}`, { + headers: { + Authorization: `Bearer ${user.token}`, + }, + }) + .then((res) => res.data.data); + } + /** * 检查当前用户是否需要任务提醒 * @returns Promise 返回是否需要提醒 diff --git a/src/pages/lesson/index.vue b/src/pages/lesson/index.vue index 40154e5..acc3248 100644 --- a/src/pages/lesson/index.vue +++ b/src/pages/lesson/index.vue @@ -31,23 +31,32 @@ const shouldCurrentUserHandle = () => { +// 获取催办成功提示文案 +const getReminderSuccessMsg = (): string => { + if (!lesson.value) return '催办信息已提交' + const role = getLessonRole(lesson.value) + if (role === 'teacher') return '催办信息已提交至课程教师' + if (role === 'admin') return '催办信息已提交至制作方' + return '催办信息已提交' +} + // 发送催办提醒 const sendReminder = async () => { if (!lesson.value) return try { toast.loading({ msg: '发送催办中...' }) await BussApi.sendReminder(lesson.value.id) - toast.success({ msg: '催办成功,已通知相关人员处理' }) - // 重新加载课程详情 + const successMsg = getReminderSuccessMsg() + // 先刷新数据(内部会覆盖 loading toast),再显示成功提示 await loadLesson() + uni.showToast({ title: successMsg, icon: 'none', duration: 2000 }) } catch (err: unknown) { + toast.close() if (err instanceof Error) { toast.error({ msg: err.message }) } else { toast.error({ msg: '催办失败' }) } - } finally { - toast.close() } } @@ -211,7 +220,7 @@ onLoad(() => {