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) {
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;

View File

@ -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);

View File

@ -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) {