将获取招生数据的接口get请求修改为post请求
This commit is contained in:
parent
dc8cf616ac
commit
1ea046f70d
|
|
@ -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: '' }
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue