From fe00be0f6e30d93277594fd506da9a224ab1431d Mon Sep 17 00:00:00 2001 From: Qian <1935003650@qq.com> Date: Wed, 3 Jun 2020 22:35:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E8=B7=B3=E8=BD=AC=E6=97=B6=E8=8F=9C=E5=8D=95=E4=B8=8D?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 2 ++ src/views/YyyfLogin.vue | 69 +++++++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/main.js b/src/main.js index b470bc7..1d3c216 100644 --- a/src/main.js +++ b/src/main.js @@ -57,6 +57,8 @@ router.beforeEach((to, from, next) => { } }else if(user && to.path =='/login'){ next({name:'Index'}) + } else if (user && user.userType == 3 && to.path == '/yyyfLoginBack') { + next({name: 'Index'}) } else { next() } diff --git a/src/views/YyyfLogin.vue b/src/views/YyyfLogin.vue index 530290f..c6e60dc 100644 --- a/src/views/YyyfLogin.vue +++ b/src/views/YyyfLogin.vue @@ -15,35 +15,48 @@ this.initLogin(); this.closeLoading(loading); }, - mounted() { - }, methods: { /** - * 教师 学校管理员 超管 http://10.10.17.37:8080/#/yyyfLoginBack?userId=20776&userName=eWFuZmEwMw%3D%3D&userType=1&authorization=87DIVy348Oxzj3ha - * 1教师 2超管 3学校管理员 + * 教师 学校管理员 超管 http://localhost:8080/#/yyyfLoginBack?userId=1&userName=eWFuZmEwMw%3D%3D&userType=1 + * 1教师 2超管 ==> 案例管理 + * 3学校管理员 ==> 后台管理 */ initLogin() { let params = Utils.parseUrl(); - let userType = params.userType; - Login.yyyfLogin(params).then(res => { - let {msg, code} = res; - if (code !== 200) { - this.$message({ - message: msg, - type: 'error' - }); - } else { - sessionStorage.setItem('user', JSON.stringify(res.data)); - sessionStorage.setItem('account',res.data.account); - sessionStorage.setItem('token', res.data.token); - if (userType == 1 || userType == 2) {//教师、超管 - this.$router.push({path: '/train'}); - }else{ - this.$router.replace({path: '/'}); - } + let self = this; + //判断是否来自以渔有方 + if (params!==undefined && params !=null && params.userId != undefined && params.userType != undefined) { + let userType = params.userType; + Login.yyyfLogin(params).then(res => { + let {msg, code} = res; + if (code !== 200) { + self.$message({ + message: msg, + type: 'error' + }); + } else { + sessionStorage.setItem('user', JSON.stringify(res.data)); + sessionStorage.setItem('account',res.data.account); + sessionStorage.setItem('token', res.data.token); + if (userType == 1 || userType == 2) {//教师、超管 + self.$router.push({path: '/train'}); + }else{ + window.location.reload(); + } - } - }); + } + }); + } else { + self.$alert('参数错误', '提示', { + type: 'error', + showClose: false, + confirmButtonText: '确定', + confirmButtonClass: 'btn-self-style', + callback: action => { + self.closeWindow() + } + }); + } }, //Loading加载 openLoading() { @@ -58,6 +71,16 @@ closeLoading(loading){ loading.close(); }, + closeWindow: function () { + if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) { + window.location.href = "about:blank"; + window.close(); + } else { + window.opener = null; + window.open("", "_self"); + window.close(); + } + }, } }