diff --git a/pages/category/category.js b/pages/category/category.js index 10c3465..49f2ccb 100644 --- a/pages/category/category.js +++ b/pages/category/category.js @@ -24,7 +24,7 @@ Page({ }) }, - bindShowProduct: function(e) { + bindTapProduct: function(e) { var that = this var cartItems = wx.getStorageSync('cartItems') || [] var thisItem = this.data.items.find(function(ele){ @@ -32,11 +32,11 @@ Page({ }) var exist = cartItems.find(function(ele){ - return ele.id === that.data.id + return ele.id === thisItem.id }) if (exist) { - exist.quantity = '1' + exist.quantity = parseInt(exist.quantity) + 1 } else { cartItems.push({ id: thisItem.id, diff --git a/pages/category/category.wxml b/pages/category/category.wxml index 1fd5929..2a2bdf2 100644 --- a/pages/category/category.wxml +++ b/pages/category/category.wxml @@ -1,7 +1,7 @@ - + {{item.name}} diff --git a/pages/show_product/show_product.js b/pages/show_product/show_product.js index de91fac..b19bbd8 100644 --- a/pages/show_product/show_product.js +++ b/pages/show_product/show_product.js @@ -34,7 +34,7 @@ Page({ }) if (exist) { - exist.quantity = this.data.quantity + exist.quantity = parseInt(exist.quantity) + 1 } else { cartItems.push({ id: this.data.id,