diff --git a/pages/index/cleanPlan.vue b/pages/index/cleanPlan.vue index fad0b18..2e8ca1a 100644 --- a/pages/index/cleanPlan.vue +++ b/pages/index/cleanPlan.vue @@ -83,7 +83,7 @@ 刷卡成功 暂不 - 上传图片 + 上传图片 @@ -199,13 +199,20 @@ export default { } }, // 上传图片 - uploadFn() { + toUploadPage() { console.log("%c%s", "color:red", "上传图片"); + const params = { + planName: this.dataInfo.planName, + areaId: this.dataInfo.areas[this.dataInfo.areas.length - 1].id, + aeraNmae: this.dataInfo.areas[this.dataInfo.areas.length - 1].aeraNmae, + }; + console.log(params); + // 先关闭弹窗再跳转 this.successShow = false; uni.navigateTo({ - url: "/pages/index/uploadPhoto", + url: "/pages/index/uploadPhoto?params=" + encodeURIComponent(JSON.stringify(params)), }); }, // 异常上报 diff --git a/pages/index/uploadPhoto.vue b/pages/index/uploadPhoto.vue index 35100cd..c4f5414 100644 --- a/pages/index/uploadPhoto.vue +++ b/pages/index/uploadPhoto.vue @@ -36,7 +36,7 @@ - {{ areaName }} — {{ planName }} + {{ params.aeraNmae }} — {{ params.planName }} @@ -111,9 +111,15 @@ export default { // 备注 remark: "", - imageList: ["/static/images/logo.png"], // 存储图片临时路径 + imageList: [], // 存储图片临时路径 + + params: {}, }; }, + onLoad(options) { + console.log("options", JSON.parse(decodeURIComponent(options.params))); + this.params = JSON.parse(decodeURIComponent(options.params)); + }, created() {}, methods: { switchTab(tab) { @@ -137,9 +143,8 @@ export default { sourceType: ["camera"], // 仅限拍照 sizeType: ["compressed"], // 压缩图片 success: async (res) => { - console.log("拍照成功", res); - - this.uploadFiles(res.tempFilePaths[0]); + // console.log("拍照成功", res); + this.imageList = [...this.imageList, res.tempFilePaths[0]]; }, fail: (err) => { uni.showToast({ title: "拍照失败,请重试", icon: "none" }); @@ -175,19 +180,22 @@ export default { return; } - const picturesDto = this.imageList.map((item) => { - return { - path: item, - }; - }); + 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({ - id: this.id, - picturesDto: picturesDto, - note: this.remark, - }); + const res = await UploadArea(formData); if (res.succeed) { // 成功的处理