Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-marketing
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f3e11dab
authored
Aug 22, 2023
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed
1 parent
17db9af8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
58 deletions
src/api/glsxUpload.js
src/api/glsxUpload.js
View file @
f3e11da
...
...
@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-08-21 11:35:26
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-08-2
1 16:25:51
* @LastEditTime: 2023-08-2
2 15:45:33
* @FilePath: \scrm-micro-marketing\src\api\glsxUpload.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -36,63 +36,63 @@ class GlsxUpload {
constructor
(
params
)
{
this
.
initParam
=
params
}
//
init() {
//
return new Promise((resolve, reject) => {
//
if (this.tcVod) return resolve({ status: 0, msg: 'init successful' })
//
const { params: { data, url } = {} } = this.initParam || {}
//
console.log(data)
//
return http({
//
data,
//
url: url,
//
returnAll: true
//
})
//
.then(res => {
//
if (res.code == '0') {
//
this.tcVod = new TcVod({
//
getSignature: () => {
//
return res.data
//
}
//
})
//
}
//
if (this.tcVod) return resolve({ status: 0, msg: 'init successful' })
//
reject({ status: -1, msg: 'init failed' })
//
})
//
.catch(err => {
//
reject({ status: -1, msg: 'init failed' })
//
})
//
})
//
}
//
uploaded(file, img) {
//
return new Promise((resolve, reject) => {
//
if (!file) return reject({ status: -1, msg: 'file is required' })
//
let params = {
//
mediaFile: file
//
}
//
if (img) params.coverFile = img
//
this.uploader = this.tcVod.upload(params)
//
this.uploader
//
.done()
//
.then(doneResult => {
//
resolve(doneResult)
//
})
//
.catch(err => {
//
reject(err)
//
})
//
})
//
}
//
uploadEvent(eventType, callback) {
//
if (!eventType) callback({ status: -1, msg: 'eventType is required' })
//
try {
//
this.uploader.on(eventType, info => {
//
callback(info)
//
})
//
} catch (err) {
//
callback(err)
//
}
//
}
//
uploadCancel() {
//
this.uploader.cancel()
//
}
init
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
tcVod
)
return
resolve
({
status
:
0
,
msg
:
'init successful'
})
const
{
params
:
{
data
,
url
}
=
{}
}
=
this
.
initParam
||
{}
console
.
log
(
data
)
return
http
({
data
,
url
:
url
,
returnAll
:
true
})
.
then
(
res
=>
{
if
(
res
.
code
==
'0'
)
{
this
.
tcVod
=
new
TcVod
({
getSignature
:
()
=>
{
return
res
.
data
}
})
}
if
(
this
.
tcVod
)
return
resolve
({
status
:
0
,
msg
:
'init successful'
})
reject
({
status
:
-
1
,
msg
:
'init failed'
})
})
.
catch
(
err
=>
{
reject
({
status
:
-
1
,
msg
:
'init failed'
})
})
})
}
uploaded
(
file
,
img
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
file
)
return
reject
({
status
:
-
1
,
msg
:
'file is required'
})
let
params
=
{
mediaFile
:
file
}
if
(
img
)
params
.
coverFile
=
img
this
.
uploader
=
this
.
tcVod
.
upload
(
params
)
this
.
uploader
.
done
()
.
then
(
doneResult
=>
{
resolve
(
doneResult
)
})
.
catch
(
err
=>
{
reject
(
err
)
})
})
}
uploadEvent
(
eventType
,
callback
)
{
if
(
!
eventType
)
callback
({
status
:
-
1
,
msg
:
'eventType is required'
})
try
{
this
.
uploader
.
on
(
eventType
,
info
=>
{
callback
(
info
)
})
}
catch
(
err
)
{
callback
(
err
)
}
}
uploadCancel
()
{
this
.
uploader
.
cancel
()
}
}
export
default
GlsxUpload
Write
Preview
Markdown
is supported
Attach a file
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 post a comment