• uniapp微信小程序用户隐私保护指引弹窗组件


    1. <template>
    2. <view v-if="showPrivacy" :class="privacyClass">
    3. <view :class="contentClass">
    4. <view class="title">用户隐私保护指引view>
    5. <view class="des">
    6. 感谢您选择使用我们的小程序,我们非常重视您的个人信息安全和隐私保护。使用我们的产品前,请您仔细阅读“
    7. <text class="link" @tap="openPrivacyContract">{{privacyContractName}} text>”,
    8. 如您同意此隐私保护指引,请点击同意按钮,开始使用此小程序,我们将尽全力保护您的个人信息及合法权益,感谢您的信任!<br />
    9. view>
    10. <view class="btns">
    11. <button class="item reject" @tap="exitMiniProgram">拒绝button>
    12. <button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization"
    13. @agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意button>
    14. view>
    15. view>
    16. view>
    17. template>
    18. <script>
    19. export default {
    20. name: 'PrivacyPopup',
    21. data() {
    22. return {
    23. isRead: false,
    24. showPrivacy: false,
    25. privacyContractName: '',
    26. resolvePrivacyAuthorization: null,
    27. };
    28. },
    29. props: {
    30. position: {
    31. type: String,
    32. default: 'center'
    33. }
    34. },
    35. computed: {
    36. privacyClass() {
    37. return this.position === 'bottom' ? 'privacy privacy-bottom' : 'privacy';
    38. },
    39. contentClass() {
    40. return this.position === 'bottom' ? 'content2 content-bottom' : 'content2';
    41. }
    42. },
    43. mounted() {
    44. if (wx.onNeedPrivacyAuthorization) {
    45. wx.onNeedPrivacyAuthorization((resolve) => {
    46. this.resolvePrivacyAuthorization = resolve;
    47. });
    48. }
    49. if (wx.getPrivacySetting) {
    50. wx.getPrivacySetting({
    51. success: (res) => {
    52. console.log(res, 'getPrivacySetting');
    53. if (res.needAuthorization) {
    54. this.privacyContractName = res.privacyContractName;
    55. this.showPrivacy = true;
    56. }
    57. },
    58. });
    59. }
    60. },
    61. methods: {
    62. openPrivacyContract() {
    63. wx.openPrivacyContract({
    64. success: () => {
    65. this.isRead = true;
    66. },
    67. fail: () => {
    68. uni.showToast({
    69. title: '遇到错误',
    70. icon: 'error',
    71. });
    72. },
    73. });
    74. },
    75. exitMiniProgram() {
    76. wx.exitMiniProgram();
    77. },
    78. handleAgreePrivacyAuthorization() {
    79. this.showPrivacy = false;
    80. if (typeof this.resolvePrivacyAuthorization === 'function') {
    81. this.resolvePrivacyAuthorization({
    82. buttonId: 'agree-btn',
    83. event: 'agree',
    84. });
    85. }
    86. },
    87. },
    88. };
    89. script>
    90. <style lang="scss" scoped>
    91. .privacy {
    92. position: fixed;
    93. top: 0;
    94. right: 0;
    95. bottom: 0;
    96. left: 0;
    97. background: rgba(0, 0, 0, .5);
    98. z-index: 9999999;
    99. display: flex;
    100. align-items: center;
    101. justify-content: center;
    102. }
    103. .privacy-bottom {
    104. align-items: flex-end;
    105. }
    106. .content2 {
    107. width: 632rpx;
    108. padding: 48rpx;
    109. box-sizing: border-box;
    110. background: #fff;
    111. border-radius: 16rpx;
    112. }
    113. .content-bottom {
    114. position: absolute;
    115. bottom: 0;
    116. width: 100%;
    117. padding: 36rpx;
    118. padding-bottom: constant(safe-area-inset-bottom);
    119. padding-bottom: env(safe-area-inset-bottom);
    120. border-radius: 16rpx 16rpx 0 0;
    121. }
    122. .content2 .title {
    123. text-align: center;
    124. color: #333;
    125. font-weight: bold;
    126. font-size: 32rpx;
    127. }
    128. .content2 .des {
    129. font-size: 26rpx;
    130. color: #666;
    131. margin-top: 40rpx;
    132. text-align: justify;
    133. line-height: 1.6;
    134. }
    135. .content2 .des .link {
    136. color: #07c160;
    137. text-decoration: underline;
    138. }
    139. .btns {
    140. margin-top: 48rpx;
    141. margin-bottom: 12rpx;
    142. display: flex;
    143. }
    144. .btns .item {
    145. width: 200rpx;
    146. height: 72rpx;
    147. overflow: visible;
    148. display: flex;
    149. align-items: center;
    150. justify-content: center;
    151. /* border-radius: 16rpx; */
    152. box-sizing: border-box;
    153. border: none !important;
    154. }
    155. .btns .reject {
    156. background: #f4f4f5;
    157. color: #07c160;
    158. font-size: 14px;
    159. font-weight: 300;
    160. margin-right: 16rpx;
    161. width: 240rpx;
    162. &::after{
    163. border: none;
    164. }
    165. }
    166. .btns .agree {
    167. width: 240rpx;
    168. background: #07c160;
    169. color: #fff;
    170. font-size: 16px;
    171. &::after{
    172. border: none;
    173. }
    174. }
    175. .privacy-bottom .btns .agree {
    176. width: 240rpx;
    177. }
    178. style>

    然后在用到的页面进行引入

    1. <template>
    2. <popup ref="privacyComponent" position="bottom" />
    3. template>
    4. <script setup>
    5. import popup from '/components/privacy-popup.vue'
    6. script>

  • 相关阅读:
    springcloud5:zookeeper和Consul
    软件外包开发需求文档编写
    网络七层协议
    RPA是什么?AI和RPA可以结合吗?
    SCAN_RESULTS_EVENT消息发送&接收
    ECharts与Excel的结合实战
    mysql8.0.34部署单节点与集群-AB复制(IO与SQL线程不同步解决方法)
    一些概念梳理
    【python】一:基础学习-数据类型及相关方法
    MySQL性能优化指南:深入分析重做日志刷新到磁盘的机制
  • 原文地址:https://blog.csdn.net/weixin_59685936/article/details/132881234