From 76b8a89da12628269ee1a2359417bf69f8095fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=B5=B7=E4=B8=80=E5=88=80?= <849005670@qq.com> Date: Wed, 17 Nov 2021 16:03:03 +0800 Subject: [PATCH] Update api.js --- src/assets/api.js | 49 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index 5a6f14d3..ce017906 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), @@ -24,20 +24,22 @@ const req = (method, url, params, responseType) => { }) } } + + let http = fetch(url, obj).then(res => res.json()); return http.then(response => response).catch(error => console.error('Error:', error)); } -export const handelResponse=(res, cb, errCb)=> { - console.log(res) - 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) @@ -53,9 +55,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) => { @@ -63,12 +70,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) } @@ -79,27 +86,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) } @@ -111,4 +118,4 @@ export const getCodesList = (params) => { export { req -} \ No newline at end of file +}