提交 e427371e 编写于 作者: 爱吃血肠's avatar 爱吃血肠

提交上次代码

上级 390065f2
......@@ -72,4 +72,10 @@ public interface UserService {
* return 当前用户
*/
public User checkUserLogin(User user);
/**
* 处理用户注册
* @param user
*/
public void userRegister(User user);
}
\ No newline at end of file
......@@ -81,6 +81,15 @@ public class UserServiceImpl implements UserService {
}
/**
* 处理用户注册
* @param user
*/
@Override
public void userRegister(User user) {
}
public UserDao getTUserDao() {
return this.userDao;
}
......
package com.yingjun.ssm.util;
/**
* 生成6位随机验证码
* @author liyunfeng
*/
public class CodeUtil {
public static Integer getRandNum(int min, int max) {
Integer randNum = min + (int)(Math.random() * ((max - min) + 1));
return randNum;
}
public static String rand(){
return getRandNum(100000,999999).toString().trim();
}
public static void main(String[]args){
rand();
}
}
......@@ -6,7 +6,9 @@ import com.yingjun.ssm.entity.User;
import com.yingjun.ssm.enums.ResultEnum;
import com.yingjun.ssm.exception.BizException;
import com.yingjun.ssm.service.UserService;
import com.yingjun.ssm.util.CodeUtil;
import com.yingjun.ssm.util.LoginContext;
import com.yingjun.ssm.util.MailUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -63,6 +65,40 @@ public class UserController {
LOG.info("用户注册");
return "/user/userResgiter";
}
/**
* 处理用户注册
* @return
*/
@ResponseBody
@RequestMapping(value = "/register",produces = {"application/json;charset=UTF-8"})
public BaseResult<Object> register(User user) {
try {
userService.userRegister(user);
} catch (BizException e) {
return new BaseResult<>(false, e.getMessage());
} catch (Exception e) {
return new BaseResult<>(false, ResultEnum.INVALID_USER.getMsg());
}
return new BaseResult<>(true, "登陆成功");
}
/**
* 用户注册时获取邮箱验证码
* @return
*/
@ResponseBody
@RequestMapping(value = "/getEmailCode",produces = {"application/json;charset=UTF-8"})
public BaseResult<Object> getEmailCode(@RequestParam String email,HttpSession session) {
try {
String code = CodeUtil.rand();
MailUtil.sendMail(email,code);
session.setAttribute("code",code);
} catch (BizException e) {
return new BaseResult<>(false, e.getMessage());
} catch (Exception e) {
return new BaseResult<>(false, ResultEnum.INVALID_USER.getMsg());
}
return new BaseResult<>(true, "登陆成功");
}
/**
* 用户登录成功到达首页
* @return
......
......@@ -20,7 +20,7 @@
<!--首页头部-->
<header>
<div class="header-content">
<div class="logo"><span class="logo-img">京东益世集群注册平台</span></div>
<div class="logo"><span class="logo-img">集群注册平台</span></div>
<div class="header-menu">
<ul>
<li class="active"><a href="/user/home">首页</a></li>
......
......@@ -51,7 +51,7 @@
</li>
</ul>
<div class="forgatPwd">
<a href="userResgiter.jsp">新用户注册</a>
<a href="/user/userRegister">新用户注册</a>
<a href="findPwd.html">忘记密码</a>
</div>
<div id="loginBtn" class="myBtn mar-t-30" style="">
......
......@@ -27,7 +27,7 @@
<li><a href="registration.html">工商注册</a></li>
<li class="active"><a href="#">个人中心</a></li>
<li><a href="enterprise.html">企业中心</a></li>
<li><a href="/contactUs/connection">联系我们</a></li>
<li><a href="#">技术支持</a></li>
</ul>
</div>
</div>
......@@ -35,12 +35,13 @@
<div class="enter-content">
<h3 class="tit">用户注册信息</h3>
<form id="register" name="register" action="userLogin.jsp" method="post">
<div class="findPwd">
<div class="contentInfo">
<ul class="getInfo margin-t-49 margin-l-40">
<li class="margin-b-19">
<label class="infoName1 inputDes" for="tel">登录手机号</label>
<input class="info write-n" type="text" name="tel" id="tel" value="139****2345" placeholder="请输入登录手机号码"/>
<label class="infoName1 inputDes" for="email">登录邮箱</label>
<input class="info write-n" type="text" name="email" id="email" value="" placeholder="请输入登录邮箱"/>
</li>
<li class="margin-b-19">
<label class="infoName1 inputDes" for="code">验证码:</label>
......@@ -49,7 +50,7 @@
</li>
<li class="margin-b-19">
<label class="infoName1 inputDes" for="newPwd">设置登录密码:</label>
<input class="info write-n" type="text" name="newPwd" id="newPwd" value="" placeholder="请设置密码"/>
<input class="info write-n" type="text" name="password" id="newPwd" value="" placeholder="请设置密码"/>
</li>
<li class="margin-b-19">
<label class="infoName1 inputDes" for="pwd-a">再次输入密码:</label>
......@@ -61,6 +62,7 @@
</div>
</div>
</div>
</form>
</div>
<footer>
......
......@@ -8,11 +8,11 @@ $(function(){
$this.next().remove();
$this.removeClass('noPass')
}
$this.after('<span class="passImg"><img src="img/pass.png"/></span>')
$this.after('<span class="passImg"><img src="/resource/img/pass.png"/></span>')
} else{
$this.next().remove();
$this.addClass('noPass')
$this.after('<span class="noPassImg-bounce"><img src="img/refuse.png"/>不能为空</span>')
$this.after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>不能为空</span>')
}
})
$("#code").blur(function(){
......@@ -24,13 +24,13 @@ $(function(){
$this.next().remove();
$this.removeClass('noPass')
}
$this.after('<span class="passImg"><img src="img/pass.png"/></span>')
$this.after('<span class="passImg"><img src="/resource/img/pass.png"/></span>')
} else{
$('.noPassImg-bounce').remove();
$('.passImg').remove();
$("#getCode").css({'margin-left':'35px'})
$this.addClass('noPass')
$this.after('<span class="noPassImg-bounce"><img src="img/refuse.png"/></span>')
$this.after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/></span>')
}
})
})
......@@ -42,31 +42,64 @@ function addReceive(){
function closeBounce(){
$(".bounces").addClass('hide');
}
function settime(val) {
// 获取验证码
function settime(val) {
var $val = $(val);
if (countdown == 0) {
if (countdown == 60){
//异步发送验证码
$.ajax({
type: 'POST',
data: $('#register').serialize(),
dataType: "json",
url: '/user/getEmailCode',
success: function (data) {
if (data.success) {
} else {
}
}
});
}
if (countdown == 0) {
$('#getCode').removeClass('countBtn');
$('#getCode').addClass('bounceBtn');
val.removeAttribute("disabled");
val.removeAttribute("disabled");
$val.children().html("获取验证码")
countdown = 60;
} else {
countdown = 60;
} else {
$('#getCode').removeClass('bounceBtn');
$('#getCode').addClass('countBtn');
val.setAttribute("disabled", true);
val.setAttribute("disabled", true);
$val.children().html("重新发送" + countdown + "s")
countdown--;
setTimeout(function() {
settime(val)
},1000)
}
}
countdown--;
setTimeout(function() {
settime(val)
},1000)
}
}
function sure(){
var $newPwd = $("#newPwd").val();
var $pwda = $("#pwd-a").val();
if($pwda != $newPwd) {
$("#pwd-a").next().remove();
$("#pwd-a").addClass('noPass')
$("#pwd-a").after('<span class="noPassImg-bounce"><img src="img/refuse.png"/>输入不一致</span>')
$("#pwd-a").after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>输入不一致</span>')
return;
}
$.ajax({
type: 'POST',
data: $('#register').serialize(),
dataType: "json",
url: '/user/register',
success: function (data) {
if (data.success) {
} else {
}
}
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册