# JSShopCartModule **Repository Path**: bigCoww/JSShopCartModule ## Basic Information - **Project Name**: JSShopCartModule - **Description**: 购物车通用模板 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-13 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JSShopCartModule [![GitHub license](https://img.shields.io/badge/platform-ios-green.svg )](https://github.com/josin22/JSShopCartModule) ![GitHub license](https://img.shields.io/badge/license-MIT-green.svg) [![CocoaPods Compatible](https://img.shields.io/badge/build-passing-green.svg)](https://github.com/josin22/JSShopCartModule) # 开始之前你需要了解的 ## 配置CocoaPods 安装[CocoaPods](https://cocoapods.org/)命令 gem install cocoapods ##使用RVM安装的Ruby不需要sudo ## 配置ReactiveCocoa 然后在你的Podfile添加一下代码 platform :ios, '8.0' use_frameworks! target '你的项目工程名' do pod 'ReactiveObjC' end 最后输入命令安装 pod install 另外常用的pod 命令 pod install --verbose --no-repo-update ##安装不更新的 pod update --verbose --no-repo-update ##更新需要更新的 打开 你的项目工程名.xcworkspace 即可~ RAC在此我就不仔细介绍了,先推荐几遍文章: Mattt Thompson写的[Reactive​Cocoa](http://nshipster.com/reactivecocoa/) Ash Furrow写的 [Getting Started with ReactiveCocoa](http://www.teehanlax.com/blog/getting-started-with-reactivecocoa/) ## 了解MVVM Google了看几篇有关的文章 [Basic MVVM with ReactiveCocoa](http://cocoasamurai.blogspot.sg/2013/03/basic-mvvm-with-reactivecocoa.html) [MVVM-IOS-Example](https://github.com/Machx/MVVM-IOS-Example) [MVVM 介绍](https://objccn.io/issue-13-1/) 译 朱宏旭 简单的介绍一下: M:model放一些数据模型 V:view视图 V:viewcontroller控制器 VM:viewmodel主要做处理逻辑和处理数据 --- # 开始着手代码 ## 项目演示 ![image](https://raw.githubusercontent.com/Josin22/JSShopCartModule/master/Source/gig1.gif) <<<<<<< HEAD ## 项目搭建框架 整体文件目录按照模块分一下子文件 ViewController : ViewController ##加载视图事件监听等等 Model : model ##基本数据模型 View : cell ##cell numbercount ##封装加减控件 header ##店铺之类 footer ##小结 cartbar ##封装购物车底部view ViewModel : service ##抽离tableview的datasource和delegate viewmodel ##处理主要的逻辑和数据 ## viewmodel类方法属性解析 ### 获取数据方法 1.循环20个从0到5之间随机取数组里取值加到最终的cartData数组里 2.店铺选择shopSelectArray默认NO状态 3.统计总共购物车数量cartGoodsCount - (void)getData{ //数据个数 NSInteger allCount = 20; NSInteger allGoodsCount = 0; NSMutableArray *storeArray = [NSMutableArray arrayWithCapacity:allCount]; NSMutableArray *shopSelectAarry = [NSMutableArray arrayWithCapacity:allCount]; //创造店铺数据 for (int i = 0; i