陈德本 6 лет назад
Родитель
Сommit
8815ddca51
4 измененных файлов с 44 добавлено и 10 удалено
  1. 9 1
      App/Api/Config/Route.php
  2. 10 2
      App/Api/Controller/Index.php
  3. 4 0
      App/Api/Controller/Search.php
  4. 21 7
      App/Api/Model/Dataoke.php

+ 9 - 1
App/Api/Config/Route.php

@@ -23,8 +23,12 @@ class Route extends Config
             "action" => "Heanup\App\Api\Controller\Category"
         ], [
             "name" => "搜索",
-            "pattern" => "/kw/:s.html",//api/material/sort/beauty/pre
+            "pattern" => "/kw/:s/index.html",//api/material/sort/beauty/pre
             "action" => "Heanup\App\Api\Controller\Search"
+        ],[
+            "name" => "搜索",
+            "pattern" => "/kw/:s/page_:s.html",//api/material/sort/beauty/pre
+            "action" => "Heanup\App\Api\Controller\Category"
         ], [
             "name" => "详情页",
             "pattern" => "/product/:s.html",//api/material/sort/beauty/pre
@@ -33,6 +37,10 @@ class Route extends Config
             "name" => "专题页",
             "pattern" => "/pages/:s.html",//api/material/sort/beauty/pre
             "action" => "Heanup\App\Api\Controller\Pages"
+        ],[
+            'name'=>'首页',
+             "pattern" => "/page_:s.html",
+            "action" => "Heanup\App\Api\Controller\Index"
         ]
     ];
 }

+ 10 - 2
App/Api/Controller/Index.php

@@ -13,9 +13,17 @@ class Index extends Controller
 
     protected function main()
     {
-        $url = Site::getData('site_url') . "/tao.php?r=index/index";
+        $url = Site::getData('site_url') . "/tao.php";
+        $page = $this->getQuery()->string("args_0");
+        $request=[
+            'r'=>'l',
+        ];
+        if ($page){
+            $request['page']=$page;
+        }
+        $url=$url."?".http_build_query($request);
         $content= Dataoke::parse(file_get_contents($url));
-        $this->setCache($content);
+//        $this->setCache($content);
         echo $content;
     }
 }

+ 4 - 0
App/Api/Controller/Search.php

@@ -15,6 +15,7 @@ class Search extends Controller
         $kw = $this->getQuery()->string("kw")?:$this->getQuery()->string("args_0");
         $bids = $this->getQuery()->string("bids");
         $cid = $this->getQuery()->string("cid");
+        $page = $this->getQuery()->string("args_1");
         $request=[
             'r'=>'l',
             'u'=>Site::getData("user_tag")
@@ -28,6 +29,9 @@ class Search extends Controller
         if ($cid){
             $request['cid']=$cid;
         }
+        if ($page){
+            $request['page']=$page;
+        }
 
         $url = Site::getData('site_url') . "/tao.php?".http_build_query($request);
         $content= Dataoke::parse(file_get_contents($url));

+ 21 - 7
App/Api/Model/Dataoke.php

@@ -35,7 +35,7 @@ class Dataoke
             if ($t['bids']) {
                 $q['bids'] = $t['bids'];
             }
-            if ($t['original_id']){
+            if ($t['original_id']) {
                 $q['original_id'] = $t['original_id'];
             }
 
@@ -47,7 +47,15 @@ class Dataoke
                 } else {
                     $s = "";
                 }
-                $new_url = "/kw/" . $t['kw'] . ".html" . $s;
+                if ($t['page']) {
+                    $new_url = "/kw/" . $t['kw'] . "/page_" . $t['page'] . ".html" . $s;
+                    $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
+                    $url = htmlentities($url);
+                    $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
+                } else {
+                    $new_url = "/kw/" . $t['kw'] . "/index.html" . $s;
+                }
+//                $new_url = "/kw/" . $t['kw'] . ".html" . $s;
                 $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
             } else {
                 if ($t['cid']) {
@@ -57,13 +65,13 @@ class Dataoke
                     } else {
                         $s = "";
                     }
-                    if ($t['page']){
-                        $new_url = "/category/".$t['cid']."/page_" . $t['page'] . ".html".$s;
+                    if ($t['page']) {
+                        $new_url = "/category/" . $t['cid'] . "/page_" . $t['page'] . ".html" . $s;
                         $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
-                        $url=htmlentities($url);
+                        $url = htmlentities($url);
                         $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
-                    }else{
-                        $new_url = "/category/" . $t['cid'] . "/index.html".$s;
+                    } else {
+                        $new_url = "/category/" . $t['cid'] . "/index.html" . $s;
                     }
                     $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
                 } else {
@@ -71,6 +79,12 @@ class Dataoke
                         $new_url = "/product/" . $t['id'] . ".html";
                         $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
                     }
+                    if ($t['page'] && $t['r'] == 'l') {
+                        $new_url = "/page_" . $t['page'] . ".html";
+                        $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
+                        $url = htmlentities($url);
+                        $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
+                    }
                 }
 
             }