wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
console.log(res)
wx.showToast({
title: '图片已上传',
icon: 'success',
image: '',
duration: 3000,
})
this.setData
var tempFilePath = res.tempFilePaths[0];
new AV.File('banner', {
blob: {
uri: tempFilePath,
},
})
.save().then(function (file) {
console.log(file.url());
var banner = file.url()
product.set('banner', file.url());
var currentUser = AV.User.current();
product.set('owner', AV.User.current());
product.save().then(function (product) {
console.log(product.id)
})
},
) .catch(console.error);
},
});
},