privacy-authorize-popup.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <u-popup
  3. v-model="visible"
  4. mode="center"
  5. border-radius="20"
  6. width="620rpx"
  7. :mask-close-able="false"
  8. :z-index="privacyZIndex"
  9. >
  10. <view class="privacy-modal">
  11. <view class="privacy-modal__title">隐私保护提示</view>
  12. <view class="privacy-modal__desc">
  13. 在使用相关功能前,请你阅读并同意
  14. <text class="privacy-modal__link" @click="openPrivacyContract">《隐私保护指引》</text>
  15. 。我们将严格按照指引处理你的个人信息。
  16. </view>
  17. <view class="privacy-modal__footer">
  18. <button class="privacy-modal__btn privacy-modal__btn--cancel" @click="handleDisagree">拒绝</button>
  19. <button
  20. id="agree-privacy-btn"
  21. class="privacy-modal__btn privacy-modal__btn--confirm"
  22. open-type="agreePrivacyAuthorization"
  23. @agreeprivacyauthorization="handleAgree"
  24. >
  25. 同意
  26. </button>
  27. </view>
  28. </view>
  29. </u-popup>
  30. </template>
  31. <script>
  32. import {
  33. clearPrivacyPopupFlag,
  34. clearPrivacyResolve,
  35. getPrivacyResolve,
  36. } from '@/utils/policy-consent-manager.js'
  37. import { PRIVACY_POPUP_Z_INDEX } from '@/utils/policy-config.js'
  38. export default {
  39. data() {
  40. return {
  41. visible: false,
  42. privacyZIndex: PRIVACY_POPUP_Z_INDEX,
  43. }
  44. },
  45. methods: {
  46. open() {
  47. this.visible = true
  48. },
  49. close() {
  50. this.visible = false
  51. clearPrivacyPopupFlag()
  52. },
  53. openPrivacyContract() {
  54. // #ifdef MP-WEIXIN
  55. if (typeof wx !== 'undefined' && wx.openPrivacyContract) {
  56. wx.openPrivacyContract({
  57. fail: () => {
  58. uni.$u.toast('暂无法打开隐私指引')
  59. },
  60. })
  61. }
  62. // #endif
  63. },
  64. handleAgree() {
  65. const resolve = getPrivacyResolve()
  66. if (resolve) {
  67. resolve({ buttonId: 'agree-privacy-btn', event: 'agree' })
  68. }
  69. clearPrivacyResolve()
  70. this.close()
  71. },
  72. handleDisagree() {
  73. const resolve = getPrivacyResolve()
  74. if (resolve) {
  75. resolve({ event: 'disagree' })
  76. }
  77. clearPrivacyResolve()
  78. this.close()
  79. },
  80. },
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .privacy-modal {
  85. padding: 40rpx 36rpx 32rpx;
  86. background: #fff;
  87. &__title {
  88. font-size: 34rpx;
  89. font-weight: 600;
  90. color: #333;
  91. text-align: center;
  92. margin-bottom: 24rpx;
  93. }
  94. &__desc {
  95. font-size: 26rpx;
  96. color: #666;
  97. line-height: 1.7;
  98. margin-bottom: 32rpx;
  99. }
  100. &__link {
  101. color: #38c148;
  102. }
  103. &__footer {
  104. display: flex;
  105. gap: 20rpx;
  106. }
  107. &__btn {
  108. flex: 1;
  109. height: 80rpx;
  110. line-height: 80rpx;
  111. font-size: 28rpx;
  112. border-radius: 10rpx;
  113. border: none;
  114. margin: 0;
  115. padding: 0;
  116. &::after {
  117. border: none;
  118. }
  119. &--cancel {
  120. background: #f1f1f1;
  121. color: #666;
  122. }
  123. &--confirm {
  124. background: #38c148;
  125. color: #fff;
  126. }
  127. }
  128. }
  129. </style>