<!-- 登录弹框 -->
<div class="mask" v-show="flag">
<div class="mask_content" v-show="type_d=='sign'">
<p class="mask_gb" @click="cloces"><img src="../static/img/home/gw_icon.png" alt=""></p>
<div class="mas_title">
<h3>登录</h3>
<img src="../static/img/home/logo.png" alt="">
</div>
<div class="mask-title">
<h3 @click='typ=0' :class="{mk_a:typ===0}">手机快速登录</h3>
<h3 @click='typ=1' :class="{mk_a:typ===1}">账号密码登录</h3>
</div>
<!-- 手机快速登录 -->
<div class="mask-meuns font14" v-show="typ==0">
<p class="ks_tels fe_tel">
<img class="tel_icon tel" src="../static/img/home/tel.png" alt="">
<input class="inp_tel" v-model="phone" @blur="get_phone" type="text" maxlength="11" placeholder="请输入手机号" />
</p>
<p class="p_inp">
<input class="inp_getS" v-model="yzm" type="text" maxlength="4" placeholder="请输入验证码" /><span class="yz" @click="send_yzm" :class="{actives_color:color==1}">{{ yzm_interval }}</span> </p>
<button class="font16 sign" @click="phone_login">登录</button>
</div>
<!-- 账号密码登录 -->
<div class="mask-meuns" v-show="typ==1">
<p class="ks_tels">
<img class="tel_icon icon" src="../static/img/home/pep.png" alt="">
<input class="inp_tel" v-model="username" type="text" placeholder="请输入账号">
</p>
<p class="ks_tels">
<img class="tel_icon icon" src="../static/img/home/mn.png" alt="">
<input v-model="passwords" @input='is_icon=false' @blur="is_icon=true" class="inp_tel inp_pass" type="password" placeholder="请输入密码">
<img v-show="is_icon==true" class="icon_jp" src="../static/img/home/jp.png" alt="">
</p>
<button class="font16 sign" @click="pwd_login">登录</button>
</div>
<p class="font14 goreg" @click="goto_regist">还没有账号?<span class="mf_reg">免费注册</span></p>
</div>
<!-- 注册账号 -->
<div class="mask_content" v-show="type_d=='register'">
<p class="mask_gb" @click="cloces"><img src="../static/img/home/gw_icon.png" alt=""></p>
<div class="mas_title">
<h3>注册</h3>
<img src="../static/img/home/logo.png" alt="">
</div>
<div class="reg_title">
<h3 class="font20">快速注册</h3>
<div class="mask-top-link"></div>
</div>
<form class="mask-meuns reg_ma font14">
<p class="ks_tels">
<img class="tel_icon tel" src="../static/img/home/tel.png" alt="">
<input v-model="mobile" @blur="check_mobile" maxlength="11" class="inp_tel" type="text" placeholder="+86 手机号"/>
</p>
<p class="p_inp">
<input class="inp_getS" v-model="sms" type="text" placeholder="手机验证码" /><span class="yz reg_yz" @click="send_sms" :class="{actives_color:color==1}">{{sms_interval}}</span>
</p>
<p class="ks_tels">
<img class="tel_icon icon" src="../static/img/home/mn.png" alt=""><input v-model="password" class="inp_tel inp_pass" type="password" placeholder="设置密码"><img class="icon_jp" src="../static/img/home/jp.png" alt="">
</p>
<form class="font14 regulations">
<input class="inp_check" type="checkbox" v-model="checked_zc"><span>我已阅读并接受<b class="clause" @click="is_kxy=true">《人民中国日语教育注册条款》</b></span>
<p class="font16 sign reg_zc" @click="register">注册</p>
</form>
</form>
<p class="font14 reg_sign" @click="goto_sign">已有账号?<span class="mf_reg">立即登录</span></p>
</div>
</div>
data() {
return {
is_kxy:false,
jp_icon:false,
activeIndex: '1',
flag: false,
type_d: 'sign',
mk_a: 0,
typ: 0,
checked: true,
xisign: 0,
mo_isflag:false,
// headList:[],
mobile:'',
sms:'',
password:'',
sms_interval: '获取验证码',
is_send: false,
phone:'',
passwords:'',
username: '',
yzm: '',
login_method: 'is_pwd',
yzm_interval: '获取验证码',
is_yzm: false,
color:0,
checked_zc:false,
xiey:'',
} },
methods: {
handleSelect(key, keyPath) {},
init(){
return get('api/Common/getHeader')
.then((res) => {
if(res.code==1){
// this.headList = res.data.menu;
this.siteObj = res.data.site;
this.titl_first = res.data.menu.slice(0,3);
this.titl_two = res.data.menu.slice(3,7);
this.titl_three = res.data.menu.slice(7);
} })
},
//协议
xiy(){
return get('api/About/privacy').then(res=>{
if(res.data){
this.xiey = res.data.pageInfo
}
})
},
//去搜索页面
go_searchPage(){
if(this.search){
this.$router.push({
name:'search',
})
sessionStorage.setItem('search_meun',this.search)
this.search =''
}else{
this.$message({
message: '请输入搜索关键字',
type: 'error',
});
} },
check_mobile() {
if (!this.mobile) return;
if (!this.mobile.match(/^1[3-9][0-9]{9}$/)) {
this.$message({
message: '手机号有误',
type: 'error',
duration: 1000,
onClose: () => {
this.mobile = '';
}
});
return false;
}
this.is_send = true;
},
//注册
register() {
if(!(this.mobile &&this.sms && this.password )){
this.$message({
message: '手机号,验证码,密码不能为空',
type: 'error',
})
return
}
if(!this.checked_zc){
this.$message({
message: '请阅读并勾选隐私协议!',
type: 'error',
})
return
}
this.is_reg() },
is_reg(){
return post('api/User/register',{
mobile: this.mobile,
code: this.sms,
password: this.password
}).then(res => {
if (res.code==1) {
this.$message({
message: '注册成功',
type: 'success',
})
//关掉注册框
this.flag= false;
this.xisign= 1;
localStorage.setItem('token',res.data.userinfo.token)
this.$router.push({
name:'index'
})
} else {
this.$message({
message: '注册失败,请稍后再试',
type: 'error',
})
}
})
},
send_sms() {
if (!this.is_send) return;
this.is_send = false;
let sms_interval_time = 60;
this.color =1
this.sms_interval = "发送中...";
let timer = setInterval(() => {
if (sms_interval_time <= 1) {
clearInterval(timer);
this.color =1
this.sms_interval = "获取验证码";
this.is_send = false; // 重新恢复点击发送功能的条件
} else {
sms_interval_time -= 1;
this.color =0;
this.sms_interval = `${sms_interval_time}秒后再发`;
this.is_send = false;
}
}, 1000); return post('api/Sms/send', {mobile:this.mobile,event:'register'}).then(res=> {
if (res.code==1) {
this.$message({
message: res.msg,
type: 'success',
})
}else{
this.$message({
message: res.msg,
type: 'error',
})
}
})
},
//登录 密码登录方法
pwd_login() {
if (!(this.username && this.passwords)) {
//用户名或密文为空
this.$message({
message: '用户名或密码不能为空',
type: 'warning'
}); } else {
//发送axios请求
return post('api/User/login', {
account: this.username,
password: this.passwords
}).then(res => {
if (res.code==1) {
//登录成功
this.$message({
message: res.msg,
type: 'success'
});
localStorage.setItem('token',res.data.userinfo.token);
//2 销毁框
this.flag = false;
this.xisign =1
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
this.username =""
this.passwords =""
})
}
},
//手机号登录
phone_login() {
if (!(this.phone && this.yzm)) {
//用户名或密文为空
this.$message({
message: '手机号或验证码不能为空',
type: 'warning'
}); } else {
//发送axios请求
return post('api/user/mobileLogin', {
mobile: this.phone,
captcha: this.yzm
}).then(res => {
if (res.code==1) {
//登录成功
this.$message({
message: res.msg,
type: 'success'
});
localStorage.setItem('token',res.data.userinfo.token);
this.flag = false;
this.xisign =1
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
} },
//退出登录
out_login(){
return get('api/User/logout').then(res=>{
// if(res.code==10401){
// localStorage.removeItem("token");
// this.xisign = 0;
// }
if(res.code==1){
this.$message({
message: res.msg,
type: 'success'
});
localStorage.removeItem("token");
this.xisign = 0;
}else{
if(res.code==10401){
localStorage.removeItem("token");
this.xisign = 0;
}else{
this.$message({
message: res.msg,
type: 'error'
}); }
} })
},
get_phone() {
if (!this.phone) return; //如果手机号没填,这个方法结束了
//js的正则 字符串.match('/正则表达式/')
if (!this.phone.match(/^1[3-9][0-9]{9}$/)) {
this.$message({
message: '手机号有误',
type: 'warning',
duration: 1000, //message的显示时间
onClose: () => {
this.phone = ''; //把手机号清空
},
});
return false;
}
this.is_yzm = true;
},
send_yzm() {
if (!this.is_yzm) return;
this.color=1;
this.is_yzm = false;
let yzm_interval_time = 60;
this.yzm_interval = "发送中...";
let timer = setInterval(() => {
if (yzm_interval_time <= 1) {
clearInterval(timer);
this.yzm_interval = "获取验证码";
this.is_yzm = true; // 重新回复点击发送功能的条件
} else {
yzm_interval_time -= 1;
this.yzm_interval = `${yzm_interval_time}秒后再发`;
}
}, 1000);
//向后端发送短信接口发请求,给这个手机号发短信
return post('/api/Sms/send',{mobile:this.phone,event:'mobilelogin'}).then(res => {
if (res) {
this.$message({
message: '短信发送成功',
type: 'success',
})
} else {
this.$message({
message: '短信发送失败,请稍后再试。。。',
type: 'error',
})
}
})
},
mo_flag(){
var that = this;
that.mo_isflag = !that.mo_isflag;
},
close_mo_isflag(){
var that = this;
that.mo_isflag = !that.mo_isflag;
},
//登录
go_sign(){
var that = this;
that.flag = true;
that.type_d = 'sign';
},
go_register(){
var that = this;
that.flag = !that.flag;
that.type_d = 'register'
},
//关闭弹窗
cloces(){
var that = this;
that.flag = false;
},
//去注册页面
goto_regist(){
var that = this;
that.flag = true;
that.type_d = 'register'
},
//去登录页面
goto_sign(){
var that = this;
that.flag = true;
that.type_d = 'sign'
}, flag_tel(){
this.isShows = true
},
no_flag_tel(){
this.isShows = false
},
flag_wechat(){
this.isFlag = true
},
no_flag_wechat(){
this.isFlag = false
}
}

参考文档:https://blog.csdn.net/weixin_44621343/article/details/116870284

nuxt.js中登录、注册(密码登录和手机验证码登录)的更多相关文章

  1. Spring Security 实现手机验证码登录

    思路:参考用户名密码登录过滤器链,重写认证和授权 示例如下(该篇示例以精简为主,演示主要实现功能,全面完整版会在以后的博文中发出): 由于涉及内容较多,建议先复制到本地工程中,然后在细细研究. 1. ...

  2. RabbitMQ+Redis模拟手机验证码登录

    RabbitMQ+Redis模拟手机验证码登录 依赖 <dependency> <groupId>org.springframework.boot</groupId> ...

  3. shiro整合shiro多验证登录(账号密码登录和使用手机验证码登录)

    1. 首先新建一个shiroConfig  shiro的配置类,代码如下: @Configuration是标识这个类是一个配置文件,在启动时会加载这个类里面的内容,这个配置文件的位置的一定一定一定不能 ...

  4. js中一次性注册多个事件

    在js中,如果想一次性给一个控件或者标签初测多个事件的方法: 假如有个<input>标签: <input id=”inputValue” value=”www.baidu.com”/ ...

  5. Nuxt.js中scss公用文件(不使用官方插件style-resources)

    项目多多少少应该都遇到有公用文件这种情况,比如说偶尔某一天产品来找你,能不能明天把网站的这个颜色给我改下?第二天再来给我换回来? 如果再css2.x时代,不使用css预处理技术,这一改只能“查找替换” ...

  6. nuxt.js中引入lib-flexible 和 postcss-px2rem 实现pc自适应

    最近一个需要用nuxt框架实现的pc自适应项目,从网上找了很多资料,最终完美实现 一.下载相关插件 npm i lib-flexible -Snpm i px2rem-loader -Dnpm ins ...

  7. js中的 Date对象 在 IOS 手机中的兼容性问题

    项目中有个时间相关的需求,很自然的用到了 js 中的 new Date() 获取时间,浏览器使用模拟手机模式访问没有问题,但是真机测试时发现,ios系统的手机无法显示时间. 定位问题发现是 new D ...

  8. JS中调用android和ios系统手机打开相机并可选择相册功能

    编写不易,如有转载,请声明出处: 梦回河口:http://blog.csdn.net/zxc514257857/article/details/57626154 实现android手机打开相机选择相册 ...

  9. 表单注册及自定义validate手机验证码验证实例

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

随机推荐

  1. Android 使用压缩纹理

    本文介绍了什么是压缩纹理,以及加载压缩纹理的核心步骤.并在 Android OpenGLES 平台上实现了压缩纹理的显示. 一.压缩纹理概念 传统的图片文件格式有 PNG . JPEG 等,这种类型的 ...

  2. python流程控制下-for、while循环补充

    循环结构之for循环 实现循环结构还可以用关键字for. for关键字 我们来看这一段代码: emotions = ['smile', 'laugh', 'cry', 'angry'] for emo ...

  3. 追求性能极致:Redis6.0的多线程模型

    Redis系列1:深刻理解高性能Redis的本质 Redis系列2:数据持久化提高可用性 Redis系列3:高可用之主从架构 Redis系列4:高可用之Sentinel(哨兵模式) Redis系列5: ...

  4. 一次 Redis 事务使用不当引发的生产事故

    这是悟空的第 170 篇原创文章 官网:http://www.passjava.cn 你好,我是悟空. 本文主要内容如下: 一.前言 最近项目的生产环境遇到一个奇怪的问题: 现象:每天早上客服人员在后 ...

  5. while循环条件不成立却无法跳出死循环的问题

    在进入循环的时候,实际上是将A从内存加载到寄存器里面运行的,在整个循环中,A这个变量都只是在读取寄存器里面的值. 而当进入中断的时候,中断里面会从内存加载A到寄存器,修改完之后又存到内存里,然后退出中 ...

  6. JAVA语言学习-面向对象(1)

    类与对象 类 类是JAVA语言中重要的复合型数据类型().类的实现包括两个部分:成员变量和成员方法("方法"可以看作是C语言中的函数) 类的声明 要使用类,首先得对其声明.声明一个 ...

  7. day11-Servlet01

    Servlet01 官方api文档:https://tomcat.apache.org/tomcat-8.0-doc/servletapi/index.html Servlet和Tomcat的关系:一 ...

  8. TKK: 更新 TKK 失败,请检查网络连接 idea翻译错误-IDEA翻译失败-Translation用不了

    IDEA 提示:更新 TKK 失败,请检查网络连接 解决方法: 1.进入 C:\Windows\System32\drivers\etc 找到 hosts文件修改 注意:如果用记事本打开不能修改,则修 ...

  9. 【云原生 · Kubernetes】Kubernetes简介及基本组件

    1.Kubernetes简介 Kubernetes是Google开源的容器集群管理系统,其提供应用部署.维护. 扩展机制等功能,如图1.3所示.利用Kubernetes能方便地管理跨机器运行容器化的应 ...

  10. Redis 常见问题

    Redis 常见问题 落叶他乡树,寒灯独夜人. 一. 什么是Redis? Redis 是一个使用 C 语言写成的,开源的高性能key-value非关系缓存数据库: Redis的数据都基于缓存的,所以很 ...