Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
5302545d
Commit
5302545d
authored
Jun 09, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 外卖商品添加图片校验
parent
4185b9b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
UploadCropImage.jsx
src/pages/ServiceGoods/components/UploadCropImage.jsx
+23
-14
No files found.
src/pages/ServiceGoods/components/UploadCropImage.jsx
View file @
5302545d
import
{
PlusOutlined
,
DeleteOutlined
,
EyeOutlined
}
from
'
@ant-design/icons
'
;
import
{
PlusOutlined
,
DeleteOutlined
,
EyeOutlined
}
from
'
@ant-design/icons
'
;
import
{
Modal
,
Upload
,
notification
,
Spin
}
from
'
antd
'
;
import
{
Modal
,
Upload
,
notification
,
Spin
}
from
'
antd
'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
forwardRef
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
forwardRef
}
from
'
react
'
;
import
{
validImageType
}
from
'
@/utils/img.valid
'
;
import
lodash
from
'
lodash
'
;
import
lodash
from
'
lodash
'
;
import
{
ReactSortable
}
from
'
react-sortablejs
'
;
import
{
ReactSortable
}
from
'
react-sortablejs
'
;
import
ImgCrop
from
'
antd-img-crop
'
;
import
ImgCrop
from
'
antd-img-crop
'
;
...
@@ -92,21 +93,29 @@ const UploadCropImage = forwardRef((props, ref) => {
...
@@ -92,21 +93,29 @@ const UploadCropImage = forwardRef((props, ref) => {
warningTip
(
`[
${
file
.
name
}
] 图片不可以大于2MB`
);
warningTip
(
`[
${
file
.
name
}
] 图片不可以大于2MB`
);
resolve
(
null
);
resolve
(
null
);
}
}
getBase64
(
file
,
url
=>
{
const
curType
=
file
.
name
.
substr
(
file
.
name
.
lastIndexOf
(
'
.
'
)
+
1
).
toLowerCase
();
const
image
=
new
Image
();
validImageType
(
file
,
curType
).
then
(
res
=>
{
image
.
addEventListener
(
'
load
'
,
()
=>
{
if
(
!
res
)
{
const
{
width
}
=
image
;
warningTip
(
`[
${
file
.
name
}
] 请上传正确图片!`
);
const
{
height
}
=
image
;
file
.
width
=
width
;
file
.
height
=
height
;
file
.
LtMB
=
LtMB
;
resolve
(
file
);
});
image
.
addEventListener
(
'
error
'
,
()
=>
{
warningTip
(
`
${
file
.
name
}
图片上传失败!`
);
resolve
(
null
);
resolve
(
null
);
});
}
else
{
image
.
src
=
url
;
getBase64
(
file
,
url
=>
{
const
image
=
new
Image
();
image
.
addEventListener
(
'
load
'
,
()
=>
{
const
{
width
}
=
image
;
const
{
height
}
=
image
;
file
.
width
=
width
;
file
.
height
=
height
;
file
.
LtMB
=
LtMB
;
resolve
(
file
);
});
image
.
addEventListener
(
'
error
'
,
()
=>
{
warningTip
(
`
${
file
.
name
}
图片上传失败!`
);
resolve
(
null
);
});
image
.
src
=
url
;
});
}
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment