欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

antd?Vue實現(xiàn)Login登錄頁面布局案例詳解?附帶驗證碼驗證功能

 更新時間:2022年05月10日 10:55:40   作者:JackieDYH  
這篇文章主要介紹了antd?Vue實現(xiàn)Login登錄頁面布局案例詳解附帶驗證碼驗證功能,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

效果

Login頁面

<!--
 * @Author: Jackie
 * @Date: 2022-05-07 14:34:06
 * @LastEditTime: 2022-05-09 15:57:44
 * @LastEditors: Jackie
 * @Description: 登錄頁 用戶名-密碼-驗證碼登錄方式
 * @FilePath: /vue-admin-template/src/views/Login.vue
 * @version: 
-->
<template>
  <div class="Login">
    <h1 class="title">JackieDYH管理平臺</h1>
    <a-form-model ref="ruleForm" :model="form" :rules="rules">
      <h5>登錄</h5>
      <a-form-model-item prop="name">
        <a-input v-model="form.name" placeholder="請輸入郵箱/手機(jī)號" />
      </a-form-model-item>
      <a-form-model-item prop="password">
        <a-input type="password" v-model="form.password" placeholder="請輸入密碼" />
      </a-form-model-item>
      <a-form-model-item prop="code" class="identify">
        <a-input v-model="form.code" placeholder="請輸入驗證碼" />
        <Identify :identifyCode="identifyCode" @click="refreshCode" />
      </a-form-model-item>
      <a-form-model-item>
        <a-button block type="primary" @click="onSubmit"> 提交 </a-button>
        <!-- <router-link
          :to="{ name: 'Password' }"
          style="float: right"
          class="pointer"
        >
          忘記密碼
        </router-link> -->
      </a-form-model-item>
    </a-form-model>
  </div>
</template>
 
<script>
import Identify from "@/components/Identify";
export default {
  name: "Login",
  components: { Identify },
  data() {
    let validateCode = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("驗證碼為空"));
        return false;
      } else if (value !== this.identifyCode) {
        callback(new Error("驗證碼不正確"));
        return false;
      } else {
        callback();
      }
    };
    return {
      identifyCodes: "1234567890",
      identifyCode: "",
      form: {
        name: "",
        password: "",
        code: "",
      },
      rules: {
        name: { required: true, message: "請輸入郵箱/手機(jī)號", trigger: "blur" },
        password: { required: true, message: "請輸入密碼", trigger: "blur" },
        code: [{ validator: validateCode, trigger: "blur" }],
      },
    };
  },
  mounted() {
    // 初始
    this.identifyCode = "";
    this.makeCode(this.identifyCodes, 4);
  },
  methods: {
    // 確認(rèn)
    onSubmit() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.$router.push("/home");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 重置表單
    resetForm() {
      this.$refs.ruleForm.resetFields();
    },
    // 驗證碼相關(guān)
    randomNum(min, max) {
      return Math.floor(Math.random() * (max - min) + min);
    },
    // 點擊刷新驗證碼
    refreshCode() {
      this.identifyCode = "";
      this.makeCode(this.identifyCodes, 4);
    },
    // 生成驗證碼
    makeCode(o, l) {
      for (let i = 0; i < l; i++) {
        this.identifyCode +=
          this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
      }
    },
  },
};
</script>
 
