policy-consent-modal.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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="policyZIndex"
  9. >
  10. <view class="policy-modal">
  11. <view class="policy-modal__title">服务协议与隐私政策</view>
  12. <view class="policy-modal__desc">
  13. 请你务必审慎阅读、充分理解相关协议。当你点击同意并开始使用本产品服务时,即表示你已阅读并同意下列条款。
  14. </view>
  15. <view class="policy-modal__links">
  16. <text>我已阅读并同意</text>
  17. <text class="policy-modal__link" @click.stop="openArticle('userAgreement')">《用户协议》</text>
  18. <text>和</text>
  19. <text class="policy-modal__link" @click.stop="openArticle('privacyPolicy')">《隐私政策》</text>
  20. </view>
  21. <u-checkbox v-model="checked" shape="circle" active-color="#38C148" class="policy-modal__checkbox">
  22. <text class="policy-modal__checkbox-text">我已阅读并同意上述协议</text>
  23. </u-checkbox>
  24. <view class="policy-modal__footer">
  25. <button class="policy-modal__btn policy-modal__btn--cancel" @click="handleDisagree">不同意</button>
  26. <button class="policy-modal__btn policy-modal__btn--confirm" @click="handleAgree">同意并继续</button>
  27. </view>
  28. </view>
  29. </u-popup>
  30. </template>
  31. <script>
  32. import { ARTICLE_CODE, ARTICLE_TITLE, POLICY_POPUP_Z_INDEX } from '@/utils/policy-config.js'
  33. export default {
  34. data() {
  35. return {
  36. visible: false,
  37. checked: false,
  38. policyZIndex: POLICY_POPUP_Z_INDEX,
  39. }
  40. },
  41. methods: {
  42. open() {
  43. this.checked = false
  44. this.visible = true
  45. },
  46. close() {
  47. this.visible = false
  48. },
  49. openArticle(type) {
  50. const code = ARTICLE_CODE[type] || ARTICLE_CODE.orderAgreement
  51. const title = ARTICLE_TITLE[type] || '协议'
  52. uni.navigateTo({
  53. url: `/pages-home/pages/user-agreement?code=${code}&title=${encodeURIComponent(title)}`,
  54. })
  55. },
  56. handleAgree() {
  57. if (!this.checked) {
  58. uni.$u.toast('请先阅读并勾选同意协议')
  59. return
  60. }
  61. this.$emit('accepted')
  62. this.close()
  63. },
  64. handleDisagree() {
  65. // #ifdef MP-WEIXIN
  66. if (typeof wx !== 'undefined' && wx.exitMiniProgram) {
  67. wx.exitMiniProgram()
  68. return
  69. }
  70. // #endif
  71. // #ifdef MP-ALIPAY
  72. if (typeof my !== 'undefined' && my.exitMiniProgram) {
  73. my.exitMiniProgram()
  74. return
  75. }
  76. // #endif
  77. uni.$u.toast('需同意协议后方可使用')
  78. },
  79. },
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .policy-modal {
  84. padding: 40rpx 50rpx;
  85. background: #fff;
  86. &__title {
  87. font-size: 34rpx;
  88. font-weight: 600;
  89. color: #333;
  90. text-align: center;
  91. margin-bottom: 24rpx;
  92. }
  93. &__desc {
  94. font-size: 26rpx;
  95. color: #666;
  96. line-height: 1.7;
  97. margin-bottom: 24rpx;
  98. }
  99. &__links {
  100. font-size: 26rpx;
  101. color: #666;
  102. line-height: 1.8;
  103. margin-bottom: 20rpx;
  104. }
  105. &__link {
  106. color: #38c148;
  107. }
  108. &__checkbox {
  109. margin-bottom: 32rpx;
  110. }
  111. &__checkbox-text {
  112. font-size: 26rpx;
  113. color: #333;
  114. }
  115. &__footer {
  116. display: flex;
  117. gap: 20rpx;
  118. margin-top: 20rpx;
  119. }
  120. &__btn {
  121. flex: 1;
  122. height: 80rpx;
  123. line-height: 80rpx;
  124. font-size: 28rpx;
  125. border-radius: 10rpx;
  126. border: none;
  127. margin: 0;
  128. padding: 0;
  129. &::after {
  130. border: none;
  131. }
  132. &--cancel {
  133. background: #f1f1f1;
  134. color: #666;
  135. }
  136. &--confirm {
  137. background: #38c148;
  138. color: #fff;
  139. }
  140. }
  141. }
  142. </style>