From d92339a03b709e3a30c278593ff219414d556f86 Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Sat, 14 Oct 2017 16:23:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UserController.php | 15 ++- .../Controllers/Weixin/UserController.php | 26 ---- app/Http/Model/User.php | 4 +- resources/views/weixin/user/login.blade.php | 2 +- .../views/weixin/user/register.blade.php | 29 +++-- .../views/weixin/user/userinfo.blade.php | 115 +++++++++++++++++- 6 files changed, 142 insertions(+), 49 deletions(-) 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 @@