Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thinkApp
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
游洁
thinkApp
Commits
f84927b8
Commit
f84927b8
authored
May 30, 2022
by
zhengke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
76abc980
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
39 deletions
+24
-39
index.js
src/utils/index.js
+24
-39
No files found.
src/utils/index.js
View file @
f84927b8
...
...
@@ -32,56 +32,38 @@ export let urlTobase64 = (file, suc) => {
* 上传文件
*/
export
function
UploadSelfFile
(
path
,
file
,
callback
,
configObj
)
{
//用户登录缓存
var
cacheInfo
=
uni
.
getStorageSync
(
"userInfo"
)
//上传配置
var
uploadConfig
=
""
;
if
(
cacheInfo
&&
cacheInfo
.
UploadConfig
)
{
uploadConfig
=
cacheInfo
.
UploadConfig
;
if
(
file
.
url
.
indexOf
(
'.excel'
)
==
-
1
)
{
uni
.
showToast
({
title
:
'请上传 excel 格式文件'
,
icon
:
'none'
,
duration
:
2000
});
return
false
;
}
//获取文件扩展名
var
index
=
file
.
url
.
lastIndexOf
(
"."
);
var
suffix
=
file
.
url
.
substr
(
index
);
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
'/Test'
;
var
newPath
=
"/EduSystem"
+
str
+
'/Upload/'
+
path
;
uni
.
showLoading
({
title
:
'文件上传中...'
});
if
(
uploadConfig
)
{
switch
(
uploadConfig
.
StoreType
)
{
//上传文件到腾讯云
case
1
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到阿里云
case
2
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到自己文件服务器
case
3
:
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
callback
,
configObj
);
break
;
}
}
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
callback
,
configObj
);
}
/**
* 上传文件到本地文件系统
*/
export
function
UploadFileToSystem
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
,
configObj
)
{
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
if
(
configObj
)
{
//是否转换图片
if
(
configObj
.
isTrans
&&
configObj
.
isTrans
==
1
)
{
url
+=
"&isTrans=1"
}
if
(
configObj
.
isCreateCover
&&
configObj
.
isCreateCover
==
1
)
{
url
+=
"&isCreateCover=1"
}
// let url = uploadConfig.UploadDomain + "/Upload?filePath=" + fileFullPath;
console
.
log
(
fileFullPath
,
'------==='
)
let
host
=
''
if
(
process
.
env
.
NODE_ENV
===
"development"
)
{
host
=
'http://192.168.10.36:8082/api'
}
else
{
host
=
'https://eduapi.oytour.com/api'
}
let
params
=
{
Uid
:
1
,
CourseId
:
1
,
ExamName
:
''
}
let
url
=
host
+
"/Upload/UploadStuExamScore?Files="
+
fileObj
+
'¶ms='
+
JSON
.
stringify
(
params
)
;
uni
.
uploadFile
({
url
:
url
,
filePath
:
fileObj
.
url
,
...
...
@@ -90,6 +72,8 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
'myfile'
:
fileObj
},
success
(
res
)
{
uni
.
hideLoading
();
return
uni
.
hideLoading
();
let
jsonObj
=
JSON
.
parse
(
res
.
data
)
let
index
=
jsonObj
.
FilePath
.
indexOf
(
"."
)
...
...
@@ -104,6 +88,7 @@ export function UploadFileToSystem(uploadConfig, fileFullPath, fileObj, successC
successCall
(
uploadResult
);
},
fail
(
err
)
{
uni
.
hideLoading
();
console
.
log
(
"uploadErr"
,
err
)
}
});
...
...
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