authorize.js 839 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import $toast from "../utils/tool/toast";
  2. export default {
  3. data:function () {
  4. return {
  5. authorize:false, // 用户是否授权
  6. }
  7. },
  8. methods:{
  9. openSetting(){
  10. this.buttonAuthorize = true;
  11. },
  12. openPoster(){
  13. this.$refs.poster && this.$refs.poster.open();
  14. }
  15. },
  16. onShow(){
  17. if (this.buttonAuthorize) {
  18. this.buttonAuthorize = false;
  19. // 获取授权
  20. uni.authorize({
  21. scope:'scope.writePhotosAlbum',
  22. success: (res) =>{
  23. this.authorize= true;
  24. },
  25. fail:() => {
  26. this.authorize= false;
  27. }
  28. });
  29. }
  30. },
  31. created(){
  32. this.buttonAuthorize = true;
  33. }
  34. }