Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jz_electricity
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengke
jz_electricity
Commits
a180f7e6
Commit
a180f7e6
authored
Feb 11, 2025
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
541fe2bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
73 deletions
+51
-73
index.js
src/plug/index.js
+51
-73
No files found.
src/plug/index.js
View file @
a180f7e6
...
...
@@ -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:802
0"
domainUrl
=
"http://192.168.
5.46:830
0"
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment