Commit a180f7e6 authored by 黄奎's avatar 黄奎

1

parent 541fe2bc
......@@ -56,10 +56,10 @@ export default {
Vue.prototype.domainManager = function () {
let domainUrl = '';
let javaUrl = 'http://192.168.2.65:8018';
domainUrl = "http://192.168.10.160:8020"
domainUrl = "http://192.168.5.46:8300"
let vtUploadUrl = "http://192.168.10.214:8120";
let vtViewUrl = "http://192.168.10.214:8130";
let vtUploadUrl = "http://192.168.5.46:8120";
let vtViewUrl = "http://192.168.5.46:8130";
let locationName = window.location.hostname;
if (locationName.indexOf('testmall.oytour') !== -1) {
......@@ -177,8 +177,8 @@ export default {
Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) {
// debugger;
var upInfo = JSON.parse(localStorage.uploadInfo);
let maxSize=500*1024
if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size>maxSize) {
let maxSize = 500 * 1024
if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size > maxSize) {
let that = this
lrz(fileObj, {
width: 750,
......@@ -235,81 +235,59 @@ 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));
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)
});
},
//上传至阿里云
Vue.prototype.uploadToAli = function (path, fileObj, successCall) {
var upInfo = JSON.parse(localStorage.uploadInfo);
var OSS = require('ali-oss');
var oss = new OSS({
region: upInfo.Region,
accessKeyId: upInfo.SecretId,
accessKeySecret: upInfo.SecretKey,
bucket: upInfo.Bucket
})
//获取文件扩展名
var filename = fileObj.name;
var index = filename.lastIndexOf(".");
var suffix = filename.substr(index);
var timestamp1 = Date.parse(new Date()) + "_" + (Math.ceil(Math.random() * 1000));
var that = this;
let str = '';
if (this.isOnline()) {
str = "/Test"
if (!this.isOnline()) {
str = "/2024"
}
var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix;
var result = oss.multipartUpload(newFileName, fileObj, {
progress: function* (p) {}
}).then(res => {
var uploadResult = {
resultCode: 1,
FileName: fileObj.name,
FileUrl: res.res.requestUrls[0].replace('http', 'https')
}
successCall(uploadResult);
})
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 => {
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 (successCall) {
successCall(uploadResult);
}
}
}).catch(function (reason) {
console.log(reason)
});
},
//公用跳转
Vue.prototype.CommonJump = function (path, obj) {
......@@ -569,4 +547,4 @@ export default {
}, faildCall)
}
}
}
\ No newline at end of file
}
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