浏览代码

添加分类

chenxiqiang 6 年前
父节点
当前提交
251cbdca12

+ 1
- 16
manage-server/app/Http/Controllers/ClassifyController.php 查看文件

@@ -9,26 +9,11 @@ class ClassifyController extends Controller
9 9
 {
10 10
     public function list(Request $request)
11 11
     {
12
-        $classify_array = [];
13 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 14
         return response()->json([
30 15
             "status" => 0,
31
-            "data" => $root
16
+            "data" => $classifys
32 17
         ]);
33 18
     }
34 19
 }

+ 12
- 2
manage-server/app/Http/Controllers/CommonController.php 查看文件

@@ -26,8 +26,18 @@ class CommonController extends Controller
26 26
         $miniProgram = app("wechat.mini_program");
27 27
 
28 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 查看文件

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

Loading…
取消
保存