Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c4626648
authored
Apr 24, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit 无网络提示
1 parent
2b6bd914
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
58 deletions
api/request/http.js
env.js
api/request/http.js
View file @
c462664
...
...
@@ -31,68 +31,82 @@ class Request {
);
}
request
(
RequestMethods
,
params
,
returnAll
,
hostType
=
"dj"
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
header
=
RequestMethods
===
"POST"
?
{
"content-type"
:
"application/x-www-form-urlencoded"
,
}
:
{
"Cache-Control"
:
"no-cache"
,
};
let
projectName
=
params
.
projectName
;
if
(
!
projectName
)
projectName
=
this
.
getRopProject
(
params
.
method
);
const
path
=
pathEnum
[
projectName
];
params
=
this
.
getData
(
params
,
hostType
);
uni
.
request
({
url
:
`
${
HOST
[
hostType
]}${
path
}
router?method=
${
params
.
method
}
`
,
data
:
params
,
method
:
RequestMethods
,
header
,
dataType
:
"json"
,
responseType
:
"text"
,
success
(
response
)
{
/**业务代码 */
let
{
data
:
{
code
,
message
},
data
,
}
=
response
;
if
(
returnAll
)
{
resolve
(
data
);
return
;
}
if
(
code
==
20
||
code
==
21
)
{
let
_this
=
this
uni
.
getNetworkType
({
success
(
res
)
{
if
(
res
.
networkType
==
'none'
){
uni
.
hideLoading
();
uni
.
reLaunch
({
url
:
"/pages/common/login"
,
});
}
else
{
if
(
code
==
"0"
)
{
resolve
(
data
.
data
);
}
else
{
uni
.
showToast
({
title
:
message
||
"系统异常"
,
icon
:
"
none
"
,
title
:
'网络异常'
,
icon
:
"
error
"
,
});
}
reject
(
'网络异常'
);
return
}
},
fail
(
error
)
{
uni
.
hideLoading
();
console
.
error
(
`
${
params
.
method
}
接口异常:`
,
error
);
uni
.
showToast
({
title
:
typeof
error
==
"string"
?
error
:
error
.
errMsg
?
error
.
errMsg
:
JSON
.
stringify
(
error
)
||
"系统异常"
,
icon
:
"error"
,
let
header
=
RequestMethods
===
"POST"
?
{
"content-type"
:
"application/x-www-form-urlencoded"
,
}
:
{
"Cache-Control"
:
"no-cache"
,
};
let
projectName
=
params
.
projectName
;
if
(
!
projectName
)
projectName
=
_this
.
getRopProject
(
params
.
method
);
const
path
=
pathEnum
[
projectName
];
params
=
_this
.
getData
(
params
,
hostType
);
uni
.
request
({
url
:
`
${
HOST
[
hostType
]}${
path
}
router?method=
${
params
.
method
}
`
,
data
:
params
,
method
:
RequestMethods
,
header
,
dataType
:
"json"
,
responseType
:
"text"
,
success
(
response
)
{
/**业务代码 */
let
{
data
:
{
code
,
message
},
data
,
}
=
response
;
if
(
returnAll
)
{
resolve
(
data
);
return
;
}
if
(
code
==
20
||
code
==
21
)
{
uni
.
hideLoading
();
uni
.
reLaunch
({
url
:
"/pages/common/login"
,
});
}
else
{
if
(
code
==
"0"
)
{
resolve
(
data
.
data
);
}
else
{
uni
.
showToast
({
title
:
message
||
"系统异常"
,
icon
:
"none"
,
});
}
}
},
fail
(
error
)
{
uni
.
hideLoading
();
console
.
error
(
`
${
params
.
method
}
接口异常:`
,
error
);
uni
.
showToast
({
title
:
typeof
error
==
"string"
?
error
:
error
.
errMsg
?
error
.
errMsg
:
JSON
.
stringify
(
error
)
||
"系统异常"
,
icon
:
"error"
,
});
reject
(
error
);
},
complete
()
{
uni
.
stopPullDownRefresh
();
},
});
reject
(
error
);
},
complete
()
{
uni
.
stopPullDownRefresh
();
},
});
}
})
});
}
getData
(
params
,
hostType
=
"scrm"
)
{
...
...
env.js
View file @
c462664
const
target
=
[
"ip"
,
"dev"
,
"uat"
,
"prod"
,
"beta"
];
const
index
=
1
;
const
index
=
2
;
/**
*
0本地
...
...
@@ -116,7 +116,6 @@ const CONFIG_ENV_MAP = {
3
:
"production"
,
4
:
"beta"
,
};
console
.
log
(
secretKey
,
"==="
);
module
.
exports
=
{
index
,
domain
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment