浏览代码

添加登陆注册

chenxiqiang 6 年前
父节点
当前提交
dc76b4fbb8
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7
    3
      manage-server/app/Http/Controllers/CommonController.php

+ 7
- 3
manage-server/app/Http/Controllers/CommonController.php 查看文件

23
     public function login(Request $request)
23
     public function login(Request $request)
24
     {
24
     {
25
         $code = $request->input("code");
25
         $code = $request->input("code");
26
-        Log::error($code);
27
 
26
 
28
         $miniProgram = app("wechat.mini_program");
27
         $miniProgram = app("wechat.mini_program");
29
-        $auth = $miniProgram->auth->session($code);
28
+        try {
29
+            $auth = $miniProgram->auth->session($code);
30
+        } catch (\Exception $e) {
31
+            return response()->json([
32
+                "error" => $e->getCode() . $e->getMessage()
33
+            ]);
34
+        }
30
         if ($auth) {
35
         if ($auth) {
31
-            dd($auth);
32
             $openid = $auth->getId();
36
             $openid = $auth->getId();
33
             $token = $auth->getToken();
37
             $token = $auth->getToken();
34
             $nickname = $auth->getNickname();
38
             $nickname = $auth->getNickname();

Loading…
取消
保存