Commit ff1475fa authored by linwenqing's avatar linwenqing

fix:读取和拍摄照片不需要授权也可以

parent 5141f95d
...@@ -40,33 +40,33 @@ function openSetting() { ...@@ -40,33 +40,33 @@ function openSetting() {
//吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛key,domain,本地file信息 //吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛key,domain,本地file信息
function getPhoto(type, token) { function getPhoto(type, token) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
hasPermissionOfCamera().then((r) => { // hasPermissionOfCamera().then((r) => {
if (!r) { // if (!r) {
reject(false) // reject(false)
} // }
let sourceType = type == 1 ? ['album'] : ['album', 'camera'] let sourceType = type == 1 ? ['album'] : ['album', 'camera']
uni.chooseImage({ uni.chooseImage({
count: 1, //默认9 count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, //从相册选择 sourceType: sourceType, //从相册选择
success: function(res) { success: function(res) {
//上传七牛 //上传七牛
let filePath = res.tempFiles[0].path //为需要上传的文件 let filePath = res.tempFiles[0].path //为需要上传的文件
upload(filePath, token) upload(filePath, token)
.then((msg) => { .then((msg) => {
//最后七牛返回的key //最后七牛返回的key
resolve({ resolve({
key: msg, key: msg,
files: res.tempFiles, files: res.tempFiles,
})
}) })
.catch((msg) => { })
console.error(msg) .catch((msg) => {
reject(msg) console.error(msg)
}) reject(msg)
}, })
}) },
}) })
// })
}) })
} }
......
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