diff --git a/niucloud/app/service/admin/uniapp/UniappAuthService.php b/niucloud/app/service/admin/uniapp/UniappAuthService.php index 18eb21e4..57d6ee3f 100644 --- a/niucloud/app/service/admin/uniapp/UniappAuthService.php +++ b/niucloud/app/service/admin/uniapp/UniappAuthService.php @@ -54,13 +54,57 @@ class UniappAuthService extends BaseAdminService */ public function getRoleMenus(int $roleId) { - $sql = "SELECT m.id, m.menu_key, m.menu_name, m.icon as menu_icon, - m.router_path as menu_path, '' as menu_params, m.sort as sort_order - FROM role_menu_permissions rmp - LEFT JOIN school_sys_menu m ON rmp.menu_id = m.id - WHERE rmp.role_id = ? AND rmp.is_enabled = 1 - ORDER BY m.sort ASC"; - $menuList = Db::query($sql, [$roleId]); + // 优先从school_sys_role.mobile_rules字段获取权限配置 + $roleData = Db::table('school_sys_role') + ->where('role_id', $roleId) + ->where('status', 1) + ->field('mobile_rules') + ->find(); + + if ($roleData && !empty($roleData['mobile_rules'])) { + // 解析mobile_rules JSON字符串 + $mobileRules = json_decode($roleData['mobile_rules'], true); + if (is_array($mobileRules)) { + // 使用查询构造器获取所有菜单信息 + $allMenus = Db::table('school_sys_menu') + ->where('app_type', 'uniapp') + ->where('status', 1) + ->field('id, menu_key, menu_name, icon as menu_icon, router_path as menu_path, sort as sort_order') + ->select() + ->toArray(); + + // 创建menu_key到菜单信息的映射 + $menuKeyToMenu = []; + foreach ($allMenus as $menu) { + $menuKeyToMenu[$menu['menu_key']] = $menu; + } + + // 按mobile_rules中的顺序构建菜单列表 + $menuList = []; + foreach ($mobileRules as $menuKey) { + if (isset($menuKeyToMenu[$menuKey])) { + $menu = $menuKeyToMenu[$menuKey]; + $menu['menu_params'] = []; + $menu['menu_icon'] = $menu['menu_icon'] ?? ''; + $menu['menu_path'] = $menu['menu_path'] ?? ''; + $menuList[] = $menu; + } + } + + return $menuList; + } + } + + // 如果mobile_rules为空,则从role_menu_permissions表获取(向后兼容) + $menuList = Db::table('role_menu_permissions') + ->alias('rmp') + ->leftJoin('school_sys_menu m', 'rmp.menu_id = m.id') + ->where('rmp.role_id', $roleId) + ->where('rmp.is_enabled', 1) + ->field('m.id, m.menu_key, m.menu_name, m.icon as menu_icon, m.router_path as menu_path, m.sort as sort_order') + ->order('m.sort', 'ASC') + ->select() + ->toArray(); // 处理参数和数据转换 foreach ($menuList as &$item) { @@ -84,38 +128,52 @@ class UniappAuthService extends BaseAdminService { Db::startTrans(); try { + // 1. 更新school_sys_role表的mobile_rules字段(主要存储方式) + $mobileRulesJson = json_encode($menuKeys, JSON_UNESCAPED_UNICODE); + Db::table('school_sys_role') + ->where('role_id', $roleId) + ->update(['mobile_rules' => $mobileRulesJson]); + + // 2. 同步到role_menu_permissions表(向后兼容) // 删除原有权限 - Db::execute("DELETE FROM role_menu_permissions WHERE role_id = ?", [$roleId]); + Db::table('role_menu_permissions') + ->where('role_id', $roleId) + ->delete(); // 添加新权限 if (!empty($menuKeys)) { - // 将menu_key转换为对应的数据库ID - $menuIds = []; - $sql = "SELECT id, menu_key FROM school_sys_menu WHERE app_type = 'uniapp' AND status = 1"; - $menuList = Db::query($sql); + // 使用查询构造器获取菜单ID映射 + $menuList = Db::table('school_sys_menu') + ->where('app_type', 'uniapp') + ->where('status', 1) + ->field('id, menu_key') + ->select() + ->toArray(); + + // 创建menu_key到ID的映射 $menuKeyToId = []; foreach ($menuList as $menu) { $menuKeyToId[$menu['menu_key']] = $menu['id']; } - // 过滤出有效的菜单ID + // 过滤出有效的菜单ID并构造插入数据 + $insertData = []; + $currentTime = date('Y-m-d H:i:s'); foreach ($menuKeys as $menuKey) { if (isset($menuKeyToId[$menuKey])) { - $menuIds[] = $menuKeyToId[$menuKey]; + $insertData[] = [ + 'role_id' => $roleId, + 'menu_id' => $menuKeyToId[$menuKey], + 'is_enabled' => 1, + 'created_at' => $currentTime, + 'updated_at' => $currentTime + ]; } } - // 插入新的权限数据 - if (!empty($menuIds)) { - $values = []; - $params = []; - foreach ($menuIds as $menuId) { - $values[] = "(?, ?, 1, NOW(), NOW())"; - $params[] = $roleId; - $params[] = $menuId; - } - $sql = "INSERT INTO role_menu_permissions (role_id, menu_id, is_enabled, created_at, updated_at) VALUES " . implode(', ', $values); - Db::execute($sql, $params); + // 批量插入权限数据 + if (!empty($insertData)) { + Db::table('role_menu_permissions')->insertAll($insertData); } } diff --git a/niucloud/app/service/api/login/UnifiedLoginService.php b/niucloud/app/service/api/login/UnifiedLoginService.php index 8b376c45..4d60c667 100644 --- a/niucloud/app/service/api/login/UnifiedLoginService.php +++ b/niucloud/app/service/api/login/UnifiedLoginService.php @@ -439,7 +439,25 @@ class UnifiedLoginService extends BaseService ]; } - // 解析用户的角色ID列表 + // 首先从 school_campus_person_role 表查询角色信息(优先级最高) + $campusRoleData = Db::table('school_campus_person_role') + ->alias('cpr') + ->leftJoin('school_sys_role sr', 'cpr.role_id = sr.role_id') + ->where('cpr.person_id', $staffInfo['id']) + ->where('sr.status', 1) + ->field('sr.role_id, sr.role_name, sr.role_key') + ->find(); + + if ($campusRoleData) { + return [ + 'role_id' => $campusRoleData['role_id'], + 'role_name' => $campusRoleData['role_name'], + 'role_code' => $campusRoleData['role_key'] ?: 'staff', + 'role_key' => $campusRoleData['role_key'], + ]; + } + + // 其次解析 sys_user 表的角色ID列表 $roleIds = []; if (!empty($staffInfo['role_ids'])) { $roleIdsStr = trim($staffInfo['role_ids'], '[]"'); @@ -448,28 +466,25 @@ class UnifiedLoginService extends BaseService } } - // 如果没有角色分配,根据account_type推断 - if (empty($roleIds)) { - return $this->getRoleInfoByAccountType($staffInfo['account_type']); - } - - // 查询第一个角色的详细信息 - $roleId = $roleIds[0]; // 取第一个角色 - $roleData = Db::table('school_sys_role') - ->where('role_id', $roleId) - ->where('status', 1) - ->find(); - - if ($roleData) { - return [ - 'role_id' => $roleData['role_id'], - 'role_name' => $roleData['role_name'], - 'role_code' => $roleData['role_key'] ?: 'staff', - 'role_key' => $roleData['role_key'], - ]; + // 如果有系统角色ID,查询第一个角色的详细信息 + if (!empty($roleIds)) { + $roleId = $roleIds[0]; // 取第一个角色 + $roleData = Db::table('school_sys_role') + ->where('role_id', $roleId) + ->where('status', 1) + ->find(); + + if ($roleData) { + return [ + 'role_id' => $roleData['role_id'], + 'role_name' => $roleData['role_name'], + 'role_code' => $roleData['role_key'] ?: 'staff', + 'role_key' => $roleData['role_key'], + ]; + } } - // 如果查询失败,使用默认角色 + // 最后根据account_type推断默认角色 return $this->getRoleInfoByAccountType($staffInfo['account_type']); } catch (\Exception $e) { @@ -543,45 +558,28 @@ class UnifiedLoginService extends BaseService private function getStaffMenuList(int $roleType, int $isAdmin = 0) { try { - // 如果是超级管理员或校长,返回所有菜单 - if ($isAdmin == 1 || $roleType == 999) { + // 如果是超级管理员,返回所有菜单 + if ($isAdmin == 1) { return $this->getAllMenuList(); } - // 查询角色对应的菜单权限 - $menuList = Db::table('sys_menus') - ->alias('m') - ->leftJoin('role_menu_permissions rmp', 'm.id = rmp.menu_id') - ->where('rmp.role_id', $roleType) - ->where('rmp.is_enabled', 1) - ->where('m.status', 1) - ->field('m.menu_key, m.menu_name, m.menu_icon, m.menu_path, m.menu_params, m.sort_order') - ->order('m.sort_order ASC') - ->select() - ->toArray(); - - // 转换为前端需要的格式 - $result = []; - foreach ($menuList as $menu) { - $menuItem = [ - 'key' => $menu['menu_key'], - 'title' => $menu['menu_name'], - 'icon' => $menu['menu_icon'], - 'path' => $menu['menu_path'], - ]; + // 从 school_sys_role 表查询移动端权限配置 + $roleData = Db::table('school_sys_role') + ->where('role_id', $roleType) + ->where('status', 1) + ->field('mobile_rules') + ->find(); - // 如果有参数,解析JSON参数 - if (!empty($menu['menu_params'])) { - $params = json_decode($menu['menu_params'], true); - if ($params) { - $menuItem['params'] = $params; - } + if ($roleData && !empty($roleData['mobile_rules'])) { + // 解析mobile_rules JSON字符串 + $mobileRules = json_decode($roleData['mobile_rules'], true); + if (is_array($mobileRules)) { + return $this->convertMobileRulesToMenuList($mobileRules); } - - $result[] = $menuItem; } - return $result; + // 如果查询不到,返回默认菜单 + return $this->getDefaultStaffMenuList($roleType); } catch (\Exception $e) { // 如果数据库查询失败,返回默认菜单(兼容处理) @@ -589,6 +587,89 @@ class UnifiedLoginService extends BaseService } } + /** + * 将 mobile_rules 转换为菜单列表 + * @param array $mobileRules + * @return array + */ + private function convertMobileRulesToMenuList(array $mobileRules) + { + // 定义移动端页面路径与菜单项的映射关系(包含首页所有功能) + $menuMapping = [ + // 考勤管理 + 'pages-common/my_attendance' => ['key' => 'attendance', 'title' => '考勤管理', 'icon' => 'clock-filled', 'path' => '/pages-common/my_attendance'], + + // 合同管理 + 'pages-common/contract/my_contract' => ['key' => 'contract_management', 'title' => '合同管理', 'icon' => 'document-filled', 'path' => '/pages-common/contract/my_contract'], + 'pages-common/contract/contract_sign' => ['key' => 'contract_sign', 'title' => '合同签署', 'icon' => 'edit-filled', 'path' => '/pages-common/contract/contract_sign'], + + // 客户资源管理 + 'pages-market/clue/index' => ['key' => 'customer_resource', 'title' => '客户资源', 'icon' => 'person-filled', 'path' => '/pages-market/clue/index'], + 'pages-market/clue/add_clues' => ['key' => 'add_customer', 'title' => '添加资源', 'icon' => 'plus-filled', 'path' => '/pages-market/clue/add_clues'], + + // 教学管理 + 'pages-coach/coach/student/student_list' => ['key' => 'student_management', 'title' => '学员管理', 'icon' => 'contact-filled', 'path' => '/pages-coach/coach/student/student_list'], + 'pages-coach/coach/schedule/schedule_table' => ['key' => 'course_query', 'title' => '课程查询', 'icon' => 'search', 'path' => '/pages-coach/coach/schedule/schedule_table'], + 'pages-market/clue/class_arrangement' => ['key' => 'course_arrangement', 'title' => '课程安排', 'icon' => 'calendar-filled', 'path' => '/pages-market/clue/class_arrangement'], + 'pages-coach/coach/my/teaching_management' => ['key' => 'resource_library', 'title' => '资料库', 'icon' => 'folder-add-filled', 'path' => '/pages-coach/coach/my/teaching_management'], + + // 财务管理 + 'pages-market/reimbursement/list' => ['key' => 'reimbursement', 'title' => '报销管理', 'icon' => 'wallet-filled', 'path' => '/pages-market/reimbursement/list'], + + // 系统页面 + 'pages/common/home/index' => ['key' => 'home', 'title' => '首页', 'icon' => 'home-filled', 'path' => '/pages/common/home/index'], + 'pages/common/profile/index' => ['key' => 'personal_center', 'title' => '个人中心', 'icon' => 'user-filled', 'path' => '/pages/common/profile/index'], + + // 数据统计 + 'pages/common/dashboard/webview?type=my_data' => ['key' => 'my_data', 'title' => '我的数据', 'icon' => 'bars', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'my_data']], + 'pages/common/dashboard/webview?type=dept_data' => ['key' => 'dept_data', 'title' => '部门数据', 'icon' => 'home', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'dept_data']], + 'pages/common/dashboard/webview?type=campus_data' => ['key' => 'campus_data', 'title' => '校区数据', 'icon' => 'location', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'campus_data']], + + // 消息管理 + 'pages-common/my_message' => ['key' => 'my_message', 'title' => '我的消息', 'icon' => 'chat-filled', 'path' => '/pages-common/my_message'], + ]; + + $menuList = []; + foreach ($mobileRules as $rule) { + if (isset($menuMapping[$rule])) { + $menuList[] = $menuMapping[$rule]; + } + } + + return $menuList; + } + + /** + * 获取所有移动端菜单(校长专用) + * @return array + */ + private function getAllMobileMenuList() + { + return [ + // 考勤管理 + ['key' => 'attendance', 'title' => '考勤管理', 'icon' => 'clock-filled', 'path' => '/pages-common/my_attendance'], + + // 合同管理 + ['key' => 'contract_management', 'title' => '合同管理', 'icon' => 'document-filled', 'path' => '/pages-common/contract/my_contract'], + + // 客户资源管理 + ['key' => 'customer_resource', 'title' => '客户资源', 'icon' => 'person-filled', 'path' => '/pages-market/clue/index'], + ['key' => 'add_customer', 'title' => '添加资源', 'icon' => 'plus-filled', 'path' => '/pages-market/clue/add_clues'], + + // 教学管理 + ['key' => 'student_management', 'title' => '学员管理', 'icon' => 'contact-filled', 'path' => '/pages-coach/coach/student/student_list'], + ['key' => 'course_query', 'title' => '课程查询', 'icon' => 'search', 'path' => '/pages-coach/coach/schedule/schedule_table'], + + // 数据统计(校长权限) + ['key' => 'my_data', 'title' => '我的数据', 'icon' => 'bars', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'my_data']], + ['key' => 'dept_data', 'title' => '部门数据', 'icon' => 'chart-filled', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'dept_data']], + ['key' => 'campus_data', 'title' => '校区数据', 'icon' => 'graph-filled', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'campus_data']], + + // 消息管理 + ['key' => 'my_message', 'title' => '我的消息', 'icon' => 'chat-filled', 'path' => '/pages/common/my/my_message'], + ]; + } + /** * 获取所有功能菜单(校长/管理员使用) * @return array diff --git a/uniapp/api/apiRoute.js b/uniapp/api/apiRoute.js index 323cbfde..ae70b09d 100644 --- a/uniapp/api/apiRoute.js +++ b/uniapp/api/apiRoute.js @@ -2,1772 +2,1665 @@ 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]; + //↓↓↓↓↓↓↓↓↓↓↓↓-----公共接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ + //统一登录接口 + 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_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) + }, + + // 课程安排列表 - 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 => { - return coachIds.includes(course.teacher_id); - }); - } - - // 场地筛选 - if (data.venue_id) { - const venueIds = Array.isArray(data.venue_id) ? data.venue_id : [data.venue_id]; + const hour = parseInt(course.time.split(':')[0]) + return hour >= 8 && hour < 12 + }) + break + case 'afternoon': // 下午 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]; + const hour = parseInt(course.time.split(':')[0]) + return hour >= 12 && hour < 18 + }) + break + case 'evening': // 晚上 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; + const hour = parseInt(course.time.split(':')[0]) + return hour >= 18 && hour < 22 + }) + break } - - 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); - }, + } + + // 处理结果格式 + 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_personnelCheckOldPwd(data = {}) { + return await http.post('/personnel/checkOldPwd', data) + }, + //公共端-教师/销售端验证旧密码是否正确 + async common_personnelEdidPassword(data = {}) { + return await http.post('/personnel/edidPassword', 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_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 getServiceList(data = {}) { + return await http.get('/member/service/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 addStudent(data = {}) { + return await http.post('/course/addStudent', data) + }, + //获取班级详情 + async jlClassInfo(data = {}) { + return await http.get('/class/jlClassInfo', data) + }, + //获取课程列表 + async courseList(data = {}) { + return await http.get('/course/courseList', 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 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_statisticsMarketData(data = {}) { + return await http.get('/statistics/marketData', data) + }, + //员工端(销售)-订单管理-列表 + async xs_orderTableList(data = {}) { + return await http.get('/orderTable', 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 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_physicalTestAdd(data = {}) { + return await http.post('/xy/physicalTest/add', data) + }, + //学生端-体测报告-编辑 + async xy_physicalTestEdit(data = {}) { + return await http.post('/xy/physicalTest/edit', data) + }, + //学生端-学习计划-列表 + async getStudyPlanList(data = {}) { + return await http.get('/xy/studyPlan', data) + }, + //学生端-学习计划-添加 + async addStudyPlan(data = {}) { + return await http.post('/xy/studyPlan/add', data) + }, + //学生端-学习计划-编辑 + async editStudyPlan(data = {}) { + return await http.post('/xy/studyPlan/edit', 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_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 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' - } - }; - + async listCallUp(data = {}) { + return await http.get('/per_list_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, - 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); + code: 1, + msg: '预约成功(模拟)', + data: { booking_id: Date.now() }, } - 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 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, - 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); + code: 1, + msg: '取消成功(模拟)', } + } - // 根据关键词搜索 - if (data.keyword) { - filteredArticles = filteredArticles.filter(article => - article.title.includes(data.keyword) || article.content.includes(data.keyword) - ); - } + return response + } catch (error) { + console.error('取消预约错误:', error) + // 模拟成功响应 + return { + code: 1, + msg: '取消成功(模拟)', + } + } + }, + + // 获取学员汇总信息 + async getStudentSummary(student_id) { + try { + return await http.get(`/student/summary/${student_id}`) + } catch (error) { + console.error('获取学员汇总信息错误:', error) + // 返回模拟数据 + return { + code: 1, + data: { + student_id: student_id, + name: '学员姓名', + booking_qualification: { + can_book: false, + remaining_courses: 0, + reason: '接口调用失败', + }, + }, + } + } + }, + + // 模拟可预约课程数据 + 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 { - 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 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: 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: ` + 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: `

什么是体适能?

体适能是指人体所具备的有充足的精力从事日常工作而不易疲劳,同时有余力享受休闲活动的乐趣,能够应付突发状况的身体适应能力。

@@ -1781,413 +1674,391 @@ export default {

• 因材施教:根据儿童的年龄特点和个体差异制定训练计划

• 寓教于乐:将训练内容游戏化,提高儿童参与的积极性

`, - 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); - } + 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) + } + }, - // 根据已读状态筛选 - if (data.is_read !== '' && data.is_read !== undefined) { - filteredMessages = filteredMessages.filter(msg => msg.is_read == data.is_read); - } + // 获取消息详情 + 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.keyword) { - filteredMessages = filteredMessages.filter(msg => - msg.title.includes(data.keyword) || msg.content.includes(data.keyword) - ); - } + // 根据已读状态筛选 + if (data.is_read !== '' && data.is_read !== undefined) { + filteredMessages = filteredMessages.filter(msg => msg.is_read == data.is_read) + } - 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); - } - }, + // 根据关键词搜索 + if (data.keyword) { + filteredMessages = filteredMessages.filter(msg => + msg.title.includes(data.keyword) || msg.content.includes(data.keyword), + ) + } - // 模拟搜索消息数据 - async searchStudentMessagesMock(data = {}) { - // 复用消息列表的Mock数据,根据关键词进行筛选 - return await this.getStudentMessageListMock(data); + 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 searchStudentMessagesMock(data = {}) { + // 复用消息列表的Mock数据,根据关键词进行筛选 + return await this.getStudentMessageListMock(data) + }, } \ No newline at end of file diff --git a/uniapp/pages/common/home/index.vue b/uniapp/pages/common/home/index.vue index 9af44f43..a65f0292 100644 --- a/uniapp/pages/common/home/index.vue +++ b/uniapp/pages/common/home/index.vue @@ -105,7 +105,13 @@ icon: 'location', path: '/pages/common/dashboard/webview', params: { type: 'campus_data' } - } + }, + { + title: '报销管理', + icon: 'wallet-filled', + path: '/pages-market/reimbursement/list', + params: { type: 'reimbursement' } + } ] } },