diff --git a/pages/index/cleanPlan.vue b/pages/index/cleanPlan.vue index a1473ac..43ea568 100644 --- a/pages/index/cleanPlan.vue +++ b/pages/index/cleanPlan.vue @@ -220,12 +220,12 @@ export default { if (!data) { return uni.showToast({ title: "未传入参数 initFn", icon: "none" }); } - uni.showModal({ - title: "开发调试查看nimei", - content: JSON.stringify(data) || "未传入参数 initFn", - showCancel: true, - success: function (res) {}, - }); + // uni.showModal({ + // title: "开发调试查看nimei", + // content: JSON.stringify(data) || "未传入参数 initFn", + // showCancel: true, + // success: function (res) {}, + // }); let cardID = data.cardID; // let nimei = data.nimei; let nimei = data.uuid; diff --git a/pages/index/list.vue b/pages/index/list.vue index d4ed42b..aa8d79b 100644 --- a/pages/index/list.vue +++ b/pages/index/list.vue @@ -204,12 +204,14 @@ export default { 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-----判断安卓苹果类型出错"); } - return + return; uni.chooseImage({ count: 1, // 每次拍摄1张 sourceType: ["camera"], // 仅限拍照 @@ -226,18 +228,18 @@ export default { }); }, // android回调 - uploadResFn(data){ + uploadResFn(data) { if (!data) { return uni.showToast({ title: "未传入参数 uploadFn", icon: "none" }); } - uni.showModal({ - title: "查看uploadFn", - content: JSON.stringify(data) || "未传入参数 initFn", - showCancel: true, - success: function (res) {}, - }); - - // this.form.url = data.path + // uni.showModal({ + // title: "查看uploadFn", + // content: JSON.stringify(data) || "未传入参数 initFn", + // showCancel: true, + // success: function (res) {}, + // }); + + this.form.url = data.path; }, // 删除图片 @@ -263,8 +265,8 @@ export default { return; } - const res = await UploadFiles([this.form.url]); - if (!res.succeed) return; + // const res = await UploadFiles([this.form.url]); + // if (!res.succeed) return; const params = { note: this.form.note, @@ -272,7 +274,8 @@ export default { reportingTime: this.reportingTime.replace(" ", "T"), userId: this.dataInfo.userId, id: this.dataInfo.id, - url: res.data[0].path, + // url: res.data[0].path, + url: this.form.url, }; const res1 = await ReportingNFCDanger(params); diff --git a/pages/index/uploadPhoto.vue b/pages/index/uploadPhoto.vue index ed3aa0e..e94c311 100644 --- a/pages/index/uploadPhoto.vue +++ b/pages/index/uploadPhoto.vue @@ -119,6 +119,7 @@ export default { onLoad(options) { console.log("options", JSON.parse(decodeURIComponent(options.params))); this.params = JSON.parse(decodeURIComponent(options.params)); + window.uploadFn = this.uploadResFn; }, created() {}, methods: { @@ -138,6 +139,32 @@ export default { // 拍照获取图片 takePhoto() { + let u = navigator.userAgent; + 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) { + console.log("%c%s", "color:red", "安卓--调用方法"); + const reqRow = { + name: "upload", + data: "", + }; + AndroidJs.func(JSON.stringify(reqRow)); // 给安卓传参 + } else { + console.log("%c%s", "color:red", "苹果--调用方法"); + const reqRow = { + name: "back-iphone", + data: "", + }; + window.webkit.messageHandlers.func.postMessage( + JSON.stringify(reqRow) + ); // 给ios 传参 + } + } catch (e) { + console.log(e, "e-----判断安卓苹果类型出错"); + } + + return; uni.chooseImage({ count: 1, // 每次拍摄1张 sourceType: ["camera"], // 仅限拍照 @@ -152,6 +179,21 @@ export default { }); }, + // android回调 + uploadResFn(data) { + if (!data) { + return uni.showToast({ title: "未传入参数 uploadFn", icon: "none" }); + } + // uni.showModal({ + // title: "查看uploadFn", + // content: JSON.stringify(data) || "未传入参数 initFn", + // showCancel: true, + // success: function (res) {}, + // }); + + this.imageList = [...this.imageList, data.path]; + }, + // 上传图片 async uploadFiles() { const res = await UploadFiles(this.imageList); @@ -186,9 +228,11 @@ export default { picturesDto: [], }; - const res = await UploadFiles(this.imageList); - if (!res.succeed) return; - params.picturesDto = res.data; + // const res = await UploadFiles(this.imageList); + // if (!res.succeed) return; + // params.picturesDto = res.data; + + params.picturesDto = this.imageList; const res2 = await UploadArea(params); if (res2.succeed) {