You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
867 B
42 lines
867 B
/*
|
|
* 发送请求 mixin
|
|
*/
|
|
import request from './server'
|
|
import {getProject} from "@@/utils/auth.js"
|
|
|
|
/* eslint-disable */
|
|
export const sendReq = {
|
|
data () {
|
|
return {
|
|
// 加载中
|
|
loading: false,
|
|
}
|
|
},
|
|
methods: {
|
|
/*
|
|
* 发送请求
|
|
*/
|
|
sendReq (params, callback, errorCallback) {
|
|
let self = this
|
|
|
|
request({
|
|
method: params.method || 'POST',
|
|
url: params.url,
|
|
data: params.data || {},
|
|
withCredentials : true,
|
|
headers: {
|
|
'Content-type': params.contentType || 'application/json;charset=utf-8',
|
|
"project" : getProject()
|
|
}
|
|
}).then((res) => {
|
|
if (res && res.data) {
|
|
callback && callback(res.data)
|
|
}
|
|
}).catch(err => {
|
|
if (err) {
|
|
errorCallback && errorCallback(err)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|