index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <script setup>
  2. import Container from "../../components/Container/Container.vue";
  3. import { onShow } from "@dcloudio/uni-app";
  4. import { request } from "../../utils/request";
  5. import { getRoute } from "../../utils/router";
  6. import uvParse from "../../uni_modules/uv-parse/components/uv-parse/uv-parse.vue";
  7. import { ref } from "vue";
  8. const replaceImageDimensions = (str) =>
  9. str
  10. .replace(
  11. /<img([^>]*?)style="([^"]*?)width:\s*[^;]+;\s*height:\s*[^;]+;([^"]*?)"([^>]*?)\/?>/g,
  12. '<img$1style="$2width:100%;height:100%;$3"$4/>'
  13. )
  14. .replace(
  15. /<img([^>]*?)width="[^"]*"([^>]*?)height="[^"]*"([^>]*?)\/?>/g,
  16. '<img$1width="100%"$2height="100%"$3/>'
  17. );
  18. const context = ref("");
  19. const titles = ref("");
  20. onShow(() => {
  21. /**
  22. * service_rights=会员服务权益,
  23. * automatic_renewal_agreement=自动续费协议
  24. * examination_countdown=倒计时,
  25. * challenge_activities=奖学金挑战信息
  26. */
  27. const { title, content_code } = getRoute().params;
  28. if (title) {
  29. titles.value = title;
  30. }
  31. request("api/question_bank/question_reception/common_config/detail", {
  32. content_code,
  33. }).then((res) => {
  34. context.value = res.data.content_detail || "";
  35. });
  36. });
  37. </script>
  38. <template>
  39. <Container :title="titles">
  40. <uvParse class="text" :content="replaceImageDimensions(context)"></uvParse>
  41. </Container>
  42. </template>
  43. <style scoped lang="scss">
  44. .text {
  45. line-height: 2;
  46. }
  47. </style>