111
This commit is contained in:
@@ -20,7 +20,7 @@ import token from '@/utils/auth.token.js'
|
||||
* showFailMessage: true, // 返回失败信息是否显示
|
||||
* catchError: true, // 是否集中管理返回的success为false的情况,如果为false,在请求处判断code值做业务处理
|
||||
*/
|
||||
const request = (options) => {
|
||||
const request = (options, noLoading) => {
|
||||
let _opts = {
|
||||
url: '', // url String 是 开发者服务器接口地址
|
||||
data: {}, // data Object/String/ArrayBuffer 否 请求的参数 App 3.3.7 以下不支持 ArrayBuffer 类型
|
||||
@@ -35,7 +35,7 @@ const request = (options) => {
|
||||
// success Function 否 收到开发者服务器成功返回的回调函数
|
||||
// fail Function 否 接口调用失败的回调函数
|
||||
// complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
showLoading: true, // 是否显示加载等待框
|
||||
showLoading: !noLoading, // 是否显示加载等待框
|
||||
loadingTitle: '加载中', // 加载等待框的提示文字
|
||||
showFailMessage: true, // 返回失败信息是否显示
|
||||
catchError: true, // 是否集中管理Catch,
|
||||
@@ -164,7 +164,7 @@ const request = (options) => {
|
||||
|
||||
}
|
||||
|
||||
const req = function(url, method = "GET", data = {}, header = {}, options = {}) {
|
||||
const req = function(url, method = "GET", data = {}, header = {}, options = {}, noLoading) {
|
||||
let _opts = {
|
||||
url: url,
|
||||
method: method,
|
||||
@@ -172,25 +172,25 @@ const req = function(url, method = "GET", data = {}, header = {}, options = {})
|
||||
header: header
|
||||
}
|
||||
Object.assign(options, _opts)
|
||||
return request(options)
|
||||
return request(options, noLoading)
|
||||
}
|
||||
|
||||
const get = function(url, data = {}, header = {}, options = {}) {
|
||||
return req(url, "GET", data, header, options)
|
||||
const get = function(url, data = {}, header = {}, options = {}, noLoading) {
|
||||
return req(url, "GET", data, header, options, noLoading)
|
||||
}
|
||||
const post = function(url, data = {}, header = {}, options = {}) {
|
||||
return req(url, "POST", data, header, options)
|
||||
const post = function(url, data = {}, header = {}, options = {}, noLoading) {
|
||||
return req(url, "POST", data, header, options, noLoading)
|
||||
}
|
||||
const formpost = function(url, data = {}, header = {}, options = {}) {
|
||||
const formpost = function(url, data = {}, header = {}, options = {}, noLoading) {
|
||||
let _head = {
|
||||
"content-type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
Object.assign(header, _head)
|
||||
return req(url, "POST", data, header, options)
|
||||
return req(url, "POST", data, header, options, noLoading)
|
||||
}
|
||||
request.get = get
|
||||
request.post = post
|
||||
request.formpost = formpost
|
||||
request.req = req
|
||||
|
||||
export default request
|
||||
export default request
|
||||
Reference in New Issue
Block a user