mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-10 03:16:47 +08:00
init
This commit is contained in:
@@ -109,4 +109,39 @@ export async function request(_url, params) {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
// router.push({path: '/login'})
|
// router.push({path: '/login'})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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