当前位置:网站首页>Vant 实现简单的登录注册模块以及个人用户中心
Vant 实现简单的登录注册模块以及个人用户中心
2022-07-03 01:09:00 【书边事.】
效果图:


代码:
个人中心:
<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"> <a href="#" style="color:#FFFFFF">今日待办</a></div>
</div>
<div> </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> </div>
<div>内容区</div>
</div>
<div style="clear:both;">
<van-tabbar
v-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> </div>
<img class="tar" src="@/assets/lz.jpg" alt="">
</div>
<van-field
left-icon="friends-o"
v-model="username"
style="margin-top:10px"
name="用户名"
label="用户 :"
placeholder="请输入用户名"
:rules="[{ required: true, message: '请填写用户名' }]"
label-width="50"
class="input"
/>
<van-field
left-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>
边栏推荐
- CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
- 什么是调。调的故事
- Is there a handling charge for spot gold investment
- MySQL foundation 07-dcl
- [my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
- uniapp组件-uni-notice-bar通告栏
- Basic concept and implementation of overcoming hash
- The industrial scope of industrial Internet is large enough. The era of consumer Internet is only a limited existence in the Internet industry
- What is tone. Diao's story
- [principles of multithreading and high concurrency: 2. Solutions to cache consistency]
猜你喜欢

MySQL - database query - condition query

Three core issues of concurrent programming - "deep understanding of high concurrent programming"

leetcode刷题_两数之和 II - 输入有序数组

C#应用程序界面开发基础——窗体控制(2)——MDI窗体
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research
![[untitled]](/img/fd/f6b90536f10325a6fdeb68dc49c72d.png)
[untitled]

串口抓包/截断工具的安装及使用详解

Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man
![[interview question] 1369 when can't I use arrow function?](/img/7f/84bba39965b4116f20b1cf8211f70a.png)
[interview question] 1369 when can't I use arrow function?
![[Arduino experiment 17 L298N motor drive module]](/img/e2/4511eaa942e4a64c8ca2ee70162785.jpg)
[Arduino experiment 17 L298N motor drive module]
随机推荐
数学知识:台阶-Nim游戏—博弈论
C application interface development foundation - form control (2) - MDI form
Telecom Customer Churn Prediction challenge
Basis of information entropy
d. LDC build shared library
[Arduino experiment 17 L298N motor drive module]
【第29天】给定一个整数,请你求出它的因子数
Scheme and practice of cold and hot separation of massive data
wirehark数据分析与取证A.pacapng
简易分析fgui依赖关系工具
2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
[androd] module dependency replacement of gradle's usage skills
Androd Gradle 对其使用模块依赖的替换
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
2022 coal mine gas drainage examination question bank and coal mine gas drainage examination questions and analysis
JUC thread scheduling
Expérience de recherche d'emploi d'un programmeur difficile
Mathematical Knowledge: Steps - Nim Games - Game Theory
看疫情之下服装企业如何顺势而为
uniapp组件-uni-notice-bar通告栏