Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
ybf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xulili
ybf
Commits
6e4d9f16
Commit
6e4d9f16
authored
Jan 10, 2020
by
Z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
Z: Dot: Request Util is done.
parent
e7fc579d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
0 deletions
+123
-0
package.json
ybf_admin/package.json
+1
-0
main.js
ybf_admin/src/api/task/main.js
+19
-0
index.vue
ybf_admin/src/pages/task/main/index.vue
+14
-0
request.js
ybf_admin/src/utils/request.js
+84
-0
yarn.lock
ybf_admin/yarn.lock
+5
-0
No files found.
ybf_admin/package.json
View file @
6e4d9f16
...
...
@@ -26,6 +26,7 @@
"fuse.js"
:
"^3.4.6"
,
"hotkeys-js"
:
"^3.7.3"
,
"js-cookie"
:
"^2.2.1"
,
"js-md5"
:
"^0.7.3"
,
"lodash"
:
"^4.17.15"
,
"lowdb"
:
"^1.0.0"
,
"mockjs"
:
"^1.1.0"
,
...
...
ybf_admin/src/api/task/main.js
0 → 100644
View file @
6e4d9f16
import
request
from
'@/utils/request'
export
function
ApiTestGet
()
{
return
request
({
url
:
'/admin/common/findLoginType'
,
method
:
'get'
})
}
export
function
ApiTestPost
(
inData
)
{
let
postData
=
{
appCode
:
"0611"
,
args
:
inData
}
return
request
({
url
:
'/admin/common/findLoginType'
,
method
:
'post'
,
data
:
postData
})
}
ybf_admin/src/pages/task/main/index.vue
View file @
6e4d9f16
...
...
@@ -19,6 +19,7 @@
import
TaskBar
from
"../bar/index"
;
import
TaskCom
from
"../com/index"
;
import
TaskCount
from
"../count/index"
;
import
{
ApiTestGet
,
ApiTestPost
}
from
"@/api/task/main"
;
export
default
{
components
:
{
...
...
@@ -33,6 +34,19 @@ export default {
}
};
},
created
()
{
let
postData
=
{
brief
:
"停车券兑换"
,
orderNo
:
"12345678"
,
point
:
"123.321"
,
procType
:
46
,
updateType
:
"dec"
,
vipId
:
1
};
ApiTestPost
(
postData
).
then
(
res
=>
{
log
(
"--->Api: Post: res ="
,
res
);
});
},
methods
:{
ztabsClick
(){},
}
...
...
ybf_admin/src/utils/request.js
0 → 100644
View file @
6e4d9f16
import
axios
from
'axios'
import
md5
from
"js-md5"
let
BASE_API
=
"https://gd.chfatech.com/guangdian"
const
log
=
console
.
log
.
bind
(
console
)
// URL 编码与拼接
const
createSign
=
(
inPostData
,
inAppSecret
)
=>
{
let
appUser
=
inPostData
.
appUser
let
appCode
=
inPostData
.
appCode
let
ts
=
inPostData
.
ts
let
args
=
JSON
.
parse
(
JSON
.
stringify
(
inPostData
.
args
));
let
appSecret
=
inAppSecret
let
res
=
""
;
// URL 编码
for
(
let
key
in
args
)
{
res
+=
encodeURIComponent
(
key
)
+
"%3d"
+
encodeURIComponent
(
args
[
key
]).
toLowerCase
()
+
"%26"
;
}
res
=
res
.
slice
(
0
,
-
3
);
// URL 拼接
res
+=
`&appUser=
${
appUser
}
&appCode=
${
appCode
}
&
${
ts
}
${
appSecret
}
`
return
res
;
};
// Basic Info
let
basicInfo
=
{
appUser
:
"user001"
,
ver
:
"v1.0"
,
appSecret
:
"JeC0mmE2ZjZmOfdmTGImYzU5Yjg1AYU2M3F="
}
// 创建 axios 实例
const
service
=
axios
.
create
({
baseURL
:
BASE_API
,
timeout
:
20000
})
// request 拦截器
service
.
interceptors
.
request
.
use
(
res
=>
{
log
(
'--->axios: res.data:'
,
res
.
data
)
let
oldPostData
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
let
newPostData
=
{
appUser
:
basicInfo
.
appUser
,
appCode
:
oldPostData
.
appCode
,
ts
:
String
(
Date
.
parse
(
new
Date
())),
ver
:
basicInfo
.
ver
,
args
:
oldPostData
.
args
}
let
postData
=
{
appUser
:
newPostData
.
appUser
,
appCode
:
newPostData
.
appCode
,
ts
:
newPostData
.
ts
,
sign
:
md5
(
createSign
(
newPostData
,
basicInfo
.
appSecret
)),
ver
:
newPostData
.
ver
,
args
:
newPostData
.
args
}
res
.
data
=
postData
return
res
},
error
=>
{
Promise
.
reject
(
error
)
}
)
// response 拦截器
service
.
interceptors
.
response
.
use
(
response
=>
{
const
res
=
response
.
data
return
res
},
error
=>
{
return
Promise
.
reject
(
error
)
}
)
export
default
service
\ No newline at end of file
ybf_admin/yarn.lock
View file @
6e4d9f16
...
...
@@ -6014,6 +6014,11 @@ js-levenshtein@^1.1.3:
resolved "https://registry.npm.taobao.org/js-levenshtein/download/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"
integrity sha1-xs7ljrNVA3LfjeuF+tXOZs4B1Z0=
js-md5@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/js-md5/-/js-md5-0.7.3.tgz#b4f2fbb0b327455f598d6727e38ec272cd09c3f2"
integrity sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==
js-message@1.0.5:
version "1.0.5"
resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz#2300d24b1af08e89dd095bc1a4c9c9cfcb892d15"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment