diff --git a/admin/src/api/contract.ts b/admin/src/api/contract.ts
index f9b67051..53cd6308 100644
--- a/admin/src/api/contract.ts
+++ b/admin/src/api/contract.ts
@@ -61,6 +61,10 @@ export const contractTemplateApi = {
savePlaceholderConfig: (contractId: number, data: any) =>
request.post(`/document_template/config/save`, data),
+ // 保存数据源配置到独立表
+ saveDataSourceConfig: (contractId: number, data: any) =>
+ request.post(`/document_template/config/datasource/save`, { contract_id: contractId, configs: data }),
+
// 更新模板状态
updateStatus: (id: number, status: string) =>
request.post(`/document_template/update_status/${id}`, { contract_status: status }),
diff --git a/admin/src/app/views/contract/contract.vue b/admin/src/app/views/contract/contract.vue
index d7ffa2ba..9eeb34d7 100644
--- a/admin/src/app/views/contract/contract.vue
+++ b/admin/src/app/views/contract/contract.vue
@@ -913,6 +913,7 @@ const handleConfigSuccess = async () => {
console.log('📦 保存数据结构:', saveData)
+ // 保存占位符配置(现在会同时保存到JSON字段和独立表)
await contractTemplateApi.savePlaceholderConfig(currentContractId.value, saveData)
console.log('✅ 保存成功')
diff --git a/niucloud/app/adminapi/controller/document/DocumentTemplate.php b/niucloud/app/adminapi/controller/document/DocumentTemplate.php
index db88ffb0..fa61cacd 100644
--- a/niucloud/app/adminapi/controller/document/DocumentTemplate.php
+++ b/niucloud/app/adminapi/controller/document/DocumentTemplate.php
@@ -113,6 +113,7 @@ class DocumentTemplate extends BaseAdminController
}
try {
+ // 保存配置(现在会同时保存到JSON字段和独立的school_document_data_source_config表)
(new DocumentTemplateService())->savePlaceholderConfig($data['template_id'], $data['configs']);
return success('配置保存成功');
} catch (\Exception $e) {
diff --git a/niucloud/app/adminapi/route/document_template.php b/niucloud/app/adminapi/route/document_template.php
index 3cd25e2a..131d7f10 100644
--- a/niucloud/app/adminapi/route/document_template.php
+++ b/niucloud/app/adminapi/route/document_template.php
@@ -32,6 +32,7 @@ Route::group('document_template', function () {
// 占位符配置
Route::post('config/save', 'document.DocumentTemplate/savePlaceholderConfig');
+ Route::post('config/datasource/save', 'document.DocumentTemplate/saveDataSourceConfig');
Route::get('datasources', 'document.DocumentTemplate/getDataSources');
// 文档生成
diff --git a/niucloud/app/api/controller/apiController/CoachStudent.php b/niucloud/app/api/controller/apiController/CoachStudent.php
new file mode 100644
index 00000000..e4d3fa83
--- /dev/null
+++ b/niucloud/app/api/controller/apiController/CoachStudent.php
@@ -0,0 +1,53 @@
+request->params([
+ ["name", ""], // 学员姓名搜索
+ ["phone", ""], // 联系电话搜索
+ ["campus_id", 0], // 校区ID
+ ["status", 0], // 学员状态
+ ["course_id", 0], // 课程ID搜索
+ ["class_id", 0], // 班级ID搜索
+ ["debug", false] // 调试模式
+ ]);
+
+ $result = (new CoachStudentService())->getMyStudents($data);
+ if ($result['code'] === 1) {
+ return success('获取成功', $result['data']);
+ } else {
+ return fail($result['msg']);
+ }
+ } catch (\Exception $e) {
+ return fail('获取我的学员列表失败:' . $e->getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/api/controller/apiController/StudentManager.php b/niucloud/app/api/controller/apiController/StudentManager.php
index 8a695d3f..98669514 100644
--- a/niucloud/app/api/controller/apiController/StudentManager.php
+++ b/niucloud/app/api/controller/apiController/StudentManager.php
@@ -89,7 +89,8 @@ class StudentManager extends BaseApiService
["leaveCount", ""], // 请假次数搜索
["courseId", 0], // 课程ID搜索
["classId", 0], // 班级ID搜索
- ["type", ""] // 查询类型
+ ["type", ""], // 查询类型
+ ["debug", false] // 调试模式
]);
$result = (new StudentService())->getList($data);
diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php
index aa3da701..d5473d90 100644
--- a/niucloud/app/api/route/route.php
+++ b/niucloud/app/api/route/route.php
@@ -261,6 +261,9 @@ Route::group(function () {
//销售端-学员-列表
Route::get('student/list', 'apiController.StudentManager/list');
+ //教练端-学员-我的学员列表
+ Route::get('coach/students/my', 'apiController.CoachStudent/getMyStudents');
+
//沟通记录-添加
Route::post('communicationRecords/add', 'apiController.CommunicationRecords/add');
Route::post('communicationRecords/edit', 'apiController.CommunicationRecords/edit');
diff --git a/niucloud/app/model/document/DocumentDataSourceConfig.php b/niucloud/app/model/document/DocumentDataSourceConfig.php
index 2ee049e7..2295ef0f 100644
--- a/niucloud/app/model/document/DocumentDataSourceConfig.php
+++ b/niucloud/app/model/document/DocumentDataSourceConfig.php
@@ -11,7 +11,7 @@ use app\model\contract\Contract;
class DocumentDataSourceConfig extends BaseModel
{
protected $pk = 'id';
- protected $name = 'document_data_source_config';
+ protected $name = 'school_document_data_source_config';
/**
* 关联合同表
diff --git a/niucloud/app/service/admin/document/DocumentTemplateService.php b/niucloud/app/service/admin/document/DocumentTemplateService.php
index ccea70a6..5a70de3e 100644
--- a/niucloud/app/service/admin/document/DocumentTemplateService.php
+++ b/niucloud/app/service/admin/document/DocumentTemplateService.php
@@ -415,11 +415,14 @@ class DocumentTemplateService extends BaseAdminService
// 开启事务
\think\facade\Db::startTrans();
try {
- // 保存配置到合同表的placeholder_config字段
+ // 1. 保存配置到合同表的placeholder_config字段(保持兼容性)
$template->placeholder_config = json_encode($configData);
$template->updated_at = date('Y-m-d H:i:s');
$template->save();
+ // 2. 同时保存到独立的数据源配置表(用户期望的表)
+ $this->saveConfigToDataSourceTable($templateId, $configData);
+
\think\facade\Db::commit();
return true;
} catch (\Exception $e) {
@@ -447,9 +450,12 @@ class DocumentTemplateService extends BaseAdminService
$insertData[] = [
'contract_id' => $contractId,
'placeholder' => $placeholder,
+ 'data_type' => $settings['data_type'] ?? 'user_input',
'table_name' => $settings['table_name'] ?? '',
'field_name' => $settings['field_name'] ?? '',
- 'field_type' => $settings['field_type'] ?? 'string',
+ 'system_function' => $settings['system_function'] ?? '',
+ 'user_input_value' => $settings['user_input_value'] ?? '',
+ 'field_type' => $settings['field_type'] ?? 'text',
'is_required' => $settings['is_required'] ?? 0,
'default_value' => $settings['default_value'] ?? '',
'created_at' => date('Y-m-d H:i:s')
diff --git a/niucloud/app/service/api/apiService/CoachStudentService.php b/niucloud/app/service/api/apiService/CoachStudentService.php
new file mode 100644
index 00000000..5474d895
--- /dev/null
+++ b/niucloud/app/service/api/apiService/CoachStudentService.php
@@ -0,0 +1,381 @@
+ 0,
+ 'msg' => '操作失败',
+ 'data' => []
+ ];
+
+ try {
+ // 获取当前登录教练的ID
+ $coachId = $this->getCurrentCoachId();
+
+ if (empty($coachId)) {
+ $res['code'] = 1;
+ $res['data'] = [];
+ $res['msg'] = '获取成功';
+ return $res;
+ }
+
+ // 查询教练负责的所有学员ID
+ $studentIds = $this->getCoachStudentIds($coachId, $data);
+
+ if (empty($studentIds)) {
+ $res['code'] = 1;
+ $res['data'] = [];
+ $res['msg'] = '获取成功';
+ return $res;
+ }
+
+ // 构建学员基础查询条件
+ $where = [];
+ $where[] = ['s.deleted_at', '=', 0];
+ $where[] = ['s.id', 'in', $studentIds];
+
+ // 支持搜索参数
+ if (!empty($data['name'])) {
+ $where[] = ['s.name', 'like', '%' . $data['name'] . '%'];
+ }
+
+ if (!empty($data['phone'])) {
+ $where[] = ['s.contact_phone', 'like', '%' . $data['phone'] . '%'];
+ }
+
+ if (!empty($data['campus_id'])) {
+ $where[] = ['s.campus_id', '=', $data['campus_id']];
+ }
+
+ if (!empty($data['status'])) {
+ $where[] = ['s.status', '=', $data['status']];
+ }
+
+ // 查询学员基础信息
+ $list = Db::table('school_student s')
+ ->leftJoin('school_campus c', 's.campus_id = c.id')
+ ->where($where)
+ ->field('s.*, c.campus_name as campus')
+ ->order('s.created_at', 'desc')
+ ->select()
+ ->toArray();
+
+ // 为每个学员添加教练专属信息
+ foreach ($list as &$student) {
+ // 获取学员最新有效的课程信息
+ $courseInfo = $this->getStudentLatestCourse($student['id']);
+ $student = array_merge($student, $courseInfo);
+
+ // 获取教练与学员的关系信息
+ $coachRelation = $this->getCoachStudentRelation($coachId, $student['id']);
+ $student = array_merge($student, $coachRelation);
+
+ // 查询该学员的课程安排记录,按日期排序获取一访和二访信息
+ $visitRecords = Db::table('school_person_course_schedule pcs')
+ ->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id')
+ ->where([
+ ['pcs.student_id', '=', $student['id']],
+ ['pcs.person_type', '=', 'student'],
+ ['pcs.deleted_at', '=', 0],
+ ['cs.deleted_at', '=', 0]
+ ])
+ ->where(function($query) use ($coachId) {
+ $query->where('cs.coach_id', $coachId)
+ ->whereOr('cs.education_id', $coachId);
+ })
+ ->field('pcs.*, cs.course_date, cs.start_time, cs.end_time')
+ ->order('cs.course_date', 'asc')
+ ->select()
+ ->toArray();
+
+ // 初始化到访信息
+ $student['first_visit_time'] = '';
+ $student['second_visit_time'] = '';
+ $student['first_visit_status'] = '未到访';
+ $student['second_visit_status'] = '未到访';
+
+ // 设置一访和二访信息
+ if (!empty($visitRecords)) {
+ if (isset($visitRecords[0])) {
+ $student['first_visit_time'] = $visitRecords[0]['course_date'];
+ $student['first_visit_status'] = '已到访';
+ }
+ if (isset($visitRecords[1])) {
+ $student['second_visit_time'] = $visitRecords[1]['course_date'];
+ $student['second_visit_status'] = '已到访';
+ }
+ }
+
+ // 保留原始访问记录数据供前端使用
+ $student['visit_records'] = $visitRecords;
+
+ // 计算教练相关的课时统计
+ $student['coach_class_count'] = count($visitRecords);
+ $student['total_class_hours'] = array_sum(array_column($visitRecords, 'class_hours'));
+ }
+
+ $res['code'] = 1;
+ $res['data'] = $list;
+ } catch (\Exception $e) {
+ $res['msg'] = '获取失败:' . $e->getMessage();
+ }
+
+ return $res;
+ }
+
+ /**
+ * 获取教练负责的学员ID集合
+ * @param int $coachId 教练ID
+ * @param array $data 查询条件
+ * @return array
+ */
+ private function getCoachStudentIds($coachId, $data = [])
+ {
+ // 1. 从 school_student_courses 表中查询 main_coach_id 或 education_id 是当前教练的学员
+ $courseStudentIds = Db::table('school_student_courses')
+ ->where(function($query) use ($coachId) {
+ $query->where('main_coach_id', $coachId)
+ ->whereOr('education_id', $coachId);
+ })
+ ->column('student_id');
+
+ // 2. 从 school_person_course_schedule 和 school_course_schedule 表联查,获取教练负责的学员
+ $scheduleStudentIds = Db::table('school_person_course_schedule pcs')
+ ->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id')
+ ->where(function($query) use ($coachId) {
+ $query->where('cs.education_id', $coachId)
+ ->whereOr('cs.coach_id', $coachId);
+ })
+ ->where('pcs.person_type', 'student')
+ ->where('pcs.deleted_at', 0)
+ ->where('cs.deleted_at', 0)
+ ->column('pcs.student_id');
+
+ // 3. 合并并去重学生ID
+ $allStudentIds = array_merge($courseStudentIds, $scheduleStudentIds);
+ $uniqueStudentIds = array_unique($allStudentIds);
+
+ return array_values($uniqueStudentIds);
+ }
+
+ /**
+ * 获取学员最新有效的课程信息
+ * @param int $studentId 学员ID
+ * @return array
+ */
+ private function getStudentLatestCourse($studentId)
+ {
+ // 先从学员课程表获取课程信息
+ $courseInfo = Db::table('school_student_courses sc')
+ ->leftJoin('school_course c', 'sc.course_id = c.id')
+ ->where([
+ ['sc.student_id', '=', $studentId]
+ ])
+ ->field('sc.total_hours, sc.gift_hours, sc.use_total_hours, sc.use_gift_hours, sc.end_date, sc.resource_id, c.course_name')
+ ->order('sc.created_at', 'desc')
+ ->find();
+
+ // 获取学员对应的资源共享ID
+ $resourceSharingId = 0;
+ if (!empty($courseInfo) && !empty($courseInfo['resource_id'])) {
+ // 通过resource_id查找对应的资源共享记录,获取最新的一条
+ $resourceSharing = Db::table('school_resource_sharing')
+ ->where('resource_id', $courseInfo['resource_id'])
+ ->field('id')
+ ->order('shared_at', 'desc')
+ ->find();
+
+ if (!empty($resourceSharing)) {
+ $resourceSharingId = $resourceSharing['id'];
+ }
+ }
+
+ // 如果没有找到资源共享ID,尝试通过学员的user_id查找
+ if (empty($resourceSharingId)) {
+ $student = Db::table('school_student')
+ ->where('id', $studentId)
+ ->field('user_id')
+ ->find();
+
+ if (!empty($student['user_id'])) {
+ // 方法1:先尝试直接用user_id作为resource_id查找
+ $resourceSharing = Db::table('school_resource_sharing')
+ ->where('resource_id', $student['user_id'])
+ ->field('id')
+ ->order('shared_at', 'desc')
+ ->find();
+
+ if (!empty($resourceSharing)) {
+ $resourceSharingId = $resourceSharing['id'];
+ } else {
+ // 方法2:通过客户资源表查找
+ $customerResource = Db::table('school_customer_resources')
+ ->where('member_id', $student['user_id'])
+ ->where('deleted_at', 0)
+ ->field('id')
+ ->order('created_at', 'desc')
+ ->find();
+
+ if (!empty($customerResource)) {
+ // 通过客户资源ID查找资源共享记录
+ $resourceSharing = Db::table('school_resource_sharing')
+ ->where('resource_id', $customerResource['id'])
+ ->field('id')
+ ->order('shared_at', 'desc')
+ ->find();
+
+ if (!empty($resourceSharing)) {
+ $resourceSharingId = $resourceSharing['id'];
+ }
+ }
+ }
+ }
+ }
+
+ if (empty($courseInfo)) {
+ return [
+ 'total_hours' => 0,
+ 'gift_hours' => 0,
+ 'use_total_hours' => 0,
+ 'use_gift_hours' => 0,
+ 'end_date' => '',
+ 'resource_sharing_id' => $resourceSharingId,
+ 'course_name' => ''
+ ];
+ }
+
+ // 返回课程信息,包含resource_sharing_id
+ return [
+ 'total_hours' => $courseInfo['total_hours'] ?? 0,
+ 'gift_hours' => $courseInfo['gift_hours'] ?? 0,
+ 'use_total_hours' => $courseInfo['use_total_hours'] ?? 0,
+ 'use_gift_hours' => $courseInfo['use_gift_hours'] ?? 0,
+ 'end_date' => $courseInfo['end_date'] ?? '',
+ 'resource_sharing_id' => $resourceSharingId,
+ 'course_name' => $courseInfo['course_name'] ?? ''
+ ];
+ }
+
+ /**
+ * 获取教练与学员的关系信息
+ * @param int $coachId 教练ID
+ * @param int $studentId 学员ID
+ * @return array
+ */
+ private function getCoachStudentRelation($coachId, $studentId)
+ {
+ // 检查教练在学员课程中的角色
+ $courseRelation = Db::table('school_student_courses')
+ ->where('student_id', $studentId)
+ ->where(function($query) use ($coachId) {
+ $query->where('main_coach_id', $coachId)
+ ->whereOr('education_id', $coachId);
+ })
+ ->field('main_coach_id, education_id')
+ ->find();
+
+ $relation_type = '';
+ if (!empty($courseRelation)) {
+ if ($courseRelation['main_coach_id'] == $coachId) {
+ $relation_type = '主教练';
+ } elseif ($courseRelation['education_id'] == $coachId) {
+ $relation_type = '教务';
+ }
+ }
+
+ // 如果没有在课程表中找到关系,检查课程安排表
+ if (empty($relation_type)) {
+ $scheduleRelation = Db::table('school_person_course_schedule pcs')
+ ->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id')
+ ->where('pcs.student_id', $studentId)
+ ->where('pcs.person_type', 'student')
+ ->where('pcs.deleted_at', 0)
+ ->where('cs.deleted_at', 0)
+ ->where(function($query) use ($coachId) {
+ $query->where('cs.coach_id', $coachId)
+ ->whereOr('cs.education_id', $coachId);
+ })
+ ->field('cs.coach_id, cs.education_id')
+ ->find();
+
+ if (!empty($scheduleRelation)) {
+ if ($scheduleRelation['coach_id'] == $coachId) {
+ $relation_type = '授课教练';
+ } elseif ($scheduleRelation['education_id'] == $coachId) {
+ $relation_type = '教务';
+ }
+ }
+ }
+
+ return [
+ 'coach_relation_type' => $relation_type ?: '相关教练'
+ ];
+ }
+
+ /**
+ * 获取当前登录教练ID
+ * @return int
+ */
+ private function getCurrentCoachId()
+ {
+ try {
+ // 从请求头获取token
+ $token = request()->header('token') ?: request()->header('Authorization');
+ if (empty($token)) {
+ return 0;
+ }
+
+ // 去掉Bearer前缀
+ $token = str_replace('Bearer ', '', $token);
+
+ // 使用项目的TokenAuth类解析token,类型为personnel(员工端)
+ $tokenInfo = \core\util\TokenAuth::parseToken($token, 'personnel');
+
+ if (!empty($tokenInfo)) {
+ // 从jti中提取用户ID(格式:用户ID_类型)
+ $jti = $tokenInfo['jti'] ?? '';
+ if (!empty($jti)) {
+ $parts = explode('_', $jti);
+ if (count($parts) >= 2) {
+ return (int)$parts[0];
+ }
+ }
+ }
+
+ return 0;
+ } catch (\Exception $e) {
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/service/api/apiService/StudentService.php b/niucloud/app/service/api/apiService/StudentService.php
index fe9da03d..c0d981d7 100644
--- a/niucloud/app/service/api/apiService/StudentService.php
+++ b/niucloud/app/service/api/apiService/StudentService.php
@@ -95,8 +95,8 @@ class StudentService extends BaseApiService
try {
// 获取当前登录人员的ID
$currentUserId = $this->getUserId();
+
if (empty($currentUserId)) {
- // 用户未登录或不是有效用户,返回空数据
$res['code'] = 1;
$res['data'] = [];
$res['msg'] = '获取成功';
@@ -104,10 +104,9 @@ class StudentService extends BaseApiService
}
// 查询符合条件的学生ID集合
- $studentIds = $this->getCoachStudentIds($currentUserId, $data);
+ $studentIds = $this->getStudentIds($currentUserId, $data);
if (empty($studentIds)) {
- // 当前教练没有负责的学员,返回空数据
$res['code'] = 1;
$res['data'] = [];
$res['msg'] = '获取成功';
@@ -192,6 +191,42 @@ class StudentService extends BaseApiService
return $res;
}
+ /**
+ * 获取学生ID集合(支持资源ID过滤)
+ * @param int $userId 当前用户ID
+ * @param array $data 查询条件
+ * @return array
+ */
+ private function getStudentIds($userId, $data = [])
+ {
+ // 如果指定了parent_resource_id,则查询该资源下的学生
+ if (!empty($data['parent_resource_id'])) {
+ $resourceId = $data['parent_resource_id'];
+
+ // 验证当前用户是否有权限访问该资源
+ $resource = Db::table('school_customer_resources')
+ ->where('id', $resourceId)
+ ->where('consultant', $userId)
+ ->where('deleted_at', 0)
+ ->find();
+
+ if (empty($resource)) {
+ // 用户无权限访问该资源
+ return [];
+ }
+
+ // 查询该资源关联的学生ID
+ $studentIds = Db::table('school_student_courses')
+ ->where('resource_id', $resourceId)
+ ->column('student_id');
+
+ return array_values(array_unique($studentIds));
+ }
+
+ // 如果没有指定资源ID,则查询当前用户(教练)负责的所有学生
+ return $this->getCoachStudentIds($userId, $data);
+ }
+
/**
* 获取教练负责的学生ID集合
* @param int $coachId 教练ID
@@ -208,10 +243,6 @@ class StudentService extends BaseApiService
})
->column('student_id');
- // 调试日志
- error_log("Coach ID: " . $coachId);
- error_log("Course Student IDs: " . json_encode($courseStudentIds));
-
// 2. 从 school_person_course_schedule 和 school_course_schedule 表联查,获取教练负责的学生
$scheduleStudentIds = Db::table('school_person_course_schedule pcs')
->leftJoin('school_course_schedule cs', 'pcs.schedule_id = cs.id')
@@ -224,14 +255,10 @@ class StudentService extends BaseApiService
->where('cs.deleted_at', 0)
->column('pcs.student_id');
- error_log("Schedule Student IDs: " . json_encode($scheduleStudentIds));
-
// 3. 合并并去重学生ID
$allStudentIds = array_merge($courseStudentIds, $scheduleStudentIds);
$uniqueStudentIds = array_unique($allStudentIds);
- error_log("Final Student IDs: " . json_encode($uniqueStudentIds));
-
return array_values($uniqueStudentIds);
}
@@ -273,28 +300,33 @@ class StudentService extends BaseApiService
*/
private function getUserId()
{
- // 员工端通过JWT token获取用户信息,支持token和Authorization两种header
- $token = request()->header('token') ?: request()->header('Authorization');
- if (empty($token)) {
- return 0; // 返回0而不是抛异常,让上层处理
- }
-
- // 去掉Bearer前缀
- $token = str_replace('Bearer ', '', $token);
-
try {
- // 解析JWT token
- $decoded = \Firebase\JWT\JWT::decode($token, new \Firebase\JWT\Key(config('app.app_key'), 'HS256'));
+ // 从请求头获取token
+ $token = request()->header('token') ?: request()->header('Authorization');
+ if (empty($token)) {
+ return 0;
+ }
+
+ // 去掉Bearer前缀
+ $token = str_replace('Bearer ', '', $token);
- // 检查token是否过期
- if ($decoded->exp < time()) {
- return 0; // token过期返回0
+ // 使用项目的TokenAuth类解析token,类型为personnel(员工端)
+ $tokenInfo = \core\util\TokenAuth::parseToken($token, 'personnel');
+
+ if (!empty($tokenInfo)) {
+ // 从jti中提取用户ID(格式:用户ID_类型)
+ $jti = $tokenInfo['jti'] ?? '';
+ if (!empty($jti)) {
+ $parts = explode('_', $jti);
+ if (count($parts) >= 2) {
+ return (int)$parts[0];
+ }
+ }
}
- // 返回用户ID
- return $decoded->user_id ?? 0;
+ return 0;
} catch (\Exception $e) {
- return 0; // token解析失败返回0
+ return 0;
}
}
}
\ No newline at end of file
diff --git a/uniapp/api/apiRoute.js b/uniapp/api/apiRoute.js
index 428bc1eb..6438edb2 100644
--- a/uniapp/api/apiRoute.js
+++ b/uniapp/api/apiRoute.js
@@ -495,6 +495,10 @@ export default {
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);
diff --git a/uniapp/pages-coach/coach/student/student_list.vue b/uniapp/pages-coach/coach/student/student_list.vue
index 9a10486d..ef3b04f2 100644
--- a/uniapp/pages-coach/coach/student/student_list.vue
+++ b/uniapp/pages-coach/coach/student/student_list.vue
@@ -160,13 +160,12 @@ import apiRoute from '@/api/apiRoute.js';
},
async getStudentList() {
try {
- // 合并基础参数和搜索表单参数,后端现在支持完整的搜索功能
- const params = { type: 'all' };
- const res = await apiRoute.xs_getStudentList(Object.assign(params, this.searchForm));
- console.log('获取学员列表响应:', res);
+ // 使用教练端专用接口,合并搜索表单参数
+ const res = await apiRoute.coach_getMyStudents(this.searchForm);
+ console.log('获取教练端学员列表响应:', res);
if(res.code == 1) {
this.studentList = res.data || [];
- console.log('学员列表更新成功:', this.studentList);
+ console.log('教练端学员列表更新成功:', this.studentList);
} else {
console.error('API返回错误:', res);
uni.showToast({
diff --git a/uniapp/pages/student/home/index.vue b/uniapp/pages/student/home/index.vue
index 12c921b5..54e36aef 100644
--- a/uniapp/pages/student/home/index.vue
+++ b/uniapp/pages/student/home/index.vue
@@ -343,7 +343,7 @@
const studentId = this.selectedStudent.student_id || this.selectedStudent.id
console.log('准备跳转到个人信息管理页面, 学员ID:', studentId)
- const url = `/pages-student/profile/index?student_id=${studentId}`
+ const url = `/pages/student/profile/index?student_id=${studentId}`
console.log('跳转URL:', url)
uni.navigateTo({
diff --git a/uniapp/pages/student/profile/index.vue b/uniapp/pages/student/profile/index.vue
index 0945b5f5..04ca56ed 100644
--- a/uniapp/pages/student/profile/index.vue
+++ b/uniapp/pages/student/profile/index.vue
@@ -25,8 +25,8 @@
{{ studentInfo.name || '学员姓名' }}
- {{ studentInfo.gender_text }}
- {{ studentInfo.ageText }}岁
+ {{ genderText }}
+ {{ ageText }}
@@ -48,7 +48,7 @@
性别
生日
-
+
-
+
@@ -208,7 +202,6 @@
},
saving: false,
showGenderPicker: false,
- showDatePicker: false,
genderOptions: [
{ value: '1', text: '男' },
{ value: '2', text: '女' }
@@ -304,8 +297,7 @@
},
changeBirthday(e) {
- this.formData.birthday = e.result
- this.showDatePicker = false
+ this.formData.birthday = e.detail.value
},
async uploadAvatar() {