浏览代码

首页接口

lizhen_gitee 7 月之前
父节点
当前提交
ab9eb1e63d
共有 2 个文件被更改,包括 31 次插入8 次删除
  1. 30 7
      application/api/controller/Index.php
  2. 1 1
      public/assets/js/backend/chihewanle.js

+ 30 - 7
application/api/controller/Index.php

@@ -3,7 +3,7 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-
+use think\Db;
 /**
  * 首页接口
  */
@@ -29,23 +29,46 @@ class Index extends Api
         $banner = list_domain_image($banner, ['image']);
 
         //四个顶部分类
-
-        //第一个顶部分类,的两个商品
-
-        //其他所有分类
-
-
+        $top_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 1])->order('weigh', 'asc')->limit(4)->select();
+        $top_category = list_domain_image($top_category, ['image']);
+        foreach($top_category as $key => $val){
+            $val['type'] = 'product';
+            if($key == 3){
+                $val['type'] = 'news';
+            }
+
+            $top_category[$key] = $val;
+        }
+
+        //底部所有分类
+        $buttom_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 0])->order('weigh', 'asc')->select();
+        $buttom_category = list_domain_image($buttom_category, ['image']);
+
+        //
+        $result = [
+            'banner' => $banner,
+            'top_category' => $top_category,
+            'buttom_category' => $buttom_category,
+        ];
+        $this->success(1,$result);
     }
 
     //吃喝玩乐
     //列表
     public function chihewanle_list(){
+        $list = Db::name('chihewanle')->field('id, title, info, image')->where(['status' => 1])->order('weigh', 'desc')->select();
+        $list = list_domain_image($list, ['image']);
 
+        $this->success(1,$list);
     }
 
     //吃喝玩乐
     //详情
     public function chihewanle_info(){
+        $id = input('id',0);
+        $info = Db::name('chihewanle')->field('id, title, info, image, content')->where('id',$id)->order('weigh', 'desc')->find();
+        $info = info_domain_image($info, ['image']);
 
+        $this->success(1,$info);
     }
 }

+ 1 - 1
public/assets/js/backend/chihewanle.js

@@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 sortName: 'weigh',
                 columns: [
                     [
-//                        {checkbox: true},
+                        {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'info', title: __('Info'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},