1111111111

This commit is contained in:
2024-03-06 10:40:48 +08:00
parent 73a486c2c6
commit 11fad13f23
12 changed files with 590 additions and 93 deletions

View File

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