mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-09 02:46:48 +08:00
Merge branch 'manage-release' of http://gitlab.dongwu-inc.com:10080/BOE/fe-stu into release
# Conflicts: # src/api/request.js
This commit is contained in:
@@ -109,4 +109,40 @@ export async function request(_url, params) {
|
||||
console.log(e)
|
||||
// router.push({path: '/login'})
|
||||
})
|
||||
}
|
||||
|
||||
// 这个方法要有 和request不一样
|
||||
export async function boeRequest(_url, params) {
|
||||
const s = _url.split(' ')
|
||||
let url = s[0]
|
||||
const method = s[1]?.toLowerCase() || 'get'
|
||||
if (method === 'get') {
|
||||
let paramsArray = [];
|
||||
//拼接参数
|
||||
if (params) {
|
||||
Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key]))
|
||||
if (url.search(/\?/) === -1) {
|
||||
url += '?' + paramsArray.join('&')
|
||||
} else {
|
||||
url += '&' + paramsArray.join('&')
|
||||
}
|
||||
}
|
||||
}
|
||||
const body = method !== 'get' ? params || {} : {}
|
||||
return axios({
|
||||
url,
|
||||
method,
|
||||
headers: {
|
||||
token: getCookie('token'),
|
||||
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
|
||||
},
|
||||
baseURL: '',
|
||||
...method !== 'get' ? {data: JSON.stringify(body)} : {}
|
||||
}).then(resp => resp.data).then(response => {
|
||||
return response
|
||||
}).catch(e => {
|
||||
console.log(2222)
|
||||
console.log(e)
|
||||
// router.push({path: '/login'})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user