From 60fff21f33b310eaf03c345276ca0ca9afb61f03 Mon Sep 17 00:00:00 2001 From: wangzeyan <258785420@qq.com> Date: Mon, 16 Jun 2025 19:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apiRoute.js | 779 +++++-------------- common/axios.js | 253 +++++-- components/AQ/AQTabber.vue | 280 ++++--- pages.json | 1190 +++++++++++++++--------------- pages/market/clue/edit_clues.vue | 152 +--- pages/market/home/index.vue | 375 ++++++++++ pages/market/index/index.vue | 614 ++++++--------- pages/student/login/login.vue | 671 ++++++++--------- 8 files changed, 2060 insertions(+), 2254 deletions(-) create mode 100644 pages/market/home/index.vue diff --git a/api/apiRoute.js b/api/apiRoute.js index 7841748..31077ea 100644 --- a/api/apiRoute.js +++ b/api/apiRoute.js @@ -2,702 +2,321 @@ import http from '../common/axios.js' //全部api接口 export default { - // getDemo(data = {}) { - // let url = '/member/member_edit' - // return http.get(url, data).then(res => { - // return res; - // }) - // }, - // postDemo(data = {}) { - // let url = '/member/member_edit' - // return http.post(url, data).then(res => { - // return res; - // }) - // }, - - //↓↓↓↓↓↓↓↓↓↓↓↓-----公共接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //教师/销售端登陆 - personnelLogin(data = {}) { - let url = '/personnelLogin' - return http.post(url, data).then(res => { - return res; - }) + async personnelLogin(data = {}) { + const response = await http.post('/personnelLogin', data); + console.log('登录响应:', response); + return response; }, //教师/销售端详情 - getPersonnelInfo(data = {}) { - let url = '/personnel/info' - return http.get(url, data).then(res => { - return res; - }) + async getPersonnelInfo(data = {}) { + return await http.get('/personnel/info', data); }, //教师/销售端详情 - editPersonnelInfo(data = {}) { - let url = '/personnel/edit' - return http.post(url, data).then(res => { - return res; - }) + async editPersonnelInfo(data = {}) { + return await http.post('/personnel/edit', data); }, //教师/销售端请假/打卡/签退-编辑 - common_attendanceEdit(data = {}) { - let url = '/attendance/edit' - return http.post(url, data).then(res => { - return res; - }) + async common_attendanceEdit(data = {}) { + return await http.post('/attendance/edit', data); }, //教师/销售端请假/打卡/签退-列表 - common_attendanceIndex(data = {}) { - let url = '/attendance/index' - return http.post(url, data).then(res => { - return res; - }) + async common_attendanceIndex(data = {}) { + return await http.post('/attendance/index', data); }, //获取字典数据 - common_Dictionary(data = {}) { - let url = '/common/getDictionary' - return http.get(url, data).then(res => { - return res; - }) + async common_Dictionary(data = {}) { + return await http.get('/common/getDictionary', data); }, //公共端-获取全部员工列表 - common_getPersonnelAll(data = {}) { - let url = '/personnel/getPersonnelAll' - return http.get(url, data).then(res => { - return res; - }) + async common_getPersonnelAll(data = {}) { + return await http.get('/personnel/getPersonnelAll', data); }, //公共端-获取全部课程列表 - common_getCourseAll(data = {}) { - let url = '/common/getCourseAll' - return http.get(url, data).then(res => { - return res; - }) + async common_getCourseAll(data = {}) { + return await http.get('/common/getCourseAll', data); }, //公共端-获取全部班级列表 - common_getClassAll(data = {}) { - let url = '/common/getClassAll' - return http.get(url, data).then(res => { - return res; - }) + async common_getClassAll(data = {}) { + return await http.get('/common/getClassAll', data); }, //公共端-教师/销售端验证旧密码是否正确 - common_personnelCheckOldPwd(data = {}) { - let url = '/personnel/checkOldPwd' - return http.post(url, data).then(res => { - return res; - }) + async common_personnelCheckOldPwd(data = {}) { + return await http.post('/personnel/checkOldPwd', data); }, - //公共端-教师/销售端验证旧密码是否正确 - common_personnelEdidPassword(data = {}) { - let url = '/personnel/edidPassword' - return http.post(url, data).then(res => { - return res; - }) + async common_personnelEdidPassword(data = {}) { + return await http.post('/personnel/edidPassword', data); }, //公共端-教师/销售端验证旧密码是否正确 - common_getPersonnelCampus(data = {}) { - let url = '/campus/getPersonnelCampus' - return http.get(url, data).then(res => { - return res; - }) + async common_getPersonnelCampus(data = {}) { + return await http.get('/campus/getPersonnelCampus', data); }, //公共端-忘记密码-通过短信验证码进行密码重置(学生/员工通用) - common_forgetPassword(data = {}) { - let url = '/common/forgetPassword' - return http.post(url, data).then(res => { - return res; - }) + async common_forgetPassword(data = {}) { + return await http.post('/common/forgetPassword', data); }, //公共端-获取配置项 - common_getConfig(data = {}) { - let url = '/common/getConfig' - return http.get(url, data).then(res => { - return res; - }) + async common_getConfig(data = {}) { + return await http.get('/common/getConfig', data); }, - //公共端-获取配置项 - common_getMiniWxOpenId(data = {}) { - let url = '/common/getMiniWxOpenId' - return http.post(url, data).then(res => { - return res; - }) + async common_getMiniWxOpenId(data = {}) { + return await http.post('/common/getMiniWxOpenId', data); }, - - - - - - - - - - - - - - - //↑↑↑↑↑↑↑↑↑↑↑↑-----公共接口相关-----↑↑↑↑↑↑↑↑↑↑↑↑ - - - - - - - - - - - - - - //↓↓↓↓↓↓↓↓↓↓↓↓-----教练接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ - - - - - - - //获取我的页面统计个数 - getStatisticsInfo(data = {}) { - let url = '/class/Statistics/info' - return http.get(url, data).then(res => { - return res; - }) - }, - //添加作业 - jlPublishJob(data = {}) { - let url = '/class/jlPublishJob/add' - return http.get(url, data).then(res => { - return res; - }) - }, - //添加作业-学员列表 - jlGetStudentList(data = {}) { - let url = '/class/jlGetStudentList/list' - return http.get(url, data).then(res => { - return res; - }) - }, - //添加作业-获取课程列表 - jlGetCoursesList(data = {}) { - let url = '/class/jlGetCoursesList/list' - return http.get(url, data).then(res => { - return res; - }) - }, - //添加作业-获取班级列表 - jlGetClassesList(data = {}) { - let url = '/class/jlGetClasses/list' - return http.get(url, data).then(res => { - return res; - }) - }, - //体测报告-详情 - physicalTestInfo(data = {}) { - let url = '/class/physicalTest/info' - return http.get(url, data).then(res => { - return res; - }) - }, - //体测报告-列表 - physicalTest(data = {}) { - let url = '/class/physicalTest' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取学员详情 - jlStudentsInfo(data = {}) { - let url = '/class/jlStudentsInfo' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取添加学员列表 - addStudentList(data = {}) { - let url = '/course/addStudentList' - return http.get(url, data).then(res => { - return res; - }) - }, - addStudent(data = {}) { - let url = '/course/addStudent' - return http.post(url, data).then(res => { - return res; - }) - }, - delStudentCourse(data = {}) { - let url = '/course/delStudentCourse' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取班级列表 - jlClassList(data = {}) { - let url = '/class/jlClassList' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取班级详情 - jlClassInfo(data = {}) { - let url = '/class/jlClassInfo' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取课程列表 - courseList(data = {}) { - let url = '/course/courseList' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取班级课程列表 - classCourseList(data = {}) { - let url = '/course/classCourseList' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取课程详情 - courseInfo(data = {}) { - let url = '/course/courseInfo' - return http.get(url, data).then(res => { - return res; - }) - }, - //教研管理文章列表 - teachingResearchList(data = {}) { - let url = '/teachingResearch/list' - return http.get(url, data).then(res => { - return res; - }) - }, - //教研管理文章详情 - teachingResearchInfo(id) { - let url = '/teachingResearch/info/' + id - return http.get(url).then(res => { - return res; - }) - }, - //获取能看的教研管理类型 - teachingResearchLookType(data = {}) { - let url = '/teachingResearch/lookType' - return http.get(url, data).then(res => { - return res; - }) - }, - //获取试卷 - getTeachingTestPaper(data = {}) { - let url = '/teachingResearch/teachingTestPaper' - return http.get(url, data).then(res => { - return res; - }) - }, - //提交试卷 - submitTestPaper(data = {}) { - let url = '/teachingResearch/submitTestPaper' - return http.get(url, data).then(res => { - return res; - }) - }, - //↑↑↑↑↑↑↑↑↑↑↑↑-----教练接口相关-----↑↑↑↑↑↑↑↑↑↑↑↑ - - - - - - - - - - - - - - + //获取我的页面统计个数 + async getStatisticsInfo(data = {}) { + return await http.get('/class/Statistics/info', data); + }, + //添加作业 + 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); + }, + //添加作业-获取班级列表 + 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 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); + }, //↓↓↓↓↓↓↓↓↓↓↓↓-----销售接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //修改销售端个人资料 - editPersonnel(data = {}) { - let url = '/personnel/info' - return http.get(url, data).then(res => { - return res; - }) + async editPersonnel(data = {}) { + return await http.get('/personnel/info', data); }, //销售端-客户资源-添加 - xs_addCustomerResources(data = {}) { - let url = '/customerResources/add' - return http.post(url, data).then(res => { - return res; - }) + async xs_addCustomerResources(data = {}) { + return await http.post('/customerResources/add', data); }, //销售端-客户资源-编辑 - xs_editCustomerResources(data = {}) { - let url = '/customerResources/edit' - return http.post(url, data).then(res => { - return res; - }) + async xs_editCustomerResources(data = {}) { + return await http.post('/customerResources/edit', data); }, //销售端-查询客户资源全部列表 - xs_getAllCustomerResources(data = {}) { - let url = '/customerResources/getAll' - return http.get(url, data).then(res => { - return res; - }) + async xs_getAllCustomerResources(data = {}) { + return await http.get('/customerResources/getAll', data); }, //销售端-客户资源-获取修改日志列表 - xs_customerResourcesGetEditLogList(data = {}) { - let url = '/customerResources/getEditLogList' - return http.get(url, data).then(res => { - return res; - }) + async xs_customerResourcesGetEditLogList(data = {}) { + return await http.get('/customerResources/getEditLogList', data); }, //销售端-资源共享-列表 - xs_resourceSharingIndex(data = {}) { - let url = '/resourceSharing/index' - return http.get(url, data).then(res => { - return res; - }) + async xs_resourceSharingIndex(data = {}) { + return await http.get('/resourceSharing/index', data); }, //销售端-资源共享-分配员工 - xs_resourceSharingAssign(data = {}) { - let url = '/resourceSharing/assign' - return http.post(url, data).then(res => { - return res; - }) + async xs_resourceSharingAssign(data = {}) { + return await http.post('/resourceSharing/assign', data); }, //销售端-资源共享-详情(客户资源详情) - xs_resourceSharingInfo(data = {}) { - let url = '/resourceSharing/info' - return http.get(url, data).then(res => { - return res; - }) + async xs_resourceSharingInfo(data = {}) { + return await http.get('/resourceSharing/info', data); }, - //销售端-沟通记录-添加 - xs_communicationRecordsAdd(data = {}) { - let url = '/communicationRecords/add' - return http.post(url, data).then(res => { - return res; - }) + async xs_communicationRecordsAdd(data = {}) { + return await http.post('/communicationRecords/add', data); }, - //销售端-获取好友关系绑定详情 - xs_chatGetChatFriendsInfo(data = {}) { - let url = '/chat/getChatFriendsInfo' - return http.get(url, data).then(res => { - return res; - }) + async xs_chatGetChatFriendsInfo(data = {}) { + return await http.get('/chat/getChatFriendsInfo', data); }, //销售端-获取聊天消息列表 - xs_chatGetChatMessagesList(data = {}) { - let url = '/chat/getChatMessagesList' - return http.get(url, data).then(res => { - return res; - }) + async xs_chatGetChatMessagesList(data = {}) { + return await http.get('/chat/getChatMessagesList', data); }, //销售端-发送聊天消息 - xs_chatSendChatMessages(data = {}) { - let url = '/chat/sendChatMessages' - return http.post(url, data).then(res => { - return res; - }) + async xs_chatSendChatMessages(data = {}) { + return await http.post('/chat/sendChatMessages', data); }, //销售端-好友关系列表 - xs_chatGetChatFriendsList(data = {}) { - let url = '/chat/getChatFriendsList' - return http.get(url, data).then(res => { - return res; - }) + async xs_chatGetChatFriendsList(data = {}) { + return await http.get('/chat/getChatFriendsList', data); }, - //员工端统计(销售)-获取销售首页数据统计 - xs_statisticsMarketHome(data = {}) { - let url = '/statistics/marketHome' - return http.get(url, data).then(res => { - return res; - }) + async xs_statisticsMarketHome(data = {}) { + return await http.get('/statistics/marketHome', data); }, - //员工端统计(销售)-获取销售数据页统计 - xs_statisticsMarketData(data = {}) { - let url = '/statistics/marketData' - return http.get(url, data).then(res => { - return res; - }) + async xs_statisticsMarketData(data = {}) { + return await http.get('/statistics/marketData', data); }, - //员工端(销售)-订单管理-列表 - xs_orderTableList(data = {}) { - let url = '/orderTable' - return http.get(url, data).then(res => { - return res; - }) + async xs_orderTableList(data = {}) { + return await http.get('/orderTable', data); }, - //员工端(销售)-订单管理-详情 - xs_orderTableInfo(data = {}) { - let url = '/orderTable/info' - return http.get(url, data).then(res => { - return res; - }) + async xs_orderTableInfo(data = {}) { + return await http.get('/orderTable/info', data); }, - //员工端(销售)-订单管理-添加 - xs_orderTableAdd(data = {}) { - let url = '/orderTable/add' - return http.post(url, data).then(res => { - return res; - }) + async xs_orderTableAdd(data = {}) { + return await http.post('/orderTable/add', data); }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //↑↑↑↑↑↑↑↑↑↑↑↑-----销售接口相关-----↑↑↑↑↑↑↑↑↑↑↑ - - - - - - - - - - - - - - //↓↓↓↓↓↓↓↓↓↓↓↓-----学生接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓ //学生登陆接口 - xy_login(data = {}) { - let url = '/customerResourcesAuth/login' - return http.post(url, data).then(res => { - return res; - }) + async xy_login(data = {}) { + const response = await http.post('/customerResourcesAuth/login', data); + console.log('学生登录响应:', response); + return response; }, //学生详情 - xy_memberInfo(data = {}) { - let url = '/customerResourcesAuth/info' - return http.get(url, data).then(res => { - return res; - }) + async xy_memberInfo(data = {}) { + return await http.get('/customerResourcesAuth/info', data); }, //学生详情-修改 - xy_memberEdit(data = {}) { - let url = '/customerResourcesAuth/edit' - return http.post(url, data).then(res => { - return res; - }) + async xy_memberEdit(data = {}) { + return await http.post('/customerResourcesAuth/edit', data); }, - //学生-意见反馈-添加 - xy_userFeedbackAdd(data = {}) { - let url = '/userFeedback/add' - return http.post(url, data).then(res => { - return res; - }) + async xy_userFeedbackAdd(data = {}) { + return await http.post('/userFeedback/add', data); }, - //学生端-获取好友关系绑定详情 - xy_chatGetChatFriendsInfo(data = {}) { - let url = '/xy/chat/getChatFriendsInfo' - return http.get(url, data).then(res => { - return res; - }) + async xy_chatGetChatFriendsInfo(data = {}) { + return await http.get('/xy/chat/getChatFriendsInfo', data); }, //学生端-获取聊天消息列表 - xy_chatGetChatMessagesList(data = {}) { - let url = '/xy/chat/getChatMessagesList' - return http.get(url, data).then(res => { - return res; - }) + async xy_chatGetChatMessagesList(data = {}) { + return await http.get('/xy/chat/getChatMessagesList', data); }, //学生端-发送聊天消息 - xy_chatSendChatMessages(data = {}) { - let url = '/xy/chat/sendChatMessages' - return http.post(url, data).then(res => { - return res; - }) + async xy_chatSendChatMessages(data = {}) { + return await http.post('/xy/chat/sendChatMessages', data); }, //学生端-好友关系列表 - xy_chatGetChatFriendsList(data = {}) { - let url = '/xy/chat/getChatFriendsList' - return http.get(url, data).then(res => { - return res; - }) + async xy_chatGetChatFriendsList(data = {}) { + return await http.get('/xy/chat/getChatFriendsList', data); }, - //学生端-体测报告-列表 - xy_physicalTest(data = {}) { - let url = '/xy/physicalTest' - return http.get(url, data).then(res => { - return res; - }) + async xy_physicalTest(data = {}) { + return await http.get('/xy/physicalTest', data); }, - //学生端-体测报告-详情 - xy_physicalTestInfo(data = {}) { - let url = '/xy/physicalTest/info' - return http.get(url, data).then(res => { - return res; - }) + async xy_physicalTestInfo(data = {}) { + return await http.get('/xy/physicalTest/info', data); }, - //学生端-学生课程安排-列表 - xy_personCourseSchedule(data = {}) { - let url = '/xy/personCourseSchedule' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseSchedule(data = {}) { + return await http.get('/xy/personCourseSchedule', data); }, - //学生端-学生课程安排-详情 - xy_personCourseScheduleInfo(data = {}) { - let url = '/xy/personCourseSchedule/info' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleInfo(data = {}) { + return await http.get('/xy/personCourseSchedule/info', data); }, - //学生端-学生课程安排-修改请假状态 - xy_personCourseScheduleEditStatus(data = {}) { - let url = '/xy/personCourseSchedule/editStatus' - return http.post(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleEditStatus(data = {}) { + return await http.post('/xy/personCourseSchedule/editStatus', data); }, - //学生端-学生课程安排-获取排课日历 - xy_personCourseScheduleGetCalendar(data = {}) { - let url = '/xy/personCourseSchedule/getCalendar' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleGetCalendar(data = {}) { + return await http.get('/xy/personCourseSchedule/getCalendar', data); }, - //学生端-学生课程安排-获取学生排课的全部场地列表 - xy_personCourseScheduleGetVenueListAll(data = {}) { - let url = '/xy/personCourseSchedule/getVenueListAll' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleGetVenueListAll(data = {}) { + return await http.get('/xy/personCourseSchedule/getVenueListAll', data); }, - //学生端-学生课程安排-获取学生排课的全部场地列表 - xy_personCourseScheduleGetMyCoach(data = {}) { - let url = '/xy/personCourseSchedule/getMyCoach' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleGetMyCoach(data = {}) { + return await http.get('/xy/personCourseSchedule/getMyCoach', data); }, - //学生端-学生课程安排-获取学生课程消耗记录列表 - xy_personCourseScheduleGetStudentCourseUsageList(data = {}) { - let url = '/xy/personCourseSchedule/getStudentCourseUsageList' - return http.get(url, data).then(res => { - return res; - }) + async xy_personCourseScheduleGetStudentCourseUsageList(data = {}) { + return await http.get('/xy/personCourseSchedule/getStudentCourseUsageList', data); }, - //学生端-获取作业列表 - xy_assignment(data = {}) { - let url = '/xy/assignment' - return http.get(url, data).then(res => { - return res; - }) + async xy_assignment(data = {}) { + return await http.get('/xy/assignment', data); }, //学生端-获取作业详情 - xy_assignmentsInfo(data = {}) { - let url = '/xy/assignment/info' - return http.get(url, data).then(res => { - return res; - }) + async xy_assignmentsInfo(data = {}) { + return await http.get('/xy/assignment/info', data); }, - - - //学生端-提交作业 - xy_assignmentSubmitObj(data = {}) { - let url = '/xy/assignment/submitObj' - return http.get(url, data).then(res => { - return res; - }) + async xy_assignmentSubmitObj(data = {}) { + return await http.get('/xy/assignment/submitObj', data); }, - //学生端-订单管理-列表 - xy_orderTableList(data = {}) { - let url = '/xy/orderTable' - return http.get(url, data).then(res => { - return res; - }) + async xy_orderTableList(data = {}) { + return await http.get('/xy/orderTable', data); }, //学生端-订单管理-详情 - xy_orderTableInfo(data = {}) { - let url = '/xy/orderTable/info' - return http.get(url, data).then(res => { - return res; - }) + async xy_orderTableInfo(data = {}) { + return await http.get('/xy/orderTable/info', data); }, - //学生端-订单管理-添加 - xy_orderTableAdd(data = {}) { - let url = '/xy/orderTable/add' - return http.post(url, data).then(res => { - return res; - }) - }, - - - - - - - - - - - - - - - - - - //↑↑↑↑↑↑↑↑↑↑↑↑-----学生接口相关-----↑↑↑↑↑↑↑↑↑↑↑↑ - - - + async xy_orderTableAdd(data = {}) { + return await http.post('/xy/orderTable/add', data); + } } \ No newline at end of file diff --git a/common/axios.js b/common/axios.js index 7cf0f5e..b28d7be 100644 --- a/common/axios.js +++ b/common/axios.js @@ -4,86 +4,199 @@ import { // import {Token} from './token.js' // var token = new Token(); +// 防抖函数 +const debounce = (fn, delay = 1000) => { + let timer = null; + return function (...args) { + if (timer) clearTimeout(timer); + timer = setTimeout(() => { + fn.apply(this, args); + }, delay); + } +} + +// 请求拦截器 +const requestInterceptor = (config) => { + // 在这里可以统一处理请求头、token等 + const token = uni.getStorageSync("token"); + if (token) { + config.header = { + ...config.header, + 'token': token + } + } + return config; +} + +// 响应拦截器 +const responseInterceptor = (response) => { + const { statusCode, data } = response; + console.log('响应数据:', response); + + // 处理HTTP状态码 + if (statusCode >= 200 && statusCode < 300) { + // 处理业务状态码 + if (data && data.code) { + if (data.code === 1) { // 成功状态码为1 + // 登录成功,保存token + if (data.data && data.data.token) { + uni.setStorageSync("token", data.data.token); + // 保存用户类型 + if (data.data.user_type) { + uni.setStorageSync("userType", data.data.user_type); + } + // 保存过期时间 + if (data.data.expires_time) { + uni.setStorageSync("expires_time", data.data.expires_time); + } + } + return data; + } else if (data.code === 401) { + // 未授权或token过期 + uni.removeStorageSync("token"); + uni.removeStorageSync("userType"); + uni.removeStorageSync("expires_time"); + uni.showToast({ + title: data.msg || '登录已过期,请重新登录', + icon: 'none' + }); + setTimeout(() => { + uni.reLaunch({ + url: '/pages/student/login/login?code=401' + }); + }, 1500); + return Promise.reject(data); + } else { + // 其他业务错误 + uni.showToast({ + title: data.msg || '请求失败', + icon: 'none' + }); + return Promise.reject(data); + } + } + return data; + } + + // HTTP错误处理 + uni.showToast({ + title: '网络请求失败', + icon: 'none' + }); + return Promise.reject(response); +}; + export default { - async post(url, param, yanci = false) { - // wx.showLoading(); - - // setTimeout(() => { - // wx.hideLoading(); - // }, 3000) - const res = await this.uni_request(url, param, 'post') - - return res; - }, - async get(url, param, yanci = false) { - // wx.showLoading(); - // setTimeout(() => { - // wx.hideLoading(); - // }, 3000) - const res = await this.uni_request(url, param, 'get') - return res; + // 存储正在进行的请求 + pendingRequests: new Map(), + + // 生成请求的唯一key + generateRequestKey(config) { + const { url, method, data } = config; + return [url, method, JSON.stringify(data)].join('&'); }, - async put(url, param) { - // wx.showLoading(); - // setTimeout(() => { - // wx.hideLoading(); - // }, 3000) - const res = await this.uni_request(url, param, 'put') - return res; + + // 取消重复请求 + cancelRequest(config) { + const requestKey = this.generateRequestKey(config); + if (this.pendingRequests.has(requestKey)) { + const controller = this.pendingRequests.get(requestKey); + controller.abort(); + this.pendingRequests.delete(requestKey); + } }, - uni_request(url, param, method, again_quest = false) { - const that = this - uni.showLoading({ - title:'加载中...' - }) - return new Promise((cback, reject) => { - console.log('请求地址',Api_url + url) - uni.request({ - url: Api_url + url, - data: param, - method: method, + + // 防抖处理 + uni_request: debounce((options) => { + return new Promise((resolve, reject) => { + // 创建请求配置 + const config = { + url: Api_url + options.url, + data: options.data, + method: options.method || 'GET', header: { 'token': uni.getStorageSync("token") }, - }).then(data => { //data为一个数组,数组第一项为错误信息,第二项为返回数据 - var [error, res] = data; - uni.hideLoading() - var res_code = res.statusCode.toString(); - var res_codes = res.data.code.toString(); - - if (res_code.charAt(0) == 2) { - if (res_code == 200) { - if (res_codes == 401) { - uni.navigateTo({ - url: `/pages/student/login/login?res_codes=${res_codes}` - }) - }else{ - cback(res.data); - } - } else { - console.log('201', url) - uni.showToast({ - title: res.data.msg, - icon: 'none' - }) - } - } else { - if (res_codes == 401) { - uni.navigateTo({ - url: `/pages/student/login/login?res_codes=${res_codes}` - }) - } else { - console.log('400/500', url, error, res) + timeout: 10000 // 设置10秒超时 + }; + + // 应用请求拦截器 + const interceptedConfig = requestInterceptor(config); + + uni.showLoading({ + title: '加载中...' + }); + + console.log('请求配置:', interceptedConfig); + + uni.request({ + ...interceptedConfig, + success: (res) => { + try { + console.log('原始响应数据:', res); + const response = responseInterceptor(res); + console.log('处理后的响应数据:', response); + resolve(response); + } catch (error) { + console.error('请求处理失败:', error); uni.showToast({ - title: res.data.msg ? res.data.msg : '请求异常', + title: error.msg || '请求失败', icon: 'none' - }) + }); + reject(error); } + }, + fail: (error) => { + console.error('请求失败:', error); + uni.showToast({ + title: '网络请求失败', + icon: 'none' + }); + reject(error); + }, + complete: () => { + uni.hideLoading(); } - }).catch(err => { - console.log('catch:', err); - }) - }) + }); + }); + }, 300), + + // 封装请求方法 + post(url, data = {}) { + return this.uni_request({ + url, + data, + method: 'POST' + }); + }, + + get(url, data = {}) { + return this.uni_request({ + url, + data, + method: 'GET' + }); }, + put(url, data = {}) { + return this.uni_request({ + url, + data, + method: 'PUT' + }); + }, + + // 统一的错误处理 + handleError(error) { + if (error.statusCode === 401) { + uni.navigateTo({ + url: `/pages/student/login/login?res_codes=${error.data.code}` + }) + } else { + uni.showToast({ + title: error.data?.msg || '请求异常', + icon: 'none' + }) + } + } } diff --git a/components/AQ/AQTabber.vue b/components/AQ/AQTabber.vue index 2c29176..2886369 100644 --- a/components/AQ/AQTabber.vue +++ b/components/AQ/AQTabber.vue @@ -2,24 +2,15 @@