Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
confucius
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
罗超
confucius
Commits
5dda09f6
Commit
5dda09f6
authored
Dec 24, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传新增提示
parent
2ce76f68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
common.js
src/api/common/common.js
+13
-9
No files found.
src/api/common/common.js
View file @
5dda09f6
...
@@ -36,7 +36,8 @@ export function UploadSelfFile(path, file, callback, configObj) {
...
@@ -36,7 +36,8 @@ export function UploadSelfFile(path, file, callback, configObj) {
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
'/Test'
;
let
str
=
'/Test'
;
var
newPath
=
"/EduSystem"
+
str
+
'/Upload/'
+
path
;
var
newPath
=
"/EduSystem"
+
str
+
'/Upload/'
+
path
;
Loading
.
show
({
var
uploadLoadding
=
Loading
;
uploadLoadding
.
show
({
message
:
'正在上传文件,请稍后...'
message
:
'正在上传文件,请稍后...'
})
})
if
(
uploadConfig
)
{
if
(
uploadConfig
)
{
...
@@ -44,26 +45,26 @@ export function UploadSelfFile(path, file, callback, configObj) {
...
@@ -44,26 +45,26 @@ export function UploadSelfFile(path, file, callback, configObj) {
//上传文件到腾讯云
//上传文件到腾讯云
case
1
:
case
1
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
callback
);
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
break
;
break
;
//上传文件到阿里云
//上传文件到阿里云
case
2
:
case
2
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
callback
);
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
);
break
;
break
;
//上传文件到自己文件服务器
//上传文件到自己文件服务器
case
3
:
case
3
:
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
callback
,
configObj
);
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
uploadLoadding
,
callback
,
configObj
);
break
;
break
;
}
}
}
}
Loading
.
hide
();
//
Loading.hide();
}
}
/**
/**
* 上传文件到本地文件系统
* 上传文件到本地文件系统
*/
*/
export
function
UploadFileToSystem
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
,
configObj
)
{
export
function
UploadFileToSystem
(
uploadConfig
,
fileFullPath
,
fileObj
,
uploadLoadding
,
successCall
,
configObj
)
{
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
if
(
configObj
)
{
if
(
configObj
)
{
//是否转换图片
//是否转换图片
...
@@ -75,6 +76,7 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
...
@@ -75,6 +76,7 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
formData
.
append
(
'myfile'
,
fileObj
)
formData
.
append
(
'myfile'
,
fileObj
)
let
xhr
=
new
XMLHttpRequest
()
let
xhr
=
new
XMLHttpRequest
()
xhr
.
onload
=
function
()
{
xhr
.
onload
=
function
()
{
uploadLoadding
.
hide
();
var
jsonObj
=
JSON
.
parse
(
xhr
.
responseText
);
var
jsonObj
=
JSON
.
parse
(
xhr
.
responseText
);
if
(
jsonObj
.
StatusCode
==
1
&&
successCall
)
{
if
(
jsonObj
.
StatusCode
==
1
&&
successCall
)
{
var
tempArray
=
[];
var
tempArray
=
[];
...
@@ -102,7 +104,7 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
...
@@ -102,7 +104,7 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
/**
/**
* 上传文件到阿里云
* 上传文件到阿里云
*/
*/
export
function
UploadFileToALi
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
)
{
export
function
UploadFileToALi
(
uploadConfig
,
fileFullPath
,
fileObj
,
uploadLoadding
,
successCall
)
{
var
OSS
=
require
(
'ali-oss'
);
var
OSS
=
require
(
'ali-oss'
);
var
oss
=
new
OSS
({
var
oss
=
new
OSS
({
region
:
uploadConfig
.
Region
,
region
:
uploadConfig
.
Region
,
...
@@ -113,6 +115,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, successCall
...
@@ -113,6 +115,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, successCall
var
result
=
oss
.
multipartUpload
(
fileFullPath
,
fileObj
,
{
var
result
=
oss
.
multipartUpload
(
fileFullPath
,
fileObj
,
{
progress
:
function
*
(
p
)
{}
progress
:
function
*
(
p
)
{}
}).
then
(
res
=>
{
}).
then
(
res
=>
{
uploadLoadding
.
hide
();
var
uploadResult
=
{
var
uploadResult
=
{
Code
:
1
,
Code
:
1
,
FileName
:
fileObj
.
name
,
FileName
:
fileObj
.
name
,
...
@@ -127,7 +130,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, successCall
...
@@ -127,7 +130,7 @@ export function UploadFileToALi(uploadConfig, fileFullPath, fileObj, successCall
/**
/**
* 上传文件到腾讯云
* 上传文件到腾讯云
*/
*/
export
function
UploadFileToTencent
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
)
{
export
function
UploadFileToTencent
(
uploadConfig
,
fileFullPath
,
fileObj
,
uploadLoadding
,
successCall
)
{
var
COS
=
require
(
'cos-js-sdk-v5'
);
var
COS
=
require
(
'cos-js-sdk-v5'
);
var
cos
=
new
COS
({
var
cos
=
new
COS
({
SecretId
:
uploadConfig
.
SecretId
,
SecretId
:
uploadConfig
.
SecretId
,
...
@@ -141,6 +144,7 @@ export function UploadFileToTencent(uploadConfig, fileFullPath, fileObj, success
...
@@ -141,6 +144,7 @@ export function UploadFileToTencent(uploadConfig, fileFullPath, fileObj, success
Body
:
fileObj
,
// 上传文件对象
Body
:
fileObj
,
// 上传文件对象
onProgress
:
function
(
progressData
)
{}
onProgress
:
function
(
progressData
)
{}
},
function
(
err
,
data
)
{
},
function
(
err
,
data
)
{
uploadLoadding
.
hide
();
if
(
data
&&
data
.
statusCode
==
200
)
{
if
(
data
&&
data
.
statusCode
==
200
)
{
var
uploadResult
=
{
var
uploadResult
=
{
Code
:
1
,
Code
:
1
,
...
@@ -194,7 +198,7 @@ export function getFileExt(filename) {
...
@@ -194,7 +198,7 @@ export function getFileExt(filename) {
*/
*/
export
function
EduDownLoad
(
cmd
,
msg
,
fileName
,
callBack
)
{
export
function
EduDownLoad
(
cmd
,
msg
,
fileName
,
callBack
)
{
console
.
log
(
"callBack"
,
callBack
);
console
.
log
(
"callBack"
,
callBack
);
return
request
({
return
request
({
url
:
cmd
,
url
:
cmd
,
method
:
'post'
,
method
:
'post'
,
...
...
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