Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
simgle_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5a4a26b0
authored
Feb 09, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.0' of
http://192.168.3.233:8090/glsx/simgle_app
into v1.0.0
2 parents
b48e560d
afeb57c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
32 deletions
api/request/http.js
api/request/http.js
View file @
5a4a26b
...
...
@@ -7,13 +7,13 @@ const HOST = {
ip
:
'http://192.168.1.125:8080'
}
class
Request
{
get
(
params
,
returnAll
=
false
,
hostType
)
{
get
(
params
,
returnAll
=
false
,
hostType
)
{
return
this
.
request
(
'GET'
,
params
,
returnAll
,
hostType
)
}
post
(
params
,
returnAll
=
false
,
hostType
)
{
post
(
params
,
returnAll
=
false
,
hostType
)
{
return
this
.
request
(
'POST'
,
params
,
returnAll
,
hostType
)
}
fetch
(
method
,
data
,
returnAll
=
true
,
hostType
)
{
fetch
(
method
,
data
,
returnAll
=
true
,
hostType
)
{
return
this
.
post
(
{
method
,
...
...
@@ -23,11 +23,11 @@ class Request {
hostType
)
}
request
(
RequestMethods
,
params
,
returnAll
,
hostType
=
'dj'
)
{
request
(
RequestMethods
,
params
,
returnAll
,
hostType
=
'dj'
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
_this
=
this
uni
.
getNetworkType
({
success
(
res
)
{
success
(
res
)
{
if
(
res
.
networkType
==
'none'
)
{
uni
.
hideLoading
()
uni
.
showToast
({
...
...
@@ -40,11 +40,11 @@ class Request {
let
header
=
RequestMethods
===
'POST'
?
{
'content-type'
:
'application/x-www-form-urlencoded'
}
'content-type'
:
'application/x-www-form-urlencoded'
}
:
{
'Cache-Control'
:
'no-cache'
}
'Cache-Control'
:
'no-cache'
}
let
projectName
=
params
.
projectName
if
(
!
projectName
)
projectName
=
_this
.
getRopProject
(
params
.
method
)
const
path
=
pathEnum
[
projectName
]
...
...
@@ -56,7 +56,7 @@ class Request {
header
,
dataType
:
'json'
,
responseType
:
'text'
,
success
(
response
)
{
success
(
response
)
{
try
{
/**业务代码 */
let
{
data
,
statusCode
}
=
response
...
...
@@ -100,7 +100,7 @@ class Request {
reject
(
error
)
}
},
fail
(
error
)
{
fail
(
error
)
{
uni
.
hideLoading
()
uni
.
$logger
.
error
(
`HTTP Request Fail:
${
JSON
.
stringify
(
params
)}
->
${
error
.
message
}
`
)
// console.error(`${params.method}接口异常:`, error)
...
...
@@ -110,7 +110,7 @@ class Request {
})
reject
(
error
)
},
complete
()
{
complete
()
{
uni
.
stopPullDownRefresh
()
}
})
...
...
@@ -118,7 +118,7 @@ class Request {
})
})
}
getData
(
params
,
hostType
=
'scrm'
)
{
getData
(
params
,
hostType
=
'scrm'
)
{
let
projectName
=
params
.
projectName
if
(
!
projectName
)
projectName
=
this
.
getRopProject
(
params
.
method
)
else
delete
params
.
projectName
...
...
@@ -150,11 +150,11 @@ class Request {
params
.
appKey
=
appKey
return
sign
(
params
,
secret
,
noSignAttr
)
}
getRopProject
(
method
)
{
getRopProject
(
method
)
{
const
projectName
=
method
.
split
(
'.'
)[
2
]
return
projectName
}
uni_request
({
url
,
method
=
'GET'
,
data
=
{},
header
=
{},
dataType
=
'json'
,
responseType
=
'text'
})
{
uni_request
({
url
,
method
=
'GET'
,
data
=
{},
header
=
{},
dataType
=
'json'
,
responseType
=
'text'
})
{
return
new
Promise
(
resolve
=>
{
uni
.
request
({
url
,
...
...
@@ -163,27 +163,27 @@ class Request {
header
,
dataType
,
responseType
,
success
(
response
)
{
success
(
response
)
{
resolve
(
response
.
data
)
}
})
})
}
shukeRequest
(
url
,
data
=
{},
method
=
'GET'
,
returnAll
=
false
)
{
shukeRequest
(
url
,
params
=
{},
method
=
'GET'
,
returnAll
=
false
)
{
let
header
=
method
===
'POST'
?
{
'content-type'
:
'application/json'
}
'content-type'
:
'application/json'
}
:
{
'Cache-Control'
:
'no-cache'
,
'Content-Type'
:
'application/json'
}
'Cache-Control'
:
'no-cache'
,
'Content-Type'
:
'application/json'
}
let
{
sessionId
}
=
uni
.
$storage
.
get
()
if
(
sessionId
)
header
.
Authorization
=
sessionId
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
uni
.
getNetworkType
({
success
(
res
)
{
success
(
res
)
{
if
(
res
.
networkType
==
'none'
)
{
uni
.
hideLoading
()
uni
.
showToast
({
...
...
@@ -195,19 +195,46 @@ class Request {
}
uni
.
request
({
url
:
`
${
shukeDomain
}
/
${
url
}
`
,
data
,
data
:
params
,
method
,
header
,
dataType
:
'json'
,
responseType
:
'text'
,
success
(
response
)
{
let
{
data
,
statusCode
}
=
response
if
(
returnAll
)
{
resolve
(
data
)
return
success
(
response
)
{
try
{
let
{
data
,
statusCode
}
=
response
if
(
!
data
||
statusCode
!=
200
)
{
uni
.
hideLoading
()
let
errMsg
=
''
if
(
!
data
)
errMsg
=
'获取数据失败,请重试。'
else
errMsg
=
'服务器暂时不可用,请稍后再次尝试。'
uni
.
$logger
.
error
(
`Request Fail:
${
JSON
.
stringify
(
params
)}
->
${
errMsg
}
`
)
return
reject
(
errMsg
)
}
if
(
returnAll
)
{
resolve
(
data
)
return
}
let
{
code
,
msg
}
=
data
if
(
code
==
401
)
{
uni
.
$storage
.
set
(
'sessionId'
,
''
)
uni
.
$storage
.
set
(
'userInfo'
,
{})
uni
.
hideLoading
()
const
pages
=
getCurrentPages
(),
currentPage
=
pages
[
pages
.
length
-
1
]
uni
.
$logger
.
local
.
warn
(
`HTTP Triggered Logout: params:
${
JSON
.
stringify
(
params
)}
method:
${
params
.
method
}
->code:
${
code
}
msg:
${
msg
}
currentPage:
${
currentPage
.
route
}
`
)
uni
.
hideLoading
()
if
(
currentPage
.
route
!=
'pages/common/login'
)
{
uni
.
reLaunch
({
url
:
'/pages/common/login'
})
}
}
else
resolve
(
data
.
data
)
}
catch
(
error
)
{
console
.
log
(
error
)
uni
.
$logger
.
error
(
`
${
params
.
method
}
处理异常:
${
error
.
msg
}
`
)
reject
(
error
)
}
resolve
(
data
.
data
)
}
})
}
...
...
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