From 26782dc550e721d54b82d4a7dedf86bbdfc3e858 Mon Sep 17 00:00:00 2001 From: jinna Date: Tue, 4 Apr 2023 17:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9axios=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=B4=E5=83=8F=E4=BD=BF=E7=94=A8=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/hospital.js | 119 +++++++++++++++++++++----------------- src/utils/axios.js | 4 +- src/views/examProject.vue | 33 ++++++----- 3 files changed, 87 insertions(+), 69 deletions(-) diff --git a/src/api/hospital.js b/src/api/hospital.js index fe7f44f..b7d4589 100644 --- a/src/api/hospital.js +++ b/src/api/hospital.js @@ -2,76 +2,91 @@ import request from "../utils/axios"; //医院列表 export const queryHosiptal = () => { - return request({ - url: '/api/blade-system/dept-hospital/list-hospital', - method: 'get', - }) + return request({ + url: "/api/blade-system/dept-hospital/list-hospital", + method: "get", + }); }; //根据医院id获取须知 export const queryArticleDetail = (createDept) => { - return request({ - url: '/api/blade-business/article/detail-publish', - method: 'get', - params: { - createDept - } - }) + return request({ + url: "/api/blade-business/article/detail-publish", + method: "get", + params: { + createDept, + }, + }); }; //查询改用户是否在黑名单内 export const checkBacklist = (cupCardNo) => { - return request({ - url: '/api/blade-business/blacklist/user-blacklist', - method: 'get', - params: { - cupCardNo - } - }) + return request({ + url: "/api/blade-business/blacklist/user-blacklist", + method: "get", + params: { + cupCardNo, + }, + }); }; //我的预约列表 export const myRecord = (createDept, cupCardNo, current, size) => { - return request({ - url: '/api/blade-business/apm-record/page', - method: 'get', - params: { - createDept, - cupCardNo, - current, - size, - } - }) + return request({ + url: "/api/blade-business/apm-record/page", + method: "get", + params: { + createDept, + cupCardNo, + current, + size, + }, + }); }; //取消预约 export const recordCancel = (id) => { - return request({ - url: '/api/blade-business/apm-record/cancel', - method: 'post', - params: { - id, - } - }) + return request({ + url: "/api/blade-business/apm-record/cancel", + method: "post", + params: { + id, + }, + }); }; //系统时间 export const getSystemTime = () => { - return request({ - url: '/api/blade-business/common-api/get-system-datetime', - method: 'get' - }) + return request({ + url: "/api/blade-business/common-api/get-system-datetime", + method: "get", + }); }; //获取预约用户头像 export const getCupImg = (cupCardNo) => { - return request({ - url: '/api/blade-business/common-api/get-cup-img', - method: 'get', - params: { - cupCardNo, - } - }) + return request({ + url: "/api/blade-business/common-api/get-cup-img", + method: "get", + params: { + cupCardNo, + }, + }); }; //存储用户头像 export const saveCupImg = (data) => { - return request({ - url: '/api/blade-business/common-api/save-cup-img', - method: 'post', - data, - }) -}; \ No newline at end of file + return request({ + url: "/api/blade-business/common-api/save-cup-img", + method: "post", + headers: { + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + }, + data, + }); +}; + +//存储用户头像 +export const saveCupImgLocal = (data) => { + return request({ + url: "/api/blade-business/common-api/save-cup-img-local", + method: "post", + // headers: { + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + // }, + data, + }); +}; diff --git a/src/utils/axios.js b/src/utils/axios.js index e138a99..1d47e73 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -13,7 +13,9 @@ axios.defaults.withCredentials = true; //HTTP Request拦截 axios.interceptors.request.use( (config) => { - config.headers["Content-Type"] = "application/json"; + if (config.url !== "/api/blade-business/common-api/save-cup-img") { + config.headers["Content-Type"] = "application/json"; + } return config; }, (error) => { diff --git a/src/views/examProject.vue b/src/views/examProject.vue index 15dbe53..4988833 100644 --- a/src/views/examProject.vue +++ b/src/views/examProject.vue @@ -217,22 +217,11 @@ export default { }) } else { - // let formData = new FormData(); - // formData.append("data", JSON.stringify(params)); - // console.log(formData) - // saveCupImg(formData).then(res => { - // this.$toast.clear(); - // if (res.code == 200) { - // this.$toast('采集成功'); - // this.avatar = avatar; - // console.log(this.avatar) - // } else { - // this.$toast(res.msg); - // } - // }, err => { - // this.$toast.clear(); - // }) - saveCupImgLocal(params).then(res => { + let formData = new FormData(); + formData.append("data", JSON.stringify(params)); + console.log(formData) + saveCupImg(formData).then(res => { + console.log(res) this.$toast.clear(); if (res.code == 200) { this.$toast('采集成功'); @@ -244,6 +233,18 @@ export default { }, err => { this.$toast.clear(); }) + // saveCupImgLocal({data:JSON.stringify(params)}).then(res => { + // this.$toast.clear(); + // if (res.code == 200) { + // this.$toast('采集成功'); + // this.avatar = avatar; + // console.log(this.avatar) + // } else { + // this.$toast(res.msg); + // } + // }, err => { + // this.$toast.clear(); + // }) } } catch (error) { this.$toast.clear();