// 选择图片
addphoto: function () {
var that = this;
wx.chooseImage({
count: 3,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
that.setData({
pho: res.tempFilePaths
})
},
})
},
//确认无误后上传图片和信息到服务器
formSubmit: function (e) {
var photos = [];
var that = this;
var tempF = this.data.pho;
tempF.map(function (me) {
new AV.File('image', {
blob: {
uri: me,
},
}).save().then(function (file) {
console.log(file.attributes.url)
photos.push(file.attributes.url)
that.setData({
photos: photos
})
}
)
});
setTimeout(function(){
var Todo = AV.Object.extend('Todo');
var todo = new Todo();
todo.set('content',e.detail.value.content);
todo.set('imagePath',photos);
todo.save().then(function (todo) {
console.log('123')
}, function (error){ })},5000)
}
图片小的时候,没问题,可3张图片的大小在7-8兆就出问题,有时候只上传1张,就执行存储到服务器了。