@@ -196,6 +196,10 @@ const user = { | |||
FedLogOut({ commit }) { | |||
return new Promise(resolve => { | |||
commit('SET_TOKEN', '') | |||
commit('SET_businessLevel', '') | |||
commit('SET_NICKNAME', '') | |||
commit('SET_ROLES', []) | |||
commit('SET_PERMISSIONS', []) | |||
removeToken() | |||
resolve() | |||
}) | |||
@@ -0,0 +1,88 @@ | |||
<template> | |||
<div class="app-container"> | |||
</div> | |||
</template> | |||
<script> | |||
import {Dialog} from "vant"; | |||
import {removeToken} from "@/utils/auth"; | |||
const TEST = 0; | |||
export default { | |||
name: "ChungengUserSSOLoginRouter", | |||
props: { | |||
redirectUrl: { | |||
type: String, | |||
default: '/', | |||
}, | |||
}, | |||
data() { | |||
return { | |||
path: this.redirectUrl, | |||
}; | |||
}, | |||
created() { | |||
this.ParseQuery(); | |||
this.Login(); | |||
}, | |||
methods: { | |||
GetToken() { | |||
if(TEST) | |||
{ | |||
if(this.$route.query.s) | |||
return this.$route.query.s; | |||
let phone = '256be4fa60c8088171b22c466a16d55a'; // https://config.net.cn/tools/SM4.html | |||
//phone += '1' | |||
let ts = Date.now(); | |||
return phone + '#' + ts; | |||
} | |||
else | |||
return this.$route.query.s; | |||
}, | |||
ShowToast(content, title) { | |||
return Dialog.alert({ | |||
title: title, | |||
message: content, | |||
theme: 'round-button', | |||
}); | |||
}, | |||
Login() { | |||
this.LogOut(); | |||
let code = this.GetToken(); | |||
if(!code) | |||
{ | |||
this.ShowToast('请从春耕App进入登录').then(() => { | |||
this.Back(); | |||
}); | |||
return false; | |||
} | |||
this.$store.dispatch("ChungengLogin", {code}) | |||
.then(() => { | |||
this.$router.push({ path: this.path }); | |||
}) | |||
.catch((error) => { | |||
this.ShowToast(error || '春耕App用户登录失败').then(() => { | |||
this.Back(); | |||
}); | |||
}); | |||
}, | |||
ParseQuery() { | |||
if(this.$route.query.redirectUrl) | |||
this.path = this.$route.query.redirectUrl; | |||
}, | |||
Back(delay) { | |||
if(delay > 0) | |||
setTimeout(() => history.back(), delay); | |||
else | |||
history.back(); | |||
}, | |||
LogOut() { | |||
// removeToken(); | |||
this.$store.dispatch('FedLogOut'); | |||
}, | |||
}, | |||
}; | |||
</script> | |||
<style scoped lang="scss"> | |||
</style> |
@@ -1,64 +1,11 @@ | |||
<template> | |||
<div class="app-container"> | |||
</div> | |||
<ChungengUserSSOLoginRouter redirect-url="/yinnong/doneCompleted/completed"/> | |||
</template> | |||
<script> | |||
import {Dialog} from "vant"; | |||
const TEST = 0; | |||
import ChungengUserSSOLoginRouter from "@/views/ChungengUserSSOLoginRouter.vue"; | |||
export default { | |||
name: "ChungengUserSSOLogin", | |||
data() { | |||
return { | |||
}; | |||
}, | |||
created() { | |||
this.Login(); | |||
}, | |||
methods: { | |||
GetToken() { | |||
if(TEST) | |||
{ | |||
if(!this.$route.query.s) | |||
return this.$route.query.s; | |||
let phone = '704d238d95b61f8304ce9e9c2d70e0bf'; | |||
//phone = '525e902f509a7147ad92e602139bd267' | |||
let ts = '1234567890123'; | |||
return phone + '#' + ts; | |||
} | |||
else | |||
return this.$route.query.s; | |||
}, | |||
ShowToast(content, title) { | |||
return Dialog.alert({ | |||
title: title, | |||
message: content, | |||
theme: 'round-button', | |||
}); | |||
}, | |||
Login() { | |||
let code = this.GetToken(); | |||
if(!code) | |||
{ | |||
this.ShowToast('请从春耕App进入登录').then(() => { | |||
history.back(); | |||
}); | |||
return false; | |||
} | |||
this.$store.dispatch("ChungengLogin", {code}) | |||
.then(() => { | |||
this.$router.push({ path: "/yinnong/doneCompleted/completed" }); | |||
}) | |||
.catch((error) => { | |||
this.ShowToast(error || '春耕App用户登录失败').then(() => { | |||
history.back(); | |||
}); | |||
}); | |||
}, | |||
}, | |||
}; | |||
components: {ChungengUserSSOLoginRouter} | |||
} | |||
</script> | |||
<style scoped lang="scss"> | |||
</style> |