Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mallapp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
viitto
mallapp
Commits
e0f413c6
Commit
e0f413c6
authored
Sep 03, 2021
by
Mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
35728aa8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
24 deletions
+53
-24
img-upload.vue
pages/kotra/billboard/components/img-upload.vue
+53
-24
No files found.
pages/kotra/billboard/components/img-upload.vue
View file @
e0f413c6
...
...
@@ -231,36 +231,64 @@
});
chooseFile
.
then
((
res
)
=>
{
let
file
=
null
;
let
listOldLength
=
this
.
lists
.
length
;
res
.
tempFiles
.
map
((
val
,
index
)
=>
{
// 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
if
(
!
multiple
&&
index
>=
1
)
return
;
if
(
val
.
size
<
(
2
*
1024
*
1024
)){
uni
.
showToast
({
title
:
'图片不能小于2M'
,
icon
:
'none'
})
}
else
if
(
val
.
size
>
maxSize
)
{
this
.
$emit
(
'on-oversize'
,
val
,
this
.
lists
);
this
.
showToast
(
'超出允许的文件大小'
);
}
else
{
if
(
maxCount
<=
lists
.
length
)
{
this
.
$emit
(
'on-exceed'
,
val
,
this
.
lists
);
this
.
showToast
(
'超出最大允许的文件个数'
);
return
;
let
that
=
this
res
.
tempFiles
.
forEach
((
val
,
index
)
=>
{
uni
.
getImageInfo
({
src
:
val
.
path
,
success
:
function
(
image
)
{
if
(
image
.
width
>
image
.
height
){
uni
.
showToast
({
title
:
'请上传竖版图片'
,
icon
:
'none'
})
}
else
{
// 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
if
(
!
multiple
&&
index
>=
1
)
return
;
if
(
val
.
size
<
(
2
*
1024
*
1024
)){
uni
.
showToast
({
title
:
'图片不能小于2M'
,
icon
:
'none'
})
}
else
if
(
val
.
size
>
maxSize
)
{
that
.
$emit
(
'on-oversize'
,
val
,
that
.
lists
);
that
.
showToast
(
'超出允许的文件大小'
);
}
else
{
if
(
maxCount
<=
that
.
lists
.
length
)
{
that
.
$emit
(
'on-exceed'
,
val
,
that
.
lists
);
that
.
showToast
(
'超出最大允许的文件个数'
);
return
;
}
that
.
lists
.
push
({
url
:
val
.
path
,
progress
:
0
,
error
:
false
});
// 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引
that
.
$emit
(
'on-list-change'
,
that
.
lists
);
that
.
$emit
(
'on-choose-complete'
,
that
.
lists
);
if
(
that
.
autoUpload
)
that
.
uploadFile
(
listOldLength
);
listOldLength
++
}
}
},
fail
:
function
(
err
){
console
.
log
(
err
)
}
lists
.
push
({
url
:
val
.
path
,
progress
:
0
,
error
:
false
});
// 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引
this
.
$emit
(
'on-list-change'
,
this
.
lists
);
}
})
})
// 每次图片选择完,抛出一个事件,并将当前内部选择的图片数组抛出去
this
.
$emit
(
'on-choose-complete'
,
this
.
lists
);
console
.
log
(
this
.
lists
,
listOldLength
,
'listOldLength'
)
if
(
this
.
autoUpload
)
this
.
uploadFile
(
listOldLength
);
})
.
catch
(
error
=>
{
...
...
@@ -292,6 +320,7 @@
},
// 上传图片
uploadFile
(
index
=
0
)
{
if
(
this
.
disabled
)
return
;
if
(
this
.
uploading
)
return
;
// 全部上传完成
...
...
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