diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 0380bc3..3952e46 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -92,12 +92,25 @@ class UserController extends CommonController $data['mobile'] = $request->input('mobile',''); $data['user_name'] = $request->input('user_name',''); $data['password'] = $request->input('password',''); + $parent_mobile = $request->input('parent_mobile',''); if (($data['mobile']=='' && $data['user_name']=='') || $data['password']=='') { return ReturnData::create(ReturnData::PARAMS_ERROR); } + if ($parent_mobile!='') + { + if($user = User::getOneUser(array('mobile'=>$parent_mobile))) + { + $data['parent_id'] = $user->id; + } + else + { + return ReturnData::create(ReturnData::PARAMS_ERROR,null,'推荐人手机号错误'); + } + } + if (isset($data['mobile']) && !Helper::isValidMobile($data['mobile'])) { return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL); @@ -111,7 +124,7 @@ class UserController extends CommonController if (User::getOneUser(array('user_name'=>$data['user_name']))) { - return ReturnData::create(ReturnData::SUCCESS,null,'用户名已存在'); + return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在'); } //添加用户 diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index 9998003..9defcc1 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -270,32 +270,6 @@ class UserController extends CommonController header('Location: '.route('weixin_user'));exit; } - if($_SERVER['REQUEST_METHOD'] == 'POST') - { - if($_POST['user_name'] == '') - { - $this->error_jump('账号不能为空'); - } - - if($_POST['password'] == '') - { - $this->error_jump('密码不能为空'); - } - - $postdata = array( - 'user_name' => $_POST['user_name'], - 'password' => md5($_POST['password']) - ); - $url = env('APP_API_URL')."/wx_login"; - $res = curl_request($url,$postdata,'POST'); - - if($res['code'] != ReturnCode::SUCCESS_CODE){$this->error_jump('登录失败');} - - $_SESSION['weixin_user_info'] = $res['data']; - - header('Location: '.route('weixin_user'));exit; - } - return view('weixin.user.register'); } diff --git a/app/Http/Model/User.php b/app/Http/Model/User.php index 7c74459..fad8ab2 100644 --- a/app/Http/Model/User.php +++ b/app/Http/Model/User.php @@ -123,7 +123,6 @@ class User extends BaseModel { $user = self::where($where)->first(); if(!$user){return false;} - $user['reciever_address'] = UserAddress::getOne($user->address_id); return $user; } @@ -146,7 +145,8 @@ class User extends BaseModel if(isset($user_name)){$data['user_name'] = $user_name;} if(isset($mobile)){$data['mobile'] = $mobile;} - if(isset($password)){$data['password'] = $password;} + if(isset($password)){$data['password'] = $password;} //md5加密 + if(isset($parent_id)){$data['parent_id'] = $parent_id;} if (isset($data) && $id = self::add($data)) { diff --git a/resources/views/weixin/user/login.blade.php b/resources/views/weixin/user/login.blade.php index 11cff05..e713026 100644 --- a/resources/views/weixin/user/login.blade.php +++ b/resources/views/weixin/user/login.blade.php @@ -46,7 +46,7 @@ 登录
-快速注册 忘记密码 +快速注册 忘记密码?
diff --git a/resources/views/weixin/user/register.blade.php b/resources/views/weixin/user/register.blade.php index 83c4702..8ef61f4 100644 --- a/resources/views/weixin/user/register.blade.php +++ b/resources/views/weixin/user/register.blade.php @@ -42,17 +42,20 @@
- +
+
+ +
提交
-已有账号 +已有账号 注册协议
@@ -64,10 +67,10 @@ function submit() var mobile = $("#mobile").val(); var password = $("#password").val(); var re_password = $("#re_password").val(); + var parent_mobile = $("#parent_mobile").val(); if(user_name == '') { - //提示 layer.open({ content: '用户名不能为空' ,skin: 'msg' @@ -79,7 +82,6 @@ function submit() if(mobile == '') { - //提示 layer.open({ content: '手机号不能为空' ,skin: 'msg' @@ -91,7 +93,6 @@ function submit() if(!validatemobile(mobile)) { - //提示 layer.open({ content: '手机号格式不正确' ,skin: 'msg' @@ -103,7 +104,6 @@ function submit() if(password == '') { - //提示 layer.open({ content: '密码不能为空' ,skin: 'msg' @@ -115,7 +115,6 @@ function submit() if(password != re_password) { - //提示 layer.open({ content: '两次密码不一致' ,skin: 'msg' @@ -125,25 +124,29 @@ function submit() return false; } - $("#login").submit(); - /* $.post('',{user_name:user_name,password:md5(password)},function(res) + //$("#login").submit(); + $.post('',{user_name:user_name,mobile:mobile,parent_mobile:parent_mobile,password:md5(password)},function(res) { if(res.code==0) { //提示 layer.open({ - content: '登录成功' + content: '注册成功' ,skin: 'msg' ,time: 2 //2秒后自动关闭 }); - location.href = ''; + setInterval(function(){location.href = '';},5000); } else { - + layer.open({ + content: res.msg + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); } - },'json'); */ + },'json'); } @include('weixin.common.footer') diff --git a/resources/views/weixin/user/userinfo.blade.php b/resources/views/weixin/user/userinfo.blade.php index 41b222f..dbc8e57 100644 --- a/resources/views/weixin/user/userinfo.blade.php +++ b/resources/views/weixin/user/userinfo.blade.php @@ -75,27 +75,130 @@ $(function(){ }); }); -
  • +
  • 用户名

     
    -
  • -
  • +
  • + + +
  • 昵称

     
    -
  • -
  • +
  • + +
  • 性别

     
    -
  • +
    +