<style lang="scss" scoped>
.Login {
  width: 100%;
  height: 100%;
  background-image: url("~@/assets/images/bg_repeat_white.png");
  overflow: auto;
  .title {
    font-size: 40px;
    font-weight: bold;
    padding: 60px 0 60px 40px;
  }
  .ant-form {
    width: 500px;
    border-radius: 5px;
    background: #fff;
    margin: auto;
    padding: 18px 40px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    .ant-dropdown-trigger {
      float: right;
      margin-right: -20px;
    }
    h5 {
      font-size: 26px;
      text-align: center;
      margin-bottom: 25px;
    }
  }
  @media screen and (min-width: 769px) and (max-width: 1000px) {
    .title {
      font-size: 50px;
      text-align: center;
    }
    .ant-form {
      width: 60%;
    }
  }
  @media screen and (max-width: 769px) {
    .title {
      font-size: 50px;
      text-align: center;
    }
    .ant-form {
      width: 90%;
    }
  }
}
</style>
<style lang="scss">
// 驗證碼樣式
.Login .identify .ant-form-item-children {
  display: flex;
  align-items: center;
  .ant-input {
    flex: 1;
    margin-right: 10px;
  }
}
</style>

 Identify驗證碼

<!--
 * @Author: Jackie
 * @Date: 2022-05-09 14:49:38
 * @LastEditTime: 2022-05-09 14:49:39
 * @LastEditors: Jackie
 * @Description: 驗證碼
 * @FilePath: /vue-admin-template/src/components/Identify.vue
 * @version: 
-->
<template>
  <canvas
    id="s-canvas"
    :width="contentWidth"
    :height="contentHeight"
    v-on="$listeners"
  ></canvas>
</template>
<script>
export default {
  name: "SIdentify",
  props: {
    identifyCode: {
      type: String,
      default: "1234",
    },
    fontSizeMin: {
      type: Number,
      default: 16,
    },
    fontSizeMax: {
      type: Number,
      default: 40,
    },
    backgroundColorMin: {
      type: Number,
      default: 180,
    },
    backgroundColorMax: {
      type: Number,
      default: 240,
    },
    colorMin: {
      type: Number,
      default: 50,
    },
    colorMax: {
      type: Number,
      default: 160,
    },
    lineColorMin: {
      type: Number,
      default: 40,
    },
    lineColorMax: {
      type: Number,
      default: 180,
    },
    dotColorMin: {
      type: Number,
      default: 0,
    },
    dotColorMax: {
      type: Number,
      default: 255,
    },
    contentWidth: {
      type: Number,
      default: 112,
    },
    contentHeight: {
      type: Number,
      default: 38,
    },
  },
  methods: {
    // 生成一個隨機(jī)數(shù)
    randomNum(min, max) {
      return Math.floor(Math.random() * (max - min) + min);
    },
    // 生成一個隨機(jī)的顏色
    randomColor(min, max) {
      let r = this.randomNum(min, max);
      let g = this.randomNum(min, max);
      let b = this.randomNum(min, max);
      return "rgb(" + r + "," + g + "," + b + ")";
    },
    drawPic() {
      let canvas = document.getElementById("s-canvas");
      let ctx = canvas.getContext("2d");
      ctx.textBaseline = "bottom";
      // 繪制背景
      ctx.fillStyle = this.randomColor(
        this.backgroundColorMin,
        this.backgroundColorMax
      );
      ctx.fillRect(0, 0, this.contentWidth, this.contentHeight);
      // 繪制文字
      for (let i = 0; i < this.identifyCode.length; i++) {
        this.drawText(ctx, this.identifyCode[i], i);
      }
      // this.drawLine(ctx)
      this.drawDot(ctx);
    },
    drawText(ctx, txt, i) {
      ctx.fillStyle = this.randomColor(this.colorMin, this.colorMax);
      ctx.font =
        this.randomNum(this.fontSizeMin, this.fontSizeMax) + "px SimHei";
      let x = (i + 1) * (this.contentWidth / (this.identifyCode.length + 1));
      let y = this.randomNum(this.fontSizeMax, this.contentHeight - 5);
      var deg = this.randomNum(-45, 45);
      // 修改坐標(biāo)原點和旋轉(zhuǎn)角度
      ctx.translate(x, y);
      ctx.rotate((deg * Math.PI) / 180);
      ctx.fillText(txt, 0, 0);
      // 恢復(fù)坐標(biāo)原點和旋轉(zhuǎn)角度
      ctx.rotate((-deg * Math.PI) / 180);
      ctx.translate(-x, -y);
    },
    drawLine(ctx) {
      // 繪制干擾線
      for (let i = 0; i < 8; i++) {
        ctx.strokeStyle = this.randomColor(
          this.lineColorMin,
          this.lineColorMax
        );
        ctx.beginPath();
        ctx.moveTo(
          this.randomNum(0, this.contentWidth),
          this.randomNum(0, this.contentHeight)
        );
        ctx.lineTo(
          this.randomNum(0, this.contentWidth),
          this.randomNum(0, this.contentHeight)
        );
        ctx.stroke();
      }
    },
    drawDot(ctx) {
      // 繪制干擾點
      for (let i = 0; i < 100; i++) {
        ctx.fillStyle = this.randomColor(0, 255);
        ctx.beginPath();
        ctx.arc(
          this.randomNum(0, this.contentWidth),
          this.randomNum(0, this.contentHeight),
          1,
          0,
          2 * Math.PI
        );
        ctx.fill();
      }
    },
  },
  watch: {
    identifyCode() {
      this.drawPic();
    },
  },
  mounted() {
    this.drawPic();
  },
};
</script>
<style lang="scss">
canvas {
  cursor: pointer;
}
</style>

