Commit a5db0a5a authored by wuwz's avatar wuwz

修改注册

parent 8dd8395e
...@@ -48,10 +48,80 @@ jQuery(document).ready(function(){ ...@@ -48,10 +48,80 @@ jQuery(document).ready(function(){
code:{required:"验证码不能为空",remote:"验证码不正确"} code:{required:"验证码不能为空",remote:"验证码不正确"}
} }
}); });
/*
*倒计时
*/
var countDown = function (start, callback) {
$(".validateCode-btn").html(start + "秒").addClass("stopBtn").removeClass("validateCode-btn");
var t = setInterval(function () {
if (start < 1) {
clearInterval(t);
callback()
}else {
$(".stopBtn").html(start + "秒");
start--;
}
}, 1000);
};
//短信接口请求
$(".validateCode-btn").on("click",function(){
if($("input[name='userName']").val()){
var mobilePhone = $("#phone").val();
jQuery.ajax({
url: "$!webPath/getPhoneCode.htm",
data:{"phone": mobilePhone},
async:false,
type:"POST",
dataType:"json",
success: function(result){
if (result.statusCode == 000000) {
countDown(60, function () {
$(".stopBtn").html("点击获取验证码").addClass("validateCode-btn").removeClass("stopBtn")
})
} else {
alert(result.statusMsg)
}
}
});
}
//
});
$(document).on("click","#password",function(){
checkValidateCode();
});
//验证码验证
function checkValidateCode(){
jude=false
var validateCode = $("#mobileCode").val();
var mobilePhone = $("#phone").val();
jQuery.ajax({
url: "$!webPath/yzPhoneCode.htm",
data:{"phone": mobilePhone,"mobileCode":validateCode},
async:false,
type:"POST",
dataType:"json",
success: function (result) {
if (result.code == 0) {
$(".verification-code-row .error-div").text("");
} else {
$(".verification-code-row .error-div").text("请输入正确的验证码");
}
}
});
}
}); });
function refreshCode(){ function refreshCode(){
jQuery("#code_img").attr("src","$!webPath/verify.htm?d"+new Date().getTime()); jQuery("#code_img").attr("src","$!webPath/verify.htm?d"+new Date().getTime());
} }
</script> </script>
</head> </head>
<body> <body>
...@@ -66,17 +136,17 @@ $!httpInclude.include("/top.htm") ...@@ -66,17 +136,17 @@ $!httpInclude.include("/top.htm")
<h1>忘记密码<span>FIND PASSWORD</span></h1> <h1>忘记密码<span>FIND PASSWORD</span></h1>
<div class="login_user_bottom" style="margin-left:auto; margin-right:auto"> <div class="login_user_bottom" style="margin-left:auto; margin-right:auto">
<div class="login_user_img"></div> <div class="login_user_img"></div>
<form action="$!webPath/find_pws.htm" method="post" id="theForm"> <form action="$!webPath/find_password.htm" method="post" id="theForm">
<table width="360" border="0" cellspacing="0" cellpadding="0" class="login_user_table"> <table width="360" border="0" cellspacing="0" cellpadding="0" class="login_user_table">
<tr> <tr>
<td width="60" class="login_nameu">手机号:</td> <td width="60" class="login_nameu">手机号:</td>
<td><span class="login_user_input input_size"> <td><span class="login_user_input input_size">
<input name="userName" type="text" id="userName" /> <input name="userName" type="text" id="phone" />
</span> </span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="login_nameu">手机验证码:</td> <td class="login_nameu">验证码:</td>
<td><span class="login_user_input input_size2"> <td><span class="login_user_input input_size2">
<input name="mobileCode" type="text" id="mobileCode" style="text-transform:;"/></span> <input name="mobileCode" type="text" id="mobileCode" style="text-transform:;"/></span>
<span class="getcode validateCode-btn">获取验证码</span> <span class="getcode validateCode-btn">获取验证码</span>
...@@ -86,7 +156,7 @@ $!httpInclude.include("/top.htm") ...@@ -86,7 +156,7 @@ $!httpInclude.include("/top.htm")
<tr> <tr>
<td class="login_nameu">新密码:</td> <td class="login_nameu">新密码:</td>
<td><span class="login_user_input input_size"> <td><span class="login_user_input input_size">
<input name="password" type="text" id="password" /> <input name="password" type="password" id="password" />
</span> </span>
</td> </td>
</tr> </tr>
......
...@@ -18,6 +18,25 @@ ...@@ -18,6 +18,25 @@
<script> <script>
jQuery(document).ready(function(){ jQuery(document).ready(function(){
//获取下级地区信息
jQuery("select[id^=areas_]").change(function(){
debugger
var areaMark = jQuery(this).attr("areaMark");
var parent_id = jQuery("#areas_"+areaMark).val();
jQuery.post("$!webPath/buyer/account_getAreaChilds.htm",{
"parent_id":parent_id,
"areaMark":areaMark
},function(data){
if(areaMark=="province"){
jQuery("#area_id").html("<option>请选择...</option>");
jQuery("#areas_city").html(data);
}
if(areaMark=="city"){
jQuery("#area_id").html(data);
}
},"text");
});
// //
jQuery.validator.addMethod("verify",function(value,element){ jQuery.validator.addMethod("verify",function(value,element){
var re = /^[0-9a-zA-Z]*$/; var re = /^[0-9a-zA-Z]*$/;
...@@ -62,7 +81,7 @@ jQuery(document).ready(function(){ ...@@ -62,7 +81,7 @@ jQuery(document).ready(function(){
required:true, required:true,
equalTo:"#password" equalTo:"#password"
}, },
email:{ /* email:{
required:true, required:true,
email:true, email:true,
remote:{ remote:{
...@@ -73,7 +92,7 @@ jQuery(document).ready(function(){ ...@@ -73,7 +92,7 @@ jQuery(document).ready(function(){
"email": function(){return $("#email").val();} "email": function(){return $("#email").val();}
} }
} }
}, }, */
agree:{ agree:{
required:true required:true
} }
...@@ -114,10 +133,10 @@ jQuery(document).ready(function(){ ...@@ -114,10 +133,10 @@ jQuery(document).ready(function(){
required:"重复密码不能为空", required:"重复密码不能为空",
equalTo:"两次输入密码不一致" equalTo:"两次输入密码不一致"
}, },
email:{ /* email:{
required:"email不能为空", required:"email不能为空",
email:"email格式不正确", email:"email格式不正确",
}, }, */
agree:{ agree:{
required:"请接受用户协议" required:"请接受用户协议"
} }
...@@ -170,7 +189,6 @@ jQuery(document).ready(function(){ ...@@ -170,7 +189,6 @@ jQuery(document).ready(function(){
} }
// //
}); });
//验证码验证 //验证码验证
function checkValidateCode(){ function checkValidateCode(){
...@@ -252,8 +270,6 @@ $(document).on("click","#typenum option",function(){ ...@@ -252,8 +270,6 @@ $(document).on("click","#typenum option",function(){
}); });
</script> </script>
</head> </head>
<body> <body>
...@@ -302,6 +318,23 @@ $!httpInclude.include("/nav1.htm") ...@@ -302,6 +318,23 @@ $!httpInclude.include("/nav1.htm")
</span></td> </span></td>
<td class="login_nameu2">再次输入您的密码</td> <td class="login_nameu2">再次输入您的密码</td>
</tr> </tr>
<tr>
<td align="right" valign="top">所在地区:</td>
<td class="px10"><span class="setinput">
<select id="areas_province" areaMark="province">
<option>请选择...</option>
#foreach($are in $areas)
<option value="$!are.id">$!are.areaName</option>
#end
</select>
<select id="areas_city" areaMark="city">
<option value="">请选择...</option>
</select>
<select id="area_id" name="area_id">
<option value="$!objs.area.id">请选择...</option>
</select>
</span></td>
</tr>
<tr id="refereetr"> <tr id="refereetr">
<td class="login_nameu">推荐人:</td> <td class="login_nameu">推荐人:</td>
<td><span class="login_user_input input_size" id="refereespan"> <td><span class="login_user_input input_size" id="refereespan">
...@@ -314,13 +347,13 @@ $!httpInclude.include("/nav1.htm") ...@@ -314,13 +347,13 @@ $!httpInclude.include("/nav1.htm")
</td> </td>
<td class="login_nameu2">推荐人手机号码</td> <td class="login_nameu2">推荐人手机号码</td>
</tr> </tr>
<tr> <!-- <tr>
<td class="login_nameu">电子邮件:</td> <td class="login_nameu">电子邮件:</td>
<td><span class="login_user_input input_size"> <td><span class="login_user_input input_size">
<input name="email" type="text" id="email" /> <input name="email" type="text" id="email" />
</span></td> </span></td>
<td class="login_nameu2">录入后不可修改</td> <td class="login_nameu2">录入后不可修改</td>
</tr> </tr> -->
#if($!config.securityCodeRegister) #if($!config.securityCodeRegister)
<tr> <tr>
<td class="login_nameu">验证码:</td> <td class="login_nameu">验证码:</td>
......
...@@ -67,6 +67,7 @@ import com.shopping.view.web.tools.AreaViewTools; ...@@ -67,6 +67,7 @@ import com.shopping.view.web.tools.AreaViewTools;
import com.shopping.view.web.tools.GoodsFloorViewTools; import com.shopping.view.web.tools.GoodsFloorViewTools;
import com.shopping.view.web.tools.GoodsViewTools; import com.shopping.view.web.tools.GoodsViewTools;
import com.shopping.view.web.tools.NavViewTools; import com.shopping.view.web.tools.NavViewTools;
import com.shopping.view.web.tools.PhoneCodeViewTools;
import com.shopping.view.web.tools.StoreViewTools; import com.shopping.view.web.tools.StoreViewTools;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
...@@ -155,6 +156,9 @@ public class IndexViewAction { ...@@ -155,6 +156,9 @@ public class IndexViewAction {
@Autowired @Autowired
private AreaViewTools areaViewTools; private AreaViewTools areaViewTools;
@Autowired
private PhoneCodeViewTools phoneCodeViewTools;
/** /**
* 页面最上面部分 * 页面最上面部分
...@@ -863,6 +867,49 @@ public class IndexViewAction { ...@@ -863,6 +867,49 @@ public class IndexViewAction {
return mv; return mv;
} }
@RequestMapping({ "/find_password.htm" })
public ModelAndView find_password(HttpServletRequest request, HttpServletResponse response, String userName,
String password, String code,String mobileCode) {
ModelAndView mv = new JModelAndView("success.html", this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
HttpSession session = request.getSession(false);
String verify_code = (String) session.getAttribute("verify_code");
if (code.toUpperCase().equals(verify_code)) {
User user = this.userService.getObjByProperty("userName", userName);
Map<String, Object>map = this.phoneCodeViewTools.yzPhoneCode(userName, mobileCode);
if(map == null) {
mv = new JModelAndView("error.html", this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
mv.addObject("op_title", "短信验证失败");
mv.addObject("url", CommUtil.getURL(request) + "/forget.htm");
}else {
if(("2").equals(map.get("code"))) {
mv = new JModelAndView("error.html", this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
mv.addObject("op_title", "短信验证码错误");
mv.addObject("url", CommUtil.getURL(request) + "/forget.htm");
}else if(("1").equals(map.get("code"))) {
mv = new JModelAndView("error.html", this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
mv.addObject("op_title", "手机号错误");
mv.addObject("url", CommUtil.getURL(request) + "/forget.htm");
}else {
user.setPassword(Md5Encrypt.md5(password));
this.userService.update(user);
mv.addObject("op_title", "修改成功,请重新登录");
mv.addObject("url", CommUtil.getURL(request) + "/user/login.htm");
}
}
} else {
mv = new JModelAndView("error.html", this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
mv.addObject("op_title", "验证码不正确");
mv.addObject("url", CommUtil.getURL(request) + "/forget.htm");
}
return mv;
}
@RequestMapping({ "/switch_recommend_goods.htm" }) @RequestMapping({ "/switch_recommend_goods.htm" })
public ModelAndView switch_recommend_goods(HttpServletRequest request, HttpServletResponse response, public ModelAndView switch_recommend_goods(HttpServletRequest request, HttpServletResponse response,
int recommend_goods_random) { int recommend_goods_random) {
......
...@@ -51,6 +51,7 @@ import com.shopping.foundation.domain.ZshFsbespoke; ...@@ -51,6 +51,7 @@ import com.shopping.foundation.domain.ZshFsbespoke;
import com.shopping.foundation.domain.ZshLayout; import com.shopping.foundation.domain.ZshLayout;
import com.shopping.foundation.domain.ZshOrder; import com.shopping.foundation.domain.ZshOrder;
import com.shopping.foundation.service.IAlbumService; import com.shopping.foundation.service.IAlbumService;
import com.shopping.foundation.service.IAreaService;
import com.shopping.foundation.service.IGoodsService; import com.shopping.foundation.service.IGoodsService;
import com.shopping.foundation.service.IGroupGoodsService; import com.shopping.foundation.service.IGroupGoodsService;
import com.shopping.foundation.service.IIntegralLogService; import com.shopping.foundation.service.IIntegralLogService;
...@@ -73,6 +74,7 @@ import com.shopping.uc.api.UCClient; ...@@ -73,6 +74,7 @@ import com.shopping.uc.api.UCClient;
import com.shopping.uc.api.UCTools; import com.shopping.uc.api.UCTools;
import com.shopping.view.web.tools.AlbumViewTools; import com.shopping.view.web.tools.AlbumViewTools;
import com.shopping.view.web.tools.ImageViewTools; import com.shopping.view.web.tools.ImageViewTools;
import com.shopping.view.web.tools.PhoneCodeViewTools;
import com.shopping.view.web.tools.QrCodeUtil; import com.shopping.view.web.tools.QrCodeUtil;
import com.shopping.view.web.tools.ResourceUtil; import com.shopping.view.web.tools.ResourceUtil;
import com.shopping.view.web.tools.SendTemplateSMS; import com.shopping.view.web.tools.SendTemplateSMS;
...@@ -133,6 +135,12 @@ public class LoginViewAction { ...@@ -133,6 +135,12 @@ public class LoginViewAction {
@Autowired @Autowired
private IOrderFormLogService orderFormLogService; private IOrderFormLogService orderFormLogService;
@Autowired
private PhoneCodeViewTools phoneCodeViewTools;
@Autowired
private IAreaService areaService;
/** /**
* 用户登录跳转页面 * 用户登录跳转页面
...@@ -200,7 +208,9 @@ public class LoginViewAction { ...@@ -200,7 +208,9 @@ public class LoginViewAction {
* List<User>list=this.userService.query("select obj from User obj ", null, -1, * List<User>list=this.userService.query("select obj from User obj ", null, -1,
* -1); mv.addObject("list", list); * -1); mv.addObject("list", list);
*/ */
List areas = this.areaService.query("select obj from Area obj where obj.parent.id is null", null, -1, -1);
mv.addObject("areas", areas);
return mv; return mv;
} }
...@@ -274,7 +284,7 @@ public class LoginViewAction { ...@@ -274,7 +284,7 @@ public class LoginViewAction {
*/ */
@RequestMapping({ "/register_finish.htm" }) @RequestMapping({ "/register_finish.htm" })
public String register_finish(HttpServletRequest request, HttpServletResponse response, String userName, public String register_finish(HttpServletRequest request, HttpServletResponse response, String userName,
String password, String email, String code, String refereeId) throws HttpException, IOException { String password, String email, String code, String refereeId,String mobileCode) throws HttpException, IOException {
// 获取refereeId推荐人id // 获取refereeId推荐人id
if (!(refereeId == null) && !(refereeId.equals(""))) { if (!(refereeId == null) && !(refereeId.equals(""))) {
...@@ -300,7 +310,23 @@ public class LoginViewAction { ...@@ -300,7 +310,23 @@ public class LoginViewAction {
if ((users != null) && (users.size() > 0)) { if ((users != null) && (users.size() > 0)) {
reg = false; reg = false;
} }
if (reg) { if (reg) {
//验证短信验证码
Map<String, Object>map = this.phoneCodeViewTools.yzPhoneCode(userName, mobileCode);
if(map == null) {
System.out.print("短信验证失败");
return "redirect:register.htm";
}else {
if(("2").equals(map.get("code"))) {
System.out.print("短信验证错误");
return "redirect:register.htm";
}else if(("1").equals(map.get("code"))) {
System.out.print("手机号错误");
return "redirect:register.htm";
}
}
User user = new User(); User user = new User();
user.setUserName(userName); user.setUserName(userName);
user.setMobile(userName); user.setMobile(userName);
......
package com.shopping.view.web.tools;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.shopping.foundation.domain.PhoneCode;
import com.shopping.foundation.service.IPhoneCodeService;
@Component
public class PhoneCodeViewTools {
@Autowired
private IPhoneCodeService phoneCodeService;
public Map<String, Object> yzPhoneCode( String phone, String mobileCode) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("phone", phone);
List<PhoneCode> phoneCode = this.phoneCodeService
.query("select obj from PhoneCode obj where obj.phone = :phone and obj.state = 0", map, -1, -1);
if (phoneCode.size() > 0) {
if (mobileCode.equals(phoneCode.get(0).getCode())) {
PhoneCode phoneC = phoneCode.get(0);
phoneC.setState("1");
this.phoneCodeService.update(phoneC);
map.put("phoneCode", "1");
map.put("msg", "验证成功");
} else {
map.put("phoneCode", "2");
map.put("msg", "验证码错误");
}
} else {
map.put("phoneCode", "0");
map.put("msg", "手机号码有误");
}
return map;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment