123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <div id="app" v-cloak>
- <router-view />
- </div>
- </template>
- <script>
- import { JudgeEnvironment } from "@/utils/validate";
- import asyncRequest from "@/apis/service/test";
- import { getCode } from "@/utils/dingding";
- export default {
- name: "App",
- data() {
- return {
- code: "",
- };
- },
- async created() {
- // const res = await asyncRequest.list({type_code:"WSM8b49211013191450"});
- // console.log(res);
- // if (res && res.code === 0 && res.data) {
- // this.tableData = res.data.list;
- // this.pageInfo.total = Number(res.data.count);
- // } else if (res && res.code >= 100 && res.code <= 104) {
- // await this.logout();
- // } else {
- // this.tableData = [];
- // this.pageInfo.total = 0;
- // }
- // axios
- // .post("/process/statistics", {})
- // .then((res) => {
- // console.log(res);
- // })
- // .catch((err) => {});
- if (JudgeEnvironment() === "isDingDing") {
- await this.testing();
- } else {
- await this.getMenu();
- }
- },
- methods: {
- async testing() {
- await getCode(async (code) => {
- this.code = code;
- if (this.code != null && this.code != "") {
- await this.setcode(this.code);
- } else {
- await this.logout();
- }
- });
- },
- async setcode(code) {
- let model = { code: code };
- this.$store
- .dispatch("user/dingUserInfor", model)
- .then(async (res) => {
- if (res === "success") {
- await this.getMenu();
- } else {
- await this.logout();
- }
- })
- .catch(async (err) => {
- await this.logout();
- });
- },
- async getMenu() {
- this.$store
- .dispatch("user/getMenuList", this)
- .then(async (res) => {
- if (res === "noToken") {
- await this.logout();
- } else if (res === "success") {
- if (
- this.$route.path === "/loadingPage" ||
- this.$route.path === "/" ||
- this.$route.path === "/login"
- ) {
- window.vm.$router.replace("/welcome");
- }
- } else {
- await this.logout();
- }
- })
- .catch(async (err) => {
- await this.logout();
- });
- },
- async logout() {
- if (this.$route.path !== "/login") {
- await this.$store.dispatch("user/logout");
- this.$router.push(`/login`);
- }
- },
- },
- };
- </script>
- <style lang="scss">
- @import "./assets/css/index.scss";
- </style>
|