Ver código fonte

添加分类

chenxiqiang 6 anos atrás
pai
commit
251cbdca12

+ 1
- 16
manage-server/app/Http/Controllers/ClassifyController.php Ver arquivo

9
 {
9
 {
10
     public function list(Request $request)
10
     public function list(Request $request)
11
     {
11
     {
12
-        $classify_array = [];
13
         $classifys = Classify::all();
12
         $classifys = Classify::all();
14
 
13
 
15
-        $root = new Classify();
16
-        $root->id = 0;
17
-        $root->pid = 0;
18
-        $root->name = '/';
19
-        $classify_array[0] = $root;
20
-
21
-        foreach ($classifys as $classify) {
22
-            $classify_array[$classify->id] = $classify;
23
-        }
24
-
25
-        foreach ($classify_array as $key=>$value) {
26
-            $classify_array[$value->pid]->children[$key] = $value;
27
-        }
28
-
29
         return response()->json([
14
         return response()->json([
30
             "status" => 0,
15
             "status" => 0,
31
-            "data" => $root
16
+            "data" => $classifys
32
         ]);
17
         ]);
33
     }
18
     }
34
 }
19
 }

+ 12
- 2
manage-server/app/Http/Controllers/CommonController.php Ver arquivo

26
         $miniProgram = app("wechat.mini_program");
26
         $miniProgram = app("wechat.mini_program");
27
 
27
 
28
         $auth = $miniProgram->auth->session($code);
28
         $auth = $miniProgram->auth->session($code);
29
-        if($auth->open)
30
-        return response()->json($auth);
29
+        if(isset($auth->openid)) {
30
+            return response()->json([
31
+                "status" => 0,
32
+                "data" => [
33
+                    "openid" => $auth->openid,
34
+                    "session_key" => $auth->session_key
35
+                ]]);
36
+        } else if(isset($auth->errcode)){
37
+            return response()->json([
38
+                "status" => $auth->errcode,
39
+                "message" => $auth->errmsg]);
40
+        }
31
     }
41
     }
32
 
42
 
33
     /**
43
     /**

+ 5
- 0
manage-server/app/Models/Classify.php Ver arquivo

12
     ];
12
     ];
13
 
13
 
14
     protected $children = [];
14
     protected $children = [];
15
+
16
+    public function setChildren($key, $value) {
17
+        $this->children[$key] = $value;
18
+        return;
19
+    }
15
 }
20
 }

Carregando…
Cancelar
Salvar