将获取招生数据的接口get请求修改为post请求

This commit is contained in:
Yu 2026-03-03 09:24:15 +08:00
parent dc8cf616ac
commit 1ea046f70d
3 changed files with 43 additions and 14 deletions

View File

@ -47,7 +47,7 @@ export function getTeacherQrcode(data: any) {
export function getTeacherQrcodeImage(teacherId: number) {
return request.get(
{ url: `adminapi/teacher/qrcode/image?id=${teacherId}` },
{ url: `frontapi/teacher/qrcode/image?id=${teacherId}` },
{ urlPrefix: '', isReturnDefaultResponse: true }
)
}
@ -68,7 +68,7 @@ export function getRecruitmentList(data: any) {
// 获取招生统计数据(总招生人数、本日、本周、本月)
export function getEnrollmentStatistical() {
return request.get(
return request.post(
{ url: 'frontapi/student/enrollmentStatistical' },
{ urlPrefix: '' }
)

View File

@ -180,11 +180,12 @@ const getStats = async () => {
}
try {
const res = await getEnrollmentStatistical()
if (res.code === 1 && res.data) {
// code
if (res && res.total_enroll_count !== undefined) {
stats.value = {
total: res.data.total_enroll_count,
today: res.data.today_enroll_count,
week: res.data.week_enroll_count
total: res.total_enroll_count,
today: res.today_enroll_count,
week: res.week_enroll_count
}
}
} catch (error) {
@ -229,7 +230,9 @@ onLoad(() => {
getData()
})
onShow(() => {
onShow(async () => {
//
await new Promise(resolve => setTimeout(resolve, 100))
getStats()
})
</script>

View File

@ -235,19 +235,31 @@ const getQrcode = async () => {
}
const getStats = async () => {
console.log('=== getStats 开始执行 ===')
try {
console.log('正在调用 getEnrollmentStatistical...')
const res = await getEnrollmentStatistical()
if (res.code === 1 && res.data) {
console.log('接口返回结果:', res)
// code
if (res && res.total_enroll_count !== undefined) {
console.log('total_enroll_count:', res.total_enroll_count)
console.log('today_enroll_count:', res.today_enroll_count)
console.log('week_enroll_count:', res.week_enroll_count)
console.log('month_enroll_count:', res.month_enroll_count)
recruitmentStats.value = {
total: res.data.total_enroll_count,
today: res.data.today_enroll_count,
week: res.data.week_enroll_count,
month: res.data.month_enroll_count
total: res.total_enroll_count,
today: res.today_enroll_count,
week: res.week_enroll_count,
month: res.month_enroll_count
}
console.log('更新后的 recruitmentStats:', recruitmentStats.value)
} else {
console.log('接口返回数据异常:', res)
}
} catch (error) {
console.error('获取招生统计失败:', error)
}
console.log('=== getStats 执行结束 ===')
}
const openQrcodeModal = () => {
@ -361,16 +373,30 @@ const logout = () => {
})
}
onShow(() => {
onShow(async () => {
console.log('=== onShow 开始执行 ===')
console.log('初始登录状态:', isLogin.value)
console.log('缓存中的token:', cache.get(TOKEN_KEY))
if (!isLogin.value && cache.get(TOKEN_KEY)) {
userStore.token = cache.get(TOKEN_KEY)
console.log('已从缓存设置token')
}
userStore.getUser()
await userStore.getUser()
console.log('getUser 完成后登录状态:', isLogin.value)
console.log('getUser 完成后用户信息:', userInfo.value)
if (isLogin.value && userInfo.value) {
console.log('条件满足,开始调用 getQrcode 和 getStats')
getQrcode()
getStats()
} else {
console.log('条件不满足,跳过数据获取')
console.log('isLogin:', isLogin.value)
console.log('userInfo:', userInfo.value)
}
console.log('=== onShow 执行结束 ===')
})
</script>