1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-01-10 11:48:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

gettop页面实现

This commit is contained in:
程序员小墨 2022-03-01 19:31:34 +08:00
parent f52fa51895
commit 080ca33954
7 changed files with 71 additions and 2 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
target/*
target/*
temp*

View File

@ -0,0 +1,5 @@
# 前端框架模板下载
> https://www.imooc.com/video/18342
>
> 资料下载

54
frontend/getotp.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./static/assets/global/plugins/jquery-1.11.0.min.js" type="text/javascript"></script>
</head>
<body>
<div>
<h3>获取OTP信息</h3>
<div>
<label>手机号</label>
<div>
<input type="text" placeholder="手机号" name="telephone" id="telephone">
</div>
</div>
<div>
<button id="getotp" type="submit">
获取OTP短信
</button>
</div>
</div>
<script>
jQuery(document).ready(function () {
$("#getotp").on("click", function () {
var telephone = $("#telephone").val();
if (telephone == null || telephone == "") {
alert("手机号不能为空");
return false; // 捕获onclick事件不让他传递到上一层
}
$.ajax({
type: "POST",
contentType: "application/x-www-form-urlencoded",
url: "http://localhost:8090/user/getotp",
data: {
"telephone": telephone,
},
success: function (data) {
if (data.status == "success") {
alert("OTP已经发送到了您的手机上请注意查收");
} else {
alert("OTP发送失败原因为" + data.data.errMsg);
}
},
error: function (data) {
alert("OTP发送失败原因为" + data.responseText);
}
})
})
})
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,9 @@ import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
public class BaseController {
public static final String CONTENT_TYPE_FORMED = "application/x-www-form-urlencoded";
// 定义ExceptionHandler解决未被Controller层吸收的Exception
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.OK)

View File

@ -16,6 +16,7 @@ import java.util.Random;
@Controller("user") // 允许被SpringBoot扫描到
@RequestMapping("/user") // 通过 "/user" 访问到
@CrossOrigin // 允许跨域
public class UserController extends BaseController {
@Autowired
@ -25,7 +26,7 @@ public class UserController extends BaseController {
private HttpServletRequest httpServletRequest;
// 用户获取OTP短信接口
@RequestMapping("/getotp")
@RequestMapping(value = "/getotp", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType getOtp(@RequestParam(name = "telephone") String telephone) {
// 需要按照一定的规则生成OTP验证码