vue配合cookie进行登录记住密码以及请求验证 以及记住密码功能
使用cookie时先在项目中导入vue-cookie包
npm install vue-cookies --save
在main.js中引入
import Vue from ‘vue’
import VueCookies from ‘vue-cookies’
Vue.use(VueCookies)
<template>
<div class="main" v-loading="loading">
<div class="login_body">
<el-form ref="form" label-width="80px">
<el-form-item label="用户名:">
<el-input v-model="form.username"></el-input>
</el-form-item>
<el-form-item label="密码:">
<el-input type="password" v-model="form.password"></el-input>
</el-form-item>
<el-form-item>
<el-checkbox v-model="rememberMe">记住我</el-checkbox>
</el-form-item>
<el-button type="primary" @click="btnLogin" @keyup.enter.native="btnLogin">Login</el-button>
</el-form>
</div>
</div>
</template>
<script>
import { reqInfo } from "../Api";
import { mapState } from "vuex";
export default {
name: "login",
data() {
return {
form: {
grant_type: "password",
scope: "SJZN",
username: "",
password: "",
client_id: "SJZN_App",
client_secret: "1q2w3e*",
},
rememberMe: false,
loading: false,
};
},
mounted() {
this.getCookie();
},
methods: {
btnLogin() {
//QS使用的目的
//正常用Json方式提交
//将对象序列化A=1&b=2&c=3这种方式提交
let result1;
var qs = require("qs");
this.loading = true;
this.$axios
.post("/connect/token", qs.stringify(this.form), {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
})
.then((response) => {
console.log(response.status);
if (response.status == 200) {
this.$axios
.get("/api/abp/application-configuration")
.then((res) => {
var result = res.data.currentUser;
console.log(result);
});
result1 = reqInfo();
console.log(result1);
this.$router.push("/robotSurveillance");
this.loading = false;
} else if (response.status == 400) {
console.log("登陆失败");
}
sessionStorage.setItem("access_token", response.data.access_token); //保存为本次会话
// this.$router.push('/') 跳转
if (this.rememberMe == true) {
const self = this;
self.setCookie(self.form.username, self.form.password, 7);
//如果记住我打钩将token保存在本地
localStorage.setItem("access_token", response.data.access_token); //永久保存,直到浏览器清除缓存
} else {
self.clearCookie(); //如果没有选中记住密码,那就清除cookie
}
})
.catch((error) => {
console.log(error.response);
});
},
setCookie(c_name, c_pwd, exdays) {
var exdate = new Date(); //获取时间
exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); //保存的天数
//字符串拼接cookie
window.document.cookie =
"userName" + "=" + c_name + ";path=/;expires=" + exdate.toGMTString();
window.document.cookie =
"userPwd" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();
},
//读取cookie
getCookie: function () {
if (document.cookie.length > 0) {
var arr = document.cookie.split("; "); //这里显示的格式需要切割一下自己可输出看下
for (var i = 0; i < arr.length; i++) {
var arr2 = arr[i].split("="); //再次切割
//判断查找相对应的值
if (arr2[0] == "userName") {
this.form.username = arr2[1]; //保存到保存数据的地方
} else if (arr2[0] == "userPwd") {
this.form.password = arr2[1];
}
}
}
},
//清除cookie
clearCookie: function () {
this.setCookie("", "", -1); //修改2值都为空,天数为负1天就好了
},
},
};
</script>
<style scoped>
.main {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: url("../assets/image/bg2.jpg") no-repeat;
background-size: 100% auto;
}
.container {
width: 100%;
height: 100%;
min-width: 1280px;
background-size: 100% 100%;
background: url("../assets/image/bg1.jpg");
position: relative;
}
.m-t-50 {
margin-top: 0;
}
.login {
width: 300px;
height: 400px;
background-color: #fff;
position: absolute;
}
.loginBtn {
margin-top: 15px;
background-color: #2f41e7;
}
footer {
width: 1280px;
display: flex;
justify-content: space-around;
position: fixed;
bottom: 16px;
left: 50%;
transform: translate(-50%);
color: #fff;
font-size: 12px;
}
.form {
position: relative;
}
.code {
position: absolute;
right: 0;
top: 0;
width: 110px;
height: 42px;
}
.input {
width: 100%;
}
.login_body {
width: 300px;
height: 300px;
}
.bottom {
position: relative;
}
.login_body .el-checkbox {
position: absolute;
right: 10px;
top: 35px;
}
</style>
1、TCP的三次握手(建立连接)和四次挥手(关闭连接)建立连接: 理解:窗口和滑动窗口TCP的流量控制TCP使用窗口机制进行流量控制什么是窗口?连接建立时,各端分配一块缓冲区用来存储接收的数据,并将缓冲区的尺寸发送给另一端接收方发送的确认信息中包含了自己剩余的缓冲区尺寸剩余缓冲区空间的数量叫做窗口2. TCP的流控过程(滑动窗口)
题目链接:A. Sereja and Swaps题意:给定一个序列,可以交换k次,问交换完后的子序列最大值的最大值是多少思路:暴力枚举每一个区间,然后每个区间[l,r]之内的值先存在优先队列内,然后找区间外如果有更大的值就替换掉。求出每个区间的最大值,最后记录下所有区间的最大值代码:By lab104_yifan, contest: Codeforces Round #243 (D
我们在实际应用开发时,需整合各个模块的代码,使其粘合在一起,而Java就是最好的粘合工具,此篇文章中,介绍了SparkMLlib的决策树,使用java开发做分类。
软件著作权申请流程详解
1 RocketMQ简介与安装、RocketMQ简介Apache RocketMQ是一个采用Java语言开发的分布式的消息系统,由阿里巴巴团队开发,与2016年底贡献给Apache,成为了Apache的一个顶级项目。在阿里内部,RocketMQ 很好地服务了 集 团大大小小上千个应用,在每年的双十一当天,更有不可思议的万亿级消息通过 RocketMQ 流转(在 2017 年的双十一当天,整个阿里巴巴集团通过 RocketMQ 流转的线上消息达到了 万亿级,峰值 TPS 达到 5600 万),在阿
简单的数据预处理到时间序列分析spss数据预处理到时间序列分析(二)产生设定新变量及画散点图相关操作时隔这么久,终于又和大家见面了,在数据导入spss以后就可以快乐的开始了,(~ ̄▽ ̄)~那么下面直入正题!既然是时间序列,字符串的时间日期数据分析就显得非常重要了。通常,字符串的时间日期数据无法用于分析,就需要生成符合时间规律的数值型时间日期数据,操作步骤看下面几张图!!!点击数据,找到‘定义日期和时间’由于我们是销售规模数据随年份和季度变化,所以选‘年,季度’,并输入第一个个案信息,即第一行
1. 修改类函数。场景: 如果要给一个类的所有方法加上计时,并打印出来。demo如下:# -*- coding:utf-8 -*-import timedef time_it(fn):"Example of a method decorator"def decorator(*args, **kwargs):t1=time.time()ret = fn(*args, **kwargs)print '...
1.前期准备在使用云开发之前需要先在app.js中初始化云开发的配置,上一篇文章已经提到。连接:https://blog.csdn.net/beekim/article/details/120977861在云开发的数据库中新建一个集合app.json中配置一个新的页面,并设置入口页面,方便调试微信官方文档中关于button关于form代码:<!--pages/datatest/datatest.wxml--><text>数据库crud测试:</text
今天工作中遇到一个问题,有一些Map < String, Object >类型的数据我需要放到redis中,但是从redis中取出来的又是String类型 需要转Map。想了想 只记得 Map.toString()这样可以将Map转换到String。不记得怎么String转map也试了试Map自带的方法中好像也没有 String 转 Map的就在网上找了个方法: public static Map<String, Object> getValue(String param
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档GraalVM 打包 Java 程序为 exe 可执行程序环境安装配置Visual StudioGraalVMnative-image使用javanative-image总结环境系统: Win10 2004VS: Visual Studio 2019GraalVM: graalvm-ce-java11-windows-amd64-20.2.0.zip安装配置Visual Studio安装 Visual Studio 主要
谈到GIS软件,首先让我们想到的便是GIS界的龙头大哥ESRI公司旗下的ArcGIS产品,从最初接触的version 9.2到如今的version 10.6,其发展可谓风生水起。MapInfo软件也不错,可是给人的感觉是渐渐被淘汰了似的,周围使用该软件的人并不算多。然后接触了一些的是国内的SuperMap软件,MapGIS软件等,很遗憾的是作为武大的学生,竟然没有使用过GeoStar的...
6、通过审查以后领到专利证书天底下并没有免费的午餐,申请专利也是需要资金的投入的,毕竟也需要费人力物力,一起来看看哪些是需要留意的申请费用的缴纳期限是自申请日起算2个月内。2、到所在地的知识产权局国家专利局服务厅提交提交所筹备的资料,当然还能够通过邮寄的方式提交资料,通过邮寄的方式低成本还能够省时间,但是通过邮寄的方式如果资料筹备的不够齐全就较为麻烦。1、首先我们要准备好申请专利所需的资料(1、申请专利请求书,2、申请专利产品的说明书再加上附图,3、如果是外观设计类的要另附清晰的外观六视图。......