From 362fffe7d40e8145ef37cef6ded3dd515fe2351c Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期四, 12 九月 2024 14:31:51 +0800 Subject: [PATCH] 调整 --- src/views/login/index.vue | 16 +++++++++++++++- src/views/student/index.vue | 41 +++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index dc9d55f..9e8f838 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -17,6 +17,7 @@ <script> import { validUsername } from "@/utils/validate"; import wxlogin from "vue-wxlogin"; +import { login } from "@/api/user"; export default { name: "Login", components: { wxlogin }, @@ -37,7 +38,7 @@ }; return { appid: "wx7103925df6236723", - redirect_uri: encodeURIComponent("https://dingdang.9village.cn/#/student"), + redirect_uri: encodeURIComponent("https://dingdang.9village.cn/#/login"), state: "1", href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7CiAgICAgICAgICBib3JkZXI6IG5vbmU7CiAgICAgICAgICB3aWR0aDogMTQwcHg7CiAgICAgICAgICBoZWlnaHQ6IDE0MHB4OwogICAgICAgIH0=", // 鑷畾涔夋牱寮忛摼鎺� loginForm: { @@ -66,9 +67,22 @@ }, }, mounted() { + let code = this.$route.query.code; + if (code) { + this.getUserDate(code); + } else { this.getWeChatUrl(); + } }, methods: { + getUserDate(code) { + login({ + code: code, + }).then((res) => { + localStorage.setItem("user", JSON.stringify(res)); + this.$router.push("/student"); + }); + }, getWeChatUrl() { // api.wachatQrUrl().then(res => { // if (res && res.code === '0000') { diff --git a/src/views/student/index.vue b/src/views/student/index.vue index 63bb9df..49be9ef 100644 --- a/src/views/student/index.vue +++ b/src/views/student/index.vue @@ -120,7 +120,7 @@ <script> import { getData, getRenew, getExpire, getDeleted, handleExport } from "@/api/student"; import StudentCreate from "./components/create.vue"; -import { login } from "@/api/user"; + export default { filters: { @@ -160,34 +160,27 @@ }, created() { // 鑾峰彇鍦板潃鏍廲ode - let code = this.$route.query.code; - if (code) { - if (localStorage.getItem("code")) { - if (code !== localStorage.getItem("code")) { - this.getUserDate(code); - } - } else { - this.getUserDate(code); - } - } else { - if (!localStorage.getItem("user")) { - this.$router.push("/login"); - } - } + // let code = this.$route.query.code; + // if (code) { + // if (localStorage.getItem("code")) { + // if (code !== localStorage.getItem("code")) { + // this.getUserDate(code); + // } + // } else { + // this.getUserDate(code); + // } + // } else { + // if (!localStorage.getItem("user")) { + // this.$router.push("/login"); + // } + // } if (localStorage.getItem("user")) { this.fetchData(); + } else { + this.$router.push("/login"); } }, methods: { - getUserDate(code) { - login({ - code: code, - }).then((res) => { - localStorage.setItem("user", JSON.stringify(res)); - localStorage.setItem("code", code); - window.location.reload(); - }); - }, handleExport() { this.download('exportPlayer?orgId=' + JSON.parse(localStorage.getItem("user")).staffs[0].org.id, { }, `瀵煎嚭_${new Date().getTime()}.xlsx`) -- Gitblit v1.8.0