Browse Source

微信登录

master
林一峰 7 years ago
parent
commit
010a973365
  1. 2
      app/Http/Controllers/Api/UserController.php
  2. 2
      app/Http/Controllers/Weixin/UserController.php
  3. 11
      app/Http/Model/User.php
  4. 2
      resources/views/weixin/common/footer.blade.php

2
app/Http/Controllers/Api/UserController.php

@ -134,7 +134,7 @@ class UserController extends CommonController
$data['password'] = $request->input('password','');
$data['openid'] = $request->input('openid','');
if (($data['user_name']=='' && $data['password']=='') || $data['openid']=='')
if (($data['user_name']=='' || $data['password']=='') && $data['openid']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}

2
app/Http/Controllers/Weixin/UserController.php

@ -323,7 +323,7 @@ class UserController extends CommonController
$res = curl_request($url,$postdata,'POST');
if($res['code'] != ReturnCode::SUCCESS_CODE){$this->error_jump('系统错误');}
dd($res);
$_SESSION['weixin_user_info'] = $res['data'];
header('Location: '.route('weixin_user'));exit;

11
app/Http/Model/User.php

@ -199,9 +199,16 @@ class User extends BaseModel
{
extract($param); //参数
$user = self::where(array('mobile'=>$user_name,'password'=>$password))->orWhere(array('user_name'=>$user_name,'password'=>$password))->orWhere(array('openid'=>$openid))->first();
if(isset($openid))
{
$user = self::where(array('openid'=>$openid))->first();
}
else
{
$user = self::where(array('mobile'=>$user_name,'password'=>$password))->orWhere(array('user_name'=>$user_name,'password'=>$password))->first();
}
if(!$user){return false;}
if(!isset($user)){return false;}
$res = self::getUserInfo($user->id);
$token = Token::getToken(Token::TYPE_WEIXIN, $user->id);

2
resources/views/weixin/common/footer.blade.php

@ -5,7 +5,7 @@
<?php $current_url = url()->current(); ?>
<a href="<?php echo route('weixin'); ?>"><li<?php if(route('weixin') == $current_url){echo ' class="on"';} ?>><img src="<?php echo env('APP_URL'); ?>/images/weixin/home_icon<?php if(route('weixin') == $current_url){echo '2';} ?>.png"><p>首页</p></li></a>
<a href="<?php echo route('weixin_category'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/brand_icon.png"><p>分类</p></li></a>
<a href="<?php echo route('weixin_cart'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/car_icon.png"><p>购物车</p></li></a>
<a href="<?php echo route('weixin_cart'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/car_icon<?php if(route('weixin_cart') == $current_url){echo '2';} ?>.png"><p>购物车</p></li></a>
<a href="<?php echo route('weixin_user'); ?>"><li<?php if(route('weixin_user') == $current_url){echo ' class="on"';} ?>><img src="<?php echo env('APP_URL'); ?>/images/weixin/center_icon<?php if(route('weixin_user') == $current_url){echo '2';} ?>.png"><p>个人中心</p></li></a></ul>
</div>
</div>
Loading…
Cancel
Save