jxdnsong
2022-10-25 bf5ba56e8a82f0ef699f2eae413d0dc2c4e4f67d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-29 09:04:54
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-09-16 17:30:22
 * @FilePath: \smart-campus\src\router\axios.js
 * @Description:
 *
 * Copyright (c) 2022 by shuishen 1109946754@qq.com, All Rights Reserved.
 */
/**
 * 全站http配置
 *
 * axios参数说明
 * isSerialize是否开启form表单提交
 * isToken是否需要token
 */
import axios from 'axios'
const httpName = window.location.protocol + '//' + window.location.hostname
const url = httpName + '/apis'
// setTimeout(() => {
//   console.log(window.location);
//   console.log(url);
// }, 3000);
window.$apiUrls = 'http://171.34.197.243:782'
// window.$apiUrls = 'http://192.168.0.109:82'
const service = axios.create({
    // baseURL: 'http://171.34.197.243:782', // 正常接口
    // baseURL: 'https://dev.jxpskj.com:8023/zhxyapi', // 师大
    baseURL: 'https://dev.jxpskj.com:8023/zhjgapi', // 经管
    timeout: 600000 // request timeout
})
 
// 返回其他状态码
service.defaults.validateStatus = function (status) {
    return status >= 200 && status <= 500
}
 
// 跨域请求,允许保存cookie
service.defaults.withCredentials = true
 
// http request拦截
service.interceptors.request.use(
    (config) => {
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)
 
// http response 拦截
service.interceptors.response.use(
    (res) => {
        return res
    },
    (error) => {
        return Promise.reject(new Error(error))
    }
)
 
export default service