登陆前端代码
This commit is contained in:
parent
ddae3a4261
commit
567732d51e
|
|
@ -83,4 +83,21 @@ export function checkCode(data) {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//南网机具认证中心登录
|
||||||
|
export function SsoLogin(data) {
|
||||||
|
return request({
|
||||||
|
url: '/user/onlineApprove',
|
||||||
|
headers: {
|
||||||
|
isToken: false
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export const constantRoutes = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
component: () => import('@/views/login'),
|
component: () => import('@/views/loginSso'),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { login, logout, getInfo, refreshToken,checkCode } from '@/api/login'
|
import { login, logout, getInfo, refreshToken,checkCode,SsoLogin } from '@/api/login'
|
||||||
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
|
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
|
||||||
|
import { Notification, MessageBox, Message, Loading } from 'element-ui'
|
||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
token: getToken(),
|
token: getToken(),
|
||||||
|
|
@ -55,8 +55,8 @@ const user = {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 验证码 登录
|
// 验证码 登录
|
||||||
textLogin({ commit }, userInfo) {
|
textLogin({ commit }, userInfo) {
|
||||||
console.log(userInfo)
|
console.log(userInfo)
|
||||||
let params = {
|
let params = {
|
||||||
phone:userInfo.phone,
|
phone:userInfo.phone,
|
||||||
|
|
@ -79,6 +79,29 @@ const user = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ssoLogin({ commit }, param) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SsoLogin(param).then(res => {
|
||||||
|
console.log(res)
|
||||||
|
let data = res.data
|
||||||
|
if(res.code==200){
|
||||||
|
console.log('登录成功1111111')
|
||||||
|
setToken(data.access_token)
|
||||||
|
commit('SET_TOKEN', data.access_token)
|
||||||
|
setExpiresIn(data.expires_in)
|
||||||
|
commit('SET_EXPIRES_IN', data.expires_in)
|
||||||
|
}else{
|
||||||
|
console.log('登录失败22222222')
|
||||||
|
this.$modal.msgError('登录失败22222222');
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
GetInfo({ commit, state }) {
|
GetInfo({ commit, state }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,175 @@
|
||||||
|
<template>
|
||||||
|
<div class="login" v-loading="loading" element-loading-text="登录加载中..."
|
||||||
|
></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// import {SsoLogin} from "@/api/login";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import {encrypt, decrypt} from '@/utils/jsencrypt'
|
||||||
|
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
|
||||||
|
export default {
|
||||||
|
name: "Login",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
code:undefined,
|
||||||
|
loading: true,
|
||||||
|
redirect: undefined,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
$route: {
|
||||||
|
handler: function (route) {
|
||||||
|
this.redirect = route.query && route.query.redirect;
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
console.log(this.$route)
|
||||||
|
let path = this.$route.query.redirect;
|
||||||
|
this.code = path.substr(path.indexOf('code=')+5);
|
||||||
|
console.log(this.code)
|
||||||
|
this.SsoLogin(this.code)
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
SsoLogin({ commit },code){
|
||||||
|
// https://test-cc.zhgkxt.com/
|
||||||
|
let param = {
|
||||||
|
code:this.code,
|
||||||
|
redirectUrl:'https://test-cc.zhgkxt.com/',
|
||||||
|
type:'authorization_code'
|
||||||
|
}
|
||||||
|
this.$store.dispatch("ssoLogin", param).then(() => {
|
||||||
|
//成功后会跳转页面入首页
|
||||||
|
this.$router.push({path: this.redirect || "/"}).catch(() => {
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
//失败返回南网登录页面
|
||||||
|
// window.location.replace('https://test-sso.csgmall.com.cn/?client_id=549OWptc&theme=zhgc_storage&response_type=code&redirect_uri=https%3A%2F%2Ftest-cc.zhgkxt.com')
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleLogin() {
|
||||||
|
this.$refs.loginForm.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true;
|
||||||
|
if (this.loginForm.rememberMe) {
|
||||||
|
Cookies.set("username", this.loginForm.username, {expires: 30});
|
||||||
|
Cookies.set("password", encrypt(this.loginForm.password), {expires: 30});
|
||||||
|
Cookies.set('rememberMe', this.loginForm.rememberMe, {expires: 30});
|
||||||
|
} else {
|
||||||
|
Cookies.remove("username");
|
||||||
|
Cookies.remove("password");
|
||||||
|
Cookies.remove('rememberMe');
|
||||||
|
}
|
||||||
|
this.$store.dispatch("Login", this.loginForm).then(() => {
|
||||||
|
this.$router.push({path: this.redirect || "/"}).catch(() => {
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
if (this.captchaEnabled) {
|
||||||
|
this.getCode();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style rel="stylesheet/scss" lang="scss">
|
||||||
|
.login {
|
||||||
|
//display: flex;
|
||||||
|
//justify-content: center;
|
||||||
|
//align-items: center;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
// background-image: url("../assets/images/login.png");
|
||||||
|
// background-size: 100% 100%;
|
||||||
|
//background: #1891FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin: 0px auto 30px auto;
|
||||||
|
font-size: 32px;
|
||||||
|
//text-align: center;
|
||||||
|
color: #707070;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-bar {
|
||||||
|
position: absolute;
|
||||||
|
height: auto;
|
||||||
|
top: 20%;
|
||||||
|
left: 14%;
|
||||||
|
width: auto;
|
||||||
|
height: 500px;
|
||||||
|
border-radius: 6px;
|
||||||
|
display: flex;
|
||||||
|
background: #fff;
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-bar {
|
||||||
|
//height: 500px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form {
|
||||||
|
//border-radius: 6px;
|
||||||
|
//height: 100%;
|
||||||
|
background: #ffffff;
|
||||||
|
width: 400px;
|
||||||
|
padding: 25px 25px 5px 25px;
|
||||||
|
|
||||||
|
.el-input {
|
||||||
|
height: 45px;
|
||||||
|
|
||||||
|
input {
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
height: 39px;
|
||||||
|
width: 14px;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-tip {
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
color: #bfbfbf;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-code {
|
||||||
|
width: 33%;
|
||||||
|
height: 38px;
|
||||||
|
float: right;
|
||||||
|
|
||||||
|
img {
|
||||||
|
cursor: pointer;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-login-footer {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
font-family: Arial;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-code-img {
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -38,9 +38,9 @@ module.exports = {
|
||||||
// target: `http://112.29.103.165:21626`,//线上环境-重庆
|
// target: `http://112.29.103.165:21626`,//线上环境-重庆
|
||||||
// target: `http://112.29.103.165:21624`,//线上环境-宁夏
|
// target: `http://112.29.103.165:21624`,//线上环境-宁夏
|
||||||
// target: `http://192.168.0.14:21624`,//线上环境
|
// target: `http://192.168.0.14:21624`,//线上环境
|
||||||
// target: `http://10.40.92.21:8080`,
|
target: `http://10.40.92.21:9201`,
|
||||||
// target: `http://10.40.92.13:8080`,
|
// target: `http://10.40.92.13:8080`,
|
||||||
target: `http://10.40.92.219:8080`,
|
// target: `http://10.40.92.219:8080`,
|
||||||
|
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue