国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

2 days ago
  1. // 用来保存图片的函数
  2. // params: 需要授权的内容
  3. // scope.userInfo 用户信息
  4. // scope.userLocation 地理位置
  5. // scope.userLocationBackground 后台定位 微信小程序
  6. // scope.address 通信地址
  7. // scope.record 录音功能
  8. // scope.writePhotosAlbum 保存到相册 抖音小程序的返回值是scope.album
  9. // scope.camera 摄像头
  10. // scope.invoice 获取发票
  11. // scope.invoiceTitle 发票抬头
  12. // scope.werun wx.getWeRunData 微信运动步数
  13. const scopeList = {
  14. userInfo: 'scope.userInfo',
  15. userLocation: 'scope.userLocation',
  16. userLocationBackground: 'scope.userLocationBackground',
  17. address: 'scope.address',
  18. record: 'scope.record',
  19. writePhotosAlbum: 'scope.writePhotosAlbum',
  20. camera: 'scope.camera',
  21. invoice: 'scope.invoice',
  22. invoiceTitle: 'scope.invoiceTitle',
  23. werun: 'scope.werun',
  24. }
  25. const authorize = ({
  26. scope,
  27. successfn,
  28. failfn,
  29. }) => {
  30. if (!scopeList[scope]) {
  31. uni.showToast({
  32. title: 'scope参数错误',
  33. icon: 'error'
  34. })
  35. return
  36. }
  37. uni.authorize({
  38. scope: scopeList[scope],
  39. success() {
  40. successfn()
  41. },
  42. fail() {
  43. failfn()
  44. }
  45. })
  46. }
  47. export {
  48. authorize
  49. }