国际研讨会照片 ppt的上传

This commit is contained in:
fengachen
2021-10-17 22:09:25 +08:00
parent 8b857e467b
commit c6f744eacf
5 changed files with 213 additions and 140 deletions
+43 -33
View File
@@ -1,4 +1,9 @@
// components/imageUpload/imageUpload.js
import {
baseUrl,
URL_CONFIG
} from "../../assets/js/http/api"
Component({
/**
* 组件的属性列表
@@ -34,7 +39,9 @@ Component({
let maxSize = this.data.maxSize * 1024 * 1024
let flag = true
let maxLength = this.data.maxLength
console.log("maxLength",maxLength);
// 将图片的id抛出
let imgids = []
console.log("maxLength", maxLength);
wx.chooseImage({
count: maxLength, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
@@ -63,7 +70,7 @@ Component({
flag = false
wx.showModal({
title: '错误提示',
content: `图片大于${that.data.maxSize}M`,
content: `图片大于${that.data.maxSize}MB`,
showCancel: false,
success(res) {
if (res.confirm) {
@@ -84,37 +91,40 @@ Component({
/**
* 上传完成后把文件上传到服务器
*/
// if (flag) {
// let count = 0;
// for (let i = 0; i < tempFilePaths.length; i++) {
// //上传文件
// wx.uploadFile({
// url: 'imgUploadUrl',
// filePath: tempFilePaths[i],
// name: 'uploadfile_ant',
// header: {
// "Content-Type": "multipart/form-data"
// },
// success: function (res) {
// console.log("上传图片", res);
// count++;
// //如果是最后一张,则隐藏等待中
// if (count == tempFilePaths.length) {
// wx.hideToast();
// }
// },
// fail: function (res) {
// wx.hideToast();
// wx.showModal({
// title: '错误提示',
// content: '上传图片失败',
// showCancel: false,
// success: function (res) {}
// })
// }
// });
// }
// }
if (flag) {
let count = 0;
for (let i = 0; i < tempFilePaths.length; i++) {
//上传文件
wx.uploadFile({
url: baseUrl + URL_CONFIG + 'sys/common/upload',
filePath: tempFilePaths[i],
name: "file",
formData: {
filetype: "image",
},
success: function (res) {
imgids.push(JSON.parse(res.data).result.id)
count++;
//如果是最后一张,则隐藏等待中
if (count == tempFilePaths.length) {
wx.hideToast();
that.triggerEvent("getIds",imgids)
}
},
fail: function (res) {
wx.hideToast();
wx.showModal({
title: '错误提示',
content: '上传图片失败',
showCancel: false,
success: function (res) {}
})
}
});
}
}
},
fail(err) {