index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view v-if="visible" class="agreement-mask" @touchmove.stop.prevent>
  3. <view class="agreement-container">
  4. <view class="agreement-header">
  5. <text class="agreement-title">{{ title || '协议详情' }}</text>
  6. </view>
  7. <scroll-view scroll-y class="agreement-body">
  8. <view class="agreement-content">
  9. <rich-text :nodes="decodedContent"></rich-text>
  10. </view>
  11. </scroll-view>
  12. <view class="agreement-footer">
  13. <button class="confirm-btn" @click="handleClose">确 定</button>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { decodeBase64 } from '@/utils/index'
  20. /**
  21. * 协议详情组件 (纯 UI 组件)
  22. * @property {Boolean} visible 控制显示隐藏
  23. * @property {String} title 协议标题
  24. * @property {String} content 协议内容 (支持 HTML)
  25. * @event {Function} close 关闭回调
  26. */
  27. export default {
  28. name: 'Agreement',
  29. props: {
  30. visible: {
  31. type: Boolean,
  32. default: false
  33. },
  34. title: {
  35. type: String,
  36. default: ''
  37. },
  38. content: {
  39. type: String,
  40. default: ''
  41. }
  42. },
  43. computed: {
  44. decodedContent() {
  45. return decodeBase64(this.content)
  46. }
  47. },
  48. methods: {
  49. /**
  50. * 关闭弹窗
  51. */
  52. handleClose() {
  53. this.$emit('close');
  54. }
  55. }
  56. };
  57. </script>
  58. <style scoped>
  59. .agreement-mask {
  60. position: fixed;
  61. top: 0;
  62. left: 0;
  63. width: 100%;
  64. height: 100%;
  65. background-color: rgba(0, 0, 0, 0.6);
  66. z-index: 1000;
  67. display: flex;
  68. align-items: center;
  69. justify-content: center;
  70. }
  71. .agreement-container {
  72. width: 600rpx;
  73. max-height: 80vh;
  74. background-color: #ffffff;
  75. border-radius: 20rpx;
  76. display: flex;
  77. flex-direction: column;
  78. overflow: hidden;
  79. animation: fadeIn 0.3s ease;
  80. }
  81. .agreement-header {
  82. padding: 30rpx;
  83. text-align: center;
  84. border-bottom: 2rpx solid #f5f5f5;
  85. }
  86. .agreement-title {
  87. font-size: 32rpx;
  88. font-weight: bold;
  89. color: #333333;
  90. }
  91. .agreement-body {
  92. flex: 1;
  93. box-sizing: border-box;
  94. max-height: 50vh;
  95. }
  96. .agreement-content {
  97. padding: 30rpx;
  98. font-size: 28rpx;
  99. line-height: 1.6;
  100. color: #666666;
  101. }
  102. .agreement-footer {
  103. padding: 30rpx;
  104. border-top: 2rpx solid #f5f5f5;
  105. }
  106. .confirm-btn {
  107. width: 100%;
  108. height: 80rpx;
  109. line-height: 80rpx;
  110. background-color: #ff5722;
  111. color: #ffffff;
  112. border-radius: 40rpx;
  113. font-size: 28rpx;
  114. }
  115. @keyframes fadeIn {
  116. from {
  117. opacity: 0;
  118. transform: scale(0.9);
  119. }
  120. to {
  121. opacity: 1;
  122. transform: scale(1);
  123. }
  124. }
  125. </style>