소스 검색

修改产品首页展示接口

chenxiqiang 6 년 전
부모
커밋
b731e6b6f8

+ 6
- 14
manage-server/app/Http/Controllers/ProductController.php 파일 보기

22
         $color = $request->input('color');
22
         $color = $request->input('color');
23
         $price = $request->input('price');
23
         $price = $request->input('price');
24
         $status = $request->input('status');
24
         $status = $request->input('status');
25
-        $location = $request->input('location');
25
+        $show = $request->input('show');
26
         if ($id) {
26
         if ($id) {
27
             $product = Product::find($id);
27
             $product = Product::find($id);
28
             $product->status = $status;
28
             $product->status = $status;
29
+            $product->show = 0;
29
         } else {
30
         } else {
30
             $product = new Product;
31
             $product = new Product;
31
             $product->status = 0;
32
             $product->status = 0;
38
             $product->color = $color;
39
             $product->color = $color;
39
             $product->price = $price;
40
             $product->price = $price;
40
             $product->classify = $classify;
41
             $product->classify = $classify;
41
-            $product->location = $location;
42
+            $product->show = $show;
42
             $product->save();
43
             $product->save();
43
             return Response()->json([
44
             return Response()->json([
44
                 "status" => 0,
45
                 "status" => 0,
99
      */
100
      */
100
     public function home(Request $request)
101
     public function home(Request $request)
101
     {
102
     {
102
-        $top = Product::where("location", "top")->limit(3)->get()->toArray();
103
-        $bottom = Product::where("location", "bottom")->first();
103
+        $top = Product::where("show", 1)->orderBy("updated_at", "desc")->limit(3)->get()->toArray();
104
 
104
 
105
         $tops = array_map(function ($t) {
105
         $tops = array_map(function ($t) {
106
             return [
106
             return [
107
                 "id" => $t["id"],
107
                 "id" => $t["id"],
108
                 "name" => $t["name"],
108
                 "name" => $t["name"],
109
-                "info" => $t["info"],
110
                 "photo" => $t["photo"],
109
                 "photo" => $t["photo"],
111
                 "location" => $t["location"]
110
                 "location" => $t["location"]
112
             ];
111
             ];
113
         }, $top);
112
         }, $top);
114
 
113
 
115
         return Response()->json([
114
         return Response()->json([
116
-            "top" => $tops,
117
-            "introduce" => "产品介绍",
118
-            "bottom" => [
119
-                "id" => $bottom["id"],
120
-                "name" => $bottom["name"],
121
-                "info" => $bottom["info"],
122
-                "photo" => $bottom["photo"],
123
-                "location" => $bottom["location"]
124
-            ]
115
+            "data" => $tops,
116
+            "status" => 0,
125
         ]);
117
         ]);
126
     }
118
     }
127
 
119
 

+ 1
- 1
manage-server/app/Models/Product.php 파일 보기

21
         'sell_num', // 销量
21
         'sell_num', // 销量
22
 		'status', // 产品状态, 上架/下架
22
 		'status', // 产品状态, 上架/下架
23
         'photo', // 产品图片
23
         'photo', // 产品图片
24
-        'location', // 产品图片
24
+        'show', // 产品轮播首页是否显示,boolean
25
 	];
25
 	];
26
 }
26
 }

+ 1
- 1
manage-server/database/migrations/2018_08_10_073946_create_products_table.php 파일 보기

36
             $table->integer('collect_num');
36
             $table->integer('collect_num');
37
             $table->integer('sell_num');
37
             $table->integer('sell_num');
38
             $table->string('photo');
38
             $table->string('photo');
39
-            $table->string('location');
39
+            $table->integer('show');
40
         });
40
         });
41
     }
41
     }
42
 
42
 

Loading…
취소
저장