从以渔有方平台跳转登录(教师、超管=>案例管理,学校管理员=>后台管理)

master
CherrysChang 5 years ago
parent a969899286
commit e3bb67c1b2
  1. 13
      src/api/server.js
  2. 30
      src/common/js/utils.js
  3. 4
      src/main.js
  4. 7
      src/router/index.js
  5. 4
      src/views/Home.vue
  6. 67
      src/views/YyyfLogin.vue

@ -45,7 +45,7 @@ export const Train = new (class {
//实训案例管理列表 //实训案例管理列表
getCaseList(params) { getCaseList(params) {
return axios return axios
.post(this.getCaseListApi, qs.stringify(params), {headers: {requestType: "noToken"}}) .post(this.getCaseListApi, qs.stringify(params)/*, {headers: {requestType: "noToken"}}*/)
.then(res => res.data); .then(res => res.data);
} }
//添加 //添加
@ -309,6 +309,7 @@ export const Login = new (class {
this.loginPublicKey = loginApi + "/login/getPublicKey"; //获取公钥 this.loginPublicKey = loginApi + "/login/getPublicKey"; //获取公钥
this.sendLoginCodeApi = loginApi + "/login/sendLoginCode"; //获取验证码 this.sendLoginCodeApi = loginApi + "/login/sendLoginCode"; //获取验证码
this.exitLogin = loginApi + "/login/exit"; //系统用户退出登录 this.exitLogin = loginApi + "/login/exit"; //系统用户退出登录
this.yyyfLoginBack = loginApi + "/yyyfLogin/login";//以渔有方用户登录
} }
sendLoginCode(params) { sendLoginCode(params) {
@ -344,6 +345,16 @@ export const Login = new (class {
.then(res => res.data); .then(res => res.data);
} }
yyyfLogin(params) {
return axios.get(this.yyyfLoginBack, {
params: params,
headers: {
requestType: "noToken"
}
})
.then(res => res.data);
}
logout() { logout() {
return axios.get(this.exitLogin, { return axios.get(this.exitLogin, {
headers: { headers: {

@ -330,6 +330,36 @@ class Utils {
}, false); }, false);
reader.readAsDataURL(file); reader.readAsDataURL(file);
} }
/**
* 解析请求路径返回路径参数
* @returns {{}}
*/
parseUrl() {
let params = {};//定义数组
let url = decodeURIComponent(location.href);
let paramsIndex = url.indexOf("?")
if (paramsIndex != -1) {
paramsIndex = paramsIndex + 1;
let paramsStr = url.substring(paramsIndex);
let paramsAttr = paramsStr.split("&");
for (let x in paramsAttr) {
let y = paramsAttr[x].split("=");
if (y[0] == undefined || y[0] == "") {
continue;
}
if (y[1] != undefined) {
let value = "";
let len = y.length;
for (let j = 1; j < len; j++) {
value += y[j] == '' && paramsAttr[x].charAt(value.length + y[0].length + 1) != '' ? '=' : y[j];
}
params[y[0]] = value;
}
}
}
return params;
}
} }
export default new Utils(); export default new Utils();

@ -48,8 +48,10 @@ router.beforeEach((to, from, next) => {
//NProgress.start(); //NProgress.start();
let user = JSON.parse(sessionStorage.getItem('user')); let user = JSON.parse(sessionStorage.getItem('user'));
if (!user && to.path != '/login') { if (!user && to.path != '/login') {
if(/train/.test(to.path)){//暂时这么写,user是需要有值的,这里先方便页面 if (/yyyfLoginBack/.test(to.path)) {
next() next()
// } else if (/train/.test(to.path)) {//暂时这么写,user是需要有值的,这里先方便页面
// next()
} else { } else {
next({path: '/login'}) next({path: '/login'})
} }

@ -1,5 +1,6 @@
import curRoutes from '@/common/js/testR.js'; //用户当前路由 测试 import curRoutes from '@/common/js/testR.js'; //用户当前路由 测试
import Utils from '@/common/js/utils.js'; import Utils from '@/common/js/utils.js';
import YyyfLogin from "../views/YyyfLogin";
// 实训案例管理主页 // 实训案例管理主页
const TrainHome = resolve => require(['@/views/TrainHome.vue'], resolve) const TrainHome = resolve => require(['@/views/TrainHome.vue'], resolve)
@ -104,6 +105,12 @@ let routes = [
name: 'Login', name: 'Login',
hidden: true hidden: true
}, },
{
path: '/yyyfLoginBack',
component: YyyfLogin,
name: 'YyyfLogin',
hidden: true
},
{ {
path: '/train', path: '/train',
component: TrainHome, component: TrainHome,

@ -14,7 +14,7 @@
<el-dropdown trigger="hover"> <el-dropdown trigger="hover">
<span class="el-dropdown-link userinfo-inner">用户 {{account}}<i class="el-icon-arrow-down el-icon--right"></i></span> <span class="el-dropdown-link userinfo-inner">用户 {{account}}<i class="el-icon-arrow-down el-icon--right"></i></span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item divided @click.native="updateMyself">修改个人信息</el-dropdown-item> <!--<el-dropdown-item divided @click.native="updateMyself">修改个人信息</el-dropdown-item>-->
<el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item> <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -145,7 +145,7 @@
} }
.userinfo { .userinfo {
// text-align: right; // text-align: right;
padding-right: 35px; //padding-right: 35px;
float: right; float: right;
.userinfo-inner { .userinfo-inner {
cursor: pointer; cursor: pointer;

@ -0,0 +1,67 @@
<template>
<section>
<h2>欢迎访问智信链管理系统</h2>
</section>
</template>
<script>
import Utils from '@/common/js/utils.js';
import {Login} from '@/api/server.js';
export default {
name: "YyyfLogin",
created() {
let loading = this.openLoading();
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学校管理员
*/
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: '/'});
}
}
});
},
//Loading
openLoading() {
const loading = this.$loading({
lock: true,
text: '正在跳转,请稍后!',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
return loading;
},
closeLoading(loading){
loading.close();
},
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save