收藏
回答

如何选择图片进行裁剪后上传到云存储空间,重点是裁剪功能怎么实现?

本地选择上传的功能已经实现,图片大小如何控制正方形等裁剪,就像微信头像显示的比例布局

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

            })

          },


回答关注问题邀请回答
收藏

1 个回答

  • 维她命系
    维她命系
    2020-06-03

    搜索一下好多这种开源的项目,一般是用canvas实现。

    2020-06-03
    有用
    回复
登录 后发表内容
问题标签