<script setup>
import Container from "../../components/Container/Container.vue";
import { onShow } from "@dcloudio/uni-app";
import { request } from "../../utils/request";
import { getRoute } from "../../utils/router";
import uvParse from "../../uni_modules/uv-parse/components/uv-parse/uv-parse.vue";
import { ref } from "vue";

const replaceImageDimensions = (str) =>
  str
    .replace(
      /<img([^>]*?)style="([^"]*?)width:\s*[^;]+;\s*height:\s*[^;]+;([^"]*?)"([^>]*?)\/?>/g,
      '<img$1style="$2width:100%;height:100%;$3"$4/>'
    )
    .replace(
      /<img([^>]*?)width="[^"]*"([^>]*?)height="[^"]*"([^>]*?)\/?>/g,
      '<img$1width="100%"$2height="100%"$3/>'
    );
const context = ref("");
const titles = ref("活动");
onShow(() => {
  const { id, title } = getRoute().params;
  if (title) {
    titles.value = title;
  }
  request("api/question_bank/question_reception/recharge_package/detail", {
    id,
  }).then((res) => {
    context.value = res.data.instructions || "";
  });
});
</script>
<template>
  <Container :title="titles">
    <uvParse class="text" :content="replaceImageDimensions(context)"></uvParse>
  </Container>
</template>
<style scoped lang="scss">
.text {
  line-height: 2;
}
</style>
