mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-21 00:36:44 +08:00
2022年5月29日从svn移到git
This commit is contained in:
208
src/api/boe/boeApiAjax.js
Normal file
208
src/api/boe/boeApiAjax.js
Normal file
@@ -0,0 +1,208 @@
|
||||
import axios from 'axios'
|
||||
import { getToken } from '@/utils/token'
|
||||
import qs from 'qs'
|
||||
import { Notification, MessageBox, Message } from 'element-ui'
|
||||
import store from '@/store'
|
||||
import errorCode from '@/utils/errorCode'
|
||||
|
||||
/**
|
||||
*request请求 axios.request(config)
|
||||
*requestJson请求 axios.request(config)
|
||||
*get请求 axios.get(url[, config])
|
||||
*post请求 axios.post(url[, data[, config]])
|
||||
*postJson请求 axios.post(url[, data[, config]])
|
||||
*put请求 axios.put(url[, data[, config]])
|
||||
*putJson请求 axios.put(url[, data[, config]])
|
||||
*patch请求 axios.patch(url[, data[, config]])
|
||||
*patchJson请求 axios.patch(url[, data[, config]])
|
||||
*delete请求 axios.delete(url[, config])
|
||||
*/
|
||||
|
||||
const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
||||
const TokenName='token';
|
||||
|
||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||
//只是用于发送json对象数据时使用post,put,patch
|
||||
const jsonRequest=axios.create({
|
||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
||||
//超时
|
||||
timeout: 10000,
|
||||
});
|
||||
//发送json对象的拦截器
|
||||
jsonRequest.interceptors.request.use(config => {
|
||||
//是否需要设置 token
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
if (getToken() && !isToken) {
|
||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
return config
|
||||
}, error => {
|
||||
console.log(error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
|
||||
// 响应拦截器
|
||||
jsonRequest.interceptors.response.use(res => {
|
||||
|
||||
const code1 = res.data.status || 200;
|
||||
const code=parseInt(code1);
|
||||
if(code===200){
|
||||
return res.data
|
||||
}else{
|
||||
if(code == 6001){ //对方是字符串,所以这里不要使用三个等号
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.href = ReLoginUrl;
|
||||
})
|
||||
}else if(code===403){
|
||||
var msg='当前操作没有权限';
|
||||
Message({message: msg, type: 'error'});
|
||||
return Promise.reject(new Error(msg))
|
||||
//return res.data;
|
||||
}else{
|
||||
//Message({message: res.data.message, type: 'error'});
|
||||
//console.log('err:' + res.data.error);
|
||||
//return Promise.reject(new Error(res.data.message))
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error)
|
||||
let { message } = error;
|
||||
if (message == "Network Error") {
|
||||
message = "后端接口连接异常";
|
||||
}
|
||||
else if (message.includes("timeout")) {
|
||||
message = "系统接口请求超时";
|
||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||
}
|
||||
else if (message.includes("Request failed with status code")) {
|
||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||
}
|
||||
Message({
|
||||
message: message,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
//用于普通的发送请求
|
||||
const formRequest=axios.create({
|
||||
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
||||
//超时
|
||||
timeout: 10000,
|
||||
})
|
||||
//发送json对象的拦截器
|
||||
formRequest.interceptors.request.use(config => {
|
||||
//是否需要设置 token
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
if (getToken() && !isToken) {
|
||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
return config
|
||||
}, error => {
|
||||
console.log(error)
|
||||
Promise.reject(error)
|
||||
});
|
||||
formRequest.interceptors.response.use(res => {
|
||||
const code = res.data.status || 200;
|
||||
if(code===200){
|
||||
return res.data
|
||||
}else{
|
||||
if(code == 6001){ //对方是字符串,所以这里不要使用三个等号
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.href = ReLoginUrl;
|
||||
})
|
||||
}else if(code===403){
|
||||
var msg='当前操作没有权限';
|
||||
Message({message: msg, type: 'error'});
|
||||
return Promise.reject(new Error(msg))
|
||||
}else{
|
||||
//Message({message: res.data.message, type: 'error'});
|
||||
//console.log('err' + res.data.error);
|
||||
//return Promise.reject(new Error(res.data.message))
|
||||
return res.data;//返回给用户做业务处理
|
||||
}
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error)
|
||||
let { message } = error;
|
||||
if (message == "Network Error") {
|
||||
message = "后端接口连接异常";
|
||||
}
|
||||
else if (message.includes("timeout")) {
|
||||
message = "系统接口请求超时";
|
||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||
}
|
||||
else if (message.includes("Request failed with status code")) {
|
||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||
}
|
||||
Message({
|
||||
message: message,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
//request请求
|
||||
const request=function(cfg){
|
||||
if(cfg.data){
|
||||
cfg.data=qs.stringify(cfg.data);
|
||||
}
|
||||
};
|
||||
//requestJson请求
|
||||
const requestJson=jsonRequest.request;
|
||||
//get请求
|
||||
const get=formRequest.request;
|
||||
//post请求
|
||||
const post=function(url,data,config){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest.post(url,data,config);
|
||||
}
|
||||
//postJson请求
|
||||
const postJson=jsonRequest.post;
|
||||
//put请求
|
||||
const put=function(url,data,config){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest.put(url,data,config);
|
||||
}
|
||||
//putJson请求
|
||||
const putJson=jsonRequest.put;
|
||||
//patch请求
|
||||
const patch=function(url,data,config){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest.patch(url,data,config);
|
||||
}
|
||||
//patchJson请求
|
||||
const patchJson=jsonRequest.patch;
|
||||
//delete请求
|
||||
const del=formRequest.delete;
|
||||
|
||||
|
||||
export default {
|
||||
request,
|
||||
requestJson,
|
||||
get,
|
||||
post,
|
||||
postJson,
|
||||
put,
|
||||
putJson,
|
||||
patch,
|
||||
patchJson,
|
||||
del
|
||||
}
|
||||
62
src/api/boe/course.js
Normal file
62
src/api/boe/course.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**控制台相关的控制数据*/
|
||||
import ajax from '@/api/boe/boeApiAjax.js'
|
||||
|
||||
/**
|
||||
* 我的学习列表
|
||||
* @param {
|
||||
* type:'online-course'
|
||||
* page:1,
|
||||
* size:10
|
||||
* } data 查询条件
|
||||
*/
|
||||
const myLearning = function(data) {
|
||||
return ajax.postJson('/b1/system/user/my-learning',data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 必修任务列表
|
||||
* @param {
|
||||
* cmtask_status:状态 0:未开始,1进行中,2已完成,4已过期(不需要此项)
|
||||
* cmtask_name:名称
|
||||
* page:1,
|
||||
* size:10
|
||||
* } data 查询条件
|
||||
*/
|
||||
const cmtaskList = function(data) {
|
||||
return ajax.postJson('/b1/system/cmtask/cmtask-list',data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测评报告
|
||||
* @param {Object} data
|
||||
* {
|
||||
* keyword: 查询关键字
|
||||
* page:1,
|
||||
* size:10
|
||||
}
|
||||
*/
|
||||
const reportList = function(data) {
|
||||
return ajax.postJson('/b1/system/quiz/report-list',data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 课程库的列表查询
|
||||
* @param {Object} data
|
||||
* {
|
||||
* keyword: 关键词
|
||||
type: online-course 在线课,face-course面授班,project 学习项目,camp-course 学习班(训练班)
|
||||
* page:1,
|
||||
* size:10
|
||||
}
|
||||
*/
|
||||
const courseList = function(data) {
|
||||
return ajax.postJson('/b1/system/search/list',data);
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
myLearning,
|
||||
cmtaskList,
|
||||
reportList,
|
||||
courseList
|
||||
}
|
||||
24
src/api/boe/login.js
Normal file
24
src/api/boe/login.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**控制台相关的控制数据*/
|
||||
import ajax from '@/api/boe/boeApiAjax.js'
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
const logout = function() {
|
||||
return ajax.post('/b1/system/user/logout',{});
|
||||
}
|
||||
|
||||
/**修改密码
|
||||
* oldPassword:'',
|
||||
* newPassword:'',
|
||||
* confirmPassword:''
|
||||
*/
|
||||
const modifyPassword = function(data) {
|
||||
return ajax.postJson('/b1/system/user/update-password',data);
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
logout,
|
||||
modifyPassword
|
||||
}
|
||||
73
src/api/boe/teacher.js
Normal file
73
src/api/boe/teacher.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/**控制台相关的控制数据*/
|
||||
import ajax from '@/api/boe/boeApiAjax.js'
|
||||
/**
|
||||
* 添加编辑接口
|
||||
* @param {
|
||||
{
|
||||
"teacher_user_id":"",// 教师对应的用户的id
|
||||
"teacher_id":"", // 教师id ,有则编辑,没有则新建教师
|
||||
"teacher_type":"", // 教师类型:0:内部讲师;1:外聘讲师;2:助教
|
||||
"teacher_name":"", // 教师名称
|
||||
"teacher_thumb_url":"", // 头像地址
|
||||
"description":"", // 介绍
|
||||
"teacher_system_id":"", // 体系id
|
||||
"teacher_system":"", // 体系名称
|
||||
"default_teaching_time":"", //初始授课时长
|
||||
"teacher_level_id":"", // 讲师级别id
|
||||
"teacher_level":"", // 讲师级别名称
|
||||
"is_certify":"", //是否认证 0:未认证 1:已认证)
|
||||
"certification":"", //认证资料图片地址
|
||||
"remark":"", // 备注
|
||||
"email":"", // 邮件(外部讲师填写)
|
||||
"mobile_no":"" // 手机号码(外部讲师填写)
|
||||
}
|
||||
* } data 查询条件
|
||||
*/
|
||||
const editTeacher = function(data) {
|
||||
return ajax.postJson('/b1/system/teacher/add-and-edit-teacher',data);
|
||||
}
|
||||
/**
|
||||
* 教师体系和级别接口
|
||||
* @param {
|
||||
longin_user_id
|
||||
* } data 查询条件
|
||||
*/
|
||||
const teacherSystem = function(id) {
|
||||
return ajax.get('/b1/system/teacher/teacher-system?longin_user_id='+ id);
|
||||
}
|
||||
/**
|
||||
* 教师详情查询接口
|
||||
* @param {
|
||||
teacher_id 教师id
|
||||
* } data 查询条件
|
||||
*/
|
||||
const teacherInfo = function(data) {
|
||||
return ajax.get('/b1/system/teacher/teacher-info',data);
|
||||
}
|
||||
/**
|
||||
* 教师删除接口
|
||||
* @param {
|
||||
teacher_id 教师id
|
||||
* } 查询条件
|
||||
*/
|
||||
const deleteTeacher = function(id) {
|
||||
return ajax.get('/b1/system/teacher/delete-teacher?teacher_id='+id);
|
||||
}
|
||||
/**
|
||||
* 教师启用禁用接口
|
||||
* @param {
|
||||
teacher_id
|
||||
status 状态;0:临时;1:正式;2:停用
|
||||
* } 查询条件
|
||||
*/
|
||||
const updateStatus = function(data) {
|
||||
return ajax.postJson('/b1/system/teacher/update-status',data);
|
||||
}
|
||||
|
||||
export default {
|
||||
editTeacher,
|
||||
teacherSystem,
|
||||
teacherInfo,
|
||||
deleteTeacher,
|
||||
updateStatus
|
||||
}
|
||||
Reference in New Issue
Block a user