Commit f84927b8 authored by zhengke's avatar zhengke

no message

parent 76abc980
......@@ -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 +'&params=' + 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)
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment