541469799@qq.com 1 vuosi sitten
vanhempi
commit
84981905e7

+ 7 - 2
app/index/controller/Cart.php

@@ -99,7 +99,7 @@ class Cart extends Controller
     {
         $userId = Session::get('user_id');
         if (empty($userId)) {
-            return $this->renderError( 'Log in');
+            return $this->renderJson( config('status.not_logged'),'Log in please!');
         }
 
         $model = new CartModel;
@@ -126,8 +126,13 @@ class Cart extends Controller
     {
         $userId = Session::get('user_id');
         if (empty($userId)) {
-            return $this->renderError( 'Log in');
+            return $this->renderJson( config('status.not_logged'),'Log in please!');
         }
+
+        if ($goodsNum <= 0){
+            return $this->renderError('Action Not Supported!');
+        }
+
         $model = new CartModel;
         if (!$model->sUpdate($goodsId, $goodsSkuId, $goodsNum)) {
             return $this->renderError($model->getError() ?: '更新失败');

+ 4 - 0
app/index/controller/User.php

@@ -18,6 +18,10 @@ class User extends Controller
 
     public function personal()
     {
+        $userId = Session::get('user_id');
+        if (empty($userId)) {
+            return view('passport/login');
+        }
         $goodsModel = new GoodsModel();
         //$goods['content'] = html_entity_decode($goods['content']);
         return view('personal', ['goods' => []]);

+ 3 - 1
app/index/view/index/productDetails.html

@@ -369,8 +369,10 @@
                         showToast("Successful")
                         window.location.href = '../cart/shoppingCart';
                         return
-                    }else {
+                    }else if (obj.status === 401 || obj.status === '401'){
                         window.location.replace('../passport/logIn.html')
+                    }else {
+                        showToast(obj.message)
                     }
                 }
             })

+ 1 - 1
app/index/view/user/personal.html

@@ -234,7 +234,7 @@
         function isLogin() {
             //用户token
             const vapesToken = localStorage.getItem("vapes_token")
-            if (!vapesToken || vapesToken == "") {
+            if (!vapesToken || vapesToken === "") {
                 setTimeout(() => {
                     window.location.href = "./login.html?return=1"
                 }, 80)