Commit 6fc8965b authored by 赵啸非's avatar 赵啸非

添加海康部分接口实现类

parent b609db8f
......@@ -5,70 +5,29 @@
</template>
<script>
import jwt_decode from "jwt-decode";
export default {
name: 'sso',
created () {
},
mounted() {
let token = this.$route.query.token
console.log("token:"+token)
console.log("解析后的token:",jwt_decode(token))
//const decode = jwt_decode(data.normal_login_token).accountId; // 解析
if(token) {
//本地登录后跳转
this.form.loginName=jwt_decode(token).userInfo.account
this.form.password=jwt_decode(token).userInfo.password
/* this.form.loginName="admin"
this.form.password="scsmile"*/
this.login()
//window.sessionStorage.setItem("token", token);
// this.$router.push('/index') // 有token直接跳转首页
}else{
let token = this.$route.query.token;
let siteid = this.$route.query.siteid;
if (token) {
window.sessionStorage.setItem("token", token);
window.sessionStorage.setItem("siteid", siteid);
this.$router.push("/index"); // 有token直接跳转首页
} else {
this.$message({
message: '没有权限,正在跳转登录页面...',
center: true
message: "没有权限,正在跳转登录页面...",
center: true,
});
setTimeout(function(){
window.location.href=process.env.VUE_APP_PORTAL_URL=='undefined'?'http://192.168.0.98:11072':process.env.VUE_APP_PORTAL_URL
setTimeout(function () {
window.location.href =
process.env.VUE_APP_PORTAL_URL == "undefined"
? "http://192.168.0.98:11072"
: process.env.VUE_APP_PORTAL_URL;
//this.$router.push('/login')
},1000)
}, 1000);
}
},
methods: {
login() {
this.loading = true;
this.$post("/login/login", this.form)
.then(this.loginSuccess)
.catch(this.loginFail);
},
loginSuccess({ data }) {
console.log("userData", data);
this.$store.commit("setUserData", data);
this.$router.push('/index') // 有token直接跳转首页
/* this.$router.replace({
path: this.redirect,
});*/
},
loginFail(error) {
this.loading = false;
this.$message.error(error.message);
},
},
data() {
return {
form: {
loginName: '',
password: '',
securityCode: '',
},
redirect: this.$route.query.redirect,
loading: true,
}
}
}
};
</script>
<style>
......
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