Commit d51c4044 authored by qinhaitao's avatar qinhaitao

feat: 🎸 完成任务id

parent daabc8c1
......@@ -3,3 +3,4 @@
.vscode
debug.log
node_modules
dist/
\ No newline at end of file
......@@ -8,10 +8,10 @@ const capi = {
receiveEnamePrize: { method: 'GET', handle: 'receiveEnamePrize' },
getItemListByItemIds: { method: 'GET', handle: 'getItemListByItemIds' },
getCollectGoodsList: { method: 'GET', handle: 'getCollectGoodsList' },
doCollectGoodsTask: { method: 'GET', handle: 'doCollectGoodsTask' },
doBrowseGoodsTask: { method: 'GET', handle: 'doBrowseGoodsTask' },
doJumpLinkTask: { method: 'GET', handle: 'doJumpLinkTask' },
doExchangeCreditsTask: { method: 'GET', handle: 'doExchangeCreditsTask' },
doCollectGoodsTask: { method: 'GET', handle: 'doCompleteTask', dedaultParams: { taskType: 'collectGoods'} },
doBrowseGoodsTask: { method: 'GET', handle: 'doCompleteTask', dedaultParams: { taskType: 'browseGoods'} },
doJumpLinkTask: { method: 'GET', handle: 'doCompleteTask', dedaultParams: { taskType: 'jumpLink'} },
doExchangeCreditsTask: { method: 'GET', handle: 'doCompleteTask', dedaultParams: { taskType: 'exchangeCredits'} },
getVipInfo: { method: 'GET', handle: 'getVipInfo' }
};
......
......@@ -68,10 +68,11 @@ export const getRequestParams = value => {
ext: {}
}
} else if (typeof value === 'object') {
const { handle, method = 'POST', ...ext } = value;
const { handle, method = 'POST', dedaultParams = {}, ...ext } = value;
return {
handle,
method,
dedaultParams,
ext: { ...ext }
}
} else {
......@@ -87,8 +88,8 @@ export const getRequestParams = value => {
export const generateAPI = (apiList, request) => {
const api = {};
Object.entries(apiList).forEach(([key, value]) => {
const { handle, method, ext } = getRequestParams(value);
api[key] = params => request(handle, method, params, ext);
const { handle, method, ext, defaultParams } = getRequestParams(value);
api[key] = params => request(handle, method, Object.assign({}, defaultParams, params) , ext);
});
api.fn = capiFn(apiList, request);
return api;
......
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