From 9c036bf3c8a2317185e2b1697c79dd7129a893e8 Mon Sep 17 00:00:00 2001 From: yaoyilin Date: Sat, 5 Nov 2022 11:30:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=89=AA=E8=A3=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复图片上传组件剪裁问题 --- app/widget/upload.go | 6 ++++-- views/includes/user/user_edit.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/widget/upload.go b/app/widget/upload.go index 76db75d..5640398 100644 --- a/app/widget/upload.go +++ b/app/widget/upload.go @@ -7,6 +7,7 @@ package widget import ( + "fmt" "gitlab.52pay.top/go/easygoadmin/utils/gconv" "html/template" "reflect" @@ -45,7 +46,8 @@ func UploadImage(param string, url interface{}, exts string, size int) template. // 计算长宽比例 cropArr := strings.Split(cropSize, "x") // 裁剪比例 - cropRate := gconv.Int(cropArr[0]) / gconv.Int(cropArr[1]) + cropRate := float64(gconv.Int(cropArr[0])) / float64(gconv.Int(cropArr[1])) + cropRateStr := fmt.Sprintf("%2f", cropRate) // 上传后缀 if exts == "" { @@ -114,7 +116,7 @@ layui.use(['upload','croppers'],function(){ ,name:"` + name + `" ,saveW:` + cropArr[0] + ` //保存宽度 ,saveH:` + cropArr[1] + ` - ,mark:` + gconv.String(cropRate) + ` //选取比例 + ,mark:` + cropRateStr + ` //选取比例 ,area:['750px','500px'] //弹窗宽度 ,url: "/upload/uploadImage" ,done: function(url){ diff --git a/views/includes/user/user_edit.html b/views/includes/user/user_edit.html index d0c9b36..e39fb06 100644 --- a/views/includes/user/user_edit.html +++ b/views/includes/user/user_edit.html @@ -121,4 +121,4 @@ {{submit "submit|立即保存,close|关闭" 1 ""}} -{{end}} \ No newline at end of file +{{end}}