Browse Source

feat:版本

super-yimizi 2 months ago
parent
commit
9ed0626971

+ 21 - 7
addons/shop/controller/api/Common.php

@@ -8,14 +8,15 @@ use think\Hook;
 use addons\shop\model\Navigation;
 use addons\shop\model\Navigation;
 use addons\shop\model\Area;
 use addons\shop\model\Area;
 use addons\shop\model\Block;
 use addons\shop\model\Block;
+use addons\shop\model\Category;
 use addons\shop\model\SearchLog;
 use addons\shop\model\SearchLog;
-
+use app\common\Enum\StatusEnum;
 /**
 /**
  * 公共
  * 公共
  */
  */
 class Common extends Base
 class Common extends Base
 {
 {
-    protected $noNeedLogin = ['init', 'area', 'getBannerList','getBannerListByIndex'];
+    protected $noNeedLogin = ['init', 'area', 'getBannerList','getDataByIndex'];
 
 
     /**
     /**
      * 初始化
      * 初始化
@@ -131,7 +132,7 @@ class Common extends Base
         $this->success('', $list);
         $this->success('', $list);
     }
     }
 
 
-    public function getBannerListByIndex()
+    public function getDataByIndex()
     {
     {
         // 固定 
         // 固定 
         $type = ['首页BANNER', '首页LOTTERY','首页ARTICE','首页MEASURE'];
         $type = ['首页BANNER', '首页LOTTERY','首页ARTICE','首页MEASURE'];
@@ -145,10 +146,6 @@ class Common extends Base
             'article' => [],
             'article' => [],
             'measure' => [],
             'measure' => [],
         ];
         ];
-        $bannerList = [];
-        $lotteryList = [];
-        $articleList = [];
-        $measureList = [];
         foreach ($list as $item) {
         foreach ($list as $item) {
             if ($item['type'] == '首页BANNER') {
             if ($item['type'] == '首页BANNER') {
                 $bannerList[] = $item;
                 $bannerList[] = $item;
@@ -167,6 +164,23 @@ class Common extends Base
         $newList['lottery'] = $lotteryList;
         $newList['lottery'] = $lotteryList;
         $newList['article'] = $articleList;
         $newList['article'] = $articleList;
         $newList['measure'] = $measureList;
         $newList['measure'] = $measureList;
+        // todo  查询活动商品
+        //  首页推荐的分类
+        $indexCategoryList = Category::where('status', StatusEnum::NORMAL)
+        ->field('id,name,image')
+        ->where("FIND_IN_SET('index',`flag`)")
+        ->order('weigh desc')
+        ->limit(8)
+        ->select();
+        //热门分类
+        $indexHotCategoryList = Category::where('status', StatusEnum::NORMAL)
+        ->field('id,name,image')
+        ->where("FIND_IN_SET('hot',`flag`)")
+        ->order('weigh desc')
+        ->limit(4)
+        ->select();
+        $newList['indexCategoryList'] = $indexCategoryList;
+        $newList['indexHotCategoryList'] = $indexHotCategoryList;
         $this->success('', $newList);
         $this->success('', $newList);
     }
     }
 }
 }

+ 1 - 1
application/api/controller/Category.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-namespace addons\shop\controller\api;
+namespace app\api\controller;
 
 
 use addons\shop\model\Category as CategoryModel;
 use addons\shop\model\Category as CategoryModel;
 use fast\Tree;
 use fast\Tree;

+ 28 - 0
application/common/Enum/StatusEnum.php

@@ -33,4 +33,32 @@ class StatusEnum
             self::DISABLED => '关闭',
             self::DISABLED => '关闭',
         ];
         ];
     }
     }
+
+    const NORMAL = 'normal'; // 正常
+    const HIDDEN = 'hidden'; // 隐藏
+
+    /**
+     * 获取状态描述
+     * @param int $status
+     * @return string
+     */
+    public static function getStrStatusText($status)
+    {
+        $map = [
+            self::NORMAL => '正常',
+            self::HIDDEN => '隐藏',
+        ];
+        return $map[$status] ?? '未知';
+    }
+    /**
+     * 获取状态映射
+     * @return array
+     */
+    public static function getStrMap()
+    {
+        return [
+            self::NORMAL => '正常',
+            self::HIDDEN => '隐藏',
+        ];
+    }
 } 
 }