wesmiler 6 lat temu
rodzic
commit
51b9eabe7e
1 zmienionych plików z 18 dodań i 7 usunięć
  1. 18 7
      public/static/weixin/js/photo.js

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

@@ -470,14 +470,16 @@ var app = new Vue({
             $("body").css('overflowY','hidden');
             // $("#cropImg").remove();
             $(".crop-img").html('<img id="cropImg" src="" alt="" off="">');
-            var iWidth = $(".crop-img").outerWidth();
+            var iWidth = $("body").outerWidth();
             var iHeight = $(".crop-img").outerHeight();
+            iHeight = iHeight? iHeight : $("body").outerHeight()-130;
             if(id>=0){
                 $("#cropImg").attr('src', _this.cropParams.old_url);
             }else{
                 $("#cropImg").attr('src', _this.cropParams.url);
             }
             $image = $("#cropImg");
+            console.log(iWidth+'++'+iHeight);
             var cropWidth = $('body').width();
             $("#cropBox").popup();
             _this.options = {
@@ -524,8 +526,8 @@ var app = new Vue({
                         var height = data.height;
                     }
                     _this.cropParams.cropData = {
-                        width: iWidth*30,
-                        height: iHeight*30,
+                        width: iWidth*10,
+                        height: iHeight*10,
                         rotate: data.rotate,
                         imageSmoothingQuality: 'high',
                         fillColor: '#fff',
@@ -605,14 +607,22 @@ var app = new Vue({
         cropSize: function(){
             var _this = this;
             var data = _this.cropParams.data;
-            if(data.height<data.width){
+            var image = new Image();
+            image.src = _this.cropParams.url;
+            var width = image.width;
+            var height = image.height;
+            if(height<width){
                 $("#cropImg").cropper("rotate", 90);
             }
             var cwidth = $(".cropper-canvas").outerWidth();
+
+            console.log(data);
             // var cheight = $(".cropper-canvas").outerHeight();
             var size = data.height<data.width? data.height: data.width;
-            var iWidth = $(".crop-img").outerWidth();
-            var iHeight = $(".crop-img").outerHeight();
+            var iWidth = $("body").outerWidth();
+            var iHeight = $("body").outerHeight()-130;
+            /*var iWidth = $(".cropper-canvas").outerWidth();
+            var iHeight = $(".cropper-canvas").outerHeight();*/
             if(size<iWidth){
                 var rate = iWidth/size;
                 $("#cropImg").cropper("zoom", rate);
@@ -627,7 +637,7 @@ var app = new Vue({
         // 确定剪切
         cropConfirm: function () {
             var _this = this;
-            $.closePopup();
+
             $("body").css('overflowY','scroll');
             $(".crop-img").show();
             this.cropPreviewStatus = false;
@@ -640,6 +650,7 @@ var app = new Vue({
                 var canvas = $image.cropper('getCroppedCanvas',_this.cropParams.cropData);
                 console.log($image);
                 var url = canvas.toBlob(function (e) {
+                    $.closePopup();
                     console.log(e);  //生成Blob的图片格式
                     if (e != null) {
                         var timestamp = Date.parse(new Date());