(obj)
| 3 | onLaunch: function () { |
| 4 | }, |
| 5 | addToCart(obj) { |
| 6 | // 1.判断是否已经添加进来 |
| 7 | const oldInfo = this.globalData.cartList.find((item) => item.iid === obj.iid) |
| 8 | if (oldInfo) { |
| 9 | oldInfo.count += 1 |
| 10 | } else { |
| 11 | obj.count = 1 |
| 12 | obj.checked = true |
| 13 | this.globalData.cartList.push(obj) |
| 14 | } |
| 15 | |
| 16 | // 2.购物车回调 |
| 17 | if (this.addCartCallback) { |
| 18 | this.addCartCallback() |
| 19 | } |
| 20 | }, |
| 21 | globalData: { |
| 22 | cartList: [] |
| 23 | } |
nothing calls this directly
no outgoing calls
no test coverage detected