ruleModel.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <Popup ref="popup" isClose mode="center" class="pop">
  3. <template #content>
  4. <scroll-view class="content-scroll" scroll-y>
  5. <rich-text
  6. :nodes="formatContent(content)"
  7. class="rich-content"
  8. ></rich-text>
  9. </scroll-view>
  10. </template>
  11. <template #footer>
  12. <view class="submit_btn" @click="close">
  13. <trans _t="我知道了" />
  14. </view>
  15. </template>
  16. </Popup>
  17. </template>
  18. <script setup>
  19. import { ref, watch } from "vue";
  20. import Popup from "./popup.vue";
  21. import { OTHER_ABOUT } from "@/api";
  22. const props = defineProps({
  23. type: {
  24. type: String,
  25. default: "agree",
  26. },
  27. });
  28. const emit = defineEmits(["close"]);
  29. const popup = ref(null);
  30. const content = ref("");
  31. const getDetail = async (type) => {
  32. try {
  33. const res = await OTHER_ABOUT(type);
  34. content.value = res.data;
  35. popup.value.open();
  36. } catch (error) {}
  37. };
  38. const formatContent = (html) => {
  39. if (!html) return "";
  40. return html
  41. .replace(/<script[^>]*?>.*?<\/script>/gi, "")
  42. .replace(/onerror\s*=/gi, "")
  43. .replace(/javascript:/gi, "");
  44. };
  45. // 打开弹窗
  46. const open = (type) => {
  47. getDetail(type);
  48. };
  49. // 关闭弹窗
  50. const close = () => {
  51. content.value = "";
  52. popup.value.close();
  53. emit("close");
  54. };
  55. defineExpose({ open, close });
  56. </script>
  57. <style lang="less" scoped>
  58. @import url("@/style.less");
  59. :deep(.u-popup__content) {
  60. width: 92%;
  61. }
  62. .submit_btn {
  63. height: 38px;
  64. padding: 16rpx 30rpx;
  65. background-color: var(--black);
  66. color: var(--light);
  67. .flex_center();
  68. border-radius: 16rpx;
  69. .size(24rpx);
  70. }
  71. .content-scroll {
  72. flex: 1;
  73. min-width: 80vw;
  74. // padding: 16px 20px;
  75. min-height: 30vh;
  76. max-height: 60vh;
  77. box-sizing: border-box;
  78. .rich-content {
  79. font-size: 15px;
  80. line-height: 1.6;
  81. color: #333;
  82. :deep(p) {
  83. margin-bottom: 12px;
  84. }
  85. :deep(a) {
  86. color: #409eff;
  87. text-decoration: none;
  88. }
  89. :deep(img) {
  90. max-width: 100%;
  91. height: auto;
  92. }
  93. }
  94. }
  95. </style>