import http from '../common/axios.js' //全部api接口 export default { //↓↓↓↓↓↓↓↓↓↓↓↓-----公共接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //统一登录接口 async unifiedLogin(data = {}) { const response = await http.post('/login/unified', data); console.log('统一登录响应:', response); return response; }, //教师/销售端详情 async getPersonnelInfo(data = {}) { return await http.get('/personnel/info', data); }, //教师/销售端详情 async editPersonnelInfo(data = {}) { return await http.post('/personnel/edit', data); }, //教师/销售端请假/打卡/签退-编辑 async common_attendanceEdit(data = {}) { return await http.post('/attendance/edit', data); }, //教师/销售端请假/打卡/签退-列表 async common_attendanceIndex(data = {}) { return await http.post('/attendance/index', data); }, //获取字典数据 async common_Dictionary(data = {}) { return await http.get('/common/getDictionary', data); }, //获取支付类型字典(员工端) async common_getPaymentTypes(data = {}) { return await http.get('/common/getPaymentTypes', data); }, //批量获取字典数据 async common_getBatchDict(keys = []) { // 支持传入数组或字符串 const keyParam = Array.isArray(keys) ? keys.join(',') : keys; return await http.get('/dict/batch', { keys: keyParam }); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----忘记密码相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ //发送验证码 async sendVerificationCode(data = {}) { // 将 reset_password 映射为后端支持的 find_pass let type = data.type || 'find_pass'; if (type === 'reset_password') { type = 'find_pass'; } return await http.post(`/send/mobile/${type}`, { mobile: data.mobile }); }, //验证验证码 async verifyCode(data = {}) { return await http.post('/common/verifyCode', data); }, //重置密码 async resetPassword(data = {}) { return await http.post('/common/resetPassword', data); }, //根据业务场景获取字典数据 async common_getDictByScene(scene = '') { return await http.get(`/dict/scene/${scene}`); }, // 课程安排列表 - Mock版本 async getCourseScheduleListMock(data = {}) { // 延迟模拟网络请求 await new Promise(resolve => setTimeout(resolve, 500)); // 模拟课程数据 const mockCourses = [ { id: 101, date: '2025-07-14', // 周一 time: '09:00', courseName: '少儿形体课', students: '已报名8人', teacher: '张教练', teacher_id: 1, status: '未点名', type: 'normal', // 普通课程 venue: '舞蹈室A', venue_id: 1, class_id: 1, duration: 1 }, { id: 102, date: '2025-07-14', // 周一 time: '14:00', courseName: '成人瑜伽', students: '已报名12人', teacher: '李教练', teacher_id: 2, status: '已点名', type: 'normal', // 普通课程 venue: '瑜伽B', venue_id: 2, class_id: 2, duration: 1 }, { id: 103, date: '2025-07-15', // 周二 time: '10:00', courseName: '私教训练', students: '已报名1人', teacher: '王教练', teacher_id: 3, status: '未点名', type: 'private', // 私教课程 venue: '健身C', venue_id: 3, class_id: 3, duration: 1 }, { id: 104, date: '2025-07-15', // 周二 time: '16:00', courseName: '儿童游泳', students: '已报名6人', teacher: '刘教练', teacher_id: 4, status: '未点名', type: 'normal', // 普通课程 venue: '泳池D', venue_id: 4, class_id: 4, duration: 1 }, { id: 105, date: '2025-07-17', // 周四 time: '14:00', courseName: '暑季特训营', students: '已报名15人', teacher: '赵教练', teacher_id: 5, status: '未点名', type: 'activity', // 活动课程 venue: '综合场馆E', venue_id: 5, class_id: 5, duration: 2 // 持续2小时 } ]; // 根据筛选条件过滤课程 let filteredCourses = [...mockCourses]; // 日期范围筛选 if (data.start_date && data.end_date) { filteredCourses = filteredCourses.filter(course => { return course.date >= data.start_date && course.date <= data.end_date; }); } // 教练筛选 if (data.coach_id) { const coachIds = Array.isArray(data.coach_id) ? data.coach_id : [data.coach_id]; filteredCourses = filteredCourses.filter(course => { return coachIds.includes(course.teacher_id); }); } // 场地筛选 if (data.venue_id) { const venueIds = Array.isArray(data.venue_id) ? data.venue_id : [data.venue_id]; filteredCourses = filteredCourses.filter(course => { return venueIds.includes(course.venue_id); }); } // 班级筛选 if (data.class_id) { const classIds = Array.isArray(data.class_id) ? data.class_id : [data.class_id]; filteredCourses = filteredCourses.filter(course => { return classIds.includes(course.class_id); }); } // 时间段筛选 if (data.time_range) { switch (data.time_range) { case 'morning': // 上午 filteredCourses = filteredCourses.filter(course => { const hour = parseInt(course.time.split(':')[0]); return hour >= 8 && hour < 12; }); break; case 'afternoon': // 下午 filteredCourses = filteredCourses.filter(course => { const hour = parseInt(course.time.split(':')[0]); return hour >= 12 && hour < 18; }); break; case 'evening': // 晚上 filteredCourses = filteredCourses.filter(course => { const hour = parseInt(course.time.split(':')[0]); return hour >= 18 && hour < 22; }); break; } } // 处理结果格式 const result = { list: filteredCourses.map(course => ({ id: course.id, course_date: course.date, time_info: { start_time: course.time, end_time: this.calculateEndTime(course.time, course.duration), duration: course.duration * 60 }, course_name: course.courseName, enrolled_count: parseInt(course.students.match(/\d+/)[0]) || 0, coach_name: course.teacher, teacher_id: course.teacher_id, status_text: course.status, course_type: course.type, venue_name: course.venue, venue_id: course.venue_id, campus_name: this.getCampusName(course.venue_id), class_id: course.class_id, available_capacity: course.type === 'private' ? 1 : (course.type === 'activity' ? 30 : 15), time_slot: `${course.time}-${this.calculateEndTime(course.time, course.duration)}` })), total: filteredCourses.length }; return { code: 1, data: result, msg: 'SUCCESS' }; }, // 计算结束时间 calculateEndTime(startTime, duration) { const [hours, minutes] = startTime.split(':').map(Number); let endHours = hours + duration; let endMinutes = minutes; if (endHours >= 24) { endHours -= 24; } return `${endHours.toString().padStart(2, '0')}:${endMinutes.toString().padStart(2, '0')}`; }, // 根据场地ID获取校区名称 getCampusName(venueId) { const campusMap = { 1: '总部校区', 2: '南山校区', 3: '福田校区', 4: '罗湖校区', 5: '宝安校区' }; return campusMap[venueId] || '总部校区'; }, //公共端-获取全部员工列表 async common_getPersonnelAll(data = {}) { return await http.get('/personnel/getPersonnelAll', data); }, //公共端-获取教练数据列表 async common_getCoachList(data = {}) { return await http.get('/personnel/getCoachList', data); }, //公共端-获取全部课程列表 async common_getCourseAll(data = {}) { return await http.get('/common/getCourseAll', data); }, //公共端-获取全部班级列表 async common_getClassAll(data = {}) { return await http.get('/common/getClassAll', data); }, //公共端-教师/销售端验证旧密码是否正确 async common_personnelCheckOldPwd(data = {}) { return await http.post('/personnel/checkOldPwd', data); }, //公共端-教师/销售端验证旧密码是否正确 async common_personnelEdidPassword(data = {}) { return await http.post('/personnel/edidPassword', data); }, //公共端-教师/销售端验证旧密码是否正确 async common_getPersonnelCampus(data = {}) { return await http.get('/campus/getPersonnelCampus', data); }, //获取全部校区 async common_getCampusesList(data = {}) { return await http.get('/campus/get_campuses_list', data); }, //公共端-忘记密码-通过短信验证码进行密码重置(学生/员工通用) async common_forgetPassword(data = {}) { return await http.post('/common/forgetPassword', data); }, //公共端-获取配置项 async common_getConfig(data = {}) { return await http.get('/common/getConfig', data); }, //公共端-获取配置项 async common_getMiniWxOpenId(data = {}) { return await http.post('/common/getMiniWxOpenId', data); }, //微信登录相关接口 async wechatLogin(data = {}) { return await http.post('/auth/login/wechat', data); }, async wechatBind(data = {}) { return await http.post('/auth/wechat/bind', data); }, async getWechatAuthUrl(data = {}) { return await http.get('/auth/wechat/auth_url', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----教练接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //获取我的页面统计个数 async getStatisticsInfo(data = {}) { return await http.get('/class/Statistics/info', data); }, //获取服务详情 async getServiceDetail(data = {}) { return await http.get('/member/service/detail', data); }, //获取服务列表 async getServiceList(data = {}) { return await http.get('/member/service/list', data); }, //完成服务 async completeService(data = {}) { return await http.post('/service/complete', data); }, //添加作业 async jlPublishJob(data = {}) { return await http.get('/class/jlPublishJob/add', data); }, //添加作业-获取课程列表 async jlGetCoursesList(data = {}) { return await http.get('/class/jlGetCoursesList/list', data); }, //添加作业-获取班级列表 async jlGetClassesList(data = {}) { return await http.get('/class/jlGetClasses/list', data); }, //体测报告-详情 async physicalTestInfo(data = {}) { return await http.get('/class/physicalTest/info', data); }, //体测报告-列表 async physicalTest(data = {}) { return await http.get('/class/physicalTest', data); }, //获取学员详情 async jlStudentsInfo(data = {}) { return await http.get('/class/jlStudentsInfo', data); }, //获取添加学员列表 async addStudentList(data = {}) { return await http.get('/course/addStudentList', data); }, async addStudent(data = {}) { return await http.post('/course/addStudent', data); }, async delStudentCourse(data = {}) { return await http.get('/course/delStudentCourse', data); }, //获取班级列表 async jlClassList(data = {}) { return await http.get('/class/jlClassList', data); }, //获取班级详情 async jlClassInfo(data = {}) { return await http.get('/class/jlClassInfo', data); }, //获取课程列表 async courseList(data = {}) { return await http.get('/course/courseList', data); }, //获取班级课程列表 async classCourseList(data = {}) { return await http.get('/course/classCourseList', data); }, //获取课程详情 async courseInfo(data = {}) { return await http.get('/course/courseInfo', data); }, //获取课程安排详情(新接口) async getScheduleDetail(data = {}) { return await http.get('/course/scheduleDetail', data); }, //教研管理文章列表 async teachingResearchList(data = {}) { return await http.get('/teachingResearch/list', data); }, //教研管理文章详情 async teachingResearchInfo(id) { return await http.get('/teachingResearch/info/' + id); }, //获取能看的教研管理类型 async teachingResearchLookType(data = {}) { return await http.get('/teachingResearch/lookType', data); }, //获取试卷 async getTeachingTestPaper(data = {}) { return await http.get('/teachingResearch/teachingTestPaper', data); }, //提交试卷 async submitTestPaper(data = {}) { return await http.get('/teachingResearch/submitTestPaper', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----销售接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //修改销售端个人资料 async editPersonnel(data = {}) { return await http.get('/personnel/info', data); }, //销售端-客户资源-添加 async xs_addCustomerResources(data = {}) { return await http.post('/customerResources/add', data); }, //销售端-客户资源-编辑 async xs_editCustomerResources(data = {}) { return await http.post('/customerResources/edit', data); }, //销售端-查询客户资源全部列表 async xs_getAllCustomerResources(data = {}) { return await http.get('/customerResources/getAll', data); }, //客户资源全部列表(用于学员搜索) async getCustomerResourcesAll(data = {}) { return await http.get('/customerResources/getAll', data); }, //搜索学员(用于课程安排) async searchStudents(data = {}) { return await http.get('/customerResources/searchStudents', data); }, // 获取预设学员信息(不受状态限制) async getPresetStudentInfo(data = {}) { return await http.get('/customerResources/getPresetStudentInfo', data); }, //获取客户资源详情 async getCustomerResourcesInfo(data = {}) { return await http.get('/resourceSharing/info', data); }, //销售端-客户资源-获取修改日志列表 async xs_customerResourcesGetEditLogList(data = {}) { return await http.get('/customerResources/getEditLogList', data); }, //销售端-客户资源-获取赠品记录列表 async xs_customerResourcesGetGiftRecordList(data = {}) { return await http.get('/customerResources/getGiftRecordList', data); }, //销售端-客户资源-获取学生标签信息 async getStudentLabel(data = {}) { return await http.get('/customerResources/getStudentLabel', data); }, //销售端-客户资源-获取所有学生标签列表 async getAllStudentLabels(data = {}) { return await http.get('/customerResources/getAllStudentLabels', data); }, //销售端-资源共享-列表 async xs_resourceSharingIndex(data = {}) { return await http.get('/resourceSharing/index', data); }, //销售端-资源共享-分配员工 async xs_resourceSharingAssign(data = {}) { return await http.post('/resourceSharing/assign', data); }, //销售端-资源共享-详情(客户资源详情) async xs_resourceSharingInfo(data = {}) { return await http.get('/resourceSharing/info', data); }, //销售端-学员-新增 async xs_addStudent(data = {}) { return await http.post('/student/add', data); }, //销售端-学员-编辑 async xs_editStudent(data = {}) { return await http.post('/student/edit', data); }, //销售端-学员-列表 async xs_getStudentList(data = {}) { return await http.get('/student/list', data); }, //教练端-我的学员列表 async coach_getMyStudents(data = {}) { return await http.get('/coach/students/my', data); }, //销售端-沟通记录-添加 async xs_communicationRecordsAdd(data = {}) { return await http.post('/communicationRecords/add', data); }, //销售端-沟通记录-编辑 async xs_communicationRecordsEdit(data = {}) { return await http.post('/communicationRecords/edit', data); }, //销售端-获取好友关系绑定详情 async xs_chatGetChatFriendsInfo(data = {}) { return await http.get('/chat/getChatFriendsInfo', data); }, //销售端-获取聊天消息列表 async xs_chatGetChatMessagesList(data = {}) { return await http.get('/chat/getChatMessagesList', data); }, //销售端-发送聊天消息 async xs_chatSendChatMessages(data = {}) { return await http.post('/chat/sendChatMessages', data); }, //销售端-好友关系列表 async xs_chatGetChatFriendsList(data = {}) { return await http.get('/chat/getChatFriendsList', data); }, //员工端统计(销售)-获取销售首页数据统计 async xs_statisticsMarketHome(data = {}) { return await http.get('/statistics/marketHome', data); }, //员工端统计(销售)-获取销售数据页统计 async xs_statisticsMarketData(data = {}) { return await http.get('/statistics/marketData', data); }, //员工端(销售)-订单管理-列表 async xs_orderTableList(data = {}) { return await http.get('/orderTable', data); }, //员工端(销售)-订单管理-详情 async xs_orderTableInfo(data = {}) { return await http.get('/orderTable/info', data); }, //员工端(销售)-订单管理-添加 async xs_orderTableAdd(data = {}) { return await http.post('/orderTable/add', data); }, //员工端(销售)-订单管理-更新支付状态 async xs_orderTableUpdatePaymentStatus(data = {}) { return await http.post('/orderTable/updatePaymentStatus', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----家长接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取家长下的孩子列表 async parent_getChildrenList(data = {}) { return await http.get('/parent/children', data); }, // 获取指定孩子的详细信息 async parent_getChildInfo(data = {}) { return await http.get('/parent/child/info', data); }, // 更新孩子信息 async parent_updateChildInfo(data = {}) { return await http.post('/parent/child/update', data); }, // 获取指定孩子的课程信息 async parent_getChildCourses(data = {}) { return await http.get('/parent/child/courses', data); }, // 获取指定孩子的订单信息 async parent_getChildOrders(data = {}) { return await http.get('/parent/child/orders', data); }, // 获取指定孩子的教学资料 async parent_getChildMaterials(data = {}) { return await http.get('/parent/child/materials', data); }, // 获取指定孩子的服务记录 async parent_getChildServices(data = {}) { return await http.get('/parent/child/services', data); }, // 获取学员服务记录列表 async getStudentServiceList(data = {}) { return await http.get('/xy/service/list', data); }, // 获取指定孩子的消息记录 async parent_getChildMessages(data = {}) { return await http.get('/parent/child/messages', data); }, // 获取指定孩子的合同信息 async parent_getChildContracts(data = {}) { return await http.get('/parent/child/contracts', data); }, // 新增孩子信息 async parent_addChild(data = {}) { return await http.post('/parent/child/add', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----学生接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //学生登陆接口 async xy_login(data = {}) { const response = await http.post('/customerResourcesAuth/login', data); console.log('学生登录响应:', response); return response; }, //学生详情 async xy_memberInfo(data = {}) { return await http.get('/customerResourcesAuth/info', data); }, //学生详情-修改 async xy_memberEdit(data = {}) { return await http.post('/customerResourcesAuth/edit', data); }, //学生-意见反馈-添加 async xy_userFeedbackAdd(data = {}) { return await http.post('/userFeedback/add', data); }, //学生端-获取好友关系绑定详情 async xy_chatGetChatFriendsInfo(data = {}) { return await http.get('/xy/chat/getChatFriendsInfo', data); }, //学生端-获取聊天消息列表 async xy_chatGetChatMessagesList(data = {}) { return await http.get('/xy/chat/getChatMessagesList', data); }, //学生端-发送聊天消息 async xy_chatSendChatMessages(data = {}) { return await http.post('/xy/chat/sendChatMessages', data); }, //学生端-好友关系列表 async xy_chatGetChatFriendsList(data = {}) { return await http.get('/xy/chat/getChatFriendsList', data); }, //学生端-体测报告-列表 async xy_physicalTest(data = {}) { return await http.get('/xy/physicalTest', data); }, //学生端-体测报告-详情 async xy_physicalTestInfo(data = {}) { return await http.get('/xy/physicalTest/info', data); }, //学生端-体测报告-添加 async xy_physicalTestAdd(data = {}) { return await http.post('/xy/physicalTest/add', data); }, //学生端-体测报告-编辑 async xy_physicalTestEdit(data = {}) { return await http.post('/xy/physicalTest/edit', data); }, //学生端-体测报告-删除 async xy_physicalTestDelete(data = {}) { return await http.post('/xy/physicalTest/delete', data); }, //学生端-学习计划-列表 async getStudyPlanList(data = {}) { return await http.get('/xy/studyPlan', data); }, //学生端-学习计划-详情 async getStudyPlanInfo(data = {}) { return await http.get('/xy/studyPlan/info', data); }, //学生端-学习计划-添加 async addStudyPlan(data = {}) { return await http.post('/xy/studyPlan/add', data); }, //学生端-学习计划-编辑 async editStudyPlan(data = {}) { return await http.post('/xy/studyPlan/edit', data); }, //学生端-学习计划-删除 async deleteStudyPlan(data = {}) { return await http.post('/xy/studyPlan/delete', data); }, //学生端-学习计划-更新进度 async updateStudyPlanProgress(data = {}) { return await http.post('/xy/studyPlan/updateProgress', data); }, //学生端-学生课程安排-列表 async xy_personCourseSchedule(data = {}) { return await http.get('/xy/personCourseSchedule', data); }, //学生端-学生课程安排-详情 async xy_personCourseScheduleInfo(data = {}) { return await http.get('/xy/personCourseSchedule/info', data); }, //学生端-学生课程安排-修改请假状态 async xy_personCourseScheduleEditStatus(data = {}) { return await http.post('/xy/personCourseSchedule/editStatus', data); }, //学生端-学生课程安排-获取排课日历 async xy_personCourseScheduleGetCalendar(data = {}) { return await http.get('/xy/personCourseSchedule/getCalendar', data); }, //学生端-学生课程安排-获取学生排课的全部场地列表 async xy_personCourseScheduleGetVenueListAll(data = {}) { return await http.get('/xy/personCourseSchedule/getVenueListAll', data); }, //学生端-学生课程安排-获取学生排课的全部场地列表 async xy_personCourseScheduleGetMyCoach(data = {}) { return await http.get('/xy/personCourseSchedule/getMyCoach', data); }, //学生端-学生课程安排-获取学生课程消耗记录列表 async xy_personCourseScheduleGetStudentCourseUsageList(data = {}) { return await http.get('/xy/personCourseSchedule/getStudentCourseUsageList', data); }, //学生端-获取作业列表 async xy_assignment(data = {}) { return await http.get('/xy/assignment', data); }, //学生端-获取作业详情 async xy_assignmentsInfo(data = {}) { return await http.get('/xy/assignment/info', data); }, //学生端-提交作业 async xy_assignmentSubmitObj(data = {}) { return await http.get('/xy/assignment/submitObj', data); }, //学生端-订单管理-列表 async xy_orderTableList(data = {}) { return await http.get('/xy/orderTable', data); }, //学生端-订单管理-列表(公开接口,用于学员端查看) async xy_getStudentOrders(data = {}) { return await http.get('/xy/student/orders', data); }, //学生端-订单管理-详情 async xy_orderTableInfo(data = {}) { return await http.get('/xy/orderTable/info', data); }, //学生端-订单管理-详情(公开接口,用于学员端查看) async xy_getStudentOrderDetail(data = {}) { return await http.get('/xy/student/orders/detail', data); }, //学生端-订单管理-添加 async xy_orderTableAdd(data = {}) { return await http.post('/xy/orderTable/add', data); }, // 获取通话记录 async listCallUp(data={}) { return await http.get('/per_list_call_up', data); }, // 更新通话记录 async updateCallUp(data={}) { return await http.post('/per_update_call_up', data); }, async getDate(data={}) { return await http.get('/course/get_date', data); }, async courseAllList(data = {}) { return await http.get('/course/courseAllList', data); }, async addSchedule(data = {}) { return await http.post('/course/addSchedule', data); }, async scheduleList(data = {}) { return await http.get('/course/scheduleList', data); }, async getStaffStatistics(data = {}) { return await http.get('/statistics/getStaffStatistics', data); }, async reimbursement_list(data = {}) { return await http.get('/personnel/reimbursement_list', data); }, async reimbursement_add(data = {}) { return await http.post('/personnel/reimbursement_add', data); }, async reimbursement_info(data = {}) { return await http.get('/personnel/reimbursement_info', data); }, async schedule_del(data = {}) { return await http.post('/course/schedule_del', data); }, // 升级等待位学员为正式学员 async upgradeStudentSchedule(data = {}) { return await http.post('/course/upgradeStudentSchedule', data); }, //课程相关API //获取学生课程信息列表(包含教练配置) async getStudentCourseInfo(data = {}) { return await http.get('/getStudentCourseInfo', data); }, //获取人员列表(教练、教务、助教) async getPersonnelList(data = {}) { return await http.get('/getPersonnelList', data); }, //更新学生课程人员配置 async updateStudentCoursePersonnel(data = {}) { return await http.post('/updateStudentCoursePersonnel', data); }, //检查学员班级关联 async checkClassRelation(data = {}) { return await http.get('/course/checkClassRelation', data); }, // 获取订单支付二维码 async getOrderPayQrcode(data = {}) { return await http.get('/getQrcode', data); }, // 查询订单支付状态 async checkOrderPaymentStatus(data = {}) { return await http.get('/checkOrderPaymentStatus', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----课程预约相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取可预约课程列表 async getAvailableCourses(data = {}) { try { // 过滤掉undefined、null、空字符串的参数 const params = {}; if (data.date !== undefined && data.date !== null && data.date !== '') { params.date = data.date; } if (data.start_date !== undefined && data.start_date !== null && data.start_date !== '') { params.start_date = data.start_date; } if (data.end_date !== undefined && data.end_date !== null && data.end_date !== '') { params.end_date = data.end_date; } if (data.coach_id !== undefined && data.coach_id !== null && data.coach_id !== '') { params.coach_id = data.coach_id; } if (data.venue_id !== undefined && data.venue_id !== null && data.venue_id !== '') { params.venue_id = data.venue_id; } if (data.course_type !== undefined && data.course_type !== null && data.course_type !== '') { params.course_type = data.course_type; } const response = await http.get('/course-booking/available/' + data.student_id, params); // 检查响应状态,如果失败则降级到Mock数据 if (response.code !== 1) { console.warn('API返回错误,降级到Mock数据:', response.msg); return await this.getAvailableCoursesMock(data); } return response; } catch (error) { console.error('获取可预约课程错误:', error); // 返回模拟数据作为后备 return await this.getAvailableCoursesMock(data); } }, // 创建课程预约 async createBooking(data = {}) { try { const response = await http.post('/course-booking/create', data); // 检查响应状态,如果失败则返回模拟成功响应 if (response.code !== 1) { console.warn('创建预约API返回错误,返回模拟成功响应:', response.msg); return { code: 1, msg: '预约成功(模拟)', data: { booking_id: Date.now() } }; } return response; } catch (error) { console.error('创建预约错误:', error); // 模拟成功响应 return { code: 1, msg: '预约成功(模拟)', data: { booking_id: Date.now() } }; } }, // 获取我的预约列表 async getMyBookingList(data = {}) { try { // 过滤掉undefined值,避免传递"undefined"字符串 const params = {}; if (data.status !== undefined && data.status !== null && data.status !== '') { params.status = data.status; } if (data.start_date !== undefined && data.start_date !== null && data.start_date !== '') { params.start_date = data.start_date; } if (data.end_date !== undefined && data.end_date !== null && data.end_date !== '') { params.end_date = data.end_date; } const response = await http.get('/course-booking/my-list/' + data.student_id, params); // 检查响应状态,如果失败则降级到Mock数据 if (response.code !== 1) { console.warn('获取预约列表API返回错误,降级到Mock数据:', response.msg); return await this.getMyBookingListMock(data); } return response; } catch (error) { console.error('获取预约列表错误:', error); // 返回模拟数据作为后备 return await this.getMyBookingListMock(data); } }, // 取消预约 async cancelBooking(data = {}) { try { const response = await http.post('/course-booking/cancel', data); // 检查响应状态,如果失败则返回模拟成功响应 if (response.code !== 1) { console.warn('取消预约API返回错误,返回模拟成功响应:', response.msg); return { code: 1, msg: '取消成功(模拟)' }; } return response; } catch (error) { console.error('取消预约错误:', error); // 模拟成功响应 return { code: 1, msg: '取消成功(模拟)' }; } }, // 获取学员汇总信息 async getStudentSummary(student_id) { try { const response = await http.get(`/student/summary/${student_id}`); return response; } catch (error) { console.error('获取学员汇总信息错误:', error); // 返回模拟数据 return { code: 1, data: { student_id: student_id, name: '学员姓名', booking_qualification: { can_book: false, remaining_courses: 0, reason: '接口调用失败' } } }; } }, // 检查预约冲突 async checkBookingConflict(data = {}) { try { const response = await http.post('/course-booking/check-conflict', data); return response; } catch (error) { console.error('检查预约冲突错误:', error); return { code: 1, data: { has_conflict: false } }; } }, // 模拟可预约课程数据 async getAvailableCoursesMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 500)); const mockCourses = [ { id: 1, course_date: data.date || '2025-08-01', start_time: '09:00', end_time: '10:00', duration: 60, course_name: '基础体能训练', course_type: '基础体能训练', coach_name: '张教练', venue_name: '训练馆A', booking_status: 'available', max_students: 8, current_students: 3 }, { id: 2, course_date: data.date || '2025-08-01', start_time: '10:30', end_time: '11:30', duration: 60, course_name: '少儿体适能', course_type: '少儿体适能', coach_name: '李教练', venue_name: '训练馆B', booking_status: 'available', max_students: 6, current_students: 2 }, { id: 3, course_date: data.date || '2025-08-01', start_time: '14:00', end_time: '15:00', duration: 60, course_name: '专项训练', course_type: '专项训练', coach_name: '王教练', venue_name: '训练馆A', booking_status: 'full', max_students: 4, current_students: 4 } ]; return { code: 1, data: { list: mockCourses, total: mockCourses.length }, msg: 'SUCCESS' }; }, // 模拟我的预约列表数据 async getMyBookingListMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 300)); const mockBookings = [ { id: 1, booking_date: this.formatDateString(new Date(Date.now() + 24 * 60 * 60 * 1000)), start_time: '16:00', end_time: '17:00', coach_name: '张教练', course_type: '基础体能训练', venue_name: '训练馆A', status: 0, status_text: '待上课' } ]; return { code: 1, data: { list: mockBookings, total: mockBookings.length }, msg: 'SUCCESS' }; }, //↓↓↓↓↓↓↓↓↓↓↓↓-----课程安排相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取课程安排列表(支持学员和教练端) async getCourseScheduleList(data = {}) { try { let response; // 如果有student_id参数,说明是学员端调用,使用学员端API if (data.student_id) { response = await http.get('/course-schedule/list/' + data.student_id, { date: data.date, status: data.status, start_date: data.start_date, end_date: data.end_date }); } else { // 否则是教练端调用,使用教练端API response = await http.get('/courseSchedule/list', { start_date: data.start_date, end_date: data.end_date, coach_id: data.coach_id, venue_id: data.venue_id, class_id: data.class_id, time_range: data.time_range, view_type: data.view_type, page: data.page || 1, limit: data.limit || 9999 }); } return response; } catch (error) { console.error('获取课程安排列表错误:', error); // 当发生错误时,返回模拟数据 return await this.getCourseScheduleListMock(data); } }, // 获取课程安排详情 async getCourseScheduleDetail(data = {}) { try { const response = await http.get('/course-schedule/detail/' + data.schedule_id); return response; } catch (error) { console.error('获取课程安排详情错误:', error); // 当发生错误时,返回模拟数据 return await this.getCourseScheduleInfoMock(data); } }, // 申请课程请假 async requestCourseLeave(data = {}) { try { const response = await http.post('/course-schedule/leave', data); return response; } catch (error) { console.error('申请课程请假错误:', error); // 模拟请假申请成功 return { code: 1, msg: '请假申请已提交' }; } }, // 获取课程安排详情(用于课程调整页面) async getCourseScheduleInfo(data = {}) { try { // 使用真实的API接口获取课程安排详情 - 调整页面专用接口 const result = await http.get('/courseSchedule/info', data); console.log('获取课程安排详情:', result); return result; } catch (error) { console.error('获取课程安排详情失败:', error); // 如果接口调用失败,降级到Mock数据 return this.getCourseScheduleInfoMock(data); } }, // 模拟课程安排详情数据 async getCourseScheduleInfoMock(data = {}) { // 模拟数据加载延迟 await new Promise(resolve => setTimeout(resolve, 500)); // 使用默认学生数据 const defaultStudents = [ { id: 1, name: '张三', avatar: '/static/icon-img/avatar.png', status: 0, status_text: '未点名', statusClass: 'status-pending' }, { id: 2, name: '李四', avatar: '/static/icon-img/avatar.png', status: 1, status_text: '已点名', statusClass: 'status-present' }, { id: 3, name: '王五', avatar: '/static/icon-img/avatar.png', status: 2, status_text: '请假', statusClass: 'status-leave' } ]; // 课程安排模拟数据 const mockScheduleInfo = { id: parseInt(data.schedule_id), course_name: '大课7+1类型', course_date: '2025-07-25', time_slot: '09:00-10:00', venue_name: '时间范围教室', campus_name: '测试校区', coach_name: '老六', status: 'pending', status_text: '即将开始', class_info: { id: 1, class_name: '少儿形体班' }, course_duration: 60, students: defaultStudents, course_info: { total_hours: 20, use_total_hours: 8, gift_hours: 2, use_gift_hours: 1, start_date: '2025-06-01', end_date: '2025-12-31' } }; return { code: 1, data: mockScheduleInfo, msg: 'SUCCESS' }; }, // 创建课程安排 async createCourseSchedule(data = {}) { const token = uni.getStorageSync("token"); const apiPath = token ? '/courseSchedule/create' : '/test/courseSchedule/create'; return await http.post(apiPath, data); }, // 批量创建课程安排 async batchCreateCourseSchedule(data = {}) { return await http.post('/courseSchedule/batchCreate', data); }, // 更新课程安排 async updateCourseSchedule(data = {}) { return await http.post('/courseSchedule/update', data); }, // 删除课程安排 async deleteCourseSchedule(data = {}) { return await http.post('/courseSchedule/delete', data); }, // 获取场地列表(课程安排模块专用) async getCourseScheduleVenues(data = {}) { return await http.get('/courseSchedule/venues', data); }, // 获取场地可用时间(课程安排模块专用) async getVenueAvailableTime(data = {}) { return await http.get('/courseSchedule/venueAvailableTime', data); }, // 获取场地时间选项(课程调整专用) async getVenueTimeOptions(data = {}) { return await http.get('/courseSchedule/venueTimeOptions', data); }, // 检查教练时间冲突 async checkCoachConflict(data = {}) { // 未登录或测试模式使用模拟数据 if (!uni.getStorageSync("token")) { return this.checkCoachConflictMock(data); } return await http.get('/courseSchedule/checkCoachConflict', data); }, // 模拟教练时间冲突检查 async checkCoachConflictMock(data = {}) { // 模拟数据加载延迟 await new Promise(resolve => setTimeout(resolve, 300)); // 模拟冲突检查逻辑 const { coach_id, date, time_slot } = data; // 日期匹配 2025-07-14 或 2025-07-15 const conflictDates = ['2025-07-14', '2025-07-15']; // 特定教练和时间段的冲突场景 const hasConflict = ( // 张教练在特定日期的时间冲突 (coach_id == 1 && conflictDates.includes(date) && time_slot === '09:00-10:00') || // 李教练在特定日期的时间冲突 (coach_id == 2 && conflictDates.includes(date) && time_slot === '14:00-15:00') || // 随机生成一些冲突情况进行测试 (Math.random() < 0.2 && coach_id && date && time_slot) ); return { code: 1, data: { has_conflict: hasConflict, conflict_schedules: hasConflict ? [ { id: Math.floor(Math.random() * 1000), course_name: hasConflict ? '冲突课程' : '', time_slot: time_slot, venue_name: '测试场地' } ] : [] }, msg: 'SUCCESS' }; }, // 获取课程安排统计 async getCourseScheduleStatistics(data = {}) { try { // 如果有student_id参数,使用学员个人统计接口 if (data.student_id) { const response = await http.get('/course-schedule/statistics/' + data.student_id, { start_date: data.start_date, end_date: data.end_date }); return response; } else { // 否则使用全局统计接口 return await http.get('/course-schedule/courseSchedule/statistics', data); } } catch (error) { console.error('获取课程统计失败:', error); // 返回默认统计数据 return { code: 1, data: { total_courses: 0, completed_courses: 0, scheduled_courses: 0, cancelled_courses: 0 }, msg: '获取统计数据成功' }; } }, // 学员加入课程安排 async joinCourseSchedule(data = {}) { return await http.post('/courseSchedule/joinSchedule', data); }, // 学员退出课程安排 async leaveCourseSchedule(data = {}) { return await http.post('/courseSchedule/leaveSchedule', data); }, // 获取筛选选项 async getCourseScheduleFilterOptions(data = {}) { return await http.get('/courseSchedule/filterOptions', data); }, // 提交课程点名 async submitScheduleSignIn(data = {}) { return await http.post('/courseSchedule/signIn', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----添加课程安排页面专用接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取课程列表(用于添加课程安排) async getCourseListForSchedule(data = {}) { // 检查是否有token,如果没有则使用测试接口 const token = uni.getStorageSync("token"); const apiPath = token ? '/course/list' : '/test/course/list'; return await http.get(apiPath, data); }, // 获取班级列表(用于添加课程安排) async getClassListForSchedule(data = {}) { const token = uni.getStorageSync("token"); const apiPath = token ? '/class/list' : '/test/class/list'; return await http.get(apiPath, data); }, // 获取教练列表(用于添加课程安排) async getCoachListForSchedule(data = {}) { const token = uni.getStorageSync("token"); const apiPath = token ? '/coach/list' : '/test/coach/list'; return await http.get(apiPath, data); }, // 获取场地列表(用于添加课程安排 - 新开发的通用接口) async getVenueListForSchedule(data = {}) { const token = uni.getStorageSync("token"); const apiPath = token ? '/venue/list' : '/test/venue/list'; return await http.get(apiPath, data); }, // 获取场地可用时间段(新开发的通用接口) async getVenueTimeSlots(data = {}) { const token = uni.getStorageSync("token"); const apiPath = token ? '/venue/timeSlots' : '/test/venue/timeSlots'; return await http.get(apiPath, data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----课程安排详情页面接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取课程安排详情 async courseScheduleDetail(data = {}) { return await http.get('/course/scheduleDetail', data); }, // 搜索可添加的学员 async searchStudentsForSchedule(data = {}) { return await http.get('/course/searchStudents', data); }, // 添加学员到课程安排 async addStudentToSchedule(data = {}) { return await http.post('/course/addStudentToSchedule', data); }, // 从课程安排中移除学员 async removeStudentFromSchedule(data = {}) { return await http.post('/course/removeStudentFromSchedule', data); }, // 更新学员课程状态(请假等) async updateStudentStatus(data = {}) { return await http.post('/course/updateStudentStatus', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----学员出勤管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 学员签到 async studentCheckin(data = {}) { return await http.post('/student/attendance/checkin', data); }, // 学员请假 async studentLeave(data = {}) { return await http.post('/student/attendance/leave', data); }, // 学员取消 async studentCancel(data = {}) { return await http.post('/student/attendance/cancel', data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----学员合同管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取学员合同列表 async getStudentContracts(data = {}) { const params = { student_id: data.student_id, status: data.status, page: data.page || 1, limit: data.limit || 10 }; return await http.get('/student/contracts', params); }, // 获取合同详情 async getStudentContractDetail(data = {}) { const params = { student_id: data.student_id }; return await http.get('/student/contract/info', { contract_id: data.contract_id, student_id: data.student_id }); }, // 获取合同签署表单配置 async getStudentContractSignForm(data = {}) { const params = { student_id: data.student_id }; return await http.get('/student/contract/sign-form', { contract_id: data.contract_id, student_id: data.student_id }); }, // 提交合同签署 async signStudentContract(data = {}) { return await http.post('/student/contract/sign', { contract_id: data.contract_id, student_id: data.student_id, form_data: data.form_data, signature_image: data.signature_image }); }, // 下载合同文件 async downloadStudentContract(data = {}) { const params = { student_id: data.student_id }; return await http.get('/student/contract/download', { contract_id: data.contract_id, student_id: data.student_id }); }, // 获取学员基本信息 async getStudentInfo(data = {}) { return await http.get('/student/student-info', { student_id: data.student_id }); }, // 获取学员基本信息 async getStudentBasicInfo(data = {}) { const params = { student_id: data.student_id }; return await http.get('/student/student-info', params); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----员工端合同管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取我的合同列表 async getMyContracts(data = {}) { return await http.get('/contract/myContracts', data); }, // 获取合同统计数据(暂时使用合同列表接口) async getContractStats(data = {}) { return await http.get('/contract/myContracts', data); }, // 获取合同详情 async getContractDetail(contractId) { return await http.get('/contract/detail', { id: contractId }); }, // 获取合同表单字段(暂时返回空,需要后端实现) async getContractFormFields(contractId) { return { code: 1, data: [] }; }, // 提交合同表单数据(暂时返回成功,需要后端实现) async submitContractFormData(contractId, data = {}) { return { code: 1, data: {} }; }, // 提交合同签名 async submitContractSignature(contractId, data = {}) { return await http.post('/contract/sign', { contract_id: contractId, sign_file: data.sign_file }); }, // 生成合同文档(暂时返回成功,需要后端实现) async generateContractDocument(contractId) { return { code: 1, data: {} }; }, //↓↓↓↓↓↓↓↓↓↓↓↓-----知识库管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取知识文章列表 async getKnowledgeList(data = {}) { try { const params = { category: data.category, page: data.page || 1, limit: data.limit || 10, keyword: data.keyword }; const response = await http.get(`/knowledge-test/list/${data.student_id}`, params); return response; } catch (error) { console.error('获取知识文章列表错误:', error); // 返回模拟数据作为后备 return await this.getKnowledgeListMock(data); } }, // 获取知识分类列表 async getKnowledgeCategories(data = {}) { try { const response = await http.get('/knowledge-test/categories'); return response; } catch (error) { console.error('获取知识分类错误:', error); // 返回模拟数据作为后备 return await this.getKnowledgeCategoriesMock(); } }, // 获取推荐文章 async getRecommendArticles(data = {}) { try { const params = { limit: data.limit || 5 }; const response = await http.get(`/knowledge-test/recommend/${data.student_id}`, params); return response; } catch (error) { console.error('获取推荐文章错误:', error); // 返回模拟数据作为后备 return await this.getRecommendArticlesMock(data); } }, // 获取文章详情 async getKnowledgeDetail(data = {}) { try { const params = { student_id: data.student_id }; const response = await http.get(`/knowledge-test/detail/${data.id}`, params); return response; } catch (error) { console.error('获取文章详情错误:', error); // 返回模拟数据作为后备 return await this.getKnowledgeDetailMock(data); } }, // 标记文章已读 async markArticleRead(data = {}) { try { const response = await http.post('/knowledge-test/mark-read', { article_id: data.article_id, student_id: data.student_id }); return response; } catch (error) { console.error('标记文章已读错误:', error); // 返回模拟成功响应 return { code: 1, msg: '标记已读成功', data: { message: '标记已读成功' } }; } }, // 收藏/取消收藏文章 async toggleArticleFavorite(data = {}) { try { const response = await http.post('/knowledge-test/toggle-favorite', { article_id: data.article_id, student_id: data.student_id, action: data.action }); return response; } catch (error) { console.error('收藏操作错误:', error); // 返回模拟成功响应 return { code: 1, msg: data.action === 'add' ? '收藏成功' : '取消收藏成功', data: { is_favorite: data.action === 'add' } }; } }, // 获取知识库统计 async getKnowledgeStats(data = {}) { try { const response = await http.get(`/knowledge-test/stats/${data.student_id}`); return response; } catch (error) { console.error('获取知识库统计错误:', error); // 返回模拟数据作为后备 return await this.getKnowledgeStatsMock(data); } }, // 搜索知识文章 async searchKnowledgeArticles(data = {}) { try { const params = { keyword: data.keyword, category: data.category, page: data.page || 1, limit: data.limit || 10 }; const response = await http.get(`/knowledge-test/search/${data.student_id}`, params); return response; } catch (error) { console.error('搜索知识文章错误:', error); // 返回模拟数据作为后备 return await this.searchKnowledgeArticlesMock(data); } }, //↓↓↓↓↓↓↓↓↓↓↓↓-----知识库Mock数据-----↓↓↓↓↓↓↓↓↓↓↓↓ // 模拟知识文章列表数据 async getKnowledgeListMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 500)); const mockArticles = [ { id: 1, title: '少儿体适能训练基础知识', image: '/static/knowledge/article1.jpg', content: '体适能是指人体所具备的有充足的精力从事日常工作而不易疲劳,同时有余力享受休闲活动的乐趣,能够应付突发状况的身体适应能力。', table_type: '2', category_name: '跳绳教案库', type: 1, url: '', status: 1, create_time: 1627804800, update_time: 1627804800, user_permission: '', is_read: false, is_favorite: false }, { id: 2, title: '儿童运动安全防护指南', image: '/static/knowledge/article2.jpg', content: '儿童参与运动时的安全防护措施是确保运动效果和避免运动伤害的重要保障。本文详细介绍了各种运动项目的安全注意事项。', table_type: '7', category_name: '少儿安防教案库', type: 1, url: '', status: 1, create_time: 1627804700, update_time: 1627804700, user_permission: '', is_read: true, is_favorite: true }, { id: 3, title: '篮球基础技巧训练方法', image: '/static/knowledge/article3.jpg', content: '篮球作为一项受欢迎的运动项目,需要掌握正确的基础技巧。本教案介绍了运球、投篮、传球等基本技能的训练方法。', table_type: '4', category_name: '篮球教案库', type: 1, url: '', status: 1, create_time: 1627804600, update_time: 1627804600, user_permission: '', is_read: false, is_favorite: false } ]; // 根据分类筛选 let filteredArticles = mockArticles; if (data.category) { filteredArticles = mockArticles.filter(article => article.table_type === data.category); } // 根据关键词搜索 if (data.keyword) { filteredArticles = filteredArticles.filter(article => article.title.includes(data.keyword) || article.content.includes(data.keyword) ); } return { code: 1, data: { list: filteredArticles, current_page: data.page || 1, last_page: 1, total: filteredArticles.length, per_page: data.limit || 10 }, msg: '获取知识文章列表成功' }; }, // 模拟知识分类数据 async getKnowledgeCategoriesMock() { await new Promise(resolve => setTimeout(resolve, 300)); return { code: 1, data: [ { value: '1', text: '课程教学大纲', icon: '📖', count: 8 }, { value: '2', text: '跳绳教案库', icon: '🏃', count: 15 }, { value: '3', text: '增高教案库', icon: '📏', count: 6 }, { value: '4', text: '篮球教案库', icon: '🏀', count: 12 }, { value: '5', text: '强化教案库', icon: '💪', count: 9 }, { value: '6', text: '空中忍者教案库', icon: '🥷', count: 7 }, { value: '7', text: '少儿安防教案库', icon: '🛡️', count: 5 }, { value: '8', text: '体能教案库', icon: '🏋️', count: 11 } ], msg: '获取知识分类成功' }; }, // 模拟推荐文章数据 async getRecommendArticlesMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 400)); const mockRecommendArticles = [ { id: 1, title: '少儿体适能训练基础知识', image: '/static/knowledge/article1.jpg', summary: '体适能是指人体所具备的有充足的精力从事日常工作而不易疲劳,同时有余力享受休闲活动的乐趣...', category_name: '跳绳教案库', create_time: 1627804800, read_count: 156 }, { id: 2, title: '儿童运动安全防护指南', image: '/static/knowledge/article2.jpg', summary: '儿童参与运动时的安全防护措施是确保运动效果和避免运动伤害的重要保障...', category_name: '少儿安防教案库', create_time: 1627804700, read_count: 89 } ]; return { code: 1, data: mockRecommendArticles.slice(0, data.limit || 5), msg: '获取推荐文章成功' }; }, // 模拟文章详情数据 async getKnowledgeDetailMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 600)); return { code: 1, data: { id: data.id, title: '少儿体适能训练基础知识', image: '/static/knowledge/article1.jpg', content: `
体适能是指人体所具备的有充足的精力从事日常工作而不易疲劳,同时有余力享受休闲活动的乐趣,能够应付突发状况的身体适应能力。
1. 促进身体发育:通过科学的运动训练,可以促进儿童骨骼、肌肉的健康发育。
2. 提高运动能力:培养儿童的协调性、平衡性、柔韧性等基本运动能力。
3. 增强体质:提高儿童的心肺功能,增强免疫力。
• 循序渐进:从简单到复杂,从易到难
• 因材施教:根据儿童的年龄特点和个体差异制定训练计划
• 寓教于乐:将训练内容游戏化,提高儿童参与的积极性
`, table_type: '2', category_name: '跳绳教案库', type: 1, url: '', status: 1, create_time: 1627804800, update_time: 1627804800, user_permission: '', exam_papers_id: 0, is_read: false, is_favorite: false }, msg: '获取文章详情成功' }; }, // 模拟知识库统计数据 async getKnowledgeStatsMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 300)); return { code: 1, data: { total_articles: 45, favorites: 8, read_articles: 23, categories_count: { '1': 8, '2': 15, '3': 6, '4': 12, '5': 9, '6': 7, '7': 5, '8': 11 } }, msg: '获取知识库统计成功' }; }, // 模拟搜索知识文章数据 async searchKnowledgeArticlesMock(data = {}) { // 复用知识文章列表的Mock数据,根据关键词进行筛选 return await this.getKnowledgeListMock(data); }, //↓↓↓↓↓↓↓↓↓↓↓↓-----学员端消息管理相关接口-----↓↓↓↓↓↓↓↓↓↓↓↓ // 获取学员消息列表 async getStudentMessageList(data = {}) { try { const params = { message_type: data.message_type, page: data.page || 1, limit: data.limit || 10, keyword: data.keyword, is_read: data.is_read }; const response = await http.get(`/message-test/list/${data.student_id}`, params); return response; } catch (error) { console.error('获取学员消息列表错误:', error); // 返回模拟数据作为后备 return await this.getStudentMessageListMock(data); } }, // 获取消息详情 async getStudentMessageDetail(data = {}) { try { const params = { student_id: data.student_id }; const response = await http.get(`/message-test/detail/${data.message_id}`, params); return response; } catch (error) { console.error('获取消息详情错误:', error); // 返回模拟数据作为后备 return await this.getStudentMessageDetailMock(data); } }, // 标记消息已读 async markStudentMessageRead(data = {}) { try { const response = await http.post('/message-test/mark-read', { message_id: data.message_id, student_id: data.student_id }); return response; } catch (error) { console.error('标记消息已读错误:', error); // 返回模拟成功响应 return { code: 1, msg: '标记已读成功', data: { message: '标记已读成功' } }; } }, // 批量标记消息已读 async markStudentMessageBatchRead(data = {}) { try { const response = await http.post('/message-test/mark-batch-read', { student_id: data.student_id, message_ids: data.message_ids, message_type: data.message_type }); return response; } catch (error) { console.error('批量标记已读错误:', error); // 返回模拟成功响应 return { code: 1, msg: '批量标记成功', data: { message: '批量标记成功', updated_count: data.message_ids?.length || 0 } }; } }, // 获取学员消息统计 async getStudentMessageStats(data = {}) { try { const response = await http.get(`/message-test/stats/${data.student_id}`); return response; } catch (error) { console.error('获取消息统计错误:', error); // 返回模拟数据作为后备 return await this.getStudentMessageStatsMock(data); } }, // 获取对话中的所有消息 async getConversationMessages(data = {}) { try { const params = { student_id: data.student_id, from_type: data.from_type, from_id: data.from_id, page: data.page || 1, limit: data.limit || 20 }; const response = await http.get('/message-test/conversation', params); return response; } catch (error) { console.error('获取对话消息错误:', error); // 返回空对话作为后备 return { code: 1, data: { list: [], current_page: 1, last_page: 1, total: 0, per_page: 20, has_more: false }, msg: 'SUCCESS' }; } }, // 学员回复消息 async replyMessage(data = {}) { try { const response = await http.post('/message-test/reply', { student_id: data.student_id, to_type: data.to_type, to_id: data.to_id, content: data.content, message_type: data.message_type || 'text', title: data.title || '' }); return response; } catch (error) { console.error('回复消息错误:', error); // 返回模拟成功响应 return { code: 1, msg: '回复发送成功', data: { message: '回复发送成功', data: { id: Date.now(), content: data.content, created_at: new Date().toISOString().replace('T', ' ').slice(0, 19), create_time: Math.floor(Date.now() / 1000), from_name: '我', is_sent_by_student: true } } }; } }, // 搜索学员消息 async searchStudentMessages(data = {}) { try { const params = { keyword: data.keyword, message_type: data.message_type, page: data.page || 1, limit: data.limit || 10 }; const response = await http.get(`/message-test/search/${data.student_id}`, params); return response; } catch (error) { console.error('搜索消息错误:', error); // 返回模拟数据作为后备 return await this.searchStudentMessagesMock(data); } }, //↓↓↓↓↓↓↓↓↓↓↓↓-----学员端消息管理Mock数据-----↓↓↓↓↓↓↓↓↓↓↓↓ // 模拟学员消息列表数据 async getStudentMessageListMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 500)); const mockMessages = [ { id: 1, from_type: 'system', from_id: 0, message_type: 'system', title: '欢迎使用学员端', content: '欢迎使用学员端,您可以在这里查看课程安排、作业任务等信息。', business_id: null, business_type: '', is_read: 0, read_time: null, create_time: Math.floor(Date.now() / 1000) - 3600, type_text: '系统消息', from_name: '系统', summary: '欢迎使用学员端,您可以在这里查看课程安排、作业任务等信息。' }, { id: 2, from_type: 'personnel', from_id: 1, message_type: 'homework', title: '新作业任务', content: '您有一项新的作业任务:完成本周的体能训练计划,请按时提交。', business_id: 1, business_type: 'homework', is_read: 0, read_time: null, create_time: Math.floor(Date.now() / 1000) - 1800, type_text: '作业任务', from_name: '教务老师', summary: '您有一项新的作业任务:完成本周的体能训练计划,请按时提交。' }, { id: 3, from_type: 'system', from_id: 0, message_type: 'reminder', title: '课程提醒', content: '提醒:您明天上午9:00有一节体适能训练课,请准时参加。', business_id: 1, business_type: 'course', is_read: 1, read_time: new Date(Date.now() - 900 * 1000).toISOString(), create_time: Math.floor(Date.now() / 1000) - 7200, type_text: '课程提醒', from_name: '系统', summary: '提醒:您明天上午9:00有一节体适能训练课,请准时参加。' }, { id: 4, from_type: 'personnel', from_id: 2, message_type: 'notification', title: '重要通知', content: '本周六将举行家长开放日活动,欢迎家长朋友们前来参观指导。', business_id: null, business_type: '', is_read: 0, read_time: null, create_time: Math.floor(Date.now() / 1000) - 86400, type_text: '通知公告', from_name: '教务老师', summary: '本周六将举行家长开放日活动,欢迎家长朋友们前来参观指导。' }, { id: 5, from_type: 'system', from_id: 0, message_type: 'feedback', title: '课程评价邀请', content: '您上次参加的体适能训练课已结束,请对本次课程进行评价。', business_id: 2, business_type: 'course', is_read: 1, read_time: new Date(Date.now() - 3600 * 1000).toISOString(), create_time: Math.floor(Date.now() / 1000) - 172800, type_text: '反馈评价', from_name: '系统', summary: '您上次参加的体适能训练课已结束,请对本次课程进行评价。' } ]; // 根据消息类型筛选 let filteredMessages = mockMessages; if (data.message_type && data.message_type !== 'all') { filteredMessages = mockMessages.filter(msg => msg.message_type === data.message_type); } // 根据已读状态筛选 if (data.is_read !== '' && data.is_read !== undefined) { filteredMessages = filteredMessages.filter(msg => msg.is_read == data.is_read); } // 根据关键词搜索 if (data.keyword) { filteredMessages = filteredMessages.filter(msg => msg.title.includes(data.keyword) || msg.content.includes(data.keyword) ); } return { code: 1, data: { list: filteredMessages, current_page: data.page || 1, last_page: 1, total: filteredMessages.length, per_page: data.limit || 10, has_more: false }, msg: '获取消息列表成功' }; }, // 模拟消息详情数据 async getStudentMessageDetailMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 300)); return { code: 1, data: { id: data.message_id, from_type: 'system', from_id: 0, message_type: 'system', title: '欢迎使用学员端', content: '欢迎使用学员端,您可以在这里查看课程安排、作业任务等信息。如有任何问题,请随时联系我们的客服团队。', business_id: null, business_type: '', is_read: 0, read_time: null, create_time: Math.floor(Date.now() / 1000) - 3600, type_text: '系统消息', from_name: '系统' }, msg: '获取消息详情成功' }; }, // 模拟消息统计数据 async getStudentMessageStatsMock(data = {}) { await new Promise(resolve => setTimeout(resolve, 300)); return { code: 1, data: { total_messages: 12, unread_messages: 5, read_messages: 7, type_counts: { 'system': 3, 'notification': 2, 'homework': 3, 'feedback': 2, 'reminder': 2 } }, msg: '获取消息统计成功' }; }, // 搜索学员消息 async searchStudentMessages(data = {}) { try { const params = { keyword: data.keyword || '', message_type: data.message_type || '', start_date: data.start_date || '', end_date: data.end_date || '', page: data.page || 1, limit: data.limit || 10 }; const response = await http.get(`/message/search/${data.student_id}`, params); return response; } catch (error) { console.error('搜索学员消息错误:', error); // 返回模拟数据作为后备 return await this.searchStudentMessagesMock(data); } }, // 模拟搜索消息数据 async searchStudentMessagesMock(data = {}) { // 复用消息列表的Mock数据,根据关键词进行筛选 return await this.getStudentMessageListMock(data); } }