wesmiler 6 years ago
parent
commit
2da4f8e376
1 changed files with 7 additions and 7 deletions
  1. 7 7
      public/static/weixin/js/photo.js

+ 7 - 7
public/static/weixin/js/photo.js

@@ -467,7 +467,7 @@ var app = new Vue({
                 return false;
             }
             $("body").css('overflowY','hidden');
-            $("#cropImg").remove();
+            // $("#cropImg").remove();
             $(".crop-img").html('<img id="cropImg" src="" alt="" off="">');
             var iWidth = $(".crop-img").outerWidth();
             var iHeight = $(".crop-img").outerHeight();
@@ -510,7 +510,7 @@ var app = new Vue({
                 viewMode: 1,
                 ready: function(data){
                     _this.cropParams.data = data;
-                    $image.cropper('setCropBoxData',{width: iWidth, height: iHeight});
+                    // $image.cropper('setCropBoxData',{width: iWidth, height: iHeight});
                     consoel.log(data);
                 },
                 crop: function (data) {
@@ -523,8 +523,8 @@ var app = new Vue({
                         var height = data.height;
                     }
                     _this.cropParams.cropData = {
-                        width: width * 10,
-                        height: height * 10,
+                        width: iWidth * 20,
+                        height: iHeight * 20,
                         rotate: data.rotate,
                         fillColor: '#fff',
                     };
@@ -603,7 +603,6 @@ var app = new Vue({
         cropSize: function(){
             var _this = this;
             var data = _this.cropParams.data;
-            console.log(_this.cropParams);
             if(data.height<data.width){
                 $("#cropImg").cropper("rotate", 90);
             }
@@ -620,8 +619,7 @@ var app = new Vue({
                 $("#cropImg").cropper("zoom", rate);
             }
 
-            var continerData = $("#cropImg").cropper('getContainerData');
-            $("#cropImg").cropper('setCropBoxData',{width: continerData.width, height: continerData.height});
+            $("#cropImg").cropper('setCropBoxData',{width: iWidth, height: iHeight,top: 0});
 
         },
         // 确定剪切
@@ -635,7 +633,9 @@ var app = new Vue({
                 $.showLoading('图片处理中...');
                 var id = _this.cropParams.id;
                 $image = $("#cropImg");
+                console.log(_this.cropParams)
                 var canvas = $image.cropper('getCroppedCanvas',_this.cropParams.cropData);
+                console.log($image);
                 var url = canvas.toBlob(function (e) {
                     console.log(e);  //生成Blob的图片格式
                     if (e != null) {