privacy-popup.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // component/privacy-popup/privacy-popup.ts
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. show: false,
  13. needAuthorization: false,
  14. privacyContractName: ''
  15. },
  16. /**
  17. * 组件的方法列表
  18. */
  19. methods: {
  20. check() {
  21. if (wx.canIUse('getPrivacySetting')) {
  22. wx.getPrivacySetting({
  23. success: res => {
  24. console.log(res)
  25. this.setData({
  26. ...res,
  27. show: res.needAuthorization
  28. })
  29. if (!res.needAuthorization) {
  30. this.privacySubmit()
  31. }
  32. }
  33. })
  34. } else {
  35. this.privacySubmit()
  36. }
  37. },
  38. handleAgreePrivacyAuthorization() {
  39. this.privacySubmit()
  40. },
  41. privacySubmit() {
  42. this.triggerEvent('privacySubmit')
  43. this.hidden()
  44. },
  45. hidden() {
  46. this.setData({
  47. show: false
  48. })
  49. },
  50. openPrivacyContract() {
  51. wx.openPrivacyContract({
  52. success() {
  53. console.log('打开隐私协议')
  54. }
  55. })
  56. }
  57. }
  58. })