1
PC-20250623MANY\Administrator
2025-08-07 6b019592ce032937fd6d3631a912fa8cd37e9fe4
src/page/login/login.vue
@@ -1,130 +1,295 @@
<template>
  <div class="login_page">
    <headers :mess="loginWay" />
    <div class="img_mess">
      <div class="logo_content animated fadeInRight">
        <img :src="Logo" alt />
      </div>
    <!-- <headers /> -->
    <tab-head :leftShow="false" :rightShow="false">
      <van-popover v-model="languageShow" trigger="click" :actions="actions" @select="onSelect" placement="bottom-end">
        <template #reference>
          <div class="multilingual">
            <img src="../../assets/img/language.svg" alt="" />
          </div>
        </template>
      </van-popover>
    </tab-head>
    <img src="../../assets/img/logo.png" alt="" class="logo">
    <div class="login_title animated slideInDown">
      <span>{{ $t("dlan") }}</span>
    </div>
    <div class="logins_content">
      <div class="login_title animated slideInDown">
        <span>{{ '邮箱登录' }}</span>
      </div>
      <div class="login_forms">
        <div class="top_forms">
          <div class="user_name">
            <input type="text" :placeholder="placeholder" v-model="userName" />
          </div>
          <div class="password">
            <input type="password"  placeholder="登录密码" v-model="userPassword" @input="handleInput()" />
          </div>
          <div class="forms_title">{{ $t('hj27') }}</div>
          <el-input :placeholder="$t('hj9')" :size="medium" v-model="userName" clearable>
          </el-input>
          <div class="forms_title">{{ $t('Password') }}</div>
          <el-input show-password :placeholder="$t('hj10')" :size="medium" v-model="userPassword"
            @input="handleInput()">
          </el-input>
        </div>
        <div class="bottom_btns">
          <div class="top_btn" @click="loginIN" :class="btnClass ? 'on' : 'off'">
            <span>{{ '安全登录' }}</span>
          </div>
          <div class="mes">
            <span>{{ '没有账户?' }}</span>
            <span @click="$router.push('/NewRegister')" style="color: rgb(54,124,248);">{{ '注册>' }}</span>
          </div>
          <van-button type="info" :disabled="!btnClass" class="butn" @click="loginIN">
            {{ $t("立即登录") }}
          </van-button>
          <van-button type="info" plain class="butn_2" @click="$router.push('/register')">
            {{ $t("免費註冊") }}
          </van-button>
          <!-- <div class="password-operate" data-v-8cc76a7b="">
            <div class="forget" data-v-8cc76a7b="" @click="getApp()">
              {{ $t("hj12") }}
            </div>
            <div class="remember" data-v-8cc76a7b="">
              <van-checkbox @change="checkboxChange" v-model="checked">{{
                $t("記住帳戶密碼")
              }}</van-checkbox>
            </div>
          </div> -->
        </div>
      </div>
      <!-- <div class="register" data-v-8cc76a7b="">
        {{ $t("還沒賬號?") }}
        <span @click="$router.push('/register')" data-v-8cc76a7b="" style="color:#c4d600">{{ $t("免費註冊") }}</span>
      </div> -->
    </div>
  </div>
