vue---移动端登录页面

news/2024/9/20 22:30:32

最近在用vue做移动端,做了一个好看的移动端登录界面,保存一下,以后方便直接使用。

具体代码:

<template><div class="main-login-container"><div class="login-top"><img class="img" :src="logintop"></div><div class="login-box"><div class="login-title">{{ loginTitle }}</div><div class="login-from"><div class="login-from-box"><div class="title">登录</div><div class="from-item"><div class="tips" v-if="loginForm.account">手机号</div><div class="input" :class="errors.account ? 'errors' : ''"><input type="text" v-model="loginForm.account" placeholder="手机号" @focus="handleFocus('account')"></div><div class="info" v-if="errors.account">* {{ errors.account }}</div></div><div class="from-item"><div class="tips" v-if="loginForm.password">密码</div><div class="input" :class="errors.password ? 'errors' : ''"><input type="password" v-model="loginForm.password" placeholder="密码" @focus="handleFocus('password')"></div><div class="info" v-if="errors.password">* {{ errors.password }}</div></div><div class="from-item"><div class="tips" v-if="loginForm.checkCode">验证码</div><div class="input code" :class="errors.checkCode ? 'errors' : ''"><input type="text" v-model="loginForm.checkCode" placeholder="验证码" @focus="handleFocus('checkcode')"><img class="img" :src="codeImg" @click="handleCode"></div><div class="info" v-if="errors.checkCode">* {{ errors.checkCode }}</div></div><div class="submit-btn" @click="handleSubmit">登录</div></div></div></div><div class="login-bottom flex"><span class="copy">&copy;</span>Copyright © 2022-现在 云科技 All Rights Reserved. 沪ICP备512451200125号</div></div>
</template><script>
import { login, checkcode } from "@/api/index.js";
import { loginTitle } from "@/settings.js";
export default {data() {return {loginTitle:'云oA管理后台',isPost: false,codeImg: "",logintop: require("@/assets/logintop.jpg"),loginForm: {account: "18313888888",password: "888888",checkCode: "123456",},errors: {account: "",password: "",checkCode: "",},redirect: undefined,};},watch: {$route: {handler: function (route) {this.redirect = route.query && route.query.redirect;},immediate: true,},},mounted() {this.handleCode();},methods: {// get code
    handleCode() {let imgSrc = checkcode();imgSrc = imgSrc + "?" + Math.round(Math.random() * 10);this.codeImg = imgSrc;},// submit
    handleSubmit() {let that = this;// validateif (that.validate()) return false;if (that.isPost) return false;that.isPost = true;that.$store.dispatch("user/login", that.loginForm).then(() => {that.isPost = false;that.$router.push({ path: that.redirect || "/" });}).catch(() => {that.isPost = false;});},// focus
    handleFocus(value) {this.errors[value] = "";},// validate
    validate() {let arr = [];if (!this.loginForm.account) {arr.push("account");this.errors.account = "账号不能为空";}if (!this.loginForm.password) {arr.push("password");this.errors.password = "密码不能为空";}if (!this.loginForm.checkCode) {arr.push("checkCode");this.errors.checkCode = "验证码不能为空";}return arr.length ? true : false;},},
};
</script>
</style>
<style lang="scss" scoped>
.main-login-container {background: #fff;position: absolute;top: 0;right: 0;bottom: 0;left: 0;.login-top {width: 100%;height: 240px;background: #0793ff;position: absolute;left: 0;top: 0;.img{width: 100%;position: absolute;left: 0;bottom: 0;}}.login-box {position: relative;z-index: 10;.login-title {font-size: 26px;color: #fff;font-weight: 600;text-align: center;line-height: 50px;padding: 70px 0 0;letter-spacing: 3px;}.login-from {margin-top: 45px;padding: 0 20px;.login-from-box {padding: 20px 0px 40px;border-radius: 10px;.title {font-size: 20px;line-height: 50px;font-weight: bold;margin-bottom: 10px;text-indent: 2px;}.from-item {margin-bottom: 15px;.tips {font-size: 14px;color: #888;text-indent: 5px;}.input {margin-top: 2px;position: relative;border-bottom: 1px solid #eee;input {width: 100%;height: 40px;text-indent: 5px;line-height: 40px;font-size: 14px;color: #333;border: none;}.img {width: 85px;height: 40px;position: absolute;right: 0;bottom: 8px;}}.code {input {width: calc(100% - 95px);}}.errors {border-bottom-color: red;}.info {text-indent: 5px;font-size: 12px;line-height: 30px;color: red;}}.submit-btn {width: 100%;margin-top: 30px;height: 45px;line-height: 45px;border-radius: 5px;background: #2c76fc;color: #fff;font-size: 18px;text-align: center;letter-spacing: 3px;cursor: pointer;}}}}.login-bottom {width: 100%;min-height: 40px;line-height: 40px;color: #bbb;text-align: center;font-size: 14px;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;position: fixed;left: 0;bottom: 0;padding: 0 40px 10px;word-break: break-all;line-height: 20px;.copy {font-size: 16px;line-height: 20px;margin-right: 5px;}}
}
</style>

用到的头部图片:

打完收工!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/31800.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

一键自动化博客发布工具,用过的人都说好(51cto篇)

使用一键自动化博客发布工具blog-auto-publishing-tools把博客发布到51cto上。51cto是一个优秀的博客平台,今天给大家讲解一下blog-auto-publishing-tools如何自动发布博客到51cto上。 当然在实现过程中有可能会遇到各种困难,不过不用担心,我们一个个来解决。 前提条件 前提…

实验三 电子传输系统安全-进展1

任务详情上周任务完成情况(代码链接,所写文档等) 本周计划上周任务完成情况将上学期电子公文传输系统重新调试通过 哈希存储用户口令并且加盐,能够切换哈希算法 使用国密证书任务 完成情况启动系统 成功哈希口令并加盐 成功使用国密证书 失败上周任务详情 1. 重新调试通过上…

ITIL4之IT服务战略

战略和IT战略战略 的概念最早源于军事领域,意在通过对战争全局的精心规划和指挥,利用有限资源高效达成政治和军事目标。这一思想逐渐扩展到商业、管理乃至信息技术领域,成为指导长远发展和资源配置的核心框架。IT战略 是将军事战略的智慧引入企业信息化管理的产物,它基于对…

SpringBoot SpringCloud Spring Cloud Alibaba 版本对应关系

最近公司的项目扫描出一些安全漏洞,于是让我给项目中的依赖升下级。有部分涉及到SpringBoot和SpringCloud,因此要考虑到兼容性,特此记录下查询各版本之间对应关系的方法。靠谱的方法还是要从官网得到,参考文章:工具篇--SpringBoot与SpringCloud 的版本对应关系&Spring…

visual studio installer“无法下载安装,请检查网络连接”问题的解决方法

打开“网络适配器” 打开“属性” 选择“Internet协议版本4(TCP/IPv4)” 选择“属性”双击进入 选择“使用下面的DNS服务器地址(E)” 首选DNS服务器填写: 114.114.114.114 备用DNS服务器填写: 8.8.8.8

如何基于surging架设流媒体视频推流(视频讲解)

前言随着直播行业大火,各种直播类产品和产品层出不穷,能够满足各方人员的需求和互动,也使得斗鱼、虎牙、抖音都随着直播业的大火而欣欣向荣, 大家也对直播平台了解不少,也参与使用,但是怎么样才能研发出视频直播平台呢?那么针对于这个问题就是我今天想给大家讲解的一些东…

2024 年 5 月 14 日 周二 多云 热(270 字)

正文今天好忙,一楼二楼来回跑。都 17:57 了,忽然打电话说要临时上来报一个表,我真服了。今晚罕见地只有我一个人吃饭。昨天练习完之后有一些进步。Routine 里面加了三步。代价就是今天右手特别疼,因为昨天练习太久,掌骨关节在地上摁太久了。文件已经出了,明天似乎就要正式…

FTP Serv-U 配置端口号

1.打开Ser-U管理控制台,如图操作 2.修改监听端口号