Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
schedule
Overview
Overview
Details
Activity
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
fengzhaoyu
schedule
Commits
1c04d685
Commit
1c04d685
authored
May 08, 2020
by
fengzhaoyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat 增加oss上传
parent
6dd980d1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
37 deletions
+59
-37
meetingDetail.js
pages/meetingDetail/meetingDetail.js
+48
-37
utils.js
utils/utils.js
+11
-0
No files found.
pages/meetingDetail/meetingDetail.js
View file @
1c04d685
import
create
from
'dd-store'
;
import
create
from
'dd-store'
;
import
{
checkFullScren
}
from
"../../utils/checkFullScren"
;
import
{
checkFullScren
}
from
"../../utils/checkFullScren"
;
import
pageStore
from
'./store'
;
import
pageStore
from
'./store'
;
import
{
getMeetingRoomAffairs
,
createMeetingTask
,
deleteMeetingTask
,
updateMeetingTask
,
uploadPermissions
}
from
'../../api/request'
;
import
{
saveFileInfo
,
getMeetingRoomAffairs
,
createMeetingTask
,
deleteMeetingTask
,
updateMeetingTask
,
uploadPermissions
}
from
'../../api/request'
;
import
{
getOssPermission
,
getuploadResource
,
isParticipate
,
deleteSchedule
,
getScheduleDetail
,
getUserScheduleInTime
,
modifySchedule
,
getMeetingRoomRepeatAffairs
}
from
'../../api/request.js'
import
{
getOssPermission
,
getuploadResource
,
isParticipate
,
deleteSchedule
,
getScheduleDetail
,
getUserScheduleInTime
,
modifySchedule
,
getMeetingRoomRepeatAffairs
}
from
'../../api/request.js'
import
{
throttle
,
getCreateShowTime
}
from
'./../../utils/utils.js'
import
{
throttle
,
getCreateShowTime
,
getRndInteger
}
from
'./../../utils/utils.js'
import
{
observer
}
from
'/utils/observer.js'
import
{
observer
}
from
'/utils/observer.js'
import
{
resolve
}
from
'path'
;
import
{
resolve
}
from
'path'
;
create
.
Page
({
create
.
Page
({
...
@@ -1609,60 +1609,71 @@ create.Page({
...
@@ -1609,60 +1609,71 @@ create.Page({
})
})
},
},
// 上传oss文件
// 上传oss文件
addOssFile
()
{
async
addOssFile
()
{
const
that
=
this
const
timestamp
=
new
Date
().
getTime
()
let
timestamp
=
new
Date
().
getTime
()
const
random
=
getRndInteger
(
1000
,
10000
)
console
.
log
(
getApp
().
globalData
.
avatar
)
const
permisson
=
await
getOssPermission
()
getOssPermission
().
then
(
res
=>
{
const
imgInfo
=
await
this
.
getOssImg
()
const
key
=
await
new
Promise
((
resolve
)
=>
{
resolve
(
permisson
.
data
.
data
.
dir
+
timestamp
+
random
+
'.'
+
imgInfo
.
files
[
0
].
fileType
)
})
const
fileName
=
await
new
Promise
((
resolve
)
=>
{
resolve
(
timestamp
+
random
+
'.'
+
imgInfo
.
files
[
0
].
fileType
)
})
await
this
.
uploadOssFile
(
permisson
,
imgInfo
,
key
)
await
this
.
saveOssFileInfo
(
permisson
,
imgInfo
,
key
,
fileName
)
},
// 获取oss上传图片 选择图片 上传图片到oss
getOssImg
()
{
return
new
Promise
((
resolve
,
rejects
)
=>
{
dd
.
chooseImage
({
dd
.
chooseImage
({
count
:
2
,
count
:
1
,
sourceType
:
[
'camera'
,
'album'
],
success
:
(
res
)
=>
{
success
:
(
success
)
=>
{
resolve
(
res
)
},
});
})
},
// 获取的图片上传到oss
uploadOssFile
(
permisson
,
imgInfo
,
key
)
{
return
new
Promise
(
resolve
=>
{
dd
.
uploadFile
({
dd
.
uploadFile
({
url
:
res
.
data
.
data
.
host
,
url
:
permisson
.
data
.
data
.
host
,
fileType
:
'image'
,
fileType
:
'image'
,
fileName
:
'file'
,
fileName
:
'file'
,
filePath
:
success
.
filePaths
[
0
],
filePath
:
imgInfo
.
filePaths
[
0
],
formData
:
{
formData
:
{
key
:
res
.
data
.
data
.
dir
+
timestamp
+
getApp
().
globalData
.
userid
,
key
:
key
,
policy
:
res
.
data
.
data
.
policy
,
policy
:
permisson
.
data
.
data
.
policy
,
OSSAccessKeyId
:
res
.
data
.
data
.
accessId
,
OSSAccessKeyId
:
permisson
.
data
.
data
.
accessId
,
success_action_status
:
200
,
success_action_status
:
200
,
signature
:
res
.
data
.
data
.
signature
signature
:
permisson
.
data
.
data
.
signature
},
},
success
:
()
=>
{
success
:
()
=>
{
console
.
log
(
11111
)
resolve
()
}
})
})
},
// 上传oss文件
saveOssFileInfo
(
permisson
,
imgInfo
,
key
,
fileName
)
{
const
data
=
{
const
data
=
{
resourceType
:
'accessory'
,
resourceType
:
'accessory'
,
creatorId
:
getApp
().
globalData
.
userid
,
creatorId
:
getApp
().
globalData
.
userid
,
category
:
'2'
,
category
:
'2'
,
scheduleId
:
that
.
store
.
data
.
scheduleId
,
scheduleId
:
this
.
store
.
data
.
scheduleId
,
groupId
:
that
.
store
.
data
.
groupId
,
groupId
:
this
.
store
.
data
.
groupId
,
creatorInfo
:
getApp
().
globalData
.
userInfo
,
creatorInfo
:
getApp
().
globalData
.
userInfo
,
description
:
''
,
description
:
''
,
logType
:
'schedule_accessory_add'
,
logType
:
'schedule_accessory_add'
,
fileKey
:
res
.
data
.
data
.
dir
+
timestamp
+
getApp
().
globalData
.
userid
fileInfos
:
JSON
.
stringify
({
fileId
:
key
,
fileName
:
fileName
,
fileType
:
imgInfo
.
files
[
0
].
fileType
,
fileSize
:
imgInfo
.
files
[
0
].
size
})
}
}
console
.
log
(
JSON
.
stringify
(
data
))
saveFileInfo
(
data
).
then
(
result
=>
{
getuploadResource
(
data
).
then
(
su
=>
{
dd
.
alert
({
dd
.
alert
({
title
:
'上传成功'
,
title
:
'上传成功'
,
content
:
JSON
.
stringify
(
su
)
content
:
JSON
.
stringify
(
result
)
})
})
},
fail
:
(
err
)
=>
{
dd
.
alert
({
title
:
'上传失败'
,
content
:
JSON
.
stringify
(
err
)
})
})
}
});
},
});
console
.
log
(
res
)
})
})
},
},
//隐藏文件操作浮窗
//隐藏文件操作浮窗
...
...
utils/utils.js
View file @
1c04d685
...
@@ -151,3 +151,13 @@ export function getCreateShowTime(createdTime) {
...
@@ -151,3 +151,13 @@ export function getCreateShowTime(createdTime) {
export
function
padZero
(
val
)
{
export
function
padZero
(
val
)
{
return
(
"00"
+
val
).
slice
(
-
2
);
return
(
"00"
+
val
).
slice
(
-
2
);
}
}
/*
获取随机数
min = 0 区间范围 默认0
max = 100 区间范围 默认100
[min, max)
*/
export
function
getRndInteger
(
min
=
0
,
max
=
100
)
{
return
Math
.
floor
(
Math
.
random
()
*
(
max
-
min
))
+
min
;
}
\ 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