<template>
  <layout :bgImgName="null" :bgHeight="null" :bgColor="null" @goBack="goBack" forceShowNavBar>
    <div v-html="html"></div>
  </layout>
</template>

<script>
import layout from './components/layout.vue';
export default {
  name: 'agreement',
  data() {
    return {
      html: '',
    };
  },
  auth: false,
  head: {
    title: '相关协议',
  },
  components: {
    layout,
  },
  mounted() {
    this.getAgreement();
  },
  methods: {
    getAgreement() {
      this.$toast.loading({
        message: '加载中...',
        forbidClick: true,
        duration: 0,
      });
      this.$axios
        .$get('public/v4/agreement/content', {
          params: {
            agreementCoding: this.$route.query.agreementCoding,
          },
        })
        .then((res) => {
          if (res.success) {
            const html = res.data.content;
            const rx = /<body[^>]*>([\s\S]+?)<\/body>/i;
            let m = rx.exec(html);
            if (m) {
              m = m[1];
            }
            this.html = m;
          }
        })
        .catch((error) => {
          this.$toast(error.message);
        })
        .finally(() => {
          this.$toast.clear();
        });
    },
    goBack() {
      sessionStorage.setItem('isAgreementBool', 1);
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped></style>
