Commit d51c4044 authored by qinhaitao's avatar qinhaitao

feat: 🎸 完成任务id

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