|
@@ -3,7 +3,7 @@
|
|
|
<div class="top"></div>
|
|
<div class="top"></div>
|
|
|
<div class="flex-center flex-column login-body">
|
|
<div class="flex-center flex-column login-body">
|
|
|
<h2>中医智能辅助诊疗系统</h2>
|
|
<h2>中医智能辅助诊疗系统</h2>
|
|
|
- <div class="login-form">
|
|
|
|
|
|
|
+ <div class="login-form" v-if="!useToken">
|
|
|
<!-- <div class="flex-center">
|
|
<!-- <div class="flex-center">
|
|
|
<img src="../assets/logo.png" alt="" class="logo" />
|
|
<img src="../assets/logo.png" alt="" class="logo" />
|
|
|
</div>-->
|
|
</div>-->
|
|
@@ -28,6 +28,9 @@
|
|
|
<el-checkbox v-model="checked">记住我</el-checkbox>
|
|
<el-checkbox v-model="checked">记住我</el-checkbox>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div v-else-if="useTokenError" style="max-width: 50vw;background-color: rgba(255,255,255,0.4);">
|
|
|
|
|
+ <el-result icon="error" title="登录错误" :subTitle="useTokenError"></el-result>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="bottom">
|
|
<div class="bottom">
|
|
@@ -38,8 +41,13 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { login, getCode, getCodeimg } from "@/api/user.js";
|
|
|
|
|
-import { setTimeout } from "timers";
|
|
|
|
|
|
|
+import {login, getCode, getCodeimg, loginBySSO} from '@/api/user.js';
|
|
|
|
|
+
|
|
|
|
|
+function getURLSearchParams(value) {
|
|
|
|
|
+ value ??= `${ location.search }&${ location.hash.split('?')[ 1 ] || '' }`;
|
|
|
|
|
+ return new URLSearchParams(value);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
name: "Home",
|
|
name: "Home",
|
|
|
components: {},
|
|
components: {},
|
|
@@ -48,12 +56,21 @@ export default {
|
|
|
name: "",
|
|
name: "",
|
|
|
pas: "",
|
|
pas: "",
|
|
|
code: "",
|
|
code: "",
|
|
|
-
|
|
|
|
|
|
|
+ useToken: true,
|
|
|
|
|
+ useTokenError: '',
|
|
|
checked: false,
|
|
checked: false,
|
|
|
src: process.env.VUE_APP_BASE_API + "captchaImage"
|
|
src: process.env.VUE_APP_BASE_API + "captchaImage"
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
|
|
+ const sso = getURLSearchParams()
|
|
|
|
|
+ this.useToken = sso.has("token")
|
|
|
|
|
+ if (this.useToken) {
|
|
|
|
|
+ localStorage.setItem("sso-token", sso.get("token"));
|
|
|
|
|
+ this.loginBySSO(sso.toString())
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ localStorage.removeItem("sso-token");
|
|
|
// this.getCodeimg()
|
|
// this.getCodeimg()
|
|
|
this.changeImg();
|
|
this.changeImg();
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -112,6 +129,29 @@ export default {
|
|
|
}, 1500);
|
|
}, 1500);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ async loginBySSO(value) {
|
|
|
|
|
+ this.useTokenError = '';
|
|
|
|
|
+ let loading;
|
|
|
|
|
+ const timer = setTimeout(() => {
|
|
|
|
|
+ loading = this.$loading({
|
|
|
|
|
+ lock: true,
|
|
|
|
|
+ text: '正在登录',
|
|
|
|
|
+ spinner: 'el-icon-loading',
|
|
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)',
|
|
|
|
|
+ });
|
|
|
|
|
+ }, 2000);
|
|
|
|
|
+ try {
|
|
|
|
|
+ const token = await loginBySSO(value);
|
|
|
|
|
+ localStorage.setItem('token', token);
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ this.$router.push({path: '/index/todaypatients'});
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.useTokenError = e.message;
|
|
|
|
|
+ }
|
|
|
|
|
+ clearTimeout(timer);
|
|
|
|
|
+ if (loading) loading.close();
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
// 修改验证码
|
|
// 修改验证码
|
|
|
changeImg() {
|
|
changeImg() {
|