privacy-authorize-popup.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. watch: {
  46. visible(val) {
  47. this.$emit('visibility-change', val)
  48. },
  49. },
  50. methods: {
  51. open() {
  52. this.visible = true
  53. this.$emit('visibility-change', true)
  54. },
  55. close() {
  56. this.visible = false
  57. clearPrivacyPopupFlag()
  58. },
  59. openPrivacyContract() {
  60. // #ifdef MP-WEIXIN
  61. if (typeof wx !== 'undefined' && wx.openPrivacyContract) {
  62. wx.openPrivacyContract({
  63. fail: () => {
  64. uni.$u.toast('暂无法打开隐私指引')
  65. },
  66. })
  67. }
  68. // #endif
  69. },
  70. handleAgree() {
  71. const resolve = getPrivacyResolve()
  72. if (resolve) {
  73. resolve({ buttonId: 'agree-privacy-btn', event: 'agree' })
  74. }
  75. clearPrivacyResolve()
  76. this.close()
  77. },
  78. handleDisagree() {
  79. const resolve = getPrivacyResolve()
  80. if (resolve) {
  81. resolve({ event: 'disagree' })
  82. }
  83. clearPrivacyResolve()
  84. this.close()
  85. },
  86. },
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .privacy-modal {
  91. padding: 40rpx 36rpx 32rpx;
  92. background: #fff;
  93. &__title {
  94. font-size: 34rpx;
  95. font-weight: 600;
  96. color: #333;
  97. text-align: center;
  98. margin-bottom: 24rpx;
  99. }
  100. &__desc {
  101. font-size: 26rpx;
  102. color: #666;
  103. line-height: 1.7;
  104. margin-bottom: 32rpx;
  105. }
  106. &__link {
  107. color: #38c148;
  108. }
  109. &__footer {
  110. display: flex;
  111. gap: 20rpx;
  112. }
  113. &__btn {
  114. flex: 1;
  115. height: 80rpx;
  116. line-height: 80rpx;
  117. font-size: 28rpx;
  118. border-radius: 10rpx;
  119. border: none;
  120. margin: 0;
  121. padding: 0;
  122. &::after {
  123. border: none;
  124. }
  125. &--cancel {
  126. background: #f1f1f1;
  127. color: #666;
  128. }
  129. &--confirm {
  130. background: #38c148;
  131. color: #fff;
  132. }
  133. }
  134. }
  135. </style>