zhangdehua 1 年間 前
コミット
a3f2b784d5

+ 6 - 0
app/api/controller/Cart.php

@@ -30,6 +30,12 @@ class Cart extends Controller
      */
     public function myCart()
     {
+        // 购物车商品列表
+//        $service = new CartService;
+//        $list = $service->getList();
+//        // 购物车商品总数量
+//        $cartTotal = (new CartModel)->getCartTotal();
+
         return view('shoppingCart');
     }
 

+ 1 - 1
app/api/controller/Comment.php

@@ -25,7 +25,7 @@ class Comment extends Controller
      * 商品评价列表
      * @param int $goodsId 商品ID
      * @param int|null $scoreType 评价评分
-     * @return array
+     * @return \think\response\Json
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException

+ 17 - 0
app/api/view/cart/shoppingCart.html

@@ -282,6 +282,7 @@
 <script src="/assets/api/js/jquery.lazyload.js"></script>
 <script>
     $(document).ready(function () {
+        const VAPES_TOKEN = "vapes_token"
 
         //支付方法
         const orderPayment = (params) => {
@@ -373,6 +374,22 @@
             productOperate($(this), "delete")
         })
 
+        //前往购物车
+        $(".shoppingCartIcon").on(tap, function () {
+            const state = isLogin()
+            if (state) {
+                window.location.href = "/api/cart/myCart.html"
+            }
+        });
+
+        const isLogin = (state) => {
+            const vapesToken = localStorage.getItem(VAPES_TOKEN);
+            state = state || true;
+            if (!vapesToken || vapesToken === "" && state) {
+                window.location.href = "./login.html?return=1"
+            }
+            return vapesToken && vapesToken !== "";
+        }
     })
 </script>
 

+ 1 - 1
app/api/view/index/index.html

@@ -563,7 +563,7 @@
         $(".shoppingCartIcon").on(tap, function () {
             const state = isLogin()
             if (state) {
-
+                window.location.href = "/api/cart/myCart.html"
             }
         });
 

+ 8 - 0
app/api/view/index/productDetails.html

@@ -435,6 +435,14 @@
             }
         });
         initRichText()
+
+        //前往购物车
+        $(".shoppingCartIcon").on(tap, function () {
+            const state = isLogin()
+            if (state) {
+                window.location.href = "/api/cart/myCart.html"
+            }
+        });
     });
 </script>