fix: 修复图片上传组件剪裁问题

修复图片上传组件剪裁问题
This commit is contained in:
yaoyilin
2022-11-05 11:30:52 +08:00
parent 3e05c5b3a0
commit 9c036bf3c8
2 changed files with 5 additions and 3 deletions

View File

@@ -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){