Browse Source

分类列表新增一个接口

wufeng 2 years ago
parent
commit
6e528a1b08
2 changed files with 55 additions and 31 deletions
  1. 54 31
      app/abutment/controller/Good.php
  2. 1 0
      app/abutment/route/app.php

+ 54 - 31
app/abutment/controller/Good.php

@@ -1498,50 +1498,73 @@ class Good extends BaseController
     }
 
     //贵金属种类列表
-    public function linst(){
-        $data=[];
-        foreach ($this->gold as $key=>$value){
-            $v =[];
-            $v['type']=$key;
-            $v['type_cn']=$value;
-            $data[]=$v;
-        }
-        return app_show(0,"获取成功",$data);
+    public function linst()
+    {
+        $data = [];
+        foreach ($this->gold as $key => $value) {
+            $v = [];
+            $v['type'] = $key;
+            $v['type_cn'] = $value;
+            $data[] = $v;
+        }
+        return json_show(0, "获取成功", $data);
     }
 
     //分类列表
-    public function wlist(){
+    public function wlist()
+    {
         $this->post = $this->request->filter('trim')->post();
-        $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
-        $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
-        $where =[["is_del","=",0],['level',"=",3]];
-        $cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? trim($this->post['cat_name']) :"";
-        if($cat_name!==""){
-            $where[]=['cat_name',"like","%$cat_name%"];
+        $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
+        $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
+        $where = [["is_del", "=", 0]];
+        $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
+        if ($cat_name !== "") {
+            $where[] = ['cat_name', "like", "%$cat_name%"];
         }
-        $search=isset($this->post['search']) && $this->post['search'] !==""? trim($this->post['search']) :"";
-        if($search!==""){
-            $where[]=['search',"like","%$search%"];
+        $search = isset($this->post['search']) && $this->post['search'] !== "" ? trim($this->post['search']) : "";
+        if ($search !== "") {
+            $where[] = ['search', "like", "%$search%"];
         }
-        $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
-        if($pid!==""){
-            $where[]=['pid',"=",$pid];
+        $pid = isset($this->post['pid']) && $this->post['pid'] !== "" ? intval($this->post['pid']) : "";
+        if ($pid !== "") {
+            $where[] = ['pid', "=", $pid];
         }
-        $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
-        if($status!==""){
-            $where[]=['status',"=",$status];
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status !== "") {
+            $where[] = ['status', "=", $status];
         }
         $count = Db::name("cat")->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
         $list = Db::name('cat')->where($where)->page($page, $size)->select();
-        $data=[];
-        foreach ($list as $value){
-            $temp= isset($value['id']) && $value['id'] !=0 ? made($value['id']):[];
-            $value['item'] = array_column($temp,'id');
-            $data[]=$value;
+        $data = [];
+        foreach ($list as $value) {
+            $temp = isset($value['id']) && $value['id'] != 0 ? made($value['id']) : [];
+            $value['item'] = array_column($temp, 'id');
+            $data[] = $value;
         }
-        return app_show(0, "获取成功", ['list' =>$data, 'count' => $count]);
+        return json_show(0, "获取成功", ['list' => $data, 'count' => $count]);
+    }
+
+    //分类列表-全部
+    public function title()
+    {
+        $where = [["is_del", "=", 0]];
+        $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
+        if ($cat_name !== "") $where[] = ['cat_name', "like", "%$cat_name%"];
+
+        $pid = isset($this->post['pid']) && $this->post['pid'] !== "" ? intval($this->post['pid']) : "";
+        if ($pid !== "") $where[] = ["pid", "=", $pid];
+
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status !== "") $where[] = ['status', "=", $status];
+
+        $list = Db::name('cat')
+            ->where($where)
+            ->select()
+            ->toArray();
+
+        return json_show(0, "获取成功", $list);
     }
 
 

+ 1 - 0
app/abutment/route/app.php

@@ -31,6 +31,7 @@ route::rule('catInfo', 'abutment/Good/catInfo');//分类信息
 route::rule('goldPriceLastList', 'abutment/Good/goldPriceLastList');//实时金价列表
 route::rule('goldLinst', 'abutment/Good/linst');//贵金属种类列表
 route::rule('catList', 'abutment/Good/wlist');//分类列表
+route::rule('catListTitle', 'abutment/Good/title');//分类列表-全部
 
 //销售订单(采销的采购单)
 route::rule('getOrderList', 'abutment/Order/getList');//列表