Commit 6cc13f41 by LJM

修复api

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