本地选择上传的功能已经实现,图片大小如何控制正方形等裁剪,就像微信头像显示的比例布局
btsImage(){
let that = this
console.log("上传imgage")
wx.chooseImage({
count:1,
sizeType:['compressed'],
sourceType:['album','camera'],
success:(res)=>{
wx.showLoading({
title: '加载中',
}),
console.log(res)
var timestamp = (new Date()).valueOf();
console.log("图片时间")
console.log(timestamp)
console.log('res.tempFilePaths[0]',res.tempFilePaths[0])
wx.cloud.uploadFile({
cloudPath:'users/image/'+app.globalData.username+'/'+timestamp,
filePath: res.tempFilePaths[0],
success:(res)=>{
console.log(res)
wx.hideLoading()
that.setData({
userimageUrl:res.fileID
})
wx.hideLoading({
complete: (res) => {},
})
wx.showToast({
title: '图片上传成功!',
duration:2000
})
},