wesmiler %!s(int64=6) %!d(string=hai) anos
pai
achega
b091e0db06
Modificáronse 1 ficheiros con 61 adicións e 58 borrados
  1. 61 58
      public/static/weixin/js/photo.js

+ 61 - 58
public/static/weixin/js/photo.js

@@ -113,73 +113,76 @@ var app = new Vue({
                 var id = $(this).attr('data-id');
 			    var opts = {
 			        scale: 12, // 添加的scale 参数
-			        width: 119,
-			        height: 169,
+			        // width: 119,
+			        // height: 169,
 			        background: '#fff',
 			    };
                 
-                html2canvas($previewImg, opts).then( function (canvas) {
-                        const context = canvas.getContext('2d');
-                        context.mozImageSmoothingEnabled = false;
-                        context.webkitImageSmoothingEnabled = false;
-                        context.msImageSmoothingEnabled = false;
-                        context.imageSmoothingEnabled = false;
+                setTimeout(function(){
+                    html2canvas($previewImg, opts).then( function (canvas) {
+                            const context = canvas.getContext('2d');
+                            context.translate(0.5,0.5);
+                            context.mozImageSmoothingEnabled = false;
+                            context.webkitImageSmoothingEnabled = false;
+                            context.msImageSmoothingEnabled = false;
+                            context.imageSmoothingEnabled = false;
 
-                        var src = canvas.toDataURL('image/jpeg');
-                        var file = _this.dataURLtoFile(src, name? name : '图片打印.jpeg');
-                        formData.append('type', 1);
-                        formData.append('taskKey', _this.taskKey);
-                        formData.append('image[]', file);
-                        formData.append('nums[]', num);
-                        formData.append('ids[]', id);
-                        formData.append('colors[]', colorType);
-                        count++;
+                            var src = canvas.toDataURL('image/jpeg');
+                            var file = _this.dataURLtoFile(src, name? name : '图片打印.jpeg');
+                            formData.append('type', 1);
+                            formData.append('taskKey', _this.taskKey);
+                            formData.append('image[]', file);
+                            formData.append('nums[]', num);
+                            formData.append('ids[]', id);
+                            formData.append('colors[]', colorType);
+                            count++;
 
-                        if(total <= (k+1)){
-                            if(count<=0){
-                                $.toast('请选择打印的图片');
-                                return false;
-                            }
-                            _this.submitting = true;
+                            if(total <= (k+1)){
+                                if(count<=0){
+                                    $.toast('请选择打印的图片');
+                                    return false;
+                                }
+                                _this.submitting = true;
 
-                            // 上传
-                            $.showLoading('文件上传处理中...');
-                            var ajax = $.ajax({
-                                url: '/weixin/upload/image',
-                                data: formData,
-                                type: "post",
-                                dataType: 'json',
-                                cache: false,
-                                contentType: false,
-                                processData: false,
-                                timeout: 30000,
-                                success: function (res) {
-                                    $.hideLoading();
-                                    _this.submitting = false;
-                                    if (res.code == 'success') {
-                                        _this.showModal();
-                                    } else if (res.code == 'login') {
-                                        login(res.data.url);
-                                    } else {
-                                        $.toast(res.message);
-                                    }
-                                },
-                                error: function(res){
-                                	_this.submitting = false;
-                                    $.toast('服务器错误');
-                                },
-                                complete: function (XMLHttpRequest, status) {
-                                    if(status == 'timeout'){
-                                        ajax.abort();
-                                        $.toast('请求超时,请重新提交');
-                                        location.reload();
+                                // 上传
+                                $.showLoading('文件上传处理中...');
+                                var ajax = $.ajax({
+                                    url: '/weixin/upload/image',
+                                    data: formData,
+                                    type: "post",
+                                    dataType: 'json',
+                                    cache: false,
+                                    contentType: false,
+                                    processData: false,
+                                    timeout: 30000,
+                                    success: function (res) {
+                                        $.hideLoading();
+                                        _this.submitting = false;
+                                        if (res.code == 'success') {
+                                            _this.showModal();
+                                        } else if (res.code == 'login') {
+                                            login(res.data.url);
+                                        } else {
+                                            $.toast(res.message);
+                                        }
+                                    },
+                                    error: function(res){
+                                        _this.submitting = false;
+                                        $.toast('服务器错误');
+                                    },
+                                    complete: function (XMLHttpRequest, status) {
+                                        if(status == 'timeout'){
+                                            ajax.abort();
+                                            $.toast('请求超时,请重新提交');
+                                            location.reload();
+                                        }
                                     }
-                                }
-                            })
+                                })
 
+                            }
                         }
-                    }
-                );
+                    );
+                }, 100)
             });
         },
         // 显示填写窗口