到此這篇關(guān)于antd Vue實現(xiàn)Login登錄頁面布局案例詳解 附帶驗證碼驗證功能的文章就介紹到這了,更多相關(guān)Vue登錄頁面布局內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue實現(xiàn)模態(tài)框的通用寫法推薦

    vue實現(xiàn)模態(tài)框的通用寫法推薦

    下面小編就為大家分享一篇vue實現(xiàn)模態(tài)框的通用寫法推薦,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • 關(guān)于應(yīng)用UI組件的移動端適配方式

    關(guān)于應(yīng)用UI組件的移動端適配方式

    這篇文章主要介紹了關(guān)于應(yīng)用UI組件的移動端適配方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue彈窗父子組件調(diào)用問題示例詳解

    vue彈窗父子組件調(diào)用問題示例詳解

    這篇文章主要介紹了vue彈窗父子組件調(diào)用問題,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-08-08
  • Vue+ElementUI啟動vue卡死的問題及解決

    Vue+ElementUI啟動vue卡死的問題及解決

    這篇文章主要介紹了Vue+ElementUI啟動vue卡死的問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • 利用Vue模擬實現(xiàn)element-ui的分頁器效果

    利用Vue模擬實現(xiàn)element-ui的分頁器效果

    這篇文章主要為大家詳細(xì)介紹了如何利用Vue模擬實現(xiàn)element-ui的分頁器效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以動手嘗試一下
    2022-11-11
  • vue使用自定義指令實現(xiàn)拖拽

    vue使用自定義指令實現(xiàn)拖拽

    這篇文章主要為大家詳細(xì)介紹了vue使用自定義指令實現(xiàn)拖拽,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • 老生常談vue2中watch的使用

    老生常談vue2中watch的使用

    watch的基本用法是在Vue實例中定義一個watch對象,該對象內(nèi)部包含需要監(jiān)聽的數(shù)據(jù)項和對應(yīng)的回調(diào)函數(shù),這篇文章主要介紹了vue2中watch的使用,需要的朋友可以參考下
    2024-01-01
  • vue中組件如何使用vue-quill-editor

    vue中組件如何使用vue-quill-editor

    這篇文章主要介紹了vue中組件如何使用vue-quill-editor問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • vue編譯器util工具使用方法示例

    vue編譯器util工具使用方法示例

    這篇文章主要為大家介紹了vue編譯器util工具使用方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • vue實現(xiàn)輪播圖片

    vue實現(xiàn)輪播圖片

    這篇文章主要為大家詳細(xì)介紹了vue實現(xiàn)簡單的輪播圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07

最新評論