Commit a5db0a5a authored by wuwz's avatar wuwz

修改注册

parent 8dd8395e
......@@ -48,10 +48,80 @@ jQuery(document).ready(function(){
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(){
jQuery("#code_img").attr("src","$!webPath/verify.htm?d"+new Date().getTime());
}
</script>
</head>
<body>
......@@ -66,17 +136,17 @@ $!httpInclude.include("/top.htm")
<h1>忘记密码<span>FIND PASSWORD</span></h1>
<div class="login_user_bottom" style="margin-left:auto; margin-right:auto">
<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">
<tr>
<td width="60" class="login_nameu">手机号:</td>
<td><span class="login_user_input input_size">
<input name="userName" type="text" id="userName" />
<input name="userName" type="text" id="phone" />
</span>
</td>
</tr>
<tr>
<td class="login_nameu">手机验证码:</td>
<td class="login_nameu">验证码:</td>
<td><span class="login_user_input input_size2">
<input name="mobileCode" type="text" id="mobileCode" style="text-transform:;"/></span>
<span class="getcode validateCode-btn">获取验证码</span>
......@@ -86,7 +156,7 @@ $!httpInclude.include("/top.htm")
<tr>
<td class="login_nameu">新密码:</td>
<td><span class="login_user_input input_size">
<input name="password" type="text" id="password" />
<input name="password" type="password" id="password" />
</span>
</td>
</tr>
......
......@@ -18,6 +18,25 @@
<script>
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){
var re = /^[0-9a-zA-Z]*$/;
......@@ -62,7 +81,7 @@ jQuery(document).ready(function(){
required:true,
equalTo:"#password"
},
email:{
/* email:{
required:true,
email:true,
remote:{
......@@ -73,7 +92,7 @@ jQuery(document).ready(function(){
"email": function(){return $("#email").val();}
}
}
},
}, */
agree:{
required:true
}
......@@ -114,10 +133,10 @@ jQuery(document).ready(function(){
required:"重复密码不能为空",
equalTo:"两次输入密码不一致"
},
email:{
/* email:{
required:"email不能为空",
email:"email格式不正确",
},
}, */
agree:{
required:"请接受用户协议"
}
......@@ -171,7 +190,6 @@ jQuery(document).ready(function(){
//
});
//验证码验证
function checkValidateCode(){
jude=false
......@@ -252,8 +270,6 @@ $(document).on("click","#typenum option",function(){
});
</script>
</head>
<body>
......@@ -302,6 +318,23 @@ $!httpInclude.include("/nav1.htm")
</span></td>
<td class="login_nameu2">再次输入您的密码</td>
</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">
<td class="login_nameu">推荐人:</td>
<td><span class="login_user_input input_size" id="refereespan">
......@@ -314,13 +347,13 @@ $!httpInclude.include("/nav1.htm")
</td>
<td class="login_nameu2">推荐人手机号码</td>
</tr>
<tr>
<!-- <tr>
<td class="login_nameu">电子邮件:</td>
<td><span class="login_user_input input_size">
<input name="email" type="text" id="email" />
</span></td>
<td class="login_nameu2">录入后不可修改</td>
</tr>
</tr> -->
#if($!config.securityCodeRegister)
<tr>
<td class="login_nameu">验证码:</td>
......
......@@ -67,6 +67,7 @@ import com.shopping.view.web.tools.AreaViewTools;
import com.shopping.view.web.tools.GoodsFloorViewTools;
import com.shopping.view.web.tools.GoodsViewTools;
import com.shopping.view.web.tools.NavViewTools;
import com.shopping.view.web.tools.PhoneCodeViewTools;
import com.shopping.view.web.tools.StoreViewTools;
import net.sf.json.JSONArray;
......@@ -156,6 +157,9 @@ public class IndexViewAction {
@Autowired
private AreaViewTools areaViewTools;
@Autowired
private PhoneCodeViewTools phoneCodeViewTools;
/**
* 页面最上面部分
*
......@@ -863,6 +867,49 @@ public class IndexViewAction {
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" })
public ModelAndView switch_recommend_goods(HttpServletRequest request, HttpServletResponse response,
int recommend_goods_random) {
......
......@@ -51,6 +51,7 @@ import com.shopping.foundation.domain.ZshFsbespoke;
import com.shopping.foundation.domain.ZshLayout;
import com.shopping.foundation.domain.ZshOrder;
import com.shopping.foundation.service.IAlbumService;
import com.shopping.foundation.service.IAreaService;
import com.shopping.foundation.service.IGoodsService;
import com.shopping.foundation.service.IGroupGoodsService;
import com.shopping.foundation.service.IIntegralLogService;
......@@ -73,6 +74,7 @@ import com.shopping.uc.api.UCClient;
import com.shopping.uc.api.UCTools;
import com.shopping.view.web.tools.AlbumViewTools;
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.ResourceUtil;
import com.shopping.view.web.tools.SendTemplateSMS;
......@@ -134,6 +136,12 @@ public class LoginViewAction {
@Autowired
private IOrderFormLogService orderFormLogService;
@Autowired
private PhoneCodeViewTools phoneCodeViewTools;
@Autowired
private IAreaService areaService;
/**
* 用户登录跳转页面
*
......@@ -200,6 +208,8 @@ public class LoginViewAction {
* List<User>list=this.userService.query("select obj from User obj ", null, -1,
* -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;
}
......@@ -274,7 +284,7 @@ public class LoginViewAction {
*/
@RequestMapping({ "/register_finish.htm" })
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
if (!(refereeId == null) && !(refereeId.equals(""))) {
......@@ -300,7 +310,23 @@ public class LoginViewAction {
if ((users != null) && (users.size() > 0)) {
reg = false;
}
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.setUserName(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