// 用来保存图片的函数
|
|
// params: 需要授权的内容
|
|
// scope.userInfo 用户信息
|
|
// scope.userLocation 地理位置
|
|
// scope.userLocationBackground 后台定位 微信小程序
|
|
// scope.address 通信地址
|
|
// scope.record 录音功能
|
|
// scope.writePhotosAlbum 保存到相册 抖音小程序的返回值是scope.album
|
|
// scope.camera 摄像头
|
|
// scope.invoice 获取发票
|
|
// scope.invoiceTitle 发票抬头
|
|
// scope.werun wx.getWeRunData 微信运动步数
|
|
const scopeList = {
|
|
userInfo: 'scope.userInfo',
|
|
userLocation: 'scope.userLocation',
|
|
userLocationBackground: 'scope.userLocationBackground',
|
|
address: 'scope.address',
|
|
record: 'scope.record',
|
|
writePhotosAlbum: 'scope.writePhotosAlbum',
|
|
camera: 'scope.camera',
|
|
invoice: 'scope.invoice',
|
|
invoiceTitle: 'scope.invoiceTitle',
|
|
werun: 'scope.werun',
|
|
}
|
|
const authorize = ({
|
|
scope,
|
|
successfn,
|
|
failfn,
|
|
}) => {
|
|
if (!scopeList[scope]) {
|
|
uni.showToast({
|
|
title: 'scope参数错误',
|
|
icon: 'error'
|
|
})
|
|
return
|
|
}
|
|
uni.authorize({
|
|
scope: scopeList[scope],
|
|
success() {
|
|
successfn()
|
|
},
|
|
fail() {
|
|
failfn()
|
|
}
|
|
})
|
|
}
|
|
|
|
export {
|
|
authorize
|
|
}
|