不支持的方法重写

wechat_user_type
Ge Hao 8 years ago
parent e596439939
commit fb252e1284
  1. 12
      pages/category/category.js
  2. 2
      pages/show_product/show_product.js

@ -32,13 +32,15 @@ Page({
bindTapProduct: function(e) {
var that = this
var cartItems = wx.getStorageSync('cartItems') || []
var thisItem = this.data.items.find(function(ele){
var thisItem = this.data.items.filter(function(ele){
return ele.id === e.currentTarget.dataset.id
})
})[0]
var exist = cartItems.find(function(ele){
return ele.id === thisItem.id
})
if (thisItem) {
var exist = cartItems.filter(function(ele){
return ele.id === thisItem.id
})[0]
}
if (exist) {
exist.quantity = parseInt(exist.quantity) + 1

@ -11,7 +11,7 @@ Page({
onLoad (params) {
var allProducts = wx.getStorageSync('products')
var id = params.id
var product = wx.getStorageSync('products').filter(function(i){
var product = allProducts.filter(function(i){
return i.id === id
})[0]

Loading…
Cancel
Save