mirror of
https://github.com/RemainderTime/spring-boot-base-demo.git
synced 2026-05-31 06:57:48 +08:00
实现简单登录成功页面并传递token
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
|
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
|
||||||
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
|
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
|
||||||
<!-- 引入样式 -->
|
<!-- 引入样式 -->
|
||||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
<script src="https://cdn.bootcdn.net/ajax/libs/jsencrypt/3.2.1/jsencrypt.min.js"></script>
|
<script src="https://cdn.bootcdn.net/ajax/libs/jsencrypt/3.2.1/jsencrypt.min.js"></script>
|
||||||
<!--http 请求插件-->
|
<!--http 请求插件-->
|
||||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
|
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
|
||||||
|
<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/4.1.0-beta.2/vue-router.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<div id="app">
|
<div id="app">
|
||||||
@@ -53,13 +55,17 @@
|
|||||||
var json = JSON.stringify(data);
|
var json = JSON.stringify(data);
|
||||||
var cipher = this.encryptByPublicKey(json);
|
var cipher = this.encryptByPublicKey(json);
|
||||||
console.log("密文 :" + cipher);
|
console.log("密文 :" + cipher);
|
||||||
|
|
||||||
var url = "http://localhost:8088/user/login";
|
var url = "http://localhost:8088/user/login";
|
||||||
axios.post(url, {
|
axios.post(url, {
|
||||||
encryptedData: cipher,
|
encryptedData: cipher,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(response);
|
var data = response.data;
|
||||||
|
if (data.code == 200) {
|
||||||
|
window.location.href = "success.html?token=" + data.data.token
|
||||||
|
} else {
|
||||||
|
alert(data.message)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
40
src/main/resources/templates/success.html
Normal file
40
src/main/resources/templates/success.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
|
||||||
|
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
|
||||||
|
<title>登录成功</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<h1>这是登录成功页面</h1>
|
||||||
|
<h1>
|
||||||
|
token:
|
||||||
|
<span style="color: forestgreen">{{token}}</span>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: '#app',
|
||||||
|
data: {
|
||||||
|
token: ''
|
||||||
|
},
|
||||||
|
mounted: function () {
|
||||||
|
this.token = this.getData("token");
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getData: function (name) {
|
||||||
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
||||||
|
var r = window.location.search.substr(1).match(reg); //匹配目标参数
|
||||||
|
if (r != null) return unescape(r[2]);
|
||||||
|
return null; //返回参数值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
;
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user