Vant 实现简单的登录注册模块以及个人用户中心

2023-10-22 00:30

本文主要是介绍Vant 实现简单的登录注册模块以及个人用户中心,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果图:

  

代码:

  个人中心:

<template><div><div class="top"><div><img class="tar" src="@/assets/lz.jpg" alt=""><p style="float:left;color:#FFFFFF;margin-left:15px;margin-top:20px">可达鸭</p><div style="float:right;height:25px;background-color:#295F96;margin-top:25px;width: 80PX; border-radius: 15px 0px 0px 15px;color:#FFFFFF">&nbsp;<a href="#" style="color:#FFFFFF">今日待办</a></div></div><div>&nbsp;</div><div style="clear: both"><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:30px;"><div>动态</div><div>0</div></div><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:110px;"><div>关注</div><div>99</div></div><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:110px;"><div>粉丝</div><div>10</div></div></div></div><div style=""><div style="float:left;margin-left:30px;margin-top:10px"><div ><van-icon size="25" name="star-o" /></div><div style="margin-top:3px">收藏</div></div><div style="float:left;margin-left:110px;margin-top:10px"><div ><van-icon size="25" name="clock-o" /></div><div style="margin-top:3px">历史</div></div><div style="float:left;margin-left:110px;margin-top:10px"><div ><van-icon size="25" name="todo-list-o" /></div><div style="margin-top:3px">作品</div></div><div style="clear: both;;width:100%;height:10px"></div></div><div style="margin-top:10px; clear: both; border-top: 1px solid #e2e2ee;"><div>&nbsp;</div><div>内容区</div></div><div style="clear:both;"><van-tabbarv-model="active"active-color="#07c160"
><van-tabbar-item icon="home-o">标签</van-tabbar-item><van-tabbar-item icon="search">标签</van-tabbar-item><van-tabbar-item icon="fire-o">标签</van-tabbar-item><van-tabbar-item icon="setting-o">标签</van-tabbar-item>
</van-tabbar></div><div></div></div> 
</template>
<style scoped>.top{height: 150px;width: 100%;background-color: #1e87ff;margin-top:-58px}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;float: left;margin-left:10px;}
</style>
<script>import Tabbar from '@/components/tab/Tabbar.vue'export default{data(){return{userName:'',pwd:'',active: 0}},//axios //getApi()  ---> axios aixos.get('http://localhost:8080/api')//后端得到了请求 --数据处理 --数据传回 //本地的浏览器得到数据components:{Tabbar,},created(){var userLogin = localStorage.getItem("userLogin");userLogin =  JSON.parse(userLogin);console.log(userLogin.name);console.log(userLogin.pwd);this.userName = userLogin.name;this.pwd = userLogin.pwd;},methods:{exit(){localStorage.removeItem("userLogin"); //移除保存的数据this.$router.replace("/home");},onClickLeft() {Toast('返回');},onClickRight() {Toast('按钮');}}}
</script>
<style>.top{height: 100px;width: 100%;background-color: #1e87ff;margin-top:-58px}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;}
</style>

   登录:

<template><van-form @submit="onSubmit"><div ><div>&nbsp;</div><img class="tar" src="@/assets/lz.jpg" alt=""></div><van-fieldleft-icon="friends-o"v-model="username"style="margin-top:10px"name="用户名"label="用户 :"placeholder="请输入用户名":rules="[{ required: true, message: '请填写用户名' }]"label-width="50"class="input"/><van-fieldleft-icon="smile-comment-o"v-model="password"type="password"name="密码"label="密码 :"placeholder="请输入密码"label-width="50":rules="[{ required: true, message: '请填写密码' }]"class="input"/><div style="margin: 16px;"><van-button round block type="info"  native-type="submit">提交</van-button></div><div class="reg"><div @click="toRegister" style="font-size: small;">没有账号?立即注册</div></div></van-form></template>
<script>
import { Dialog } from 'vant';export default{data(){return{username:'',password:'',show:false,userList:[],}},methods:{onSubmit(){var list  = localStorage.getItem("userList");console.log(list);if(list == null ){Dialog.alert({title: '尊敬的用户您好:',message: '登录账户不存在,重新登录!',theme: 'round-button',}).then(() => {this.username = '';this.password = '';}); }else{this.userList = JSON.parse(list);for(var i = 0 ; i < this.userList.length ; i++){console.log(this.userList[i].name);console.log(this.userList[i].pwd);if(this.userList[i].name == this.username && this.userList[i].pwd == this.password){Dialog.alert({title: '尊敬的用户您好:',message: '登录成功!',theme: 'round-button',}).then(() => {this.$router.replace({path:'/home'});});localStorage.setItem("userLogin",JSON.stringify(this.userList[i]));return  ;}}Dialog.alert({title: '尊敬的用户您好:',message: '登录账户不存在,重新登录!',theme: 'round-button',}).then(() => {this.username = '';this.password = '';}); }},toRegister(){this.$router.replace('/user/register')}},components:{[Dialog.Component.name]: Dialog.Component,}}
</script>
<style scoped>/* .juli{margin-top: 50px;background-color: pink;} */.input{margin-top: 50px;border-bottom: 1px solid #e2e2ee;}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;}/* .back{} */
</style>

这篇关于Vant 实现简单的登录注册模块以及个人用户中心的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/257917

相关文章

Python实现AVIF图片与其他图片格式间的批量转换

《Python实现AVIF图片与其他图片格式间的批量转换》这篇文章主要为大家详细介绍了如何使用Pillow库实现AVIF与其他格式的相互转换,即将AVIF转换为常见的格式,比如JPG或PNG,需要的小... 目录环境配置1.将单个 AVIF 图片转换为 JPG 和 PNG2.批量转换目录下所有 AVIF 图

Pydantic中model_validator的实现

《Pydantic中model_validator的实现》本文主要介绍了Pydantic中model_validator的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价... 目录引言基础知识创建 Pydantic 模型使用 model_validator 装饰器高级用法mo

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

Redis分片集群的实现

《Redis分片集群的实现》Redis分片集群是一种将Redis数据库分散到多个节点上的方式,以提供更高的性能和可伸缩性,本文主要介绍了Redis分片集群的实现,具有一定的参考价值,感兴趣的可以了解一... 目录1. Redis Cluster的核心概念哈希槽(Hash Slots)主从复制与故障转移2.

springboot+dubbo实现时间轮算法

《springboot+dubbo实现时间轮算法》时间轮是一种高效利用线程资源进行批量化调度的算法,本文主要介绍了springboot+dubbo实现时间轮算法,文中通过示例代码介绍的非常详细,对大家... 目录前言一、参数说明二、具体实现1、HashedwheelTimer2、createWheel3、n

使用Python实现一键隐藏屏幕并锁定输入

《使用Python实现一键隐藏屏幕并锁定输入》本文主要介绍了使用Python编写一个一键隐藏屏幕并锁定输入的黑科技程序,能够在指定热键触发后立即遮挡屏幕,并禁止一切键盘鼠标输入,这样就再也不用担心自己... 目录1. 概述2. 功能亮点3.代码实现4.使用方法5. 展示效果6. 代码优化与拓展7. 总结1.

Mybatis 传参与排序模糊查询功能实现

《Mybatis传参与排序模糊查询功能实现》:本文主要介绍Mybatis传参与排序模糊查询功能实现,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、#{ }和${ }传参的区别二、排序三、like查询四、数据库连接池五、mysql 开发企业规范一、#{ }和${ }传参的

使用Python开发一个简单的本地图片服务器

《使用Python开发一个简单的本地图片服务器》本文介绍了如何结合wxPython构建的图形用户界面GUI和Python内建的Web服务器功能,在本地网络中搭建一个私人的,即开即用的网页相册,文中的示... 目录项目目标核心技术栈代码深度解析完整代码工作流程主要功能与优势潜在改进与思考运行结果总结你是否曾经

Docker镜像修改hosts及dockerfile修改hosts文件的实现方式

《Docker镜像修改hosts及dockerfile修改hosts文件的实现方式》:本文主要介绍Docker镜像修改hosts及dockerfile修改hosts文件的实现方式,具有很好的参考价... 目录docker镜像修改hosts及dockerfile修改hosts文件准备 dockerfile 文

基于SpringBoot+Mybatis实现Mysql分表

《基于SpringBoot+Mybatis实现Mysql分表》这篇文章主要为大家详细介绍了基于SpringBoot+Mybatis实现Mysql分表的相关知识,文中的示例代码讲解详细,感兴趣的小伙伴可... 目录基本思路定义注解创建ThreadLocal创建拦截器业务处理基本思路1.根据创建时间字段按年进