Commit 0adf3cc1 authored by 周远喜's avatar 周远喜

登陆切换

parent 0c231368
......@@ -2,7 +2,7 @@ import request from '@/plugins/request';
export function AccountLogin (data) {
return request({
url: '/api/login',
url: `${authUrl}/api/services/app/auth/login`,
method: 'post',
data
});
......
......@@ -33,7 +33,6 @@ export default {
},
mounted() {
this.getMenu();
this.initUserInfo();
},
watch: {
// 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
......@@ -66,29 +65,7 @@ export default {
}
},
methods: {
//获取用户基本信息
initUserInfo() {
let userInfo = this.$store.state.admin.user.info;
let parma = {
Id: userInfo.userId
};
this.$http.sysUser.getuserinfo(parma).then(res => {
if (res.result) {
if (
res.result.avatarUrl &&
res.result.avatarUrl != "" &&
res.result.avatarUrl != null
) {
res.result.avatarUrl = fileUrlDown + res.result.avatarUrl;
}
this.$store.commit("admin/user/setUserAvatar", res.result);
} else {
this.$Message.error("用户信息查询失败!");
}
});
},
//用户中心结束
//menu
getMenu() {
this.$http.sysUser.getusermenu().then(res => {
if (res.result) {
......
<template>
<div class="account">
<Carousel v-model="value1" autoplay autoplay-speed="5000" loop class="zmd">
<Carousel v-model="value1" autoplay :autoplay-speed="5000" loop class="zmd">
<CarouselItem>
<div class="bg bg0">1</div>
</CarouselItem>
......@@ -29,17 +29,16 @@
<!-- <div class="page-account-top-desc tc">SaaS MES 制造执行系统</div> -->
</div>
<h3 class="mb20">用户登陆</h3>
<Login @on-submit="oidc">
<UserName name="username" value="admin" />
<Password name="password" value="admin" enter-to-submit />
<Login @on-submit="handleSubmit">
<UserName name="username" value="13211111111" />
<Password name="password" value="1" enter-to-submit />
<div class="page-account-auto-login mb20">
<Checkbox v-model="autoLogin" >{{ $t('page.login.remember') }}</Checkbox>
<Checkbox v-model="autoLogin">{{ $t('page.login.remember') }}</Checkbox>
<a href>{{ $t('page.login.forgot') }}</a>
</div>
<div class="mt20">
<Submit class="shadown">{{ $t('page.login.submit') }}</Submit>
</div>
</Login>
</div>
</div>
......@@ -58,6 +57,7 @@ export default {
components: { iCopyright },
data() {
return {
value1: 0,
autoLogin: true
};
},
......@@ -66,34 +66,6 @@ export default {
},
methods: {
...mapActions("admin/account", ["login"]),
oidc() {
let that = this;
mgr.getUser().then(function(user) {
if (user) {
console.info("user",user)
that.msg = "该用户已经登录";
const userInfos = {
token: user.access_token,
login_id: user.profile.name,
userId:
user.profile[
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
],
accountId: user.profile.sub,
tanantCode: user.profile.TanantCode,
name: "Aresn",
avatar:
"https://dev-file.iviewui.com/userinfoPDvn9gKWYihR24SpgC319vXY8qniCqj4/avatar",
access: ["admin"]
};
// that.$store.commit('setUserInfo',userInfos);
that.oidcLogin(userInfos);
window.location = "/";
} else {
mgr.signinRedirect();
}
});
},
/**
* @description 登录
* 表单校验已有 iView Pro 自动完成,如有需要修改,请阅读 iView Pro 文档
......@@ -104,26 +76,50 @@ export default {
this.login({
username,
password
}).then(() => {
// 重定向对象不存在则返回顶层路径
this.$router.replace(this.$route.query.redirect || "/");
}).then(r => {
if (r > 0) {
this.$Message.success("登陆成功!");
this.initUserInfo(r);
} else {
this.$Message.error("登陆失败!");
}
});
}
},
oidcLogin(user) {
util.cookies.set("uuid", user.userId);
util.cookies.set("token", user.token);
// 设置 vuex 用户信息
this.$store.dispatch("admin/user/set", user, { root: true });
// 用户登录后从持久化数据加载一系列的设置
this.$store.dispatch("load");
this.$store.commit("setUserInfo", user);
initUserInfo(id) {
let parma = {
Id: id
};
this.$http.sysUser.getuserinfo(parma).then(res => {
if (res.result) {
if (
res.result.avatarUrl &&
res.result.avatarUrl != "" &&
res.result.avatarUrl != null
) {
res.result.avatarUrl = fileUrlDown + res.result.avatarUrl;
}
let info = res.result;
info.auth = ["admin"];
info.avatar = info.avatarUrl;
info.userId=info.id;
info.name=info.userName;
this.$store.dispatch("admin/user/set", info, {
root: true
});
// setUserInfo
this.$store.commit("setUserInfo",info)
this.$router.replace(this.$route.query.redirect || "/");
} else {
this.$Message.error("用户信息22查询失败!");
}
});
}
}
};
</script>
<style lang="less">
@jianju:40px;
@jianju: 40px;
.account {
position: fixed;
width: 100%;
......@@ -160,30 +156,31 @@ export default {
left: @jianju;
right: @jianju;
bottom: @jianju;
background: rgba(38,128,235, 0.3);
background: rgba(38, 128, 235, 0.3);
display: flex;
.ad{
.ad {
flex: 1;
text-align: center;
img{margin-top: 400px;}
img {
margin-top: 400px;
}
}
.login {
background-color: white;
width: 600px;
padding: 150px 90px;
padding: 150px 90px;
// background-image: url("../../../assets/images/login/33.png");
// background-repeat: no-repeat;
// background-position-y: 525px;
// background-position-y: 525px;
.ivu-input-wrapper {
margin-bottom: 5px;
}
.mt20{
.mt20 {
margin-top: 50px;
.shadown{
box-shadow: 1px 5px 15px #2680EB;
.shadown {
box-shadow: 1px 5px 15px #2680eb;
}
.ivu-btn-large{
.ivu-btn-large {
height: 50px !important;
}
}
......
......@@ -94,7 +94,7 @@ Vue.component("DTSpan", DTSpan)
Vue.component("DTSearch", DTSearch)
//注入mock
require("../mock")
// require("../mock")
Vue.prototype.$api=request;
Vue.prototype.$http=Api;
Vue.prototype.$u = Henq;
......
......@@ -13,6 +13,14 @@ function errorCreate (msg) {
// 记录和显示错误
function errorLog (err) {
if(err&&err.response&&err.response.status==500){
console.log(err.response)
Message.error({
content: err.response.data.error.message,
duration: 5
})
return;
}
// 添加到日志
$nuxt.$store.dispatch('admin/log/push', {
message: '数据请求异常',
......@@ -28,18 +36,18 @@ function errorLog (err) {
console.log(err);
}
// 显示提示,可配置使用 iView 的 $Message 还是 $Notice 组件来显示
if (Setting.errorModalType === 'Message') {
Message.error({
content: err.message,
duration: Setting.modalDuration
});
} else if (Setting.errorModalType === 'Notice') {
Notice.error({
title: '提示',
desc: err.message,
duration: Setting.modalDuration
});
}
// if (Setting.errorModalType === 'Message') {
// Message.error({
// content: err.message,
// duration: Setting.modalDuration
// });
// } else if (Setting.errorModalType === 'Notice') {
// Notice.error({
// title: '提示',
// desc: err.message,
// duration: Setting.modalDuration
// });
// }
}
// 创建一个 axios 实例
......@@ -83,7 +91,7 @@ service.interceptors.request.use(
},
error => {
// 发送失败
console.log(error);
// console.log(error);
Promise.reject(error);
}
);
......@@ -132,7 +140,7 @@ service.interceptors.response.use(
case 505: error.message = 'HTTP版本不受支持'; break;
default: break;
}
}
}
errorLog(error);
// console.warn("Erro:",error)
return Promise.reject(error);
......
This diff is collapsed.
......@@ -41,8 +41,8 @@ export const mutations={
},
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
sessionStorage.setItem("token", userInfo.token);
// sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
// sessionStorage.setItem("token", userInfo.token);
},
addUser(state,user){
state.userMap.push(user);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment