Commit 8697bd32 authored by wildfirecode13's avatar wildfirecode13

1

parent a8bce5b4
...@@ -20,7 +20,11 @@ const apiList = { ...@@ -20,7 +20,11 @@ const apiList = {
handle: 'getActivityBaseInfoById', handle: 'getActivityBaseInfoById',
isShowLoading: true isShowLoading: true
}, },
login: 'login' login: {
handle: 'login',
method:'get',
isShowLoading: true
}
}; };
// 生成API // 生成API
......
...@@ -6,7 +6,7 @@ cloud.init({ ...@@ -6,7 +6,7 @@ cloud.init({
}); });
App({ App({
requestType: 'cloud', // ams:ams接口,cloud: 云函数 requestType: 'yapi', // ams:ams接口,cloud: 云函数
cloudName: 'floor', // 主云函数项目名 base clientTemplate2C cloudName: 'floor', // 主云函数项目名 base clientTemplate2C
cloud, cloud,
tbcc, tbcc,
......
...@@ -27,7 +27,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => { ...@@ -27,7 +27,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
if (isShowLoading) { if (isShowLoading) {
my.showLoading(); my.showLoading();
} }
const requestAms = () => { const requestAms = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
my.request({ my.request({
...@@ -48,11 +48,43 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => { ...@@ -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 = () => { const requestCloud = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
cloud.function.invoke(_cloudName, params, handle).then(res => { cloud.function.invoke(_cloudName, params, handle).then(res => {
console.log(handle, params, res); console.log('requestCloud', handle, params, res);
hideMyLoading(); hideMyLoading();
if (res && res.success) { if (res && res.success) {
resolve(res); resolve(res);
...@@ -66,8 +98,13 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => { ...@@ -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();
}; };
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment