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}}