Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hello_taobao
Project
Project
Details
Activity
Releases
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
wildfirecode13
hello_taobao
Commits
8697bd32
Commit
8697bd32
authored
Sep 07, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a8bce5b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
7 deletions
+48
-7
api.js
dist/api.js
+5
-1
app.js
dist/app.js
+1
-1
request.js
dist/tbcc-sdk/lib/request.js
+42
-5
No files found.
dist/api.js
View file @
8697bd32
...
...
@@ -20,7 +20,11 @@ const apiList = {
handle
:
'getActivityBaseInfoById'
,
isShowLoading
:
true
},
login
:
'login'
login
:
{
handle
:
'login'
,
method
:
'get'
,
isShowLoading
:
true
}
};
// 生成API
...
...
dist/app.js
View file @
8697bd32
...
...
@@ -6,7 +6,7 @@ cloud.init({
});
App
({
requestType
:
'
cloud
'
,
// ams:ams接口,cloud: 云函数
requestType
:
'
yapi
'
,
// ams:ams接口,cloud: 云函数
cloudName
:
'floor'
,
// 主云函数项目名 base clientTemplate2C
cloud
,
tbcc
,
...
...
dist/tbcc-sdk/lib/request.js
View file @
8697bd32
...
...
@@ -27,7 +27,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if
(
isShowLoading
)
{
my
.
showLoading
();
}
const
requestAms
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
my
.
request
({
...
...
@@ -48,11 +48,43 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
});
})
};
const
requestMock
=
()
=>
{
const
mockUrlPrefix
=
{
ams
:
'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri='
,
yapi
:
'https://docs.dui88.com/mock/140/'
};
const
mockUrl
=
null
;
const
requestPrefix
=
mockUrl
||
mockUrlPrefix
[
requestType
];
return
new
Promise
((
resolve
,
reject
)
=>
{
// const url = requestPrefix + _cloudName + '.';
const
url
=
requestPrefix
+
_cloudName
+
'.'
+
handle
;
console
.
log
(
`requestMock url,method=>
${
method
}
=>`
,
url
)
my
.
request
({
url
:
url
,
method
,
data
:
params
,
dataType
:
'json'
}).
then
(({
data
:
res
})
=>
{
hideMyLoading
();
console
.
log
(
'mock res=>'
,
JSON
.
stringify
(
res
))
if
(
res
&&
res
.
success
)
{
resolve
(
res
);
}
else
{
reject
(
res
);
}
}).
catch
(()
=>
{
hideMyLoading
();
reject
();
});
})
};
const
requestCloud
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cloud
.
function
.
invoke
(
_cloudName
,
params
,
handle
).
then
(
res
=>
{
console
.
log
(
handle
,
params
,
res
);
console
.
log
(
'requestCloud'
,
handle
,
params
,
res
);
hideMyLoading
();
if
(
res
&&
res
.
success
)
{
resolve
(
res
);
...
...
@@ -66,8 +98,13 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
});
});
};
return
requestType
===
'ams'
?
requestAms
()
:
requestCloud
();
console
.
log
(
'requestCloud'
,
_cloudName
,
handle
,
params
);
// return requestType === 'ams' ? requestAms() : requestCloud();
return
(
requestType
===
'ams'
||
requestType
===
'yapi'
)
?
requestMock
()
:
requestCloud
();
};
};
...
...
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