<!-- 登录弹框 -->
<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. MySQL数据库-数据表(上)

    数据表的基本操作. MySQL 数据库支持多种数据类型,大致可以分为 3 类:数值类型.日期和时间类型.字符串(字符)类型. (1)数值类型 数值类型用于存储数字型数据,这些类型包括整数类型(TINY ...

  2. Asp-Net-Core开发笔记:集成Hangfire实现异步任务队列和定时任务

    前言 最近把Python写的数据采集平台往.Net Core上迁移,原本的采集任务使用多进程+线程池的方式来加快采集速度,使用Celery作为异步任务队列兼具定时任务功能,这套东西用着还行,但反正就折 ...

  3. TF-GNN踩坑记录(一)

    引言 Batch size作为一个在训练中经常被使用的参数,在图神经网络的训练中也是必不可少,但是在TF-GNN中要求使用 merge_batch_to_components() 把batch之后的图 ...

  4. python 运行错误收集

    目录 global全局声明错误 global全局声明错误 SyntaxError: name 'is_login' is used prior to global declaration 解决办法:g ...

  5. 记一个深层的bug

    1. 业务场景 产品需要每隔几天进行一次组件的更新,在自动化测试中,每隔30s检测一次更新源上的某个文件MD5值是否与本地一致,不一致代表有更新的版本,开始更新. 2. 问题出现 一个再平常不过的繁忙 ...

  6. 齐博x1小程序集群必须带上固定的标志

    小程序集群的也类似登录接口一样,需要带上特殊的标志.建议是在所有请求的头部header 加上 wxappid 如下图所示,跟登录标志 token 并列在一起. 如果不方便修改头部header 请求的时 ...

  7. 使用NEON指令加速RGB888和RGB565的相互转换

    最近在做一个项目需要将RGB888转换为RGB565,用C语言转换的代码很简单,这是从ffmpeg中摘抄的代码 static inline void rgb24to16_c(const uint8_t ...

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

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

  9. F118校准(二)-- 操作步骤(使用任意品牌PG点屏,并使用PX01 PG校准F118)

    1. 准备工作 硬件连接: CA310通过USB线材连接PC PX01通过USB线材连接PC F118通过灰排线连接PX01左上角的GPIO扩展口(如下图所示) 启动LcdTools软件,点击&quo ...

  10. web安全学习(sql注入1)

    web安全学习(sql注入1) 一.简介 sql语句就是数据库语句,而sql注入就是用户将自己构造的恶意sql语句提交,然后服务器执行提交的危险语句.sql注入可能造成信息泄露以及服务器被控制等危害. ...