diff --git a/niucloud/app/Request.php b/niucloud/app/Request.php
index e60fb0ef..0ebb981d 100644
--- a/niucloud/app/Request.php
+++ b/niucloud/app/Request.php
@@ -1,7 +1,9 @@
paramFilter($this->param($key, $default, $filter_rule ?? ''), $item_filter);
//过滤后产生空字符串,按照默认值
- if($input[$name] === '')
- {
+ if ($input[$name] === '') {
$input[$name] = $default;
}
}
@@ -110,7 +111,8 @@ class Request extends \think\Request
* @param string $app_type
* @return mixed|string
*/
- public function appType(string $app_type = ''){
+ public function appType(string $app_type = '')
+ {
if (!empty($app_type)) {
static::$auth_info['app_type'] = $app_type;
return $app_type;
@@ -123,7 +125,8 @@ class Request extends \think\Request
* 获取管理端token
* @return array|string|null
*/
- public function adminToken(){
+ public function adminToken()
+ {
return $this->header(system_name('admin_token_name'));
}
@@ -132,7 +135,8 @@ class Request extends \think\Request
* 获取会员token
* @return array|string|null
*/
- public function apiToken(){
+ public function apiToken()
+ {
return $this->header(system_name('api_token_name'));
}
@@ -140,7 +144,8 @@ class Request extends \think\Request
* 获取场景
* @return array|string
*/
- public function getChannel(){
+ public function getChannel()
+ {
return $this->header(system_name('channel_name'), ChannelDict::H5);
}
@@ -149,7 +154,8 @@ class Request extends \think\Request
* @param $data
* @return void
*/
- public function pushGet($data){
+ public function pushGet($data)
+ {
$param = $this->get();
$this->withGet(array_merge($param, $data));
}
@@ -159,7 +165,8 @@ class Request extends \think\Request
* @param $data
* @return void
*/
- public function pushHeader($data){
+ public function pushHeader($data)
+ {
$param = $this->header();
$this->withHeader(array_merge($param, $data));
}
@@ -170,11 +177,27 @@ class Request extends \think\Request
* @param $value
* @return mixed|string|void
*/
- public function auth($key, $value = ''){
+ public function auth($key, $value = '')
+ {
if (!empty($value)) {
static::$auth_info[$key] = $value;
} else {
return static::$auth_info[$key] ?? '';
}
}
+
+ /**
+ * 获取人员角色信息
+ * @return array|string
+ */
+ public function getRoleInfo($key = false)
+ {
+ $id = static::$auth_info['member_id'] ?? 0;
+ $role = CampusPersonRole::where('person_id', $id)
+ ->find();
+ if ($role) {
+ $role = $role->toArray();
+ }
+ return $key ? $role[$key] ?? '' : $role;
+ }
}
diff --git a/niucloud/app/api/controller/member/Member.php b/niucloud/app/api/controller/member/Member.php
index 36d69585..0443e39f 100644
--- a/niucloud/app/api/controller/member/Member.php
+++ b/niucloud/app/api/controller/member/Member.php
@@ -203,5 +203,7 @@ class Member extends BaseApiController
return success(( new MemberService() )->contract_sign($data));
}
-
+ public function get_classes_list(){
+ return success(( new MemberService() )->get_classes_list());
+ }
}
diff --git a/niucloud/app/api/route/member.php b/niucloud/app/api/route/member.php
index 3b1cc958..a628a57f 100644
--- a/niucloud/app/api/route/member.php
+++ b/niucloud/app/api/route/member.php
@@ -122,6 +122,9 @@ Route::group('member', function () {
Route::get('sktj', 'member.Member/sktj');
Route::post('contract_sign', 'member.Member/contract_sign');
+ Route::get('get_classes_list', 'member.Member/get_classes_list');
+ Route::get('get_courses_list', 'member.Member/get_courses_list');
+
})->middleware(ApiChannel::class)
->middleware(ApiPersonnelCheckToken::class, true)
->middleware(ApiLog::class);
diff --git a/niucloud/app/model/personnel_data/PersonnelData.php b/niucloud/app/model/personnel_data/PersonnelData.php
index 4cb7dcec..105cd515 100644
--- a/niucloud/app/model/personnel_data/PersonnelData.php
+++ b/niucloud/app/model/personnel_data/PersonnelData.php
@@ -42,7 +42,7 @@ class PersonnelData extends BaseModel
* 定义软删除标记字段.
* @var string
*/
- protected $deleteTime = 'delete_time';
+ protected $deleteTime = 'deleted_at';
/**
* 定义软删除字段的默认值.
diff --git a/niucloud/app/service/api/member/MemberService.php b/niucloud/app/service/api/member/MemberService.php
index 54d0d284..b72e70e3 100644
--- a/niucloud/app/service/api/member/MemberService.php
+++ b/niucloud/app/service/api/member/MemberService.php
@@ -14,9 +14,11 @@ namespace app\service\api\member;
use app\model\assignment\Assignment;
use app\model\attendance\Attendance;
use app\model\campus\Campus;
+use app\model\class_grade\ClassGrade;
use app\model\class_resources_rel\ClassResourcesRel;
use app\model\communication_records\CommunicationRecords;
use app\model\contract_sign\ContractSign;
+use app\model\course\Course;
use app\model\course_schedule\CourseSchedule;
use app\model\member\Member;
use app\model\person_course_schedule\PersonCourseSchedule;
@@ -479,4 +481,16 @@ class MemberService extends BaseApiService
return true;
}
+ public function get_classes_list()
+ {
+ $data['classes'] = ClassGrade::where('status',1)
+ ->when($this->campus_id, function ($query) {
+ $query->where('campus_id', $this->campus_id);
+ })
+ ->select();
+ $data['course'] = Course::select();
+ return $data;
+ }
+
+
}
diff --git a/niucloud/core/base/BaseApiService.php b/niucloud/core/base/BaseApiService.php
index bc1bc07d..de7e6e19 100644
--- a/niucloud/core/base/BaseApiService.php
+++ b/niucloud/core/base/BaseApiService.php
@@ -21,11 +21,13 @@ class BaseApiService extends BaseService
protected $member_id;
protected $channel;
+ protected $campus_id;
public function __construct()
{
parent::__construct();
$this->member_id = $this->request->memberId();
$this->channel = $this->request->getChannel();
+ $this->campus_id = $this->request->getRoleInfo('campus_id');
}
}
\ No newline at end of file
diff --git a/uniapp/api/apiRoute.js b/uniapp/api/apiRoute.js
index 777ec115..8c3b7fd2 100644
--- a/uniapp/api/apiRoute.js
+++ b/uniapp/api/apiRoute.js
@@ -30,30 +30,6 @@ export default {
return await http.get('/common/getDictionary', data);
},
- // 课程安排列表
- async getCourseScheduleList(data = {}) {
- return await http.get('/courseSchedule/list', data);
- },
-
- // 课程安排时间段
- async getCourseScheduleTimeSlots(data = {}) {
- return await http.get('/courseSchedule/timeSlots', data);
- },
-
- // 课程安排筛选选项
- async getCourseScheduleFilterOptions(data = {}) {
- return await http.get('/courseSchedule/filterOptions', data);
- },
-
- // 课程安排详情
- async getCourseScheduleInfo(data = {}) {
- return await http.get('/courseSchedule/info', data);
- },
-
- // 提交课程点名
- async submitScheduleSignIn(data = {}) {
- return await http.post('/courseSchedule/signIn', data);
- },
// 课程安排列表 - Mock版本
async getCourseScheduleListMock(data = {}) {
@@ -310,10 +286,7 @@ export default {
async jlPublishJob(data = {}) {
return await http.get('/class/jlPublishJob/add', data);
},
- //添加作业-学员列表
- async jlGetStudentList(data = {}) {
- return await http.get('/class/jlGetStudentList/list', data);
- },
+
//添加作业-获取课程列表
async jlGetCoursesList(data = {}) {
return await http.get('/class/jlGetCoursesList/list', data);
@@ -625,7 +598,9 @@ export default {
},
// 创建课程安排
async createCourseSchedule(data = {}) {
- return await http.post('/courseSchedule/create', data);
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/courseSchedule/create' : '/test/courseSchedule/create';
+ return await http.post(apiPath, data);
},
// 批量创建课程安排
async batchCreateCourseSchedule(data = {}) {
@@ -639,11 +614,11 @@ export default {
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);
},
@@ -676,22 +651,33 @@ export default {
//↓↓↓↓↓↓↓↓↓↓↓↓-----添加课程安排页面专用接口-----↓↓↓↓↓↓↓↓↓↓↓↓
// 获取课程列表(用于添加课程安排)
async getCourseListForSchedule(data = {}) {
- return await http.get('/course/list', data);
+ // 检查是否有token,如果没有则使用测试接口
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/course/list' : '/test/course/list';
+ return await http.get(apiPath, data);
},
// 获取班级列表(用于添加课程安排)
async getClassListForSchedule(data = {}) {
- return await http.get('/class/list', data);
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/class/list' : '/test/class/list';
+ return await http.get(apiPath, data);
},
// 获取教练列表(用于添加课程安排)
async getCoachListForSchedule(data = {}) {
- return await http.get('/coach/list', data);
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/coach/list' : '/test/coach/list';
+ return await http.get(apiPath, data);
},
- // 获取场地列表(用于添加课程安排)
+ // 获取场地列表(用于添加课程安排 - 新开发的通用接口)
async getVenueListForSchedule(data = {}) {
- return await http.get('/venue/list', data);
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/venue/list' : '/test/venue/list';
+ return await http.get(apiPath, data);
},
- // 获取场地可用时间段
+ // 获取场地可用时间段(新开发的通用接口)
async getVenueTimeSlots(data = {}) {
- return await http.get('/venue/timeSlots', data);
+ const token = uni.getStorageSync("token");
+ const apiPath = token ? '/venue/timeSlots' : '/test/venue/timeSlots';
+ return await http.get(apiPath, data);
},
}
\ No newline at end of file
diff --git a/uniapp/common/axios.js b/uniapp/common/axios.js
index 908c444b..1b562bde 100644
--- a/uniapp/common/axios.js
+++ b/uniapp/common/axios.js
@@ -10,9 +10,9 @@ const debounce = (fn, delay = 1000) => {
return function (...args) {
return new Promise((resolve, reject) => {
if (timer) clearTimeout(timer);
- timer = setTimeout(() => {
+ timer = setTimeout(async () => {
try {
- const result = fn.apply(this, args);
+ const result = await fn.apply(this, args);
resolve(result);
} catch (error) {
reject(error);
@@ -38,12 +38,13 @@ const requestInterceptor = (config) => {
// 响应拦截器
const responseInterceptor = (response) => {
const { statusCode, data } = response;
- console.log('响应数据:', response);
+ console.log('响应拦截器处理:', { statusCode, data });
// 处理HTTP状态码
if (statusCode >= 200 && statusCode < 300) {
// 处理业务状态码
- if (data && data.code) {
+ if (data && typeof data.code !== 'undefined') {
+ console.log('业务状态码:', data.code);
if (data.code === 1) { // 成功状态码为1
// 登录成功,保存token
if (data.data && data.data.token) {
@@ -59,6 +60,7 @@ const responseInterceptor = (response) => {
}
return data;
} else if (data.code === 401) {
+ console.error('401错误 - 未授权');
// 未授权或token过期,清除所有用户缓存信息
// 清除token
uni.removeStorageSync("token");
@@ -91,25 +93,23 @@ const responseInterceptor = (response) => {
url: '/pages/student/login/login?code=401'
});
}, 1500);
- return Promise.reject(data);
+ throw new Error(data.msg || '未授权');
} else {
// 其他业务错误
- uni.showToast({
- title: data.msg || '请求失败',
- icon: 'none'
- });
- return Promise.reject(data);
+ console.error('业务错误:', data);
+ throw new Error(data.msg || '请求失败');
}
}
return data;
}
// HTTP错误处理
+ console.error('HTTP错误:', response);
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
- return Promise.reject(response);
+ throw new Error('网络请求失败');
};
export default {
@@ -132,8 +132,9 @@ export default {
}
},
- // 防抖处理
- uni_request: debounce((options) => {
+ // 简化请求处理,去掉防抖避免问题
+ uni_request(options) {
+ console.log('发起请求:', options);
return new Promise((resolve, reject) => {
// 创建请求配置
const config = {
@@ -146,22 +147,27 @@ export default {
timeout: 10000 // 设置10秒超时
};
+ console.log('请求配置:', config);
+
// 应用请求拦截器
const interceptedConfig = requestInterceptor(config);
uni.showLoading({
title: '加载中...'
});
+
+ console.log('即将发起uni.request');
uni.request({
...interceptedConfig,
success: (res) => {
+ console.log('请求成功响应:', res);
try {
const response = responseInterceptor(res);
resolve(response);
} catch (error) {
console.error('请求处理失败:', error);
uni.showToast({
- title: error.msg || '请求失败',
+ title: error.message || '请求失败',
icon: 'none'
});
reject(error);
@@ -176,11 +182,12 @@ export default {
reject(error);
},
complete: () => {
+ console.log('请求完成');
uni.hideLoading();
}
});
});
- }, 100),
+ },
// 封装请求方法
post(url, data = {}) {
@@ -192,6 +199,7 @@ export default {
},
get(url, data = {}) {
+ console.log('调用get方法:', { url, data });
return this.uni_request({
url,
data,
diff --git a/uniapp/common/config.js b/uniapp/common/config.js
index 1fd4154f..476a0ab1 100644
--- a/uniapp/common/config.js
+++ b/uniapp/common/config.js
@@ -3,12 +3,12 @@
// const img_domian = 'http://146.56.228.75:20025/'
//本地测试地址
-// const Api_url='http://zhjwxt.test/api'
-// const img_domian = 'http://zhjwxt.test/'
+const Api_url='http://localhost:20080/api'
+const img_domian = 'http://localhost:20080/'
-
-const Api_url='https://api.hnhbty.cn/api'
-const img_domian = 'https://api.hnhbty.cn/'
+// 生产环境地址
+// const Api_url='https://api.hnhbty.cn/api'
+// const img_domian = 'https://api.hnhbty.cn/'
// const Api_url='http://146.56.228.75:20024/api'
// const img_domian = 'http://146.56.228.75:20024/'
diff --git a/uniapp/components/custom-picker/single-picker.vue b/uniapp/components/custom-picker/single-picker.vue
new file mode 100644
index 00000000..45c35853
--- /dev/null
+++ b/uniapp/components/custom-picker/single-picker.vue
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uniapp/pages.json b/uniapp/pages.json
index 275e8572..47d5fc32 100644
--- a/uniapp/pages.json
+++ b/uniapp/pages.json
@@ -1,5 +1,6 @@
{
- "pages": [{
+ "pages": [
+ {
"path": "pages/student/login/login",
"style": {
"navigationBarTitleText": "",
diff --git a/uniapp/pages/coach/schedule/add_schedule.vue b/uniapp/pages/coach/schedule/add_schedule.vue
index d47aacae..72cddb15 100644
--- a/uniapp/pages/coach/schedule/add_schedule.vue
+++ b/uniapp/pages/coach/schedule/add_schedule.vue
@@ -247,11 +247,45 @@ export default {
venues: this.venueOptions.length
});
+ // 检查是否有必要的数据
+ if (this.courseOptions.length === 0) {
+ uni.showToast({
+ title: '暂无可用课程',
+ icon: 'none'
+ });
+ }
+
+ if (this.coachOptions.length === 0) {
+ uni.showToast({
+ title: '暂无可用教练',
+ icon: 'none'
+ });
+ }
+
+ if (this.venueOptions.length === 0) {
+ uni.showToast({
+ title: '暂无可用场地',
+ icon: 'none'
+ });
+ }
+
} catch (error) {
console.error('加载筛选选项失败:', error);
+
+ // 提供更详细的错误信息
+ let errorMsg = '加载数据失败';
+ if (error.response) {
+ errorMsg = `服务器错误: ${error.response.status}`;
+ } else if (error.request) {
+ errorMsg = '网络连接失败,请检查网络';
+ } else {
+ errorMsg = error.message || '未知错误';
+ }
+
uni.showToast({
- title: '加载筛选选项失败',
- icon: 'none'
+ title: errorMsg,
+ icon: 'none',
+ duration: 3000
});
} finally {
uni.hideLoading();
@@ -327,9 +361,18 @@ export default {
console.error('加载时间段失败:', error);
// 如果API失败,则使用默认时间段
this.generateTimeSlotOptions();
+
+ let errorMsg = '获取可用时间段失败,使用默认时间段';
+ if (error.response && error.response.status === 404) {
+ errorMsg = '该场地暂无可用时间段';
+ } else if (error.request) {
+ errorMsg = '网络连接失败,使用默认时间段';
+ }
+
uni.showToast({
- title: '获取可用时间段失败,使用默认时间段',
- icon: 'none'
+ title: errorMsg,
+ icon: 'none',
+ duration: 2000
});
}
},
@@ -500,9 +543,29 @@ export default {
}
} catch (error) {
console.error('创建课程安排失败:', error);
+
+ // 提供更详细的错误信息
+ let errorMsg = '创建失败,请重试';
+ if (error.response) {
+ if (error.response.status === 401) {
+ errorMsg = '登录已过期,请重新登录';
+ } else if (error.response.status === 403) {
+ errorMsg = '没有权限执行此操作';
+ } else if (error.response.status >= 500) {
+ errorMsg = '服务器内部错误,请联系管理员';
+ } else {
+ errorMsg = `请求失败: ${error.response.status}`;
+ }
+ } else if (error.request) {
+ errorMsg = '网络连接失败,请检查网络后重试';
+ } else {
+ errorMsg = error.message || '创建失败,请重试';
+ }
+
uni.showToast({
- title: '创建失败,请重试',
- icon: 'none'
+ title: errorMsg,
+ icon: 'none',
+ duration: 3000
});
} finally {
this.submitting = false;
diff --git a/uniapp/pages/coach/student/student_list.vue b/uniapp/pages/coach/student/student_list.vue
index 14987ff4..9f3f6cb4 100644
--- a/uniapp/pages/coach/student/student_list.vue
+++ b/uniapp/pages/coach/student/student_list.vue
@@ -37,62 +37,68 @@
-
+
学员搜索
+
+
+
-
+
-
+
-
+
-
+
- {{ searchForm.courseIndex >= 0 ? courseList[searchForm.courseIndex].name : '请选择' }}
-
+ {{ selectedCourseName || '请选择' }}
+
-
-
+
+ >
- {{ searchForm.classIndex >= 0 ? classList[searchForm.classIndex].name : '请选择' }}
-
+ {{ selectedClassName || '请选择' }}
+
-
-
+
+ >
- 搜索
+ 搜索
@@ -103,9 +109,11 @@