From 024693a55cac7fef2b6f415f5cd2bc302f573f44 Mon Sep 17 00:00:00 2001 From: Ge Hao Date: Thu, 20 Oct 2016 15:09:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=20=E6=95=B0=E9=87=8F=E5=8F=A0=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/category/category.js | 6 +++--- pages/category/category.wxml | 2 +- pages/show_product/show_product.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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,