<template>
<!--   <div
    :class="'container' + (mode ? ' old_container' : '')"
    v-loading="loading"
    element-loading-text="页面加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="#FFFFFF"
  > -->
  <div
    :class="'container' + (mode ? ' old_container' : '')"
  >


  <!--  v-loading="loading"
    van-loading-text="页面加载中"
    van-loading-spinner="el-icon-loading"
    van-loading-background="#FFFFFF" -->
    <div class="title">{{ info.title }}</div>
    <div class="date">{{ modifyDate(info.publicTime) }}</div>
    <hr />
    <div class="content"></div>
  </div>
</template>
<script>
import { mgop } from "@aligov/jssdk-mgop";
export default {
  data() {
    return {
      loading: true,
      info: {
        title: "加载中...",
        publicTime: "加载中...",
      },
    };
  },
  created() {
    this.mode = this.$root.mode;
    this.onInit();
  },
  mounted() {},
  computed: {
    watchMode() {
      return this.$root.mode;
    },
  },
  watch: {
    watchMode(val, oldVal) {
      this.mode = val;
    },
  },
  methods: {
    // 获取数据
    onInit() {
      if (this.$route.params.id) {
        window.sessionStorage.setItem("zszcId", this.$route.params.id);
      }
      mgop({
        api: "mgop.kykj.houseexpropriat.getpoliciesinfo",
        host: "https://mapi.zjzwfw.gov.cn/",
        dataType: "JSON",
        type: "POST",
        data: {
          ticket: window.sessionStorage.getItem("ticket"),
          id: window.sessionStorage.getItem("zszcId"),
        },
        appKey: "es4b8zmz+2001833218+dehllx",
        onSuccess: (data) => {
          this.loading = false;
          if (data.data.success) {
            const { data: res } = data;
            this.info = res.data;
            let content = document.querySelector(".content");
            content.innerHTML = res.data.contents;
          } else {
            let code = [6501, 6001];
            if (code.indexOf(data.data.bizCode) != -1) {


     this.$toast({
            message: "登录超时，请重新登录",
            duration: 3000,
            type: "info",
        })/*  */

        /*       this.$message({
                message: "请求超时，请重新登录",
                duration: 3000,
                type: "info",
                center: true,
              }); */
              setTimeout(() => {
                window.location.replace(
                  "https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=fwzs"
                );
              }, 3000);
            } else {
     this.$toast({
            message: "请求出错",
            duration: 3000,
            type: "error",
        })
       /*        this.$message({
                message: "请求出错",
                duration: 3000,
                type: "error",
                center: true,
              }); */
            }
          }
        },
        onFail: function (err) {
          this.loading = false;
this.$notify({ type: 'warning', message: '请求失败',duration: 3000, });


   /*        this.$notify({
            title: "错误",
            message: "请求失败",
            type: "error",
            duration: 3000,
          }); */
        },
      });
    },
    modifyDate(date) {
      return (date + "").substr(0, 10);
    },
  },
};
</script>
<style lang="less" scoped>
.container {
  padding: 20px;
  .title {
    text-align: center;
    font-weight: bolder;
    font-size: 16px;
  }
  .date {
    text-align: center;
    margin: 10px 0;
    font-size: 16px;
  }
}
.old_container {
  .title,
  .date {
    font-size: 22px;
  }
}
</style>
