This commit is contained in:
yuping
2022-12-14 17:42:01 +08:00
parent dbe75e2f96
commit 982a77c6a3

View File

@@ -109,4 +109,39 @@ export async function request(_url, params) {
console.log(e)
// 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'})
})
}