<!--  -->
<template>
  <div class="empty-main" v-if="emptyCon">
    <img :src="emptyCon.url" class="empty-img" />
    <p class="empty-texts">{{ emptyCon.con }}</p>
    <a class="empty-link" target="_blank" @click="choiceCourse">{{
      emptyCon.linkName
    }}</a>
  </div>
</template>

<script>
import { getContent } from "@/api/ajax";
export default {
  components: {},
  props: ["navType"],
  data() {
    return {};
  },
  computed: {
    emptyCon: function () {
      let _this = this;
      let obj = {};
      //let MethodName = "login_control-CreateAccessCode";
      // let res = await getContent(MethodName, {});
      //let AccessCode = "";
      switch (_this.navType) {
        case "0": //系统通知
          obj = {
            url: require("../../assets/Personalcenter/1.png"),
            con: this.$t("Key677"), //Key677 没有任何通知
            link: "",
          };
          break;
        case "1":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key464"), // "您还未购买任何教材",
            linkName: this.$t("Key465"), //"去查看",
            child_sys_key: "GCLS-LC",
            link: `/GCLS-LC/#/learncenter/ListPage?id=TEXTBOOK`,
          };
          break;
        case "2":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key70"), //"您还未购买任何课程",
            linkName: this.$t("Key71"), //"去选课",
            child_sys_key: "GCLS-LC",
            link: `/GCLS-LC/#/learncenter/ListPage?id=COURSE`,
          };
          break;
        case "3":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key70"), //"您还未购买任何课程",
            linkName: this.$t("Key71"), //"去选课",
            child_sys_key: "GCLS-TRC",
            link: `/GCLS-TRC/#/EnterSys`,
          };
          break;
        case "4":
          obj = {
            url: require("../../assets/Personalcenter/3.png"),
            con: this.$t("Key466"), //"您还未购买任何资料",
            linkName: this.$t("Key465"), //"去查看",
            child_sys_key: "GCLS-TC",
            link: `/GCLS-TC/#/EnterSys`,
          };
          break;
        case "5":
          obj = {
            url: require("../../assets/Personalcenter/4.png"),
            con: this.$t("Key467"), //"没有订单",
            link: "",
          };
          break;
        case "6":
          obj = {
            url: require("../../assets/Personalcenter/5.png"),
            con: this.$t("Key468"), //"你还未添加任何收藏",
            link: "",
          };
          break;
        case "7":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key464"), // "您还未购买任何教材",
            link: ``,
          };
          break;
      }

      return obj;
    },
  },
  watch: {},
  //方法集合
  methods: {
    async handleData() {
      let _this = this;
      let obj = {};
      let MethodName = "login_control-CreateAccessCode";
      let res = await getContent(MethodName, {});
      let AccessCode = res.access_code;
      switch (_this.navType) {
        case "0": //系统通知
          obj = {
            url: require("../../assets/Personalcenter/1.png"),
            con: this.$t("Key677"), //Key677 没有任何通知
            link: "",
          };
          break;
        case "1":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key464"), // "您还未购买任何教材",
            linkName: this.$t("Key465"), //"去查看",
            link: `/GCLS-LC/#/EnterSys?AccessCode=${AccessCode}`,
          };
          break;
        case "2":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key70"), //"您还未购买任何课程",
            linkName: this.$t("Key71"), //"去选课",
            link: `/GCLS-LC/#/EnterSys?AccessCode=${AccessCode}`,
          };
          break;
        case "3":
          obj = {
            url: require("../../assets/Personalcenter/2.png"),
            con: this.$t("Key70"), //"您还未购买任何课程",
            linkName: this.$t("Key71"), //"去选课",
            link: `/GCLS-TRC/#/EnterSys?AccessCode=${AccessCode}`,
          };
          break;
        case "4":
          obj = {
            url: require("../../assets/Personalcenter/3.png"),
            con: this.$t("Key466"), // "您还未购买任何资料",
            linkName: this.$t("Key465"), //"去查看",
            link: `/GCLS-TC/#/EnterSys?AccessCode=${AccessCode}`,
          };
          break;
        case "5":
          obj = {
            url: require("../../assets/Personalcenter/4.png"),
            con: this.$t("Key467"), //"没有订单",
            link: "",
          };
          break;
        case "6":
          obj = {
            url: require("../../assets/Personalcenter/5.png"),
            con: this.$t("Key468"), //"你还未添加任何收藏",
            link: "",
          };
          break;
      }

      return obj;
    },
    choiceCourse() {
      let MethodName = "login_control-IsCanEnterChildSys_PC";
      let data = {
        child_sys_key: this.emptyCon.child_sys_key,
      };
      getContent(MethodName, data).then((res) => {
        let is_can_enter_child_sys = res.is_can_enter_child_sys;
        if (is_can_enter_child_sys == "true") {
          window.location.href = this.emptyCon.link;
        } else {
          this.$message({
            showClose: true,
            message: "您没有权限",
            type: "warning",
          });
        }
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类
.empty-main {
  width: 100%;
  height: 778px;
  box-sizing: border-box;
  padding-top: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  .empty-img {
    margin-bottom: 16px;
    width: 160px;
    height: 160px;
  }
  .empty-texts {
    font-weight: normal;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: #969799;
  }
  .empty-link {
    font-weight: normal;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: #ff9900;
    cursor: pointer;
    margin-top: 10px;
  }
}
</style>