feat: 上传图片调试

This commit is contained in:
yangzhe 2025-04-30 09:24:41 +08:00
parent ce75f9b8f6
commit aa6e56c556
3 changed files with 70 additions and 23 deletions

View File

@ -220,12 +220,12 @@ export default {
if (!data) { if (!data) {
return uni.showToast({ title: "未传入参数 initFn", icon: "none" }); return uni.showToast({ title: "未传入参数 initFn", icon: "none" });
} }
uni.showModal({ // uni.showModal({
title: "开发调试查看nimei", // title: "nimei",
content: JSON.stringify(data) || "未传入参数 initFn", // content: JSON.stringify(data) || " initFn",
showCancel: true, // showCancel: true,
success: function (res) {}, // success: function (res) {},
}); // });
let cardID = data.cardID; let cardID = data.cardID;
// let nimei = data.nimei; // let nimei = data.nimei;
let nimei = data.uuid; let nimei = data.uuid;

View File

@ -204,12 +204,14 @@ export default {
name: "back-iphone", name: "back-iphone",
data: "", data: "",
}; };
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // ios window.webkit.messageHandlers.func.postMessage(
JSON.stringify(reqRow)
); // ios
} }
} catch (e) { } catch (e) {
console.log(e, "e-----判断安卓苹果类型出错"); console.log(e, "e-----判断安卓苹果类型出错");
} }
return return;
uni.chooseImage({ uni.chooseImage({
count: 1, // 1 count: 1, // 1
sourceType: ["camera"], // sourceType: ["camera"], //
@ -226,18 +228,18 @@ export default {
}); });
}, },
// android // android
uploadResFn(data){ uploadResFn(data) {
if (!data) { if (!data) {
return uni.showToast({ title: "未传入参数 uploadFn", icon: "none" }); return uni.showToast({ title: "未传入参数 uploadFn", icon: "none" });
} }
uni.showModal({ // uni.showModal({
title: "查看uploadFn", // title: "uploadFn",
content: JSON.stringify(data) || "未传入参数 initFn", // content: JSON.stringify(data) || " initFn",
showCancel: true, // showCancel: true,
success: function (res) {}, // success: function (res) {},
}); // });
// this.form.url = data.path this.form.url = data.path;
}, },
// //
@ -263,8 +265,8 @@ export default {
return; return;
} }
const res = await UploadFiles([this.form.url]); // const res = await UploadFiles([this.form.url]);
if (!res.succeed) return; // if (!res.succeed) return;
const params = { const params = {
note: this.form.note, note: this.form.note,
@ -272,7 +274,8 @@ export default {
reportingTime: this.reportingTime.replace(" ", "T"), reportingTime: this.reportingTime.replace(" ", "T"),
userId: this.dataInfo.userId, userId: this.dataInfo.userId,
id: this.dataInfo.id, id: this.dataInfo.id,
url: res.data[0].path, // url: res.data[0].path,
url: this.form.url,
}; };
const res1 = await ReportingNFCDanger(params); const res1 = await ReportingNFCDanger(params);

View File

@ -119,6 +119,7 @@ export default {
onLoad(options) { onLoad(options) {
console.log("options", JSON.parse(decodeURIComponent(options.params))); console.log("options", JSON.parse(decodeURIComponent(options.params)));
this.params = JSON.parse(decodeURIComponent(options.params)); this.params = JSON.parse(decodeURIComponent(options.params));
window.uploadFn = this.uploadResFn;
}, },
created() {}, created() {},
methods: { methods: {
@ -138,6 +139,32 @@ export default {
// //
takePhoto() { 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({ uni.chooseImage({
count: 1, // 1 count: 1, // 1
sourceType: ["camera"], // 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() { async uploadFiles() {
const res = await UploadFiles(this.imageList); const res = await UploadFiles(this.imageList);
@ -186,9 +228,11 @@ export default {
picturesDto: [], picturesDto: [],
}; };
const res = await UploadFiles(this.imageList); // const res = await UploadFiles(this.imageList);
if (!res.succeed) return; // if (!res.succeed) return;
params.picturesDto = res.data; // params.picturesDto = res.data;
params.picturesDto = this.imageList;
const res2 = await UploadArea(params); const res2 = await UploadArea(params);
if (res2.succeed) { if (res2.succeed) {