PrivacyAgreement.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <fs-modal v-model="showPrivacy" :showTitle="false" :showCancel="false" :showConfirm="false" :maskClickable="false">
  3. <view class="modal-content">
  4. <view class="modal-content-title bdb">用户隐私保护提示</view>
  5. <view class="modal-content-section">
  6. <view class="section">
  7. 欢迎使用我们的服务!在您开始体验我们提供的便捷与高效之前,请您务必仔细阅读我们的<text class="primary" @click="handleOpenPrivacyContract">{{
  8. privacyContractName }}</text>。该指引详细阐述了我们如何收集、使用、存储和保护您的个人信息,以及您在使用服务过程中所享有的权利。
  9. </view>
  10. <view class="section">
  11. 我们深知个人信息对您的重要性,并承诺将严格按照相关法律法规和<text class="primary" @click="handleOpenPrivacyContract">{{
  12. privacyContractName }}</text>的约定,保护您的个人信息安全。我们建议您完整阅读隐私指引,以便更好地了解我们的隐私保护措施。
  13. </view>
  14. <view class="section">
  15. 如果您对<text class="primary" @click="handleOpenPrivacyContract">{{
  16. privacyContractName }}</text>的内容表示理解并同意,请您点击“同意”按钮,以开始使用本小程序。您的点击同意将视为对我们隐私指引的认可和接受。
  17. </view>
  18. </view>
  19. <view class="modal-content-footer-btn bdt tw-flex tw-items-center tw-justify-around">
  20. <button class="xc-button bg-danger tw-w-[46%] tw-rounded-[8rpx]"
  21. @click="handleRefusePrivacyAuthorization">拒绝</button>
  22. <button class="xc-button bg-success tw-w-[46%] tw-rounded-[8rpx]" id="agree-btn"
  23. open-type="agreePrivacyAuthorization" @click="handleAgreePrivacyAuthorization">同意</button>
  24. </view>
  25. </view>
  26. </fs-modal>
  27. </template>
  28. <script setup>
  29. const TNAME = '《用户隐私保护指引》'
  30. const emits = defineEmits(['change'])
  31. const showPrivacy = ref(false)
  32. const privacyContractName = ref(TNAME)
  33. onMounted(() => {
  34. initGetPrivacySetting()
  35. })
  36. // 获取隐私设置
  37. const initGetPrivacySetting = () => {
  38. if (!uni.getPrivacySetting) {
  39. // H5端 直接跳过
  40. showPrivacy.value = false
  41. emits('change', false)
  42. return false
  43. }
  44. uni.getPrivacySetting({
  45. success: (res) => {
  46. privacyContractName.value = res.privacyContractName || TNAME
  47. if (res.needAuthorization) {
  48. showPrivacy.value = true // 需要授权
  49. } else {
  50. handleAgreePrivacyAuthorization() // 不需要授权
  51. }
  52. },
  53. fail: (err) => {
  54. handleAgreePrivacyAuthorization()
  55. },
  56. })
  57. }
  58. // 查看隐私协议内容
  59. const handleOpenPrivacyContract = () => {
  60. uni.openPrivacyContract({
  61. success: (res) => { },
  62. fail: (err) => {
  63. uni.showToast({
  64. title: '打开隐私协议失败',
  65. icon: 'none',
  66. })
  67. },
  68. complete: () => { }
  69. });
  70. }
  71. // 同意隐私授权
  72. const handleAgreePrivacyAuthorization = () => {
  73. showPrivacy.value = false
  74. emits('change', false)
  75. }
  76. // 拒绝隐私授权
  77. const handleRefusePrivacyAuthorization = () => {
  78. showPrivacy.value = false
  79. emits('change', true)
  80. }
  81. // 导出
  82. defineExpose({
  83. initGetPrivacySetting,
  84. })
  85. </script>
  86. <style lang="scss" scoped>
  87. .modal-content {
  88. padding: 20rpx;
  89. text-align: left;
  90. &-title {
  91. font-size: 38rpx;
  92. padding-bottom: 20rpx;
  93. font-weight: 700;
  94. text-align: center;
  95. }
  96. &-section {
  97. min-height: 200rpx;
  98. max-height: 600rpx;
  99. overflow-y: auto;
  100. word-wrap: break-word;
  101. white-space: pre-line;
  102. .section {
  103. text-indent: 2em;
  104. margin: 10rpx 0;
  105. }
  106. }
  107. &-footer-btn {
  108. padding-top: 30rpx;
  109. }
  110. }
  111. </style>