zzzz
2024-04-23 c61ac52dc5e6aaf5363584a557648e04d854e672
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;