privacy-popup.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="popup-mask" v-if="visible" @click.stop>
  3. <view class="popup-content">
  4. <!-- 顶部: 标题 + 关闭按钮 -->
  5. <view class="popup-header">
  6. <text class="popup-title">{{ title }}</text>
  7. <view class="close-icon" @click="close">×</view>
  8. </view>
  9. <!-- 内容滚动区 -->
  10. <scroll-view scroll-y class="popup-body">
  11. <slot>
  12. <text class="default-text">{{ content }}</text>
  13. </slot>
  14. </scroll-view>
  15. <!-- 底部按钮 -->
  16. <view class="popup-footer">
  17. <button class="confirm-btn" @click="close">我知道了</button>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'privacy-popup',
  25. props: {
  26. visible: {
  27. type: Boolean,
  28. default: false
  29. },
  30. title: {
  31. type: String,
  32. default: '协议标题'
  33. },
  34. content: {
  35. type: String, // 备用,主要用 slot
  36. default: ''
  37. }
  38. },
  39. methods: {
  40. close() {
  41. this.$emit('close');
  42. }
  43. }
  44. }
  45. </script>
  46. <style scoped>
  47. .popup-mask {
  48. position: fixed;
  49. top: 0;
  50. left: 0;
  51. right: 0;
  52. bottom: 0;
  53. background-color: rgba(0, 0, 0, 0.4); /* 半透明遮罩 */
  54. z-index: 999;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. }
  59. .popup-content {
  60. width: 80%; /* 宽度大概屏幕 80% */
  61. max-height: 70%;
  62. background-color: #fff;
  63. border-radius: 16rpx;
  64. display: flex;
  65. flex-direction: column;
  66. overflow: hidden;
  67. }
  68. .popup-header {
  69. height: 100rpx;
  70. display: flex;
  71. align-items: center;
  72. justify-content: center;
  73. position: relative;
  74. border-bottom: 2rpx solid #eee;
  75. }
  76. .popup-title {
  77. font-size: 32rpx;
  78. font-weight: bold;
  79. color: #333;
  80. }
  81. .close-icon {
  82. position: absolute;
  83. right: 30rpx;
  84. top: 50%;
  85. transform: translateY(-50%);
  86. font-size: 40rpx;
  87. color: #999;
  88. line-height: 1;
  89. padding: 10rpx; /* 增加点击区域 */
  90. }
  91. .popup-body {
  92. padding: 30rpx;
  93. font-size: 28rpx;
  94. color: #666;
  95. line-height: 1.6;
  96. max-height: 600rpx; /* 限制高度滚动 */
  97. box-sizing: border-box;
  98. }
  99. .popup-footer {
  100. padding: 30rpx;
  101. border-top: 2rpx solid #eee;
  102. }
  103. .confirm-btn {
  104. background: linear-gradient(90deg, #FF6F00 0%, #FF5722 100%);
  105. color: #fff;
  106. font-size: 30rpx;
  107. font-weight: bold;
  108. height: 80rpx;
  109. line-height: 80rpx;
  110. border-radius: 8rpx;
  111. box-shadow: 0 4rpx 10rpx rgba(255, 87, 34, 0.2);
  112. }
  113. .confirm-btn::after {
  114. border: none;
  115. }
  116. </style>