From a569565bfb665cb47e21740f9ea1660ef2c97cea Mon Sep 17 00:00:00 2001 From: yangzhe Date: Fri, 11 Apr 2025 13:22:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apiList.js | 9 ++++----- pages/index/uploadPhoto.vue | 23 +++++++---------------- utils/request.js | 33 ++++++++++++++++++--------------- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/api/apiList.js b/api/apiList.js index 43764ab..8e723d9 100644 --- a/api/apiList.js +++ b/api/apiList.js @@ -33,8 +33,7 @@ export const GetPlanInfoAre = (data) => request.post("/api/App/GetPlanInfoAre", data); // 获取计划列表 -export const GetPlanList = (data) => - request.get("/api/App/GetPlanList", data); +export const GetPlanList = (data) => request.get("/api/App/GetPlanList", data); // 获取单位信息 export const GetCompanyInformation = (data) => @@ -48,6 +47,6 @@ export const ReportingNFCDanger = (data) => export const UploadFiles = (formData) => request.upload("/api/App/UploadFiles", formData); -// 上传 -export const UploadArea = (data) => - request.post("/api/App/UploadArea", data); +// 修改上传接口定义 +export const UploadArea = (fileList, formData) => + request.upload("/api/App/UploadArea", fileList, formData); diff --git a/pages/index/uploadPhoto.vue b/pages/index/uploadPhoto.vue index c4f5414..27b40c3 100644 --- a/pages/index/uploadPhoto.vue +++ b/pages/index/uploadPhoto.vue @@ -180,22 +180,13 @@ export default { return; } - const params = { - id: this.params.areaId, - note: this.remark, - }; - - const formData = new FormData(); - formData.append("id", this.params.areaId); - formData.append("note", this.remark); - for (const file of this.imageList) { - formData.append("files", file); - } - - console.log("提交表单", params); - console.log("提交表单", picturesDto, this.remark); - - const res = await UploadArea(formData); + const res = await UploadArea( + this.imageList, // 文件路径数组 + { + id: this.params.areaId, + note: this.remark, + } + ); if (res.succeed) { // 成功的处理 diff --git a/utils/request.js b/utils/request.js index 57c13ea..98b9ca0 100644 --- a/utils/request.js +++ b/utils/request.js @@ -45,16 +45,17 @@ const baseRequest = async (url, method, data = {}, loading = true) => { reslove(res); } } else { - if(successData.statusCode === 401){ - console.log(successData,'successData--') - console.log('%c%s', 'color:red', '登录过期') + if (successData.statusCode === 401) { + console.log(successData, "successData--"); + console.log("%c%s", "color:red", "登录过期"); uni.showModal({ title: "提示", content: "登陆过期,请重新登陆", showCancel: false, success: function (res) { let u = navigator.userAgent; - let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android + let isAndroid = + u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android // let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios try { if (isAndroid && AndroidJs) { @@ -70,7 +71,9 @@ const baseRequest = async (url, method, data = {}, loading = true) => { name: "back-iphone", data: "", }; - window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // 给ios 传参 + window.webkit.messageHandlers.func.postMessage( + JSON.stringify(reqRow) + ); // 给ios 传参 } } catch (e) { console.log(e, "e-----判断安卓苹果类型出错"); @@ -78,7 +81,7 @@ const baseRequest = async (url, method, data = {}, loading = true) => { }, }); reject(res); - return + return; } console.log("网络连接失败,请稍后重试", url); toast("网络连接失败,请稍后重试"); @@ -94,8 +97,8 @@ const baseRequest = async (url, method, data = {}, loading = true) => { }); }; -// 添加文件上传的基础方法 -const baseUpload = async (api, filePath, formData = {}, loading = true) => { +// 修改基础上传方法以支持多文件 +const baseUpload = async (api, fileList, formData = {}, loading = true) => { if (loading) { uni.showLoading({ title: "上传中...", @@ -109,14 +112,14 @@ const baseUpload = async (api, filePath, formData = {}, loading = true) => { return new Promise((resolve, reject) => { uni.uploadFile({ url: BASE_URL + api, - filePath: filePath, - name: "Files", // 文件对应的 key - formData: formData, + files: fileList.map((filePath) => ({ + name: "Files", + uri: filePath, + })), + formData: formData, // 额外的表单数据 header: header, success: (res) => { if (loading) uni.hideLoading(); - - // 处理响应数据 if (res.statusCode === 200) { const data = JSON.parse(res.data); if (data.succeed) { @@ -147,8 +150,8 @@ const baseUpload = async (api, filePath, formData = {}, loading = true) => { const request = {}; // 将 upload 方法添加到 request 对象中 -request.upload = (api, filePath, formData, loading) => - baseUpload(api, filePath, formData, loading); +request.upload = (api, fileList, formData, loading) => + baseUpload(api, fileList, formData, loading); ["options", "get", "post", "put", "head", "delete", "trace", "connect"].forEach( (method) => { From b306ba4cdb441aa0fafafcf9edf1bd14d33175d3 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Fri, 11 Apr 2025 17:24:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=BF=9D=E6=B4=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apiList.js | 7 ++--- api/env.js | 6 ++-- pages/index/cleanDetails.vue | 54 +++++++++++++++++++++++------------- pages/index/cleanPlan.vue | 22 +++++++++++++-- pages/index/uploadPhoto.vue | 26 ++++++++++------- 5 files changed, 76 insertions(+), 39 deletions(-) diff --git a/api/apiList.js b/api/apiList.js index 8e723d9..bb3f035 100644 --- a/api/apiList.js +++ b/api/apiList.js @@ -44,9 +44,8 @@ export const ReportingNFCDanger = (data) => request.post("/api/App/ReportingNFCDanger", data); // 上传图片 -export const UploadFiles = (formData) => - request.upload("/api/App/UploadFiles", formData); +export const UploadFiles = (fileList, params) => + request.upload("/api/App/UploadFiles", fileList, params); // 修改上传接口定义 -export const UploadArea = (fileList, formData) => - request.upload("/api/App/UploadArea", fileList, formData); +export const UploadArea = (data) => request.post("/api/App/UploadArea", data); diff --git a/api/env.js b/api/env.js index e37f13e..5baa9a0 100644 --- a/api/env.js +++ b/api/env.js @@ -2,10 +2,12 @@ let BASE_URL //开发环境中 if (process.env.NODE_ENV === 'development') { // 开发环境 - BASE_URL = 'http://10.30.2.228:8556' //开发环境请求地址 + // BASE_URL = 'http://10.30.2.228:8556' //开发环境请求地址 + BASE_URL = 'http://sl.vrgon.com:8005' //开发环境请求地址 } else { // 生产环境 - BASE_URL = 'http://10.30.2.228:8556' //生成环境请求地址 + // BASE_URL = 'http://10.30.2.228:8556' //生成环境请求地址 + BASE_URL = 'http://sl.vrgon.com:8005' //生成环境请求地址 } export default BASE_URL \ No newline at end of file diff --git a/pages/index/cleanDetails.vue b/pages/index/cleanDetails.vue index 0963690..5b5c714 100644 --- a/pages/index/cleanDetails.vue +++ b/pages/index/cleanDetails.vue @@ -2,64 +2,78 @@ - 保洁区域名称 - 所在区域:学校操场 + {{ dataInfo.name }} + 所属计划:{{ dataInfo.planName }} 区域详情 - 室内/室外 + {{ dataInfo.areaType }} 区域类型 - 保洁员1号 + {{ dataInfo.userName }} 保洁人员 - 2024/1/27 9:53:35 + {{ dataInfo.cleanTime }} 清扫时间 - 清扫完成 + {{ dataInfo.note }} 备注 保洁区域图片 - + mode="scaleToFill" + style="width: 180rpx; height: 180rpx; border-radius: 18rpx" + :src="BASE_URL + '/uploads/' + v.path" + >