Commit 5dda09f6 authored by 黄奎's avatar 黄奎

上传新增提示

parent 2ce76f68
...@@ -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',
......
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