index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="policy-dialog" v-if="visible" @click="onMaskClick">
  3. <view class="dialog-content" @click.stop>
  4. <view class="dialog-header">
  5. <text class="dialog-title">{{ title }}</text>
  6. <view class="close-btn" @click="onClose">
  7. <uni-icons type="closeempty" size="20" color="#999"></uni-icons>
  8. </view>
  9. </view>
  10. <scroll-view scroll-y class="dialog-body">
  11. <view class="policy-content">
  12. <text class="policy-text">{{ content }}</text>
  13. </view>
  14. </scroll-view>
  15. <view class="dialog-footer">
  16. <button class="confirm-btn" @click="onClose">我知道了</button>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import { ref, watch } from 'vue'
  23. const props = defineProps({
  24. visible: {
  25. type: Boolean,
  26. default: false
  27. },
  28. title: {
  29. type: String,
  30. default: ''
  31. },
  32. content: {
  33. type: String,
  34. default: ''
  35. },
  36. maskClosable: {
  37. type: Boolean,
  38. default: true
  39. }
  40. })
  41. const emit = defineEmits(['update:visible', 'close'])
  42. const onClose = () => {
  43. emit('update:visible', false)
  44. emit('close')
  45. }
  46. const onMaskClick = () => {
  47. if (props.maskClosable) {
  48. onClose()
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .policy-dialog {
  54. position: fixed;
  55. top: 0;
  56. left: 0;
  57. right: 0;
  58. bottom: 0;
  59. background: rgba(0, 0, 0, 0.5);
  60. display: flex;
  61. align-items: center;
  62. justify-content: center;
  63. z-index: 9999;
  64. padding: 40rpx;
  65. }
  66. .dialog-content {
  67. width: 100%;
  68. max-height: 80vh;
  69. background: #fff;
  70. border-radius: 32rpx;
  71. display: flex;
  72. flex-direction: column;
  73. overflow: hidden;
  74. }
  75. .dialog-header {
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. position: relative;
  80. padding: 32rpx;
  81. border-bottom: 1rpx solid #f5f5f5;
  82. }
  83. .dialog-title {
  84. font-size: 32rpx;
  85. font-weight: bold;
  86. color: #333;
  87. }
  88. .close-btn {
  89. position: absolute;
  90. right: 32rpx;
  91. top: 50%;
  92. transform: translateY(-50%);
  93. }
  94. .dialog-body {
  95. flex: 1;
  96. padding: 32rpx;
  97. overflow-y: auto;
  98. }
  99. .policy-content {
  100. line-height: 1.8;
  101. }
  102. .policy-text {
  103. font-size: 28rpx;
  104. color: #666;
  105. white-space: pre-wrap;
  106. }
  107. .dialog-footer {
  108. padding: 24rpx 32rpx;
  109. border-top: 1rpx solid #f5f5f5;
  110. }
  111. .confirm-btn {
  112. width: 100%;
  113. height: 88rpx;
  114. background: linear-gradient(90deg, #ffd53f, #ff9500);
  115. color: #333;
  116. border: none;
  117. border-radius: 44rpx;
  118. font-size: 30rpx;
  119. font-weight: bold;
  120. }
  121. </style>