Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-common
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 2624b12f
authored
Sep 30, 2022
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://192.168.3.233:8090/npm/glsx-common
into master
2 parents
632a43a5
70fcdb8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
src/http.js
src/util.js
src/http.js
View file @
2624b12
...
...
@@ -4,7 +4,7 @@
* @Last Modified by: huyue
* @Last Modified time: 2021-07-16 18:02:05
*/
import
{
createSign
}
from
'./util'
import
util
from
'./util'
import
axios
from
'axios'
import
qs
from
'qs'
function
Http
(
options
=
{})
{
...
...
@@ -32,13 +32,18 @@ Http.prototype.create = function () {
data
.
sessionId
=
this
.
customer
.
sessionId
||
data
.
sessionId
if
(
sign
)
{
let
_configSign
=
this
.
customer
.
sign
||
{}
data
=
createSign
(
Object
.
assign
({},
_configSign
,
data
),
this
.
customer
.
secret
,
noSignAttr
,
this
.
customer
.
signWay
)
data
=
util
.
createSign
(
Object
.
assign
({},
_configSign
,
data
),
this
.
customer
.
secret
,
noSignAttr
,
this
.
customer
.
signWay
)
}
const
method
=
config
.
method
.
toLowerCase
()
if
(
method
==
'get'
)
{
config
.
params
=
data
}
else
if
(
method
==
'post'
)
{
config
.
data
=
qs
.
stringify
(
data
)
if
(
config
.
format
==
'formData'
)
{
config
.
headers
[
'Content-Type'
]
=
'multipart/form-data'
config
.
data
=
util
.
appendFormData
(
data
)
}
else
{
config
.
data
=
qs
.
stringify
(
data
)
}
}
return
config
},
...
...
src/util.js
View file @
2624b12
...
...
@@ -173,6 +173,17 @@ export const Util = {
},
[])
collect
.
sign
=
{
sha1
,
md5
}[
way
](
secret
+
str
.
join
(
''
)
+
secret
).
toUpperCase
()
return
collect
},
// 转为formData数据
appendFormData
:
function
(
obj
)
{
delete
obj
.
sessionId
const
formData
=
new
FormData
()
for
(
let
k
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
k
))
{
formData
.
append
(
k
,
obj
[
k
])
}
}
return
formData
}
}
export
const
createSign
=
Util
.
createSign
...
...
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