直接判断有没有code就可以 基本代码贴上
public function index(Request $request) { $user = session(‘user‘);//用户资料 if(empty($user)) { $response = $this->wechat->oauth->scopes([‘snsapi_base‘])->redirect(); return $response; }else{ dd($user); } } public function login(Request $request) { $code = $request->input(‘code‘);
//处理40163问题 if($code) { $accessToken = $this->wechat->oauth->getAccessToken($code); $user = $this->wechat->oauth->user($accessToken); dd($user); } return redirect(‘pay/index‘); }