Commit 6cc13f41 by LJM

修复api

parent cf08ab1b
......@@ -178,14 +178,16 @@
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
var self = this;
var time = parseInt(new Date().getTime() / 1000);
uni.chooseImage({
uni.chooseMedia({
count: 4,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
const tempFilePaths = chooseImageRes.tempFiles;
let maxNum = tempFilePaths.length * 1 + self.form.check_in_pic.length * 1;
if (maxNum > 4) {
uni.hideLoading();
......@@ -195,10 +197,9 @@
return false;
}
for (let i = 0; i < tempFilePaths.length; i++) {
console.log(tempFilePaths[i]);
uni.uploadFile({
url: API.upload,
filePath: tempFilePaths[i],
filePath: tempFilePaths[i].tempFilePath,
name: 'upload',
formData: {
source: '1',
......@@ -208,7 +209,6 @@
success: uploadFileRes => {
uni.hideLoading();
var data = JSON.parse(uploadFileRes.data);
console.log(data);
if (data.code === 200) {
self.form.check_in_pic.push(data.data[0]);
} else {
......@@ -220,7 +220,6 @@
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
......
......@@ -171,20 +171,20 @@
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
uni.chooseMedia({
count: this.maxNum,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
const imagePaths = chooseImageRes.tempFiles;
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
......@@ -201,7 +201,7 @@
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
src: imagePath.tempFilePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment