浏览代码

商城购物车增加删除提示

skyblued 3 年之前
父节点
当前提交
4f3628b08c
共有 1 个文件被更改,包括 17 次插入13 次删除
  1. 17 13
      src/views/cart/index.tsx

+ 17 - 13
src/views/cart/index.tsx

@@ -1,7 +1,7 @@
 import { defineComponent, ref } from 'vue'
 import ColHeader from '@/components/col-header'
 import styles from './index.module.less'
-import { Checkbox, SubmitBar, Card, Stepper, CheckboxGroup } from 'vant'
+import { Checkbox, SubmitBar, Card, Stepper, CheckboxGroup, Dialog } from 'vant'
 import request from '@/helpers/request'
 import { cartConfirm, formateAttr } from './cart'
 import ColResult from '@/components/col-result'
@@ -88,17 +88,21 @@ export default defineComponent({
     },
 
     async onDeleteCartItem() {
-      const ids = this.selectItems.join(',')
-      try {
-        let { code, data } = await request.post(
-          '/api-mall-portal/cart/delete?ids=' + ids
-        )
-        if (code === 200) {
-          this.getCartList()
-          this.selectItems = []
-          this.isManage = false
-        }
-      } catch (error) {}
+      Dialog.confirm({
+        message: '是否确认删除选中的商品?'
+      }).then(async () => {
+        const ids = this.selectItems.join(',')
+        try {
+          let { code, data } = await request.post(
+            '/api-mall-portal/cart/delete?ids=' + ids
+          )
+          if (code === 200) {
+            this.getCartList()
+            this.selectItems = []
+            this.isManage = false
+          }
+        } catch (error) {}
+      })
     },
     //生成确认订单
     async generateConfirmOrder() {
@@ -170,7 +174,7 @@ export default defineComponent({
                                   e.stopPropagation()
                                 }}
                                 onChange={() => {
-                                  if (item.quantity){
+                                  if (item.quantity) {
                                     this.setCartItem(item)
                                   }
                                 }}