</template>
<script>
import { Toast } from 'mint-ui'
import headers from "./components/header.vue";
import Logo from "@/assets/img/LOGO2.png";
import * as api from '@/axios/api';
// import headers from "./components/header.vue";
import tabHead from "../../components/tabHead.vue";
import * as api from "@/axios/api";
import { Notify } from "vant";
import { mapActions, mapMutations } from "vuex";
export default {
  name: "newLogin",
  data() {
    return {
      loginWay: "手机号登录",
      checked: false,
      loginWay: this.$t("hj8"),
      currentLoginMode: "email",
      placeholder: "电子邮箱",
      Logo,
      placeholder: this.$t("hj16"),
      userPassword: "",
      userName: "",
      btnClass: false
      btnClass: false,
      medium: "medium",
      languageShow: false, // 语言选择
      // 多语言配置
      actions: [
        {
          text: "English",
          lang: "en"
        },
        { text: "español", lang: "es" }
      ],
    };
  },
  components: {
    headers
    // headers,
    tabHead,
  },
  mounted() {
    const ret = window.localStorage.getItem("login_admin");
    this.checked = window.localStorage.getItem("login_checked") === "true";
    if (ret && this.checked) {
      this.userPassword = JSON.parse(ret).userPassword;
      this.userName = JSON.parse(ret).phone;
      this.btnClass = true;
    }
  },
  methods: {
    ...mapActions(["setUseInfo"]),
    ...mapMutations(["undataToken"]),
    checkboxChange(e) {
      window.localStorage.setItem("login_checked", e);
    },
    getApp() {
      // Toast('您所在的地区暂未开通此服务')
      //Toast 弹窗大小
      Notify({ type: "warning", message: this.$t("hj17") });
    },
    handleInput() {
      if (this.userPassword !== "" && this.userName !== '') {
      if (this.userPassword !== "" && this.userName !== "") {
        this.btnClass = true;
      } else {
        this.btnClass = false;
      }
    },
    async loginIN () {
    async loginIN() {
      let opts = {
        phone: this.userName,
        userPwd: this.userPassword
      }
      };
      let data = await api.login(opts);
      let data = await api.login(opts)
      if (data.status === 0) {
        this.$store.state.userInfo.phone = this.userName
        this.$store.state.userInfo.token = data.data.token
        this.setUseInfo();
        if (this.checked) {
          window.localStorage.setItem(
            "login_admin",
            JSON.stringify({
              phone: this.userName,
              userPassword: this.userPassword
            })
          );
        } else {
          window.localStorage.setItem("login_admin", "");
        }
        this.$store.state.userInfo.phone = this.userName;
        this.$store.state.userInfo.token = data.data.token;
        this.undataToken(data.data.token);
        window.localStorage.setItem("USERTOKEN", data.data.token);
        // Notify({ type: "success", message: this.$t("hj36") });
        window.localStorage.clear()
        window.localStorage.setItem("USERTOKEN",data.data.token);
        this.$router.push('/home')
        setTimeout(() => {
          // this.$router.push("/home");
          this.$router.push("/home_index");
        }, 1000);
      } else {
        Toast(data.msg)
        Notify({ type: "warning", message: data.msg });
      }
      if (navigator.vibrate) {
        // 支持
        navigator.vibrate([55]);
      }
    },
    // 选择语言
    onSelect(e) {
      window.localStorage.setItem("language", e.lang);
      this.$i18n.locale = e.lang;
    },
  },
  beforeDestroy() {},
  created() {}
  beforeDestroy() { },
  created() { }
};
</script>
<style scoped lang="less">
.login_page {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overflow-y: auto;
@green: #c4d600;
.password-operate {
  display: flex;
  justify-content: space-between;
  margin-top: 0.53333rem;
  .forget {
    font-style: normal;
    font-weight: 400;
    font-size: 0.37333rem;
    line-height: 0.53333rem;
    color: #8c9fad;
  }
}
/deep/ .van-checkbox__icon--checked .van-icon {
  background: @green;
  border-color: @green;
}
.register {
  font-style: normal;
  font-weight: 500;
  font-size: 0.37333rem;
  color: #8c9fad;
  margin: 0.4rem auto;
  padding: 0.34667rem 0.4rem;
  width: 100%;
  height: 6rem;
  text-align: center;
  span {
    color: rgb(5, 106, 239);
  }
}
.login_title {
  font-family: "DINPro", serif;
  font-style: normal;
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 0.66667rem;
  color: #14181f;
  text-align: center;
}
/deep/ .van-checkbox__label {
  font-style: normal;
  font-weight: 500;
  font-size: 0.37333rem;
  line-height: 0.53333rem;
  color: #8c9fad;
}
/deep/ .van-button__text {
  font-size: 24px;
  font-family: "DINPro";
}
.login_page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  .multilingual {
    width: .8em;
    height: .8em;
    margin-left: 0.25em;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.logo {
  width: 50vw;
  margin: 10vw auto 15vw;
}
.logins_content {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 9.7436rem;
  margin-top: 0.4359rem;
  padding: 0 0.2564rem;
  .login_title {
    width: 100%;
    height: 2.0513rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.6923rem;
    color: #fff;
  }
  background: #fff;
  // padding: 0 0.4564rem;
  .login_forms {
    width: 100%;
    height: 7.9231rem;
    border-top-left-radius: 0.26667rem;
    border-top-right-radius: 0.26667rem;
    padding: 0.34667rem 0.4rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    .top_forms {
      width: 100%;
      height: 4.5128rem;
      height: auto;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      .forms_title {
        font-size: .4rem;
        margin-top: .5rem;
        margin-bottom: .2rem;
      }
      .user_name,
      .password {
        width: 100%;
        height: 35%;
        background: #1e1e1e;
        height: 50px;
        background: #fff;
        // background: #1e1e1e;
        border-radius: 0.3564rem;
        > input {
        >input {
          width: 100%;
          height: 100%;
          padding-left: 0.3564rem;
@@ -132,29 +297,63 @@
        }
      }
    }
    /deep/.el-input__inner {
      width: 100%;
      height: 70px;
      background-color: #fff !important;
      // background: #1e1e1e;
      border-radius: 8px;
      font-size: 0.45rem !important;
      border: #ddd solid 1px;
    }
    .bottom_btns {
      width: 100%;
      height: 3.3333rem;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      margin-top: 0.5128rem;
      .top_btn {
      // margin-top: 0.8528rem;
      .butn {
        width: 100%;
        height: 40%;
        border-radius: 0.3564rem;
        background: rgb(131, 174, 243);
        margin-top: 40px;
        height: 60px;
        border-radius: 8px;
        background: @green;
        border: none;
      }
      .butn_2 {
        width: 100%;
        margin-top: 40px;
        height: 60px;
        border-radius: 8px;
        color: @green;
        border-color: @green;
        margin-top: .4rem;
      }
      .top_btn {
        border: none;
        width: 100%;
        height: 1.25rem;
        border-radius: 8px;
        background: @green;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.5128rem;
        margin-top: 0.75rem;
        >span {
          font-weight: 530 !important;
        }
      }
      .top_btn.on {
        background: rgb(0, 71, 187);
      }
      .mes {
        width: 100%;
        height: 40%;
        // width: 100%;
        height: 20%;
        margin-top: 0.4rem;
        display: flex;
        justify-content: flex-end;
        align-items: center;
@@ -163,19 +362,137 @@
    }
  }
}
.login_bom {
  position: absolute;
  bottom: 2.6rem;
  width: 100%;
  height: 4rem;
  padding: 0 2rem;
}
.line {
  //分割线
  width: 100%;
  height: 0.3846rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.3846rem;
  .left_line {
    width: 20%;
    height: 0.01rem;
    background: #e5e5e5;
  }
  .center_line {
    width: 50%;
    height: 0.01rem;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    >span {
      font-size: 0.3046rem;
      color: #000;
      background-color: #fff;
    }
  }
  .right_line {
    width: 20%;
    height: 0.01rem;
    background: #e5e5e5;
  }
}
.myzh {
  // width: calc(100% - 4rem);
  // position: absolute;
  bottom: 0.01rem;
  text-align: center;
  display: flex;
  align-items: center;
  .mes {
    // width: 100%;
    height: 40%;
    font-size: 0.3846rem;
  }
}
.imgDemo {
  display: flex;
  justify-content: space-between;
  position: relative;
  transform: translateY(50%);
}
.appImg {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgb(246, 246, 247);
  border-radius: 100%;
}
.appImg img {
  width: 0.8rem;
  height: 0.8rem;
}
.img_mess {
  width: 100%;
  height: 4.0513rem;
  display: flex;
  justify-content: center;
  align-items: center;
  .logo_content {
    width: 3rem;
    height: 3.5769rem;
    > img {
    >img {
      width: 100%;
      height: 100%;
    }
  }
}
/deep/.el-input__suffix {
  width: 1rem !important;
  display: flex;
  justify-content: center;
  align-items: center;
}
/deep/.el-input__suffix-inner {
  display: flex;
  justify-content: center;
  align-items: center;
}
/deep/.el-input__icon {
  width: 1rem !important;
  display: flex;
  justify-content: center;
  align-items: center;
}
.on .top_btn {
  background: @green !important;
}
/deep/.el-icon-circle-close::before {
  font-size: 0.5rem !important;
}
/deep/.el-input__clear {
  font-size: 0.5rem !important;
}
</style>