From a6e1218315a79ecf33330ebd0cede2a45b5ef1a5 Mon Sep 17 00:00:00 2001
From: pushuo <229102104@qq.com>
Date: Tue, 28 Jun 2022 21:03:23 +0800
Subject: [PATCH] wip
---
themes/default/cart.blade.php | 45 ++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/themes/default/cart.blade.php b/themes/default/cart.blade.php
index cc8719d1..ba30206b 100644
--- a/themes/default/cart.blade.php
+++ b/themes/default/cart.blade.php
@@ -43,7 +43,7 @@
|
|
@@ -53,7 +53,7 @@
|
@{{ product.subtotal_format }} |
-
+
|
@@ -123,47 +123,58 @@
}
},
- quantityChange(quantity, product_id) {
+ quantityChange(quantity, cart_id) {
+ const self = this;
$.ajax({
- url: `/carts/${product_id}`,
+ url: `/carts/${cart_id}`,
type: 'PUT',
data: {quantity: quantity,},
success: function(res) {
- console.log(res)
+ self.setUpdateData(res);
}
})
},
- checkedBtnDelete(product_id) {
+ checkedBtnDelete(cart_id) {
+ const self = this;
+
$.ajax({
- url: `/carts/${product_id}`,
+ url: `/carts/${cart_id}`,
type: 'DELETE',
success: function(res) {
- console.log(res)
+ self.setUpdateData(res);
}
})
},
- selectedBtnDelete() {
+ selectedBtnSelected() {
+ const self = this;
const product_ids = this.products.filter(e => e.selected).map(x => x.product_id)
$.ajax({
url: `/carts/select`,
type: 'POST',
- data: {ku_ids: product_ids},
+ data: {sku_ids: product_ids},
success: function(res) {
- console.log(res)
+ self.setUpdateData(res);
}
})
},
+
+ setUpdateData(res) {
+ console.log(res)
+ this.products = res.carts
+ this.amount_format = res.amount_format
+ this.total_quantity = res.quantity
+ }
},
// 实例被挂载后调用
mounted () {
- if (this.products.length) {
- this.products.forEach((e) => {
- this.$set(e, 'selected', false)
- })
- }
+ // if (this.products.length) {
+ // this.products.forEach((e) => {
+ // this.$set(e, 'selected', false)
+ // })
+ // }
},
})