From cb5c9968b763362d399e1c7fce1129ec7434aba8 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期三, 26 四月 2023 14:07:31 +0800
Subject: [PATCH] session保存token
---
src/views/login.vue | 111 +++++++++++++++++++++++++++++++------------------------
1 files changed, 63 insertions(+), 48 deletions(-)
diff --git a/src/views/login.vue b/src/views/login.vue
index 9e8fef2..42d2136 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -10,7 +10,7 @@
<Col class="content">
<div>
<Header />
- <div v-if="!socialLogining">
+ <div v-if="!socialLogining" style="margin-top: 150px">
<Form
ref="usernameLoginForm"
:model="form"
@@ -18,13 +18,16 @@
class="form"
v-if="tabName == 'username'"
>
+ <FormItem>
+ <h1 style="margin-left: 40%;">鐧� 闄�</h1>
+ </FormItem>
<FormItem prop="username">
<Input
v-model="form.username"
prefix="ios-contact"
size="large"
clearable
- placeholder="璐﹀彿/閭/鎵嬫満鍙�"
+ placeholder="璐﹀彿"
autocomplete="off"
/>
</FormItem>
@@ -39,34 +42,34 @@
autocomplete="off"
/>
</FormItem>
- <!--<FormItem prop="imgCode">-->
- <!--<Row-->
- <!--type="flex"-->
- <!--justify="space-between"-->
- <!--style="align-items: center; overflow: hidden"-->
- <!-->-->
- <!--<Input-->
- <!--v-model="form.imgCode"-->
- <!--size="large"-->
- <!--clearable-->
- <!--placeholder="璇疯緭鍏ュ浘鐗囬獙璇佺爜"-->
- <!--:maxlength="10"-->
- <!--class="input-verify"-->
- <!--/>-->
- <!--<div-->
- <!--class="code-image"-->
- <!--style="position: relative; font-size: 12px"-->
- <!-->-->
- <!--<Spin v-if="loadingCaptcha" fix></Spin>-->
- <!--<img-->
- <!--:src="captchaImg"-->
- <!--@click="getCaptchaImg"-->
- <!--alt="鍔犺浇楠岃瘉鐮佸け璐�"-->
- <!--style="width: 110px; cursor: pointer; display: block"-->
- <!--/>-->
- <!--</div>-->
- <!--</Row>-->
- <!--</FormItem>-->
+ <FormItem prop="imgCode">
+ <Row
+ type="flex"
+ justify="space-between"
+ style="align-items: center; overflow: hidden"
+ >
+ <Input
+ v-model="form.imgCode"
+ size="large"
+ clearable
+ placeholder="璇疯緭鍏ュ浘鐗囬獙璇佺爜"
+ :maxlength="10"
+ class="input-verify"
+ />
+ <div
+ class="code-image"
+ style="position: relative; font-size: 12px"
+ >
+ <Spin v-if="loadingCaptcha" fix></Spin>
+ <img
+ :src="captchaImg"
+ @click="getCaptchaImg"
+ alt="鍔犺浇楠岃瘉鐮佸け璐�"
+ style="width: 110px; cursor: pointer; display: block"
+ />
+ </div>
+ </Row>
+ </FormItem>
</Form>
<!--<Row justify="space-between" align="middle">-->
@@ -121,6 +124,7 @@
<!--</VueFurcateTree>-->
<!--</div>-->
+
</template>
@@ -190,7 +194,9 @@
]
}
],
+ sessionStorage: null,
showMore: false,
+ code:"",
captchaId: "",
captchaImg: "",
loadingCaptcha: true,
@@ -203,10 +209,11 @@
sending: false,
errorCode: "",
form: {
- username: "admin",
- password: "123456",
+ username: "",
+ password: "",
code: "",
},
+ showChangePass: false,
};
},
methods: {
@@ -215,7 +222,8 @@
initCaptcha().then((res) => {
this.loadingCaptcha = false;
if (res.success) {
- this.captchaId = res.result;
+ this.code = res.result.code;
+ this.captchaId = res.result.captchaId;
this.captchaImg = drawCodeImage + this.captchaId;
}
});
@@ -239,14 +247,15 @@
},
afterLogin(res) {
let accessToken = res.result;
- this.setStore("accessToken", accessToken);
+ console.log("login_afterLogin()",accessToken)
+ this.setSessionStore("accessToken", accessToken);
getOtherSet().then((res) => {
if (res.result) {
let domain = res.result.ssoDomain;
- Cookies.set("accessToken", accessToken, {
- domain: domain,
- expires: 7,
- });
+ // Cookies.set("accessToken", accessToken, {
+ // domain: domain,
+ // expires: 7,
+ // });
}
});
// 鑾峰彇鐢ㄦ埛淇℃伅
@@ -284,6 +293,11 @@
},
submitLogin() {
if (this.tabName == "username") {
+ if(this.code.toUpperCase()!=this.form.imgCode.toUpperCase()){
+ this.$Message.error("楠岃瘉鐮侀敊璇�");
+ this.getCaptchaImg();
+ return
+ }
this.loading = true;
login({
username: this.form.username,
@@ -394,14 +408,14 @@
if (res.success) {
this.socialLogining = true;
let accessToken = res.result;
- this.setStore("accessToken", accessToken);
+ this.setSessionStore("accessToken", accessToken);
getOtherSet().then((res) => {
if (res.result) {
let domain = res.result.ssoDomain;
- Cookies.set("accessToken", accessToken, {
- domain: domain,
- expires: 7,
- });
+ // Cookies.set("accessToken", accessToken, {
+ // domain: domain,
+ // expires: 7,
+ // });
}
});
// 鑾峰彇鐢ㄦ埛淇℃伅
@@ -478,16 +492,17 @@
});
},
test() {
- this.$Notice.info({
- title: "娴嬭瘯浣撻獙璐﹀彿",
- desc: "璐﹀彿锛歵est鎴杢est2<br>瀵嗙爜锛�123456",
- });
+ // this.$Notice.info({
+ // title: "娴嬭瘯浣撻獙璐﹀彿",
+ // desc: "璐﹀彿锛歵est鎴杢est2<br>瀵嗙爜锛�123456",
+ // });
},
},
mounted() {
//this.showNotice();
this.relatedLogin();
- //this.getCaptchaImg();
+ this.getCaptchaImg();
+
},
};
</script>
--
Gitblit v1.9.1