智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

158 lines
4.2 KiB

import http from '../common/axios.js'
import { Api_url } from '../common/config.js'
export default {
//↓↓↓↓↓↓↓↓↓↓↓↓-----学员信息管理接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取当前用户的学员列表
async getStudentList(data = {}) {
return await http.get('/student/mychild', data);
},
// 获取学员概览信息(首页用)
async getStudentSummary(studentId) {
return await http.get(`/student/summary/${studentId}`);
},
// 获取学员详细信息(包含体测信息)
async getStudentInfo(studentId) {
return await http.get(`/student/info/${studentId}`);
},
// 更新学员信息
async updateStudentInfo(data = {}) {
return await http.put('/student/update', data);
},
// 上传学员头像
async uploadStudentAvatar(data = {}) {
return await http.post('/student/avatar', data);
},
// 获取未读消息数量
async getUnreadMessageCount(studentId) {
try {
if (!studentId) {
throw new Error('学员ID不能为空')
}
// 调用消息统计API
const response = await http.get(`/message/stats/${studentId}`)
if (response && response.code === 1) {
return {
code: 1,
data: {
unread_count: response.data.unread_messages || 0
}
}
} else {
throw new Error(response?.msg || 'API调用失败')
}
} catch (error) {
console.error('获取未读消息数量失败:', error)
// 降级到0未读消息
return {
code: 1,
data: {
unread_count: 0
}
}
}
},
//↓↓↓↓↓↓↓↓↓↓↓↓-----体测数据管理接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取学员体测数据列表(从school_physical_test表)
async getPhysicalTestList(data = {}) {
return await http.get('/physical-test/list', data);
},
// PDF转图片接口
async convertPdfToImage(data = {}) {
return await http.post('/physical-test/pdf-to-image', data);
},
// 生成体测分享图片
async generateShareImage(data = {}) {
return await http.post('/physical-test/share', data);
},
//↓↓↓↓↓↓↓↓↓↓↓↓-----添加孩子相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 添加孩子
async addChild(data = {}) {
return await http.post('/student/add-child', data);
},
// 上传头像
async uploadAvatar(filePath, studentId) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: Api_url + '/student/avatar',
filePath: filePath,
name: 'image',
formData: {
'student_id': studentId
},
header: {
'token': uni.getStorageSync('token') || ''
},
success: (uploadFileRes) => {
console.log('上传文件响应:', uploadFileRes)
try {
const result = JSON.parse(uploadFileRes.data)
resolve(result)
} catch (e) {
console.error('响应数据解析失败:', e)
reject(new Error('响应数据解析失败'))
}
},
fail: (error) => {
console.error('文件上传失败:', error)
reject(error)
}
})
})
},
// 添加孩子时上传头像(不需要student_id)
async uploadAvatarForAdd(filePath) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: Api_url + '/file/avatar',
filePath: filePath,
name: 'file',
header: {
'token': uni.getStorageSync('token') || ''
},
success: (uploadFileRes) => {
console.log('上传文件响应:', uploadFileRes)
try {
const result = JSON.parse(uploadFileRes.data)
resolve(result)
} catch (e) {
console.error('响应数据解析失败:', e)
reject(new Error('响应数据解析失败'))
}
},
fail: (error) => {
console.error('文件上传失败:', error)
reject(error)
}
})
})
},
//↓↓↓↓↓↓↓↓↓↓↓↓-----员工工资管理接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取员工工资列表
async getSalaryList(data = {}) {
return await http.get('/member/salary/list', data);
},
// 获取员工工资详情
async getSalaryInfo(data = {}) {
return await http.get(`/member/salary/info/${data.id}`);
},
async is_pass(data = {}) {
return await http.post('/student/is_pass', data)
},
async set_pass(data = {}) {
return await http.post('/student/set_pass', data)
},
}