微信选取图片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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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