简单实现登录页面

1、Vue实现登录页面

  <div class="login_bd">
      <form>
        <div class="itemPhone">
          <div class="left">
            <span class="text">用户名:</span>
            <input
              class="input"
              v-model="user.mobile"
              placeholder="请输入手机号码"
            />
          </div>
        </div>
        <div class="itemPhone">
          <div class="left">
            <span class="text">密 码:</span>
            <input
              class="input"
              v-model="user.password"
              placeholder="请输入密码"
              type="password"
            />
          </div>
        </div>
        <div class="submit">
          <button >立即登录</button>
        </div>
        <div class="sign">
          <router-link to="/register">未有账号?请注册</router-link>
        </div>
      </form>
    </div>

css样式:

  .login_bd {
    width: 95%;
    margin: 50px auto 0;
    background: #fff;
    border-radius: 7px;
    height: 260px;

    .itemPhone {
      padding: 10px 20px 0 20px;

      .left {
        display: flex;
        align-items: center;
        border-bottom: 1px solid #c5c8ce;

        .text {
          text-align: right;
          text-align-last: right;
        }

        .input {
          flex: 1.1;
          padding: 20px 0 20px 15px;
        }
      }

      .right {
        flex: 0.9;

        button {
          font-size: 14px;
          background: #05C7BE;
          color: #fff;
          border-radius: 5px;
          height: 35px;
          line-height: 35px;
        }
      }
    }

    .submit {
      padding: 20px 20px 10px 20px;

      button {
        border-radius: 5px;
        background: #05C7BE;
        color: #fff;
        width: 100%;
        height: 40px;
        border: none;
      }
    }

    .sign {
      float: right;
      font-size: 14px;
      padding: 10px 20px 0 0;
      color: #808695;
      text-decoration: underline;
    }
  }

2、uniapp小程序登陆页面:

    <view class="login">
      <form @submit="formSubmit">
        <view class="itemPhone" v-for="item in formContent" :key="item.id">
          <view class="left">
            <text :class="item.icon + ' ' + 'iconfont'" />
            <input
              class="input"
              :placeholder="item.placeholder"
              :name="item.name"
              :value="item.value"
              :password="item.password"
              :maxlength="item.maxlength"
              @input="changeInput($event, item.name)"
            />
            <view class="right" v-if="item.name === 'code'">
              <button @click="countDown" class="code" v-if="!isCountdown">
                获取验证码
              </button>
              <button class="isCountdown" v-else>{{ times }}S</button>
            </view>
          </view>
        </view>
        <view class="submit">
          <button form-type="submit">立即登录</button>
        </view>

        <view class="signList" v-if="showCode">
          <text @click="toPassword('code')">短信登录</text>
        </view>
        <view class="signList" v-else>
          <text @click="toPassword('')">密码登录</text>
        </view>
        <view class="sign">
          <text @click="toRegister">注册用户</text>
        </view>
      </form>
    </view>

formContent的数据格式如下:
const formContent= [
  {
    id: 1,
    title: '手机号',
    name: 'mobile',
    type: 'text',
    placeholder: '请输入您的手机号',
    err: false,
    maxlength: 11,
    msg: '',
    value: '',
    icon: 't-icon iconshoujitongxun',
    password: false
  },
  {
    id: 2,
    title: '验证码',
    name: 'code',
    placeholder: '请输入您的验证码',
    maxlength: 6,
    err: false,
    msg: '',
    value: '',
    icon: 't-icon iconyanzhengma',
    password: true
  }
];

css样式:

  .login {
    width: 95%;
    height: 540px/2;
    margin: 0 auto;
    background: #fff;
    border-radius: 7px;
    margin-top: -40px;
    .itemPhone {
      padding: 10px 20px 0 20px;
      .left {
        display: flex;
        align-items: center;
        border-bottom: 1px solid @border-color;

        .input {
          flex: 1.1;
          padding: 20px 0 20px 15px;
        }
      }

      .right {
        flex: 0.9;

        button {
          font-size: 14px;
          background: @primary-color;
          color: #fff;
          border-radius: 5px;
          height: 35px;
          line-height: 35px;
        }
      }
    }
    .submit {
      padding: 20px 20px 10px 20px;

      .hoverClass {
        background: @primary-hover-color;
      }

      button {
        border-radius: 5px;
        background: @primary-color;
        color: #fff;
      }
    }
    .sign {
      float: right;
      font-size: 14px;
      padding: 10px 20px 0 0;
      color: @sub-color;
      text-decoration: underline;
    }
  }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kjs_pass

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值