From f42aa899f6264062d66a53e41e8954468725aa7a Mon Sep 17 00:00:00 2001
From: zzzz <690498789@qq.com>
Date: Tue, 23 Apr 2024 00:16:26 +0800
Subject: [PATCH] 1
---
src/page/login/index.vue | 67 +++++++++++++++++++++++++++++----
1 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/src/page/login/index.vue b/src/page/login/index.vue
index 34bb5ca..e880925 100644
--- a/src/page/login/index.vue
+++ b/src/page/login/index.vue
@@ -27,13 +27,22 @@
v-model="password"
typeText="password"
/>
- <div class="forget colorMain" @click="$router.push('/forget')">
- {{ $t("忘记密码?") }}
- </div>
- <div class="remember" data-v-8cc76a7b="">
- <van-checkbox @change="checkboxChange" v-model="checked">{{
- $t("記住帳戶密碼")
- }}</van-checkbox>
+ <div
+ style="
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-top: 10px;
+ "
+ >
+ <div class="forget colorMain" @click="$router.push('/forget')">
+ {{ $t("忘记密码?") }}
+ </div>
+ <div class="remember" data-v-8cc76a7b="">
+ <van-checkbox @change="checkboxChange" v-model="checked">{{
+ $t("記住帳戶密碼")
+ }}</van-checkbox>
+ </div>
</div>
<div class="btn btnMain" @click="verifyLogin">{{ $t("登录") }}</div>
<div class="noTips textColor">
@@ -74,6 +83,27 @@
icon: "",
};
},
+ mounted() {
+ const ret = window.localStorage.getItem("login_admin");
+ this.checked = window.localStorage.getItem("login_checked") === "true";
+ console.log(ret, this.checked);
+ if (ret && this.checked) {
+ this.password = JSON.parse(ret).password;
+ this.username = JSON.parse(ret).username;
+ }
+ },
+ activated() {
+ const ret = window.localStorage.getItem("login_admin");
+ this.checked = window.localStorage.getItem("login_checked") === "true";
+ console.log(ret, this.checked);
+ if (ret && this.checked) {
+ this.password = JSON.parse(ret).password;
+ this.username = JSON.parse(ret).username;
+ } else {
+ this.password = "";
+ this.username = "";
+ }
+ },
computed: {
...mapGetters({
theme: "home/theme",
@@ -81,7 +111,9 @@
},
methods: {
...mapActions("user", [GET_USERINFO, SET_CONFIG]),
- checkboxChange(e) {},
+ checkboxChange(e) {
+ window.localStorage.setItem("login_checked", e);
+ },
getRegType(activeIndex, bFlag) {
switch (activeIndex) {
case 0:
@@ -148,6 +180,18 @@
password: this.password,
})
.then((res) => {
+ if (this.checked) {
+ window.localStorage.setItem(
+ "login_admin",
+ JSON.stringify({
+ username: this.username,
+ password: this.password,
+ })
+ );
+ } else {
+ window.localStorage.setItem("login_admin", "");
+ }
+
this.GET_USERINFO(res.data);
this.SET_CONFIG(); //获取判断是否乘以杠杆字段
this.$router.push("/home");
@@ -165,6 +209,13 @@
</script>
<style lang="scss" scoped>
+::v-deep .van-icon {
+ width: 1.3rem;
+ height: 1.3rem;
+}
+::v-deep .van-checkbox__icon {
+ height: auto;
+}
.login {
width: 100%;
padding: 30px;
--
Gitblit v1.9.3