Commit 4cbf4509 authored by 黄奎's avatar 黄奎

文件上传修改

parent be8e13eb
......@@ -550,15 +550,7 @@
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
// this.UploadSelfFile(this.FileType().Video, file.file, res => {
// if (res.resultCode == 1) {
// that.addpageMsg.Image = res.VideoCoverImg;
// that.addpageMsg.Path = res.FileUrl;
// that.addpageMsg.Name = res.FileName;
// that.addPageList();
// that.$forceUpdate();
// }
// })
this.UploadFileToTencent(this.FileType().Video, file.file, res => {
if (res.resultCode == 1) {
if (that.addpageMsg.Type == 2) {
......
......@@ -2,11 +2,7 @@
<div class="orderList">
<div class="head-title">
订单列表
<!-- <el-upload class="upload-demo" ref="upload" :action="importFileUrl" :multiple="true" :on-success="successUpload"
:show-file-list="false" accept=".csv">
<el-button :loading="btnLoad" size="small" type="primary">
赞羊导入</el-button>
</el-upload> -->
<el-button @click="dialogVisible = true" style="float: right; margin-top: -5px" size="small" type="primary">批量导出
</el-button>
<el-button @click="ClearHsz" style="float: right; margin-top: -5px; margin-right: 20px" size="small"
......@@ -19,21 +15,7 @@
<el-date-picker v-model="dateList" @change="(msg.pageIndex = 1), getList()" size="small" type="datetimerange"
range-separator="至" value-format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
<!-- <span style="margin-left: 15px;font-size:14px">所属平台:</span>
<el-select class="w120" @change="(msg.pageIndex = 1), getList()" v-model="msg.OrderSource" size="small"
placeholder="请选择">
<el-option label="全部平台" :value="0"></el-option>
<el-option v-for="item in platList" :key="item.Id" :label="item.Name" :value="item.Id">
</el-option>
</el-select> -->
<!-- <span style="margin-left: 15px;font-size:14px">订单类型:</span>
<el-select class="w120" @change="(msg.pageIndex = 1), getList()" v-model="msg.OrderType" size="small"
placeholder="请选择">
<el-option label="全部订单" :value="0"></el-option>
<el-option v-for="item in orderTypeList" :key="item.Id" :label="item.Name" :value="item.Id">
</el-option>
</el-select> -->
<span style="margin-left: 15px;font-size:14px">配送方式:</span>
<el-select class="w120" @change="(msg.pageIndex = 1), getList()" v-model="msg.DeliveryMethod" size="small"
placeholder="请选择">
......
......@@ -262,15 +262,6 @@
//上传视频
UploadVideo(file) {
var that = this;
// this.UploadSelfFile(this.FileType().Video, file.file, res => {
// if (res.resultCode == 1) {
// that.addpageMsg.Image = res.VideoCoverImg;
// that.addpageMsg.Path = res.FileUrl;
// that.addpageMsg.Name = res.FileName;
// that.addPageList();
// that.$forceUpdate();
// }
// })
that.uploadLoadingObj = this.$loading({
lock: true,
text: '正在上传视频,请稍后...',
......@@ -285,7 +276,6 @@
that.addpageMsg.Path = res.FileUrl;
that.addpageMsg.Name = res.FileName;
that.cutPicture(res.FileUrl);
//that.addPageList();
}
})
},
......
This diff is collapsed.
......@@ -200,11 +200,10 @@ export default {
if (upInfo.StoreType == 1) {
var cachaInfo = that.getLocalStorage();
if (cachaInfo && cachaInfo.TenantId == 29) {
that.uploadStart(path, fileObj, callback)
that.RealUploadToTencent(path, fileObj, callback)
} else {
that.uploadStart(path, newFile, callback)
that.RealUploadToTencent(path, newFile, callback)
}
console.log("cachaInfo", cachaInfo)
}
if (upInfo.StoreType == 2) {
that.uploadToAli(path, newFile, callback)
......@@ -215,7 +214,7 @@ export default {
}).catch(function (error) {
if (upInfo && upInfo.IsDefault == 1) {
if (upInfo.StoreType == 1) {
that.uploadStart(path, fileObj, callback)
that.RealUploadToTencent(path, fileObj, callback)
}
if (upInfo.StoreType == 2) {
that.uploadToAli(path, fileObj, callback)
......@@ -229,7 +228,7 @@ export default {
} else {
if (upInfo && upInfo.IsDefault == 1) {
if (upInfo.StoreType == 1) {
this.uploadStart(path, fileObj, callback)
this.RealUploadToTencent(path, fileObj, callback)
}
if (upInfo.StoreType == 2) {
this.uploadToAli(path, fileObj, callback)
......@@ -239,66 +238,46 @@ export default {
}
}
},
Vue.prototype.uploadStart = function (path, fileObj, callback) {
var upInfo = JSON.parse(localStorage.uploadInfo);
//获取文件扩展名
var filename = fileObj.name;
var index = filename.lastIndexOf(".");
var suffix = filename.substr(index);
var timestamp1 = Date.parse(new Date()) + "_" + (Math.ceil(Math.random() * 1000));
Vue.prototype.RealUploadToTencent = function (path, fileObj, callback) {
var that = this;
let str = '';
if (this.isOnline()) {
str = "/Test"
if (!this.isOnline()) {
str = "/2024"
}
var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix;
var uploadMsg = {
Bucket: upInfo.Bucket,
Region: upInfo.Region,
SecretId: upInfo.SecretId,
SecretKey: upInfo.SecretKey,
};
var COS = require('cos-js-sdk-v5');
var cos = new COS({
SecretId: uploadMsg.SecretId,
SecretKey: uploadMsg.SecretKey,
});
cos.putObject({
Bucket: uploadMsg.Bucket,
Region: uploadMsg.Region, //存储桶所在地域,必须字段
Key: newFileName, //文件名
StorageClass: 'STANDARD',
Body: fileObj, // 上传文件对象
onProgress: function (progressData) {}
}, function (err, data) {
if (data && data.statusCode == 200) {
var uploadResult = {
resultCode: 1,
FileName: fileObj.name,
FileUrl: "https://" + data.Location
}
if (callback) {
callback(uploadResult);
var newFileName = str + '/Upload/' + path;
var uploadUrl = that.domainManager().VTUploadUrl + "/Upload/UploadToTecent?isDomain=1&filePath=" + newFileName;
var formData = new FormData();
formData.append("myfile", fileObj);
that.$http.post(uploadUrl, formData, {})
.then(res => {
if (res && res.data.StatusCode == 1 && res.data.FilePath) {
var uploadResult = {
resultCode: 1,
FileName: fileObj.name,
FileUrl:res.data.FilePath,
VideoCoverImg: that.domainManager().VTViewUrl + res.data.VideoCoverImg
}
if (callback) {
callback(uploadResult);
}
}
} else {
/*上传文件异常*/
console.log(err || data);
}
});
}).catch(function (reason) {
console.log(reason)
});
},
//上传至阿里云【2024-05-20转为后台上传】
Vue.prototype.uploadToAli = function (path, fileObj, successCall) {
var that = this;
let str = '';
if (this.isOnline()) {
if (!this.isOnline()) {
str = "/2024"
}
var newFileName = str + '/Upload/' + path + "/";
var uploadUrl = that.domainManager().VTUploadUrl + "/Upload/UploadToALiOSS?filePath=" + newFileName;
var newFileName = str + '/Upload/' + path;
var uploadUrl = that.domainManager().VTUploadUrl + "/Upload/UploadToALiOSS?isDomain=1&filePath=" + newFileName;
var formData = new FormData();
formData.append("myfile", fileObj);
that.$http.post(uploadUrl, formData, {})
.then(res => {
console.log("ali_res", res);
if (res && res.data.StatusCode == 1 && res.data.FilePath) {
var uploadResult = {
resultCode: 1,
......
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