Browse Source

SEO友好型路由

zhangdehua 10 tháng trước cách đây
mục cha
commit
f7f9f17556
2 tập tin đã thay đổi với 13 bổ sung12 xóa
  1. 7 6
      app/index/controller/Index.php
  2. 6 6
      app/index/view/index/index.html

+ 7 - 6
app/index/controller/Index.php

@@ -130,9 +130,9 @@ class Index extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function productDetails()
+    public function productDetails($goodsId)
     {
-        $goodsId = $this->request->param('goodsId', 0);
+        //$goodsId = $this->request->param('goodsId', 0);
         if (empty($goodsId)) {
             return \redirect('index');
         }
@@ -154,7 +154,7 @@ class Index extends Controller
 
     public function aboutUs(): View
     {
-        return view('aboutUs');
+        return view('index/aboutUs');
     }
 
     public function privacyPolicy(): View
@@ -177,9 +177,9 @@ class Index extends Controller
         return view('returnWarranty');
     }
 
-    public function newsDetail(): View
+    public function newsDetail($newsId): View
     {
-        $newsId = $this->request->param('newsId');
+        //$newsId = $this->request->param('newsId');
         if (empty($newsId)) {
             return view('/error');
         }
@@ -189,8 +189,9 @@ class Index extends Controller
         return view('newsDetails', ['article' => $article]);
     }
 
-    public function goldTest()
+    public function goldTest($name)
     {
+        dd('this is '.$name);
         $service = new OrderGetYundanService();
         $r = $service->orderCreateYundans($this->storeId);
         dd($r);

+ 6 - 6
app/index/view/index/index.html

@@ -43,7 +43,7 @@
         <div class="goodsModel" id="newGoodsModel" data-type="new">
             <div class="newGoodsContainer">
                 {foreach $newGoods as $goods}
-                <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
+                <a href="/index/index/productDetails/goodsId/{$goods['goods_id']}.html">
                     <div class="newGoodsItem" data-id="{$goods['goods_id']}">
                         <div class="goodsImgBox">
                             <img class="lazy" src="/assets/index/asstes/icon/transparent.png"
@@ -97,7 +97,7 @@
         <div class="goodsModel" id="bestGoodsModel" data-type="best">
             <div class="newGoodsContainer">
                 {foreach $bestseller as $goods}
-                <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
+                <a href="/index/index/productDetails/goodsId/{$goods['goods_id']}.html">
                     <div class="newGoodsItem" data-id="{$goods['goods_id']}">
                         <div class="goodsImgBox" data-id="{$goods['goods_id']}">
                             <img class="lazy" src="{$goods['goods_images'][0]['preview_url']}"
@@ -160,7 +160,7 @@
         </div>
         <div class="newConterBox">
             {foreach $article as $art}
-            <a href="/index/index/newsDetail.html?newsId={$art['article_id']}">
+            <a href="/index/index/newsDetail/newsId/{$art['article_id']}.html">
                 <div class="newConterItem">
                     <div class="newsDateBox">
                         <p>{$art['month_day']}</p>
@@ -194,7 +194,7 @@
         <h2 class="superDealTitle">Super Deal</h2>
         <div class="newGoodsContainer ">
             {foreach $superDealsOne as $deal}
-            <a href="/index/index/productDetails.html?goodsId={$deal['goods_id']}">
+            <a href="/index/index/productDetails/goodsId/{$deal['goods_id']}.html">
                 <div class="newGoodsItem" data-id="{$deal['goods_id']}">
                     <div class="newGoodsTag">New</div>
                     <div class="goodsImgBox">
@@ -241,8 +241,8 @@
         </div>
         <div class="newGoodsContainer ">
             {foreach $superDealsTwo as $deal}
-            <a href="/index/index/productDetails.html?goodsId={$goods['goods_id']}">
-                <div class="newGoodsItem" data-id="{$goods['goods_id']}">
+            <a href="/index/index/productDetails/goodsId/{$deal['goods_id']}.html">
+                <div class="newGoodsItem" data-id="{$deal['goods_id']}">
                     <div class="newGoodsTag">New</div>
                     <div class="goodsImgBox">
                         <img class="lazy" src="/assets/index/asstes/icon/transparent.png"