Commit a180f7e6 authored by 黄奎's avatar 黄奎

1

parent 541fe2bc
...@@ -56,10 +56,10 @@ export default { ...@@ -56,10 +56,10 @@ export default {
Vue.prototype.domainManager = function () { Vue.prototype.domainManager = function () {
let domainUrl = ''; let domainUrl = '';
let javaUrl = 'http://192.168.2.65:8018'; 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 vtUploadUrl = "http://192.168.5.46:8120";
let vtViewUrl = "http://192.168.10.214:8130"; let vtViewUrl = "http://192.168.5.46:8130";
let locationName = window.location.hostname; let locationName = window.location.hostname;
if (locationName.indexOf('testmall.oytour') !== -1) { if (locationName.indexOf('testmall.oytour') !== -1) {
...@@ -177,8 +177,8 @@ export default { ...@@ -177,8 +177,8 @@ export default {
Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) { Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) {
// debugger; // debugger;
var upInfo = JSON.parse(localStorage.uploadInfo); var upInfo = JSON.parse(localStorage.uploadInfo);
let maxSize=500*1024 let maxSize = 500 * 1024
if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size>maxSize) { if ((fileObj.type == "image/png" || fileObj.type == "image/jpeg") && fileObj.size > maxSize) {
let that = this let that = this
lrz(fileObj, { lrz(fileObj, {
width: 750, width: 750,
...@@ -235,81 +235,59 @@ export default { ...@@ -235,81 +235,59 @@ export default {
} }
}, },
Vue.prototype.uploadStart = function (path, fileObj, callback) { Vue.prototype.uploadStart = function (path, fileObj, callback) {
var upInfo = JSON.parse(localStorage.uploadInfo); var that = this;
//获取文件扩展名
var filename = fileObj.name;
var index = filename.lastIndexOf(".");
var suffix = filename.substr(index);
var timestamp1 = Date.parse(new Date()) + "_" + (Math.ceil(Math.random() * 1000));
let str = ''; let str = '';
if (this.isOnline()) { if (!this.isOnline()) {
str = "/Test" str = "/2024"
} }
var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix; var newFileName = str + '/Upload/' + path;
var uploadMsg = { var uploadUrl = that.domainManager().VTUploadUrl + "/Upload/UploadToTecent?isDomain=1&filePath=" + newFileName;
Bucket: upInfo.Bucket, var formData = new FormData();
Region: upInfo.Region, formData.append("myfile", fileObj);
SecretId: upInfo.SecretId, that.$http.post(uploadUrl, formData, {})
SecretKey: upInfo.SecretKey, .then(res => {
}; if (res && res.data.StatusCode == 1 && res.data.FilePath) {
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 = { var uploadResult = {
resultCode: 1, resultCode: 1,
FileName: fileObj.name, FileName: fileObj.name,
FileUrl: "https://" + data.Location FileUrl: res.data.FilePath,
VideoCoverImg: that.domainManager().VTViewUrl + res.data.VideoCoverImg
} }
if (callback) { if (callback) {
callback(uploadResult); callback(uploadResult);
} }
} else {
/*上传文件异常*/
console.log(err || data);
} }
}).catch(function (reason) {
console.log(reason)
}); });
}, },
//上传至阿里云 //上传至阿里云
Vue.prototype.uploadToAli = function (path, fileObj, successCall) { Vue.prototype.uploadToAli = function (path, fileObj, successCall) {
var upInfo = JSON.parse(localStorage.uploadInfo); var that = this;
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));
let str = ''; let str = '';
if (this.isOnline()) { if (!this.isOnline()) {
str = "/Test" str = "/2024"
} }
var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix; var newFileName = str + '/Upload/' + path;
var result = oss.multipartUpload(newFileName, fileObj, { var uploadUrl = that.domainManager().VTUploadUrl + "/Upload/UploadToALiOSS?isDomain=1&filePath=" + newFileName;
progress: function* (p) {} var formData = new FormData();
}).then(res => { formData.append("myfile", fileObj);
that.$http.post(uploadUrl, formData, {})
.then(res => {
if (res && res.data.StatusCode == 1 && res.data.FilePath) {
var uploadResult = { var uploadResult = {
resultCode: 1, resultCode: 1,
FileName: fileObj.name, FileName: fileObj.name,
FileUrl: res.res.requestUrls[0].replace('http', 'https') FileUrl: res.data.FilePath,
VideoCoverImg: that.domainManager().VTViewUrl + res.data.VideoCoverImg
} }
if (successCall) {
successCall(uploadResult); successCall(uploadResult);
}) }
}
}).catch(function (reason) {
console.log(reason)
});
}, },
//公用跳转 //公用跳转
Vue.prototype.CommonJump = function (path, obj) { Vue.prototype.CommonJump = function (path, obj) {
......
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