【微信小程序】裁剪头像插件

用户上传头像,需要裁剪成正方形,之前在网上找到的不好用,有bug,自己动手写了一个,欢迎来找bug。没bug那咱们就放心用吧。

2022-11-07新增:图片裁剪框外背景移动和停止的时候加了不同的背景透明度。

参数介绍:

imageUrl:需要裁剪的图片链接
show:是否显示裁剪图片组件

wxml调用:

<avatar-cropper imageUrl="{
    {image_url}}" bind:returnImageUrl="returnImageUrl"  show="{
    {showCutImage}}" ></avatar-cropper>

js调用:

returnImageUrl: function (e) {
   
	//e.detail.imageUrl,e.detail.showCutImage  
}

wxml代码:

<view class="container" wx:if="{
    {show}}">
  <view class="top {
    {moving?'bg-5':'bg-9'}}" style="height:{
       {
       (systemInfo.windowHeight-300)/2}}px;"></view>
  <view class="left {
    {moving?'bg-5':'bg-9'}}" style="width: {
       {
       (systemInfo.windowWidth-300)/2}}px;top: {
       {
       (systemInfo.windowHeight-300)/2}}px;height: 300px;"></view>
  <view class="right {
    {moving?'bg-5':'bg-9'}}" style="width: {
       {
       (systemInfo.windowWidth-300)/2}}px;top: {
       {
       (systemInfo.windowHeight-300)/2}}px;height: 300px;"></view>
  <view class="bottom {
    {moving?'bg-5':'bg-9'}}" style="top:{
       {
       (systemInfo.windowHeight-300)/2+300}}px;"></view>
  <canvas canvas-id="myCanvas" class="canvas">
    
  </canvas>
  <movable-area scale-area class="movable-area" style="top: {
       {
       (systemInfo.windowHeight-300)/2}}px;left
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值