VueDemo-11.登录功能
11.登录功能)11.1 构建登录页面<template><div class="box"><header class="header"><van-nav-bartitle="嗨购登录"left-arrow@click-left="$router.back()"></van-nav-bar></header>......
·
11.登录功能
)
11.1 构建登录页面
<template> <div class="box"> <header class="header"> <van-nav-bar title="嗨购登录" left-arrow @click-left="$router.back()" ></van-nav-bar> </header> <div class="content"> <div class="form" v-if="type === '1'"> <van-field v-model="loginname" placeholder="用户名/手机号/邮箱" clearable/> <van-field v-model="password" type="password" placeholder="请输入密码" clearable/> <div class="my-button"> <van-button color="#ff6666" :disabled="adminameFlag" block round @click="adminameLoginFn">登录</van-button> </div> </div> <div class="form" v-if="type === '0'"> <van-field v-model="tel" type="tel" placeholder="手机号码" clearable/> <van-field v-model="telcode" center clearable placeholder="请输入短信验证码" > <template #button> <van-button size="small" >发送短信验证码</van-button> </template> </van-field> <div class="my-button"> <van-button color="#ff6666" block round>登录</van-button> </div> </div> <!-- 登录方式以及 注册提示 --> <ul class="more"> <li @click="changeType"> <span v-if="type === '1'">短信验证码登录</span> <span v-else>账号密码登录</span> </li> <router-link to="/register/step1" tag="li"> 手机快速注册 </router-link> </ul> <div class="my-divider"> <van-divider>其他登录方式</van-divider> </div> <div class="my-login-type"> <van-row type="flex" justify="center"> <van-col span="6"> <van-image :src="qq" width="48" height="48"/> <p>QQ</p> </van-col> <van-col span="6"> <van-image :src="wx" width="48" height="48"/> <p>微信</p> </van-col> <van-col span="6"> <van-image :src="apple" width="48" height="48"/> <p>苹果</p> </van-col> </van-row> </div> </div> </div> </template> <script> import Vue from 'vue' import { NavBar, Field, Button, Divider, Col, Row, Image as VanImage } from 'vant' Vue.use(NavBar) Vue.use(Field) Vue.use(Button) Vue.use(Divider) Vue.use(Col) Vue.use(Row) Vue.use(VanImage) export default { data () { return { qq: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAADwJJREFUeAHtXW2MXUUZnplz7r27t9vtF3VLEQVaR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BON12AUuOmwLRrnFTACLjpsisZ3UDLGeD60Ki1ROAHH98wK1Oqi8Q2kFbMMtS1RaFVAWmaWxRtR2ASrwKRxL0ThI1gJZml+EIV1sAIzDbVzVYwEa9pMQW1DFF6ANWWyUCBC1AZYWbMGtbYoNA9AWjNlqF2KxjuQysaHArNzvw/B8Zn30BArL6JsStA7Eo3DBiglZl2gLSq1MzCyTHzAF9F5vgfCFBMn0RCl1k4ItWkTgLAhWm2oBYp9k8+ruePShCmA0DkUnWdVqBUUeRSXxvDp/bJZAWOvKSrMwljp5tWMtxL3Bu577OlD9VAzG/ahl+n9z6J8jjufC3r/NymV9w+HyQ4Ihd7/bk6jJYM1T8FI9s8fOO9ksEswJj3FOQwbJF6EYATX51GM8NWgnLYDytL1uRylc/UQta3TaqX6fasmf2xWwUldn09yws8/u2GgXcdf9faz7orYCcHJXJ/T0iqn3/YqN3/ZrTdAWyTOq20ZI87tLckT9xe2FIl7HEsmVon7LEsSxL2eJf4Ycb9pyRxxz2tJmCLuuy2ZJe79LQmTRP2DJQmiDsSS9DhRD2NJkagLsiTnEfVRdvhJZ+vEnKiXc6Fu0In6SSfqSJ2op3WhrtiJ+mon6sydqLd3ou/Aif4LJ/pQnOjHcaIvyYn+LDf61Jzo13Oib9GN/k0n+ljd6Od1o6/Zjf5uN/rc3ej3d+S7B458/+HWdzDWyn55bcjvYPwGhuimKWCwYFgAAAAASUVORK5CYII=', tel: '', password: '', loginname: '', telcode: '', type: '1' // 1表示账户名密码 0表示手机验证码 } }, computed: { adminameFlag () { if (this.loginname !== '' && this.password !== '') { return false } else { return true } } }, methods: { changeType () { this.type = this.type === '1' ? '0' : '1' }, adminameLoginFn () { } } } </script> <style lang="stylus"> .container .box .content padding 30px 15px background-color #ffffff .form .my-button margin-top 30px .more margin-top 20px display flex li flex 1 &:nth-child(1) text-align left &:nth-child(2) text-align right .my-divider margin-top 80px </style>
11.2 注册路由
{ path: '/login', name: 'login', component: () => import(/* webpackChunkName: 'user' */'../views/login/index.vue'), meta: { hidden: true } }, { path: '*', // 404 ---- 路由懒加载 ---- 一般用不到 component: () => import(/* webpackChunkName: 'error' */'../views/error/notFound.vue') }
11.3 实现登录
import request from '../utils/request' // 验证手机号码是否被注册 export function doCheckPhone (params) { return request.post('/user/docheckphone', params) } // 发送短信验证码 export function doSendMsgCode (params) { return request.post('/user/dosendmsgcode', params) } // 验证短信验证码 export function doCheckCode (params) { return request.post('/user/docheckcode', params) } // 注册 export function doFinishRegister (params) { return request.post('/user/dofinishregister', params) } // 登录 export function login (params) { return request.post('/user/login', params) }
<template> <div class="box"> <header class="header"> <van-nav-bar title="嗨购登录" left-arrow @click-left="$router.back()" ></van-nav-bar> </header> <div class="content"> <div class="form" v-if="type === '1'"> <van-field v-model="loginname" placeholder="用户名/手机号/邮箱" clearable/> <van-field v-model="password" type="password" placeholder="请输入密码" clearable/> <p class="passwordTip" v-if="passwordTipFlag">输入至少6位,包含至少一个大写字母,1个小写字母,1个数字</p> <div class="my-button"> <van-button color="#ff6666" :disabled="adminameFlag" block round @click="adminameLoginFn">登录</van-button> </div> </div> <div class="form" v-if="type === '0'"> <van-field v-model="tel" type="tel" placeholder="手机号码" clearable/> <van-field v-model="telcode" center clearable placeholder="请输入短信验证码" > <template #button> <van-button size="small" >发送短信验证码</van-button> </template> </van-field> <div class="my-button"> <van-button color="#ff6666" block round>登录</van-button> </div> </div> <!-- 登录方式以及 注册提示 --> <ul class="more"> <li @click="changeType"> <span v-if="type === '1'">短信验证码登录</span> <span v-else>账号密码登录</span> </li> <router-link to="/register/step1" tag="li"> 手机快速注册 </router-link> </ul> <div class="my-divider"> <van-divider>其他登录方式</van-divider> </div> <div class="my-login-type"> <van-row type="flex" justify="center"> <van-col span="6"> <van-image :src="qq" width="48" height="48"/> <p>QQ</p> </van-col> <van-col span="6"> <van-image :src="wx" width="48" height="48"/> <p>微信</p> </van-col> <van-col span="6"> <van-image :src="apple" width="48" height="48"/> <p>苹果</p> </van-col> </van-row> </div> </div> </div> </template> <script> import Vue from 'vue' import { NavBar, Field, Button, Divider, Col, Row, Image as VanImage, Dialog, Toast } from 'vant' import { login } from './../../api/user' Vue.use(NavBar) Vue.use(Field) Vue.use(Button) Vue.use(Divider) Vue.use(Col) Vue.use(Row) Vue.use(VanImage) Vue.use(Dialog) Vue.use(Toast) export default { data () { return { qq: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAADwJJREFUeAHtXW2MXUUZnplz7r27t9vtF3VLEQVaRKlABPxAQ+gqrR8pRASK/qAaP6JFfkFi/KFm4x/wIxqjSAImQgvRFA2kyA9LgZqYKH6CUqCEUgKFdkvpdrfbu3vvPWfG9zm7c++Zs3fv55m56+7eZHdmzsx533eed87MnHdm3sPZHP0NDSnx0IXMH+k94ue9nD857vsBE57yGVce5zLgglE8Ej9gSvhK8lApTnGfybCnLwgKYTFYMXFmcOPzLBga4nIuVnWqAnNAMgB+31UsK4KR3OlTmVzoCT9NsbxQBkuWlovSX1H80p9Yaa4opKsKGFJK3L1nuNcr5XtL0sumCXgjWlkRlsJsYWL75oGJIXqgGpW3le9cAYp6iXP3sVzw1lh+Muf32KpYK3R7isGkv7q/cGgjK3LOVSv3dlrWmQIA/Fl/ONIblpf2pd29dAqCvh/dlJc5Nf7GljMnXCnCugIA/Jqdw3m1rK9PMu7pys7lUDAV8tHx8aM3DxRsK8KqAjbsV9njB8aXz9UW36gR4Ik444K+k/s38FKjsu3mW1HAjbt2eU/nN/cXwkxvu4LNpfvyXnniw4U9Yw9t3RqmLVfqCnjnrtd7J72Vyytz9LQl7hY9er/oCU+cPLz17Ik0RUhNAejr1+0d6R8r5JakKeBco9WfL54+ePWKsbTGhlQUsPEp5b84Mb4iKIvMXAPMhjx+Rpbf29s3sm+Q3rs7/HWsgA27VPbYErZSBQXRoSz/V7dzPy/fcZqd2L+1swG6I9DO+fWhnuH+wqqFBj5aCuqMugODTlpO20/A2kffzJfksuWdMJ8v92bF6M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ode: '', type: '1' // 1表示账户名密码 0表示手机验证码 } }, computed: { adminameFlag () { if (this.loginname !== '' && /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(this.password)) { return false } else { return true } }, passwordTipFlag () { if (this.password === '' || /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(this.password)) { return false } else { return true } } }, methods: { changeType () { this.type = this.type === '1' ? '0' : '1' }, adminameLoginFn () { console.log('1111111') login({ loginname: this.loginname, password: this.password }).then(res => { if (res.data.code === '10010') { // 账户不存在,提醒用户是否要立即注册 Dialog.confirm({ message: '该用户还未注册,是否立即注册', confirmButtonText: '立即注册', confirmButtonColor: '#ff6666', cancelButtonText: '取消', cancelButtonColor: '#999' }) .then(() => { this.$router.push('/register') }) .catch(() => { // on cancel }) } else if (res.data.code === '10011') { // 提醒用户密码错误, 视情况而定是否需要清空密码输入框 this.password = '' Toast('密码错误') } else { // 登录成功 Toast('登录成功') localStorage.setItem('userid', res.data.data.userid) // 知道是谁 localStorage.setItem('token', res.data.data.token) // 后端验证用户的登录状态 localStorage.setItem('loginState', true) // 前端自检登录状态 // 返回上一页 this.$router.back() } }) } } } </script> <style lang="stylus"> .container .box .content padding 30px 15px background-color #ffffff .form .my-button margin-top 30px .more margin-top 20px display flex li flex 1 &:nth-child(1) text-align left &:nth-child(2) text-align right .my-divider margin-top 80px .passwordTip color #f66 font-size 12px </style>
注册和登录联动测试
发现注册之后回到登录,登录成功,又回到了注册页面
Login push。 Step1 push。step2 push step3。 ===》。step3。go(-3) login
Login push Step1 replace step2 replace step3 ==> step3 back() login
登录成功
保存状态
更多推荐
已为社区贡献6条内容
所有评论(0)