新增催办成功消息提示
This commit is contained in:
@@ -361,6 +361,23 @@ export default class BussApi {
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取用户信息
|
||||
* @param id - 用户ID
|
||||
* @returns Promise<User> 返回用户信息
|
||||
*/
|
||||
static getUserById(id: number): Promise<User> {
|
||||
const user = useUser();
|
||||
return http
|
||||
.server()
|
||||
.get(`users/${id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${user.token}`,
|
||||
},
|
||||
})
|
||||
.then((res) => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前用户是否需要任务提醒
|
||||
* @returns Promise<boolean> 返回是否需要提醒
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
<!-- 催办按钮区域 -->
|
||||
<div
|
||||
v-if="lesson && !shouldCurrentUserHandle() && lessonProgress !== 100 && (user.hasRole('teacher') || user.hasRole('admin'))"
|
||||
v-if="lesson && !shouldCurrentUserHandle() && lessonProgress !== 100 && (user.hasRole('teacher') || user.hasRole('admin') || user.hasRole('liaison'))"
|
||||
class="px-4 pt-2">
|
||||
<wd-button type="warning" :round="false" plain block @click="sendReminder">
|
||||
<wd-icon name="bell" class="mr-1"></wd-icon>
|
||||
|
||||
Reference in New Issue
Block a user