소스 검색

购物车商品数量减为0时,删除错误

D 1 년 전
부모
커밋
b22cdae4fe
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      sheep/store/cart.js

+ 7 - 1
sheep/store/cart.js

@@ -57,7 +57,13 @@ const cart = defineStore({
 
     // 移除购物车
     async delete(ids) {
-      const { code } = await CartApi.deleteCart(ids.join(','));
+      let idsTemp = '';
+      if (Array.isArray(ids)) {
+        idsTemp = ids.join(',');
+      } else {
+        idsTemp = ids;
+      }
+      const { code } = await CartApi.deleteCart(idsTemp);
       if (code === 0) {
         await this.getList();
       }