policy-consent-modal.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. watch: {
  42. visible(val) {
  43. this.$emit('visibility-change', val)
  44. },
  45. },
  46. methods: {
  47. open() {
  48. this.checked = false
  49. this.visible = true
  50. // 同步触发 visibility,确保立即 hideTabBar
  51. this.$emit('visibility-change', true)
  52. },
  53. close() {
  54. this.visible = false
  55. },
  56. openArticle(type) {
  57. const code = ARTICLE_CODE[type] || ARTICLE_CODE.orderAgreement
  58. const title = ARTICLE_TITLE[type] || '协议'
  59. uni.navigateTo({
  60. url: `/pages-home/pages/user-agreement?code=${code}&title=${encodeURIComponent(title)}`,
  61. })
  62. },
  63. handleAgree() {
  64. if (!this.checked) {
  65. uni.$u.toast('请先阅读并勾选同意协议')
  66. return
  67. }
  68. this.$emit('accepted')
  69. this.close()
  70. },
  71. handleDisagree() {
  72. // #ifdef MP-WEIXIN
  73. if (typeof wx !== 'undefined' && wx.exitMiniProgram) {
  74. wx.exitMiniProgram()
  75. return
  76. }
  77. // #endif
  78. // #ifdef MP-ALIPAY
  79. if (typeof my !== 'undefined' && my.exitMiniProgram) {
  80. my.exitMiniProgram()
  81. return
  82. }
  83. // #endif
  84. uni.$u.toast('需同意协议后方可使用')
  85. },
  86. },
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .policy-modal {
  91. padding: 40rpx 50rpx;
  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: 24rpx;
  105. }
  106. &__links {
  107. font-size: 26rpx;
  108. color: #666;
  109. line-height: 1.8;
  110. margin-bottom: 20rpx;
  111. }
  112. &__link {
  113. color: #38c148;
  114. }
  115. &__checkbox {
  116. margin-bottom: 32rpx;
  117. }
  118. &__checkbox-text {
  119. font-size: 26rpx;
  120. color: #333;
  121. }
  122. &__footer {
  123. display: flex;
  124. gap: 20rpx;
  125. margin-top: 20rpx;
  126. }
  127. &__btn {
  128. flex: 1;
  129. height: 80rpx;
  130. line-height: 80rpx;
  131. font-size: 28rpx;
  132. border-radius: 10rpx;
  133. border: none;
  134. margin: 0;
  135. padding: 0;
  136. &::after {
  137. border: none;
  138. }
  139. &--cancel {
  140. background: #f1f1f1;
  141. color: #666;
  142. }
  143. &--confirm {
  144. background: #38c148;
  145. color: #fff;
  146. }
  147. }
  148. }
  149. </style>