Ver Fonte

delete api fule

zhangdehua há 1 ano atrás
pai
commit
ee540f5c4e

+ 4 - 4
app/index/controller/Cart.php

@@ -95,11 +95,11 @@ class Cart extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function add(int $goodsId, string $goodsSkuId, int $goodsNum)
+    public function add(int $goodsId, string $goodsSkuId, int $goodsNum) :Json
     {
         $userId = Session::get('user_id');
         if (empty($userId)) {
-            return view('passport/logIn');
+            return $this->renderError( 'Log in');
         }
 
         $model = new CartModel;
@@ -116,7 +116,7 @@ class Cart extends Controller
      * @param int $goodsId 商品ID
      * @param string $goodsSkuId 商品sku索引
      * @param int $goodsNum 商品数量
-     * @return Json |\think\response\View
+     * @return Json
      * @throws BaseException
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -126,7 +126,7 @@ class Cart extends Controller
     {
         $userId = Session::get('user_id');
         if (empty($userId)) {
-            return view('passport/logIn');
+            return $this->renderError( 'Log in');
         }
         $model = new CartModel;
         if (!$model->sUpdate($goodsId, $goodsSkuId, $goodsNum)) {

+ 4 - 0
app/index/view/index/productDetails.html

@@ -369,6 +369,8 @@
                         showToast("Successful")
                         window.location.href = '../cart/shoppingCart';
                         return
+                    }else {
+                        window.location.replace('../passport/logIn.html')
                     }
                 }
             })
@@ -439,6 +441,7 @@
         initRichText()
 
         //前往购物车
+/*
         $(".shoppingCartIcon").on(tap, function () {
             const state = isLogin()
             if (state) {
@@ -468,6 +471,7 @@
                 })
             }
         });
+*/
     });
 </script>