From 3f0f3b75bace505e17162aff3169cb368dba44e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E5=B3=B0?= <1feng.0595@gmail.com> Date: Mon, 16 Oct 2017 00:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UserController.php | 49 ++- app/Http/Model/User.php | 38 ++- public/images/weixin/ad_tit.png | Bin 5396 -> 3022 bytes .../views/weixin/user/userinfo.blade.php | 286 ++++++++++++++++-- routes/web.php | 1 + 5 files changed, 339 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 3952e46..bae8163 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -31,8 +31,15 @@ class UserController extends CommonController //修改用户信息 public function userInfoUpdate(Request $request) { - $data = ''; - if($request->input('user_name', null)!==null){$data['user_name'] = $request->input('user_name');} + if($request->input('user_name', null)!==null) + { + $data['user_name'] = $request->input('user_name'); + + if(User::getOneUser($data)) + { + return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在'); + } + } if($request->input('email', null)!==null){$data['email'] = $request->input('email');} if($request->input('sex', null)!==null){$data['sex'] = $request->input('sex');} if($request->input('birthday', null)!==null){$data['birthday'] = $request->input('birthday');} @@ -49,13 +56,47 @@ class UserController extends CommonController if($request->input('password', null)!==null){$data['password'] = $request->input('password');} if($request->input('head_img', null)!==null){$data['head_img'] = $request->input('head_img');} - if ($data != '') + if (isset($data)) { - User::modify(['id'=>Token::$uid],$data); + User::modify(array('id'=>Token::$uid),$data); } return ReturnData::create(ReturnData::SUCCESS); } + + //修改用户密码、支付密码 + public function userPasswordUpdate(Request $request) + { + if($request->input('password', '')!='' && $request->input('old_password', '')!='') + { + $data['password'] = $request->input('password'); + $data['old_password'] = $request->input('old_password'); + + if($data['password'] == $data['old_password']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'新旧密码相同');} + } + + if($request->input('pay_password', '')!='') + { + $data['pay_password'] = $request->input('pay_password'); + $data['old_pay_password'] = $request->input('old_pay_password',''); + + if($data['pay_password'] == $data['old_pay_password']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'新旧密码相同');} + } + + if (isset($data)) + { + $res = User::userPasswordUpdate(array('id'=>Token::$uid),$data); + + if($res === false) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); + } + + return ReturnData::create(ReturnData::SUCCESS); + } + + return ReturnData::create(ReturnData::PARAMS_ERROR); + } //用户列表 public function userList(Request $request) diff --git a/app/Http/Model/User.php b/app/Http/Model/User.php index fad8ab2..521d03b 100644 --- a/app/Http/Model/User.php +++ b/app/Http/Model/User.php @@ -128,14 +128,46 @@ class User extends BaseModel } //获取用户信息 - public static function getUserInfo($user_id) + public static function getUserInfo($user_id) { $user = self::where('id', $user_id)->first(); if(!$user){return false;} $user->reciever_address = UserAddress::getOne($user->address_id); $user->collect_goods_count = CollectGoods::where('user_id', $user_id)->count(); - - return $user; + + $userinfo = $user->makeVisible(array('pay_password'))->toArray(); + $user->pay_password = 0; + if($userinfo['pay_password']){$user->pay_password = 1;} + + return $user; + } + + //修改用户密码、支付密码 + public static function userPasswordUpdate($where,array $param) + { + extract($param); + $data = ''; + + $user = self::where($where)->first(); + if(!$user){return false;} + + $user = $user->makeVisible(array('password','pay_password'))->toArray(); + + if(isset($old_password) && $old_password!=$user['password']){return false;} //旧密码错误 + if(isset($password) && $password==''){return false;} //新密码为空 + + if(isset($old_pay_password) && $old_pay_password!=$user['pay_password']){return false;} + if(isset($pay_password) && $pay_password==''){return false;} + + if(isset($password)){$data['password'] = $password;} + if(isset($pay_password)){$data['pay_password'] = $pay_password;} + + if ($data != '' && self::where($where)->update($data)) + { + return true; + } + + return false; } //注册 diff --git a/public/images/weixin/ad_tit.png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^26+`6F&>@n&o!kjQ4?7XpT?Ho|Ph19eI>t)X^^XN?0!e=6o%4Lc-*`pkIv$cO5-68{oD4+IS zg`5k{eZ-Xg*1-oKFy5}iVDYwEuh5bP%Ae(kc%!3#xxN1;KAx?vdHUWq
    -
  • +
  • @@ -35,15 +35,19 @@

    头像

    - -
  • + + + -
  • +
  • 性别

     
    @@ -167,20 +212,66 @@ function update_nickname()
  • +
+ +
    +
  • +
    +

    修改密码

    +
     
    +
    + +
  • + -
- -
    -
  • -
    -

    修改密码

    -
     
    -
    - -
  • -
  • +
  • 支付密码

     
    -
  • + +
diff --git a/routes/web.php b/routes/web.php index 90dbe42..767d642 100644 --- a/routes/web.php +++ b/routes/web.php @@ -131,6 +131,7 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web Route::post('/user_signin', 'UserController@signin'); //签到 Route::get('/user_info', 'UserController@userInfo'); //用户详细信息 Route::post('/user_info_update', 'UserController@userInfoUpdate'); //修改用户信息 + Route::post('/user_password_update', 'UserController@userPasswordUpdate'); //修改用户密码、支付密码 Route::get('/user_list', 'UserController@userList'); //用户列表 Route::get('/user_money_list', 'UserMoneyController@userMoneyList'); //用户余额明细