Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-file-upload
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
You need to sign in or sign up before continuing.
Commit 9dfeb43f
authored
Feb 23, 2022
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
上传图片格式处理
1 parent
3bb822d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
src/views/upload/index.vue
src/views/upload/index.vue
View file @
9dfeb43
...
@@ -52,7 +52,7 @@ export default {
...
@@ -52,7 +52,7 @@ export default {
// 根据手机屏幕宽度计算图片宽度
// 根据手机屏幕宽度计算图片宽度
computedWidth
(){
computedWidth
(){
const
screen
=
window
.
screen
.
width
const
screen
=
window
.
screen
.
width
const
imageW
=
(
screen
-
(
16
*
2
+
10
*
2
+
6.8256
*
3
))
/
3
const
imageW
=
(
screen
-
(
16
*
2
+
10
*
2
+
8
*
3
))
/
3
this
.
size
=
`
${
imageW
}
px`
this
.
size
=
`
${
imageW
}
px`
},
},
// 获取附件信息
// 获取附件信息
...
@@ -95,6 +95,7 @@ export default {
...
@@ -95,6 +95,7 @@ export default {
this
.
currentItem
=
item
this
.
currentItem
=
item
},
},
afterRread
(
file
,
e
)
{
afterRread
(
file
,
e
)
{
console
.
log
(
file
,
e
);
this
.
uploadImage
(
file
)
this
.
uploadImage
(
file
)
},
},
beforeDelete
(
file
,
e
)
{
beforeDelete
(
file
,
e
)
{
...
@@ -104,7 +105,11 @@ export default {
...
@@ -104,7 +105,11 @@ export default {
// 上传图片
// 上传图片
uploadImage
(
file
)
{
uploadImage
(
file
)
{
const
imgFile
=
file
.
content
const
imgFile
=
file
.
content
const
base64
=
file
.
file
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
console
.
log
(
file
.
file
.
name
);
let
fileName
=
file
.
file
.
name
let
index
=
fileName
.
lastIndexOf
(
"."
)
fileName
=
fileName
.
substring
(
index
+
1
,
fileName
.
length
);
const
base64
=
fileName
+
'@'
+
imgFile
.
split
(
','
)[
1
]
let
para
=
{
let
para
=
{
file
:
base64
,
file
:
base64
,
fileType
:
'image'
fileType
:
'image'
...
@@ -113,6 +118,8 @@ export default {
...
@@ -113,6 +118,8 @@ export default {
upload
.
uploadImageApi
(
para
).
then
(
res
=>
{
upload
.
uploadImageApi
(
para
).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
this
.
uploadFile
(
res
.
data
)
this
.
uploadFile
(
res
.
data
)
}
else
{
this
.
showToast
(
res
.
message
)
}
}
})
})
},
},
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment