Commit 41367d83 authored by linwenqing's avatar linwenqing

chore:冗余代码删除

parent b616278a
function appLogin() {
return new Promise(function(resolve, reject) {
uni.login({
success(res) {
if (!res.code) {
uni.hideLoading()
uni.showModal({
content: res.errMsg,
showCancel: false,
})
}
resolve(res)
},
fail() {
uni.hideLoading()
uni.showModal({
content: '小程序登录失败',
showCancel: false,
})
reject()
},
})
})
}
export default {
appLogin,
}
function hasPermissionOfCamera() {
//如果没权限提示文字,还没取得权限会自动吊起询问权限,已经有权限自动返回true
return new Promise((r, j) => {
uni.authorize({
scope: 'scope.camera',
success: function() {
r(true)
},
fail: function() {
uni.showModal({
content: '拒绝授权将无法进行拍照和上传图片,是否去设置打开?',
confirmText: '确认',
cancelText: '取消',
success(res) {
if (res.confirm) {
openSetting()
}
},
fail() {
j(false)
},
})
},
complete: function() {
console.log('done!')
},
})
})
}
function openSetting() {
// 打开设置
wx.openSetting({
success(res) {
console.log(res)
},
})
}
//吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛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
......@@ -61,12 +18,10 @@ function getPhoto(type, token) {
})
})
.catch((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