zhaodengke преди 1 година
родител
ревизия
1f32b02ca6
променени са 3 файла, в които са добавени 96 реда и са изтрити 57 реда
  1. +4
    -0
      src/store/modules/user.js
  2. +88
    -0
      src/views/ChungengUserSSOLoginRouter.vue
  3. +4
    -57
      src/views/chungengUserSSOLogin.vue

+ 4
- 0
src/store/modules/user.js Целия файл

@@ -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()
})


+ 88
- 0
src/views/ChungengUserSSOLoginRouter.vue Целия файл

@@ -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>

+ 4
- 57
src/views/chungengUserSSOLogin.vue Целия файл

@@ -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>

Зареждане…
Отказ
Запис