wesmiler 1 неделя назад
Родитель
Сommit
0b5256ce25

+ 0 - 29
app/Http/Controllers/Api/v1/GoodsController.php

@@ -72,35 +72,6 @@ class GoodsController extends webApp
     }
 
     /**
-     * 创业大礼包
-     * @return array
-     */
-    public function data()
-    {
-        $areaId = $this->areaId;
-        $buyType = $this->buyType;
-        if($areaId<=0){
-            $cacheInfo = RedisService::get("caches:index:area_".get_client_ip());
-            $areaId = isset($cacheInfo['area_id'])?$cacheInfo['area_id'] : 1;
-            $buyType = isset($cacheInfo['buy_type'])?$cacheInfo['buy_type'] : 1;
-        }
-        try {
-            $data = [
-                // 轮播
-                'banners' => AdService::make()->getListByPosition(1),
-                'goods' => GoodsService::make()->getListByType(2, $buyType, $this->userId),
-                'areaId'=> $areaId,
-                'buyType'=> $buyType,
-            ];
-
-            return showJson(1010, true, $data);
-        } catch (\Exception $exception) {
-            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
-            return showJson(1046, false, $error);
-        }
-    }
-
-    /**
      * 收藏
      */
     public function collect()

+ 10 - 0
app/Http/Controllers/Api/v1/IndexController.php

@@ -64,10 +64,20 @@ class IndexController extends webApp
      */
     public function data()
     {
+        $areaId = $this->areaId;
+        $buyType = $this->buyType;
+        if($areaId<=0){
+            $cacheInfo = RedisService::get("caches:index:area_".get_client_ip());
+            $areaId = isset($cacheInfo['area_id'])?$cacheInfo['area_id'] : 1;
+            $buyType = isset($cacheInfo['buy_type'])?$cacheInfo['buy_type'] : 1;
+        }
         try {
             $data = [
                 // 轮播
                 'banners' => AdService::make()->getListByPosition(1),
+                'goods' => $this->userId?GoodsService::make()->getListByType(2, $buyType, $this->userId):[],
+                'areaId'=> $areaId,
+                'buyType'=> $buyType,
             ];
 
             return showJson(1010, true, $data);

+ 1 - 2
routes/api.php

@@ -99,8 +99,7 @@ Route::prefix('v1')->middleware('web.login')->group(function() {
     Route::post('/cart/delete', [\App\Http\Controllers\Api\v1\CartController::class, 'delete']);
     Route::post('/cart/count', [\App\Http\Controllers\Api\v1\CartController::class, 'count']);
 
-    // 商品 
-    Route::get('/goods/data', [\App\Http\Controllers\Api\v1\GoodsController::class, 'data']);
+    // 商品
     Route::post('/goods/buyGoods', [\App\Http\Controllers\Api\v1\GoodsController::class, 'buyGoods']);
     Route::post('/goods/collect', [\App\Http\Controllers\Api\v1\GoodsController::class, 'collect']);