微信选取图片api调整

This commit is contained in:
donqi 2023-11-29 22:05:04 +08:00
parent ca8ddc2446
commit 2cf2c98e5d
9 changed files with 63 additions and 39 deletions

View File

@ -711,10 +711,9 @@
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
console.log(res)
// //
res.tempFilePaths.forEach((tmpPath) => { res.tempFiles.forEach((fileObj) => {
this.$request.uploadFile(tmpPath).then((url) => { this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
// //
imgList.push(url); imgList.push(url);
}); });

View File

@ -531,14 +531,15 @@
this.specialSkill[index].insurEndDate = e[1]; this.specialSkill[index].insurEndDate = e[1];
}, },
async chooseImage(e, imgList) { async chooseImage(e, imgList) {
uni.chooseImage({ uni.chooseMedia({
count: 1, //9 count: 1, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
// //
res.tempFilePaths.forEach((tmpPath) => { res.tempFiles.forEach((fileObj) => {
this.$request.uploadFile(tmpPath).then((url) => { this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
// //
imgList.push(url); imgList.push(url);
}); });

View File

@ -744,13 +744,14 @@
chooseImgList(e, imgListField, cropWidth, cropHeight) { chooseImgList(e, imgListField, cropWidth, cropHeight) {
this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2; this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2;
this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.15; this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.15;
uni.chooseImage({ uni.chooseMedia({
count: 1, //9 count: 1, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
res.tempFilePaths.forEach((tmpUrl, index) => { res.tempFiles.forEach((fileObj, index) => {
this.url2Crop = tmpUrl; this.url2Crop = fileObj.tempFilePath;
this.curImgListField = imgListField; this.curImgListField = imgListField;
}); });
} }
@ -773,8 +774,9 @@
this.url2Crop = ""; this.url2Crop = "";
}, },
chooseImgNoCrop(e, imgListField) { chooseImgNoCrop(e, imgListField) {
uni.chooseImage({ uni.chooseMedia({
count: 9, //9 count: 9, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
@ -782,10 +784,10 @@
title: '上传中', title: '上传中',
mask: true mask: true
}); });
res.tempFilePaths.forEach((tmpUrl, index) => { res.tempFiles.forEach((fileObj, index) => {
this.$request.uploadFile(tmpUrl).then((url) => { this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
this.formData[imgListField].push(url); this.formData[imgListField].push(url);
if (index === res.tempFilePaths.length - 1) { if (index === res.tempFiles.length - 1) {
uni.hideLoading(); uni.hideLoading();
} }
}); });

View File

@ -108,15 +108,20 @@
}) })
}, },
chooseImage(e) { chooseImage(e) {
uni.chooseImage({ uni.chooseMedia({
count: 9, //9 count: 9, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
let tempFilePaths = [];
res.tempFiles.forEach((fileObj) => {
tempFilePaths.push(fileObj.tempFilePath)
})
if (this.imgList.length != 0) { if (this.imgList.length != 0) {
this.imgList = this.imgList.concat(res.tempFilePaths) this.imgList = this.imgList.concat(tempFilePaths)
} else { } else {
this.imgList = res.tempFilePaths this.imgList = tempFilePaths
} }
} }
}); });

View File

@ -99,15 +99,20 @@
}, },
methods: { methods: {
chooseImgList(e) { chooseImgList(e) {
uni.chooseImage({ uni.chooseMedia({
count: 9, //9 count: 9, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
let tempFilePaths = [];
res.tempFiles.forEach((fileObj) => {
tempFilePaths.push(fileObj.tempFilePath)
})
if (this.formData.imgList.length != 0) { if (this.formData.imgList.length != 0) {
this.formData.imgList = this.formData.imgList.concat(res.tempFilePaths) this.formData.imgList = this.formData.imgList.concat(tempFilePaths)
} else { } else {
this.formData.imgList = res.tempFilePaths this.formData.imgList = tempFilePaths
} }
} }
}); });

View File

@ -96,8 +96,9 @@
this.order = orderInfo; this.order = orderInfo;
}, },
chooseImgList(e, imgList) { chooseImgList(e, imgList) {
uni.chooseImage({ uni.chooseMedia({
count: 12 - imgList.length, //9 count: 12 - imgList.length, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
@ -105,10 +106,10 @@
title: '上传中', title: '上传中',
mask: true mask: true
}); });
res.tempFilePaths.forEach((tmpUrl, index) => { res.tempFiles.forEach((fileObj, index) => {
this.$request.uploadFile(tmpUrl).then((url) => { this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
imgList.push(url); imgList.push(url);
if (index === res.tempFilePaths.length - 1) { if (index === res.tempFiles.length - 1) {
uni.hideLoading(); uni.hideLoading();
} }
}); });

View File

@ -91,8 +91,9 @@
this.reasonType = e.detail.value; this.reasonType = e.detail.value;
}, },
chooseImgList(e, imgList) { chooseImgList(e, imgList) {
uni.chooseImage({ uni.chooseMedia({
count: 3 - imgList.length, //9 count: 3 - imgList.length, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
@ -100,10 +101,10 @@
title: '上传中', title: '上传中',
mask: true mask: true
}); });
res.tempFilePaths.forEach((tmpUrl, index) => { res.tempFiles.forEach((fileObj, index) => {
this.$request.uploadFile(tmpUrl).then((url) => { this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
imgList.push(url); imgList.push(url);
if (index === res.tempFilePaths.length - 1) { if (index === res.tempFiles.length - 1) {
uni.hideLoading(); uni.hideLoading();
} }
}); });

View File

@ -79,15 +79,20 @@
uni.$emit(this.$globalFun.HIDE_MODAL, e); uni.$emit(this.$globalFun.HIDE_MODAL, e);
}, },
chooseImage(e) { chooseImage(e) {
uni.chooseImage({ uni.chooseMedia({
count: 1, //9 count: 1, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
let tempFilePaths = [];
res.tempFiles.forEach((fileObj) => {
tempFilePaths.push(fileObj.tempFilePath)
})
if (this.imgList.length != 0) { if (this.imgList.length != 0) {
this.imgList = this.imgList.concat(res.tempFilePaths) this.imgList = this.imgList.concat(tempFilePaths)
} else { } else {
this.imgList = res.tempFilePaths this.imgList = tempFilePaths
} }
} }
}); });

View File

@ -73,15 +73,20 @@
this.toWho = toWho; this.toWho = toWho;
}, },
chooseImgList(e) { chooseImgList(e) {
uni.chooseImage({ uni.chooseMedia({
count: 9, //9 count: 9, //9
mediaType: ['image'],
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
sourceType: ['album'], // sourceType: ['album'], //
success: (res) => { success: (res) => {
let tempFilePaths = [];
res.tempFiles.forEach((fileObj) => {
tempFilePaths.push(fileObj.tempFilePath);
})
if (this.imgList.length != 0) { if (this.imgList.length != 0) {
this.imgList = this.imgList.concat(res.tempFilePaths) this.imgList = this.imgList.concat(tempFilePaths)
} else { } else {
this.imgList = res.tempFilePaths this.imgList = tempFilePaths
} }
} }
}); });