Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
746cb5dca4
|
|
@ -47,7 +47,7 @@ export function getTeacherQrcode(data: any) {
|
||||||
|
|
||||||
export function getTeacherQrcodeImage(teacherId: number) {
|
export function getTeacherQrcodeImage(teacherId: number) {
|
||||||
return request.get(
|
return request.get(
|
||||||
{ url: `adminapi/teacher/qrcode/image?id=${teacherId}` },
|
{ url: `frontapi/teacher/qrcode/image?id=${teacherId}` },
|
||||||
{ urlPrefix: '', isReturnDefaultResponse: true }
|
{ urlPrefix: '', isReturnDefaultResponse: true }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ export function getRecruitmentList(data: any) {
|
||||||
|
|
||||||
// 获取招生统计数据(总招生人数、本日、本周、本月)
|
// 获取招生统计数据(总招生人数、本日、本周、本月)
|
||||||
export function getEnrollmentStatistical() {
|
export function getEnrollmentStatistical() {
|
||||||
return request.get(
|
return request.post(
|
||||||
{ url: 'frontapi/student/enrollmentStatistical' },
|
{ url: 'frontapi/student/enrollmentStatistical' },
|
||||||
{ urlPrefix: '' }
|
{ urlPrefix: '' }
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,12 @@ const getStats = async () => {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getEnrollmentStatistical()
|
const res = await getEnrollmentStatistical()
|
||||||
if (res.code === 1 && res.data) {
|
// 接口直接返回数据对象,没有 code 包装
|
||||||
|
if (res && res.total_enroll_count !== undefined) {
|
||||||
stats.value = {
|
stats.value = {
|
||||||
total: res.data.total_enroll_count,
|
total: res.total_enroll_count,
|
||||||
today: res.data.today_enroll_count,
|
today: res.today_enroll_count,
|
||||||
week: res.data.week_enroll_count
|
week: res.week_enroll_count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -229,7 +230,9 @@ onLoad(() => {
|
||||||
getData()
|
getData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onShow(() => {
|
onShow(async () => {
|
||||||
|
// 等待一下确保登录状态已确定
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100))
|
||||||
getStats()
|
getStats()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -235,19 +235,31 @@ const getQrcode = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStats = async () => {
|
const getStats = async () => {
|
||||||
|
console.log('=== getStats 开始执行 ===')
|
||||||
try {
|
try {
|
||||||
|
console.log('正在调用 getEnrollmentStatistical...')
|
||||||
const res = await 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 = {
|
recruitmentStats.value = {
|
||||||
total: res.data.total_enroll_count,
|
total: res.total_enroll_count,
|
||||||
today: res.data.today_enroll_count,
|
today: res.today_enroll_count,
|
||||||
week: res.data.week_enroll_count,
|
week: res.week_enroll_count,
|
||||||
month: res.data.month_enroll_count
|
month: res.month_enroll_count
|
||||||
}
|
}
|
||||||
|
console.log('更新后的 recruitmentStats:', recruitmentStats.value)
|
||||||
|
} else {
|
||||||
|
console.log('接口返回数据异常:', res)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取招生统计失败:', error)
|
console.error('获取招生统计失败:', error)
|
||||||
}
|
}
|
||||||
|
console.log('=== getStats 执行结束 ===')
|
||||||
}
|
}
|
||||||
|
|
||||||
const openQrcodeModal = () => {
|
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)) {
|
if (!isLogin.value && cache.get(TOKEN_KEY)) {
|
||||||
userStore.token = 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) {
|
if (isLogin.value && userInfo.value) {
|
||||||
|
console.log('条件满足,开始调用 getQrcode 和 getStats')
|
||||||
getQrcode()
|
getQrcode()
|
||||||
getStats()
|
getStats()
|
||||||
|
} else {
|
||||||
|
console.log('条件不满足,跳过数据获取')
|
||||||
|
console.log('isLogin:', isLogin.value)
|
||||||
|
console.log('userInfo:', userInfo.value)
|
||||||
}
|
}
|
||||||
|
console.log('=== onShow 执行结束 ===')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue