<template>
  <div>
    <j-nav-bar />
    <div class="contract" v-if="contractHtml" v-html="contractHtml"></div>
    <div v-else class="noData">{{ $t('app.none') + $t('app.contract') }}</div>
  </div>
</template>

<script lang="ts" setup>
import {onMounted, ref} from 'vue'
import {getContract} from "@/api";
import {showToast} from "vant";
import {useRoute} from "vue-router";
import { useI18n } from 'vue-i18n';

const route = useRoute()
const { t } = useI18n()

const contractHtml = ref('')



const _getContract = () => {
  if (route.query.tradeNo) {
    getContract({tradeNo: route.query.tradeNo}).then(res => {
      contractHtml.value = res
    })
  } else {
    showToast(t('app.none') + t('app.contract'))
  }
}

onMounted(() => {
  _getContract()
})
</script>

<style lang="scss" scoped>
.contract {
  //width: 100%;
  padding: 20px ;
}
.noData {
  height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #cccccc;
  font-size: 50px;
  font-weight: bold;
}
</style>