Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
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
Damon
study
Commits
ff1475fa
Commit
ff1475fa
authored
Aug 02, 2021
by
linwenqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:读取和拍摄照片不需要授权也可以
parent
5141f95d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
upload.js
src/common/upload.js
+25
-25
No files found.
src/common/upload.js
View file @
ff1475fa
...
...
@@ -40,33 +40,33 @@ function openSetting() {
//吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛key,domain,本地file信息
function
getPhoto
(
type
,
token
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
hasPermissionOfCamera
().
then
((
r
)
=>
{
if
(
!
r
)
{
reject
(
false
)
}
let
sourceType
=
type
==
1
?
[
'album'
]
:
[
'album'
,
'camera'
]
uni
.
chooseImage
({
count
:
1
,
//默认9
sizeType
:
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sourceType
:
sourceType
,
//从相册选择
success
:
function
(
res
)
{
//上传七牛
let
filePath
=
res
.
tempFiles
[
0
].
path
//为需要上传的文件
upload
(
filePath
,
token
)
.
then
((
msg
)
=>
{
//最后七牛返回的key
resolve
({
key
:
msg
,
files
:
res
.
tempFiles
,
})
// hasPermissionOfCamera().then((r) => {
// if (!r) {
// reject(false)
// }
let
sourceType
=
type
==
1
?
[
'album'
]
:
[
'album'
,
'camera'
]
uni
.
chooseImage
({
count
:
1
,
//默认9
sizeType
:
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sourceType
:
sourceType
,
//从相册选择
success
:
function
(
res
)
{
//上传七牛
let
filePath
=
res
.
tempFiles
[
0
].
path
//为需要上传的文件
upload
(
filePath
,
token
)
.
then
((
msg
)
=>
{
//最后七牛返回的key
resolve
({
key
:
msg
,
files
:
res
.
tempFiles
,
})
.
catch
((
msg
)
=>
{
console
.
error
(
msg
)
reject
(
msg
)
}
)
},
}
)
})
.
catch
((
msg
)
=>
{
console
.
error
(
msg
)
reject
(
msg
)
})
}
,
})
// })
})
}
...
...
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