[关闭]
@2890594972 2018-04-13T06:00:50.000000Z 字数 458 阅读 967

面向对象写购物车-重构

面向对象 1511


面向对象分析

image_1cat7hs7s12c21dq91n9h1qf7bka9.png-179.7kB

面向对象设计

  1. // 产品对象
  2. function Product(id, name, price, num, shopId){
  3. this.id = id;
  4. this.name = name;
  5. this.price = price;
  6. this.num = num;
  7. this.shopId = shopId;
  8. }
  9. // 购物车对象
  10. // 用来做什么: 管理数据,实现增删改查
  11. /*
  12. * 管理数据,有增删改查
  13. * add, delete, edit, get.
  14. * isExit
  15. **/
  16. // 用来做什么: 管理事件,用来监听交互事件
  17. /**
  18. * initEvent
  19. * 店铺单个: check
  20. * 店铺全选: checkAll
  21. * 全选: checkTotalAll
  22. * 增加和减少: plus, minus
  23. */
  24. // 用来做什么: 管理UI, 响应UI, 用来更新数据
  25. /**
  26. * 更新店铺价: uiShopTotalPrice,
  27. * 更新所有店铺: uiAllTotalPrice
  28. * 删除页面节点: uiDelete
  29. **/
  30. function Shopcar(){
  31. // 产品列表
  32. this.productList = [];
  33. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注