mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 11:56:46 +08:00
style:增加滚动条样式
This commit is contained in:
@@ -1,8 +1,45 @@
|
||||
import axios from "axios";
|
||||
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
axios.defaults.withCredentials = true;
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: 'http://localhost:8082/api',
|
||||
timeout: 1000 * 100
|
||||
baseURL: '/api',
|
||||
timeout: 1000 * 5
|
||||
});
|
||||
|
||||
http.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
config.headers.token = token;
|
||||
} else {
|
||||
console.log("当前请求页面无token,请执行操作!!!")
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(err) => {
|
||||
console.log('登陆前拦截', err)
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
http.interceptors.response.use(
|
||||
(response) => {
|
||||
const { data: { code, msg } } = response;
|
||||
if (code === 0 || code === 200) {
|
||||
return response;
|
||||
} else {
|
||||
console.log('api %o', msg);
|
||||
}
|
||||
return response;
|
||||
},
|
||||
function (error) {
|
||||
console.log('api error %o', error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default http;
|
||||
@@ -1,19 +1,74 @@
|
||||
import http from "./config";
|
||||
|
||||
// 接口
|
||||
export const getUserInfo = () => http.get('/');
|
||||
export const getUserById = (x, y, z) => http.post('/getuserbyid', { x, y, z });
|
||||
import qs from 'qs';
|
||||
|
||||
|
||||
// 使用方法
|
||||
/**
|
||||
* 接口传参数方式(get)
|
||||
* axios.get('/user', {
|
||||
* params: {
|
||||
* id: 12345,
|
||||
* name: user
|
||||
* }
|
||||
* }).then(res => console.log(res))
|
||||
*
|
||||
* 接口传参三种方式(post/put/patch)
|
||||
*
|
||||
* 1.'Content-Type'= 'multipart/form-data',传参格式为 formData。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'multipart/form-data')
|
||||
* var formData=new FormData();
|
||||
* formData.append('user',123456);formData.append('pass',12345678);
|
||||
* axios.post("/notice",formData).then()
|
||||
*
|
||||
* 2.'Content-Type'= 'application/x-www-form-urlencoded',传参格式为 query 形式,使用$qs.stringify。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* let data = {"code":"1234","name":"yyyy"};
|
||||
* axios.post(`${this.$url}/test/testRequest`,qs.stringify({data})).then()
|
||||
*
|
||||
* 3.'Content-Type'= 'application/json,传参格式为 raw (JSON格式)。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'application/json;charset=UTF-8')
|
||||
* let data = {"code":"1234","name":"yyyy"}
|
||||
* axios.post(`${this.$url}/test/testRequest`,data).then()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// 接口-请求
|
||||
|
||||
// 根据投票ID获取题干信息
|
||||
export const getStemInfo = (stemId) => http.post('/vote/queryStemByStemId', qs.stringify({ stemId: stemId }));
|
||||
|
||||
// 测试方法
|
||||
// import * as api from '../../api/index'
|
||||
// api.getUserById(6, 7, 8).then(res => {
|
||||
// api.getStemInfo(4).then(res => {
|
||||
// console.log(res)
|
||||
// }).catch(err => {
|
||||
// console.log(err)
|
||||
// })
|
||||
|
||||
// api.getUserInfo().then(res => {
|
||||
// 获取字典列表
|
||||
export const getList = (pageno, pagesize) => http.post('/dict/getList', {
|
||||
"dictCode": "",
|
||||
"pageNo": pageno,
|
||||
"pageSize": pagesize
|
||||
})
|
||||
|
||||
// 测试方法
|
||||
// import * as api from '../../api/index'
|
||||
// api.getList(0,0).then(res => {
|
||||
// console.log(res)
|
||||
// }).catch(err => {
|
||||
// console.log(err)
|
||||
// })
|
||||
|
||||
// 根据活动ID获取活动信息接口
|
||||
export const getActivityList = (activityId) => http.get('/activity', { params: { "activityId": activityId } })
|
||||
|
||||
// 测试方法
|
||||
// import * as api from '../../api/index'
|
||||
// api.getActivityList(4).then(res => {
|
||||
// console.log(res)
|
||||
// }).catch(err => {
|
||||
// console.log(err)
|
||||
|
||||
55
src/api/index1.js
Normal file
55
src/api/index1.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import http from "./config";
|
||||
// import qs from 'qs';
|
||||
|
||||
|
||||
/**
|
||||
* 接口传参数方式(get)
|
||||
* axios.get('/user', {
|
||||
* params: {
|
||||
* id: 12345,
|
||||
* name: user
|
||||
* }
|
||||
* }).then(res => console.log(res))
|
||||
*
|
||||
* 接口传参三种方式(post/put/patch)
|
||||
*
|
||||
* 1.'Content-Type'= 'multipart/form-data',传参格式为 formData。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'multipart/form-data')
|
||||
* var formData=new FormData();
|
||||
* formData.append('user',123456);formData.append('pass',12345678);
|
||||
* axios.post("/notice",formData).then()
|
||||
*
|
||||
* 2.'Content-Type'= 'application/x-www-form-urlencoded',传参格式为 query 形式,使用$qs.stringify。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* let data = {"code":"1234","name":"yyyy"};
|
||||
* axios.post(`${this.$url}/test/testRequest`,qs.stringify({data})).then()
|
||||
*
|
||||
* 3.'Content-Type'= 'application/json,传参格式为 raw (JSON格式)。
|
||||
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded')
|
||||
* (request的Header:'Content-Type'= 'application/json;charset=UTF-8')
|
||||
* let data = {"code":"1234","name":"yyyy"}
|
||||
* axios.post(`${this.$url}/test/testRequest`,data).then()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// 接口-请求
|
||||
|
||||
// 获取学习路径图列表
|
||||
export const getLearnPath = (obj) => http.post('/admin/router/list', obj);
|
||||
|
||||
//获取关卡
|
||||
export const getChapter = (obj) => http.post('/admin/router/detail', { params: obj });
|
||||
|
||||
//新建或编辑关卡
|
||||
export const editChapter = (obj) => http.post('/admin/router/editChapter', obj);
|
||||
|
||||
// 测试方法
|
||||
// import * as api from '../../api/index'
|
||||
// api.getLearnPath({}).then(res => {
|
||||
// console.log(res)
|
||||
// }).catch(err => {
|
||||
// console.log(err)
|
||||
// })
|
||||
Reference in New Issue
Block a user