userPrivacy.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <!-- 隐私保护指引弹窗 -->
  4. <u-popup v-model="privacyShow" mode="bottom" border-radius="12" :mask-close-able="false">
  5. <view class="privacyBox">
  6. <view class="privacyTit">{{ title }}</view>
  7. <view class="privacyDesc">
  8. 感谢您的使用,在使用本小程序前,您应当阅读并同意
  9. <text @click="openClick">{{ title }}</text>
  10. 。当您点击同意并开始使用程序服务时,即表示您已理解并同意该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法使用该功能。
  11. </view>
  12. <view class="privacyPost">
  13. <view class="refuseBtn" @click="close">
  14. <!-- <navigator target="miniProgram" open-type="exit">不同意并退出</navigator> -->
  15. 不同意
  16. </view>
  17. <button class="agreeBtn" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="agreeClick">同意并继续</button>
  18. </view>
  19. </view>
  20. </u-popup>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'userPrivacy',
  26. data() {
  27. return {
  28. // 隐私设置弹窗开关
  29. privacyShow: false,
  30. title: '',
  31. resolve: null
  32. };
  33. },
  34. methods: {
  35. // 打开隐私协议
  36. openClick() {
  37. wx.openPrivacyContract({
  38. success: () => {}, // 打开成功
  39. fail: () => {}, // 打开失败
  40. complete: () => {}
  41. });
  42. },
  43. // 同意
  44. agreeClick() {
  45. // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
  46. this.privacyShow = false;
  47. uni.showTabBar();
  48. },
  49. //close
  50. close() {
  51. this.privacyShow = false;
  52. uni.showTabBar();
  53. },
  54. //获取隐私协议
  55. getPrivacySettingFn() {
  56. var _this = this;
  57. // 隐私政策
  58. wx.getPrivacySetting({
  59. success: (res) => {
  60. console.log(res);
  61. // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
  62. if (res.needAuthorization) {
  63. // 需要弹出隐私协议
  64. _this.privacyShow = true;
  65. _this.title = res.privacyContractName;
  66. uni.hideTabBar();
  67. return;
  68. } else {
  69. // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口
  70. }
  71. },
  72. fail: () => {},
  73. complete: () => {}
  74. });
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss">
  80. .privacyBox {
  81. width: 100%;
  82. padding: 60rpx;
  83. box-sizing: border-box;
  84. }
  85. .privacyTit {
  86. font-size: 32rpx;
  87. font-weight: bold;
  88. text-align: center;
  89. overflow: hidden;
  90. }
  91. .privacyDesc {
  92. font-size: 28rpx;
  93. overflow: hidden;
  94. margin-top: 30rpx;
  95. color: #000;
  96. }
  97. .privacyDesc text {
  98. color: #409eff;
  99. }
  100. .privacyPost {
  101. overflow: hidden;
  102. margin-top: 60rpx;
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. }
  107. .privacyPost .refuseBtn {
  108. flex: 1;
  109. height: 80rpx;
  110. line-height: 80rpx;
  111. text-align: center;
  112. font-size: 28rpx;
  113. font-weight: bold;
  114. color: #fff;
  115. background-color: #f5f5f5;
  116. border-radius: 12rpx;
  117. box-sizing: border-box;
  118. overflow: hidden;
  119. color: #a5a5a5;
  120. }
  121. .privacyPost .agreeBtn {
  122. flex: 1;
  123. height: 80rpx;
  124. line-height: 80rpx;
  125. text-align: center;
  126. font-size: 28rpx;
  127. font-weight: bold;
  128. color: #fff;
  129. background-color: #07c25f;
  130. border-radius: 12rpx;
  131. box-sizing: border-box;
  132. overflow: hidden;
  133. margin-left: 20rpx;
  134. }
  135. </style>