<!--
 * @Description: file content
 * @Version: 2.0
 * @Author: ljl
 * @Date: 2022-06-21 11:56:02
 * @LastEditors: ljl
 * @LastEditTime: 2022-07-13 12:00:18
 * @FilePath: \zyypt-ssb-vue_app\src\views\index.vue
-->
<template>
  <div></div>
</template>
<script>
import { setCookies, removeAllCookie } from "@/utils/auth";
import { getAppUser } from "@/api/index";
export default {
  name: "Home",
  created() {
    removeAllCookie();
    let appCode = ipConfig.appCode;
    let winCode = this.getUrlParms("code");
    let code = winCode ? winCode : appCode;
    if (!code) {
      //跳转获取code值
      window.location.href = ipConfig.userURL + "getAppUrl";
    } else {
      getAppUser({ code: code }).then((res) => {
        setCookies("myInfo", JSON.stringify(res.data));
        setCookies("idcard", res.data.idcard);
        this.$router.push({
          name: "ConsultationRecord",
        });
      });
    }
  },

  methods: {
    getUrlParms: function (name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
      var getHref = decodeURI(window.location.search);
      var r = getHref.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    },
  },
};
</script>