登陆页面

vue 框架 主要看样式,其他的根据需求改

<!-- 登陆 -->
<template>
  <div class="login">
    <div class="loginTop">欢迎登陆</div>
    <div class="loginContent">
      <input
        type="text"
        name="phone"
        class="phone"
        v-model="phone"
        placeholder="请输入手机号"
        required
      />
      <input
        type="text"
        name="password"
        class="password"
        v-model="password"
        placeholder="请输入密码"
        required
      />
      <div>
        <button class="btn" @click="login">登陆</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phone: '',
      password: '',
    }
  },
  methods: {
    login: async function () {
      // let res = await this.$store.dispatch('getLogin', {
      //   phone: this.phone,
      //   password: this.password,
      // })
      // if (res.data.code === 200) {
      //   this.$store.commit('updateIsLogin',true)
      //   this.$router.push('/infoUser')
      // }else{
      //   console.log("error");
      //   showFailToast("用户名或密码错误")
      //   this.password = ""
      // }
      var myreg = /^[1][3,4,5,7,8][0-9]{9}$/
      if (this.phone.trim() === '') {
        this.$toast({
          message: '手机号不能为空',
          icon: 'manager',
        })
      } else if (this.password.trim() === '') {
        this.$toast({
          message: '密码不能为空',
          icon: 'warning',
        })
      } else if (this.phone.trim() !== '' && this.password.trim() !== '') {
        if (!myreg.test(this.phone)) {
          this.$toast({
            message: '手机号格式不正确',
            icon: 'warning',
          })
        } else {
          this.$toast({
            type: 'success',
            message: '登陆成功',
            icon: 'success',
          })
          this.$store.commit('updateIsLogin', true)
          this.$router.push('/infoUser')
        }
      }
    },
  },
}
</script>

<style lang="less" scoped>
.login {
  width: 100%;
  height: 100vh;
  padding: 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: rgba(57, 92, 120, 0.607);
  .loginTop {
    margin-top: 1rem;
    font-size: .6rem;
    color: #fff;
  }
  .loginContent {
    margin-top: 1rem;
    // background-color: aqua;
    width: 6rem;
    text-align: center;
    height: 4rem;
    color: #fff;
    .phone {
      width: 90%;
      height: 0.8rem;
      margin-top: 0.6rem;
      margin-bottom: 10px;
      background: none;
      border: none;
      border-bottom: 1px solid rgb(214, 212, 212);
    }
    .password {
      width: 90%;
      height: 0.8rem;
      margin-top: 0.6rem;
      margin-bottom: 10px;
      background: none;
      border: none;
      border-bottom: 1px solid rgb(214, 212, 212);
    }
    .btn {
      width: 90%;
      background-color: rgb(228, 133, 179);
      height: 40px;
      border: none;
      border-radius: 5px;
      margin-top: 0.8rem;
    }
  }
}
</style>

结果
image

posted @ 2022-12-02 17:00  合起来的彳亍  阅读(23)  评论(0编辑  收藏  举报