diff --git a/src/assets/api.js b/src/assets/api.js index 364522f1..5bba1e8e 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -15,7 +15,7 @@ const req = (method, url, params, responseType) => { } } } - if (method == "post") { + if (method == "post" || method == "put") { obj = { method: method, body: JSON.stringify(params), @@ -25,24 +25,24 @@ const req = (method, url, params, responseType) => { } } + let http = fetch(url, obj).then(res =>{ console.log(res.headers.get('Date-Time')); return res.json() - }); - + } ); return http.then(response => response).catch(error => console.error('Error:', error)); } -export const handelResponse=(res, cb, errCb)=> { - console.log(errCb); - if (res.code == 200) { - cb(res.data,res.msg) - } else { - if (typeof errCb == 'function') { - errCb(res.msg) - } - } - } +export const handelResponse = (res, cb, errCb) => { + console.log(res) + if (res.code == 200) { + cb(res.data, res.message) + } else { + if (typeof errCb == 'function') { + errCb(res.message) + } + } +} //营销计划列表 export const getPlanList = (params) => { return req('get', baseurl + "/plan", params) @@ -58,9 +58,14 @@ export const getReSellerOption = (params) => { } + + + + + //新建营销计划 -export const getPlanStep = (id, params) => { - return req('get', baseurl + "/plan/step/:" + id, params) +export const addPlanStep = (id, params) => { + return req('post', baseurl + "/plan/step/" + id, params) } //获取营销计划草稿信息 export const getDraftInfo = (id, params) => { @@ -68,12 +73,12 @@ export const getDraftInfo = (id, params) => { } //启用停用 营销计划 export const startOrStopPlan = (id, params) => { - return req('put', baseurl + "/plan/status/:" + id, params) + return req('put', baseurl + "/plan/status/" + id, params) } //创建key批次信息 export const addKeysBatchInfo = (id, params) => { - return req('post', baseurl + "/plan/:" + id + "/keys", params) + return req('post', baseurl + "/plan/" + id + "/keys", params) } @@ -84,27 +89,27 @@ export const getKeysBatchInfo = (id, params) => { //启用停用key批次信息 export const startOrStopKeybatch = (id, params) => { - return req('put', baseurl + "/keys/status/:" + id, params) + return req('put', baseurl + "/keys/status/" + id, params) } //获取key批次详细信息 export const getKeyBatchDetail = (id, params) => { - return req('get', baseurl + "/keys/:" + id, params) + return req('get', baseurl + "/keys/" + id, params) } //更新key批次详细信息 export const putKeyBatchDetail = (id, params) => { - return req('put', baseurl + "/keys/:" + id, params) + return req('put', baseurl + "/keys/" + id, params) } //发送密钥邮件 export const postKeyEmail = (id, params) => { - return req('post', baseurl + "/keys/send/:" + id, params) + return req('post', baseurl + "/keys/send/" + id, params) } //修改密钥邮件 export const putKeyEmail = (id, params) => { - return req('put', baseurl + "/keys/receive/:" + id, params) + return req('put', baseurl + "/keys/receive/" + id, params) } @@ -116,4 +121,4 @@ export const getCodesList = (params) => { export { req -} \ No newline at end of file +}