ZxcZxc123 vor 2 Jahren
Ursprung
Commit
66bea0e8e1
2 geänderte Dateien mit 45 neuen und 0 gelöschten Zeilen
  1. 43 0
      app/api/controller/Pub.php
  2. 2 0
      app/api/route/pub.php

+ 43 - 0
app/api/controller/Pub.php

@@ -367,6 +367,49 @@ class Pub extends BaseController
         return app('json')->success(['list' => [$article], 'count' => 1]);
         return app('json')->success(['list' => [$article], 'count' => 1]);
     }
     }
 
 
+
+    /**
+     * 课程列表页面
+     */
+    public function index()
+    {
+        $userInfo = Db::name("document_user")->where('uid', $this->uid)->find();
+
+        $EducationModel = model('Education');
+        $where["audit"] = 1;
+        $type = input("type", "");
+        if ($type !== "") {
+            $where["type1"] = $type;
+        }
+        $grlist = Db::name("education_gr")->where($where)->limit(20)->order("od asc,recommend desc,gr_id desc")->select();
+        foreach ($grlist as $v) {
+            $count = Db::name("education_course")->where("course_status", 1)->where(["gr_id" => $v["gr_id"], "course_audit" => 1])->field("count(*) as count,sum(course_play_count) as alll")->find();
+            $v["count"] = $count["count"];
+            $count["alll"] += $v["times"];
+            $v["alll"] = $count["alll"] ? $count["alll"] : 0;;
+            $ngrlist[] = $v;
+        }
+
+        $where["recommend"] = 1;
+        $recommendList = Db::name("education_gr")->where($where)->limit(9)->order("od asc,recommend desc,gr_id desc")->select();
+        $recommendListResult = array();
+        if (count($recommendList) > 0) {
+            foreach ($recommendList as $recommend) {
+                $recommendListResult[] = array(
+                    "img" => $recommend["indeximg"],
+                    "href" => url('kcz', array("gr_id" => $recommend["gr_id"]))
+                );
+            }
+        }
+
+        $result = [
+            'userInfo' => $userInfo,
+            'grlist' => $ngrlist,
+            'recommendList' => $recommendListResult,
+        ];
+        return json($result);
+    }
+
     
     
     /**
     /**
      * bug提交
      * bug提交

+ 2 - 0
app/api/route/pub.php

@@ -40,6 +40,8 @@ Route::group('pub', function () {
     Route::rule('getWorkerList','Pub/getWorkerList');
     Route::rule('getWorkerList','Pub/getWorkerList');
     //获取文章详情
     //获取文章详情
     Route::rule('getArtDetail','pub/getArtDetail');
     Route::rule('getArtDetail','pub/getArtDetail');
+    //课程列表页面
+    Route::rule('index','Pob/index');