<!-- 登录弹框 -->
<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. 矩阵顺时针打印(C++)(? 为什么不能AC,9度1391)

    #include <iostream> #include <fstream> using namespace std; int a[1000][1000]; void prin ...

  2. oneplus8手机蓝牙连接tws耳机无法双击退出语音助手

    通过蓝牙协议栈我们知道,蓝牙耳机可以通过发送AT指令唤醒或者退出语音助手 唤醒语音助手: AT+BVRA=1 退出语音助手: AT+BVRA=0 但是实际操作中发现双击可以唤醒但再次双击却无法退出语音 ...

  3. Vue实现长按图片识别图中二维码

    Vue实现长按图片识别图中二维码 思路:要想实现可以识别图片中的二维码,那必定是要将这张图进行上传操作,上传则需要file对象格式.不管是在H5还是APP中,展示的图片都是通过url的方式展示在img ...

  4. 2022-08-12-esp32把玩记-②_用Micropython点ssd1306_oled屏幕

    layout: post cid: 8 title: esp32把玩记-② 用Micropython点ssd1306 oled屏幕 slug: 8 date: 2022/08/12 15:12:39 ...

  5. 简单将Springboot项目部署到linux服务器上

    1.使用springboot的jar包方式 直接使用maven工具按照步骤点击就可以直接打包 2.到target目录下找到 jar包 3.将jar包放到linux的任意文件夹下(此项目是之前的kafk ...

  6. 创建Vue工程常用的命令

    创建一个vue项目的步骤 1.创建一个名称为myapp的工程 vue init webpack myapp 2.进入工程目录 cd myapp 3.安装 vue-router npm install ...

  7. 知识图谱-生物信息学-医学顶刊论文(Bioinformatics-2021)-KG4SL:用于人类癌症综合致死率预测的知识图神经网络

    5.(2021.7.12)Bioinformatics-KG4SL:用于人类癌症综合致死率预测的知识图神经网络 论文标题:KG4SL: knowledge graph neural network f ...

  8. 二十六、StatefulSet资源控制器

    StatefulSet资源控制器 一.statefulset介绍 StatefulSet 是为了解决有状态服务的问题而设计的资源控制器. 匹配 Pod name ( 网络标识 ) 的模式为:(stat ...

  9. flutter 系列之:flutter 中的幽灵offstage

    目录 简介 Offstage详解 Offstage的使用 总结 简介 我们在使用flutter的过程中,有时候需要控制某些组件是否展示,一种方法是将这个组件从render tree中删除,这样这个组件 ...

  10. 1分钟完成在线测试部署便捷收集班级同学文件的web管理系统

    最近CSDN推出了一个新功能[云IDE],个人对这个新功能(比赛奖金 )挺感兴趣的,于是瞬速地拿之前自己搞的一个便捷收集班级同学文件的web管理系统(下面简称该项目为cfile)体验了一下,发现功能还 ...