Commit 00430ebcaf2a7af20f9b4930fa8daef48f052f77
1 parent
2a2948fd
no message
Showing
4 changed files
with
91 additions
and
21 deletions
CNLiveMineModule/Classes/Controller/CNLiveMineController.m
| ... | ... | @@ -43,31 +43,82 @@ static const CGFloat timeValue = 1.5; |
| 43 | 43 | @"name":@"我的订单", |
| 44 | 44 | @"style":@"1", |
| 45 | 45 | @"margin":@"10", |
| 46 | - @"titles":@[@"订单", @"待付款", @"待收货",@"待评价",@"售后"], | |
| 47 | - @"images":@[@"mine_order",@"mine_pending",@"mine_received",@"mine_evaluate",@"mine_refund"] | |
| 46 | + @"buttons":@[@{ | |
| 47 | + @"title":@"订单", | |
| 48 | + @"image":@"mine_order" | |
| 49 | + },@{ | |
| 50 | + @"title":@"待付款", | |
| 51 | + @"image":@"mine_pending" | |
| 52 | + },@{ | |
| 53 | + @"title":@"待收货", | |
| 54 | + @"image":@"mine_received" | |
| 55 | + },@{ | |
| 56 | + @"title":@"待评价", | |
| 57 | + @"image":@"mine_evaluate" | |
| 58 | + },@{ | |
| 59 | + @"title":@"售后", | |
| 60 | + @"image":@"mine_refund" | |
| 61 | + } | |
| 62 | + ] | |
| 48 | 63 | }, |
| 49 | 64 | @{ |
| 50 | 65 | @"name":@"常用工具", |
| 51 | 66 | @"style":@"2", |
| 52 | 67 | @"margin":@"10", |
| 53 | - @"titles": @[@"收货地址", @"补贴余额", @"我的收藏",@"发布记录",@"邀请好友",@"设置",@"小家音响",@"我的礼盒",@"路径工具"], | |
| 54 | - @"images":@[@"mine_address",@"mine_card",@"mine_like",@"mine_release",@"mine_invitation",@"mine_set",@"mine_home_box",@"mine_gift_box",@"mine_tool_map"] | |
| 68 | + @"buttons":@[@{ | |
| 69 | + @"title":@"收货地址", | |
| 70 | + @"image":@"mine_address" | |
| 71 | + },@{ | |
| 72 | + @"title":@"补贴余额", | |
| 73 | + @"image":@"mine_card" | |
| 74 | + },@{ | |
| 75 | + @"title":@"我的收藏", | |
| 76 | + @"image":@"mine_like" | |
| 77 | + },@{ | |
| 78 | + @"title":@"发布记录", | |
| 79 | + @"image":@"mine_release" | |
| 80 | + },@{ | |
| 81 | + @"title":@"邀请好友", | |
| 82 | + @"image":@"mine_invitation" | |
| 83 | + },@{ | |
| 84 | + @"title":@"设置", | |
| 85 | + @"image":@"mine_set" | |
| 86 | + },@{ | |
| 87 | + @"title":@"小家音响", | |
| 88 | + @"image":@"mine_home_box" | |
| 89 | + },@{ | |
| 90 | + @"title":@"我的礼盒", | |
| 91 | + @"image":@"mine_gift_box" | |
| 92 | + },@{ | |
| 93 | + @"title":@"路径工具", | |
| 94 | + @"image":@"mine_tool_map" | |
| 95 | + } | |
| 96 | + ] | |
| 55 | 97 | }, |
| 56 | 98 | @{ |
| 57 | 99 | @"name":@"购买的商品", |
| 58 | 100 | @"pic":@"mine_buy_commodity", |
| 59 | 101 | @"style":@"3", |
| 60 | 102 | @"margin":@"10", |
| 61 | - @"titles": @[@"电子票"], | |
| 62 | - @"images":@[@"mine_e-ticket"] | |
| 103 | + @"buttons":@[@{ | |
| 104 | + @"title":@"电子票", | |
| 105 | + @"image":@"mine_e-ticket" | |
| 106 | + } | |
| 107 | + ] | |
| 63 | 108 | }, |
| 64 | 109 | @{ |
| 65 | 110 | @"name":@"大众体育", |
| 66 | 111 | @"pic":@"mine_china_sport", |
| 67 | 112 | @"style":@"4", |
| 68 | 113 | @"margin":@"10", |
| 69 | - @"titles": @[@"我的活动", @"我的记录"], @"images":@[@"mine_activity",@"mine_record"] | |
| 70 | - | |
| 114 | + @"buttons":@[@{ | |
| 115 | + @"title":@"我的活动", | |
| 116 | + @"image":@"mine_activity" | |
| 117 | + },@{ | |
| 118 | + @"title":@"我的记录", | |
| 119 | + @"image":@"mine_record" | |
| 120 | + } | |
| 121 | + ] | |
| 71 | 122 | } |
| 72 | 123 | ]; |
| 73 | 124 | for(NSDictionary *dic in data){ |
| ... | ... | @@ -336,6 +387,7 @@ static const CGFloat timeValue = 1.5; |
| 336 | 387 | } |
| 337 | 388 | return _data; |
| 338 | 389 | } |
| 390 | + | |
| 339 | 391 | - (CNLiveMineNavigationBar *)navigationBar { |
| 340 | 392 | if (!_navigationBar) { |
| 341 | 393 | _navigationBar = [[CNLiveMineNavigationBar alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)]; | ... | ... |
CNLiveMineModule/Classes/Model/CNLiveMineModel.h
| ... | ... | @@ -17,14 +17,19 @@ typedef NS_ENUM(NSInteger, CNLiveMineCellType) { |
| 17 | 17 | |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | +@interface CNLiveMineButtonModel : NSObject | |
| 21 | +@property (nonatomic, copy) NSString *title; | |
| 22 | +@property (nonatomic, copy) NSString *image; | |
| 23 | + | |
| 24 | +@end | |
| 25 | + | |
| 20 | 26 | @interface CNLiveMineModel : NSObject |
| 21 | 27 | @property (nonatomic, copy) NSString *name; |
| 22 | 28 | @property (nonatomic, copy) NSString *pic; |
| 23 | 29 | |
| 24 | 30 | @property (nonatomic, copy) NSString *style; |
| 25 | 31 | |
| 26 | -@property (nonatomic, strong) NSArray *titles; | |
| 27 | -@property (nonatomic, strong) NSArray *images; | |
| 32 | +@property (nonatomic, strong) NSArray *buttons; | |
| 28 | 33 | |
| 29 | 34 | @property (nonatomic, assign) CNLiveMineCellType type; |
| 30 | 35 | ... | ... |
CNLiveMineModule/Classes/Model/CNLiveMineModel.m
| ... | ... | @@ -10,7 +10,11 @@ |
| 10 | 10 | |
| 11 | 11 | @implementation CNLiveMineModel |
| 12 | 12 | static const NSInteger margin = 10; |
| 13 | - | |
| 13 | ++ (NSDictionary *)mj_objectClassInArray{ | |
| 14 | + return @{ | |
| 15 | + @"buttons" : @"CNLiveMineButtonModel" | |
| 16 | + }; | |
| 17 | +} | |
| 14 | 18 | - (CNLiveMineCellType)type{ |
| 15 | 19 | if([self.style isEqualToString:@"1"]){ |
| 16 | 20 | return CNLiveMineCellTypeOrder; |
| ... | ... | @@ -40,7 +44,7 @@ static const NSInteger margin = 10; |
| 40 | 44 | } |
| 41 | 45 | //工具 |
| 42 | 46 | else if(self.type == CNLiveMineCellTypeTool){ |
| 43 | - return 2*margin+titleHeight+ceilf(self.titles.count/4.0)*(btnHeight+margin); | |
| 47 | + return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin); | |
| 44 | 48 | |
| 45 | 49 | } |
| 46 | 50 | //商品 |
| ... | ... | @@ -51,10 +55,15 @@ static const NSInteger margin = 10; |
| 51 | 55 | } |
| 52 | 56 | //大众体育 |
| 53 | 57 | else if(self.type == CNLiveMineCellTypeSports){ |
| 54 | - return 2*margin+titleHeight+ceilf(self.titles.count/4.0)*(btnHeight+margin); | |
| 58 | + return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin); | |
| 55 | 59 | |
| 56 | 60 | } |
| 57 | 61 | return 0.0000001f; |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | @end |
| 65 | + | |
| 66 | +@implementation CNLiveMineButtonModel | |
| 67 | + | |
| 68 | + | |
| 69 | +@end | ... | ... |
CNLiveMineModule/Classes/View/CNLiveMineCell.m
| ... | ... | @@ -112,11 +112,12 @@ |
| 112 | 112 | }]; |
| 113 | 113 | |
| 114 | 114 | CGFloat width = SCREEN_WIDTH-2*self.model.margin; |
| 115 | - CGFloat btnWidth = width/self.model.titles.count*1.0; | |
| 115 | + CGFloat btnWidth = width/self.model.buttons.count*1.0; | |
| 116 | 116 | CGFloat btnHeight = 60; |
| 117 | 117 | |
| 118 | - for(int i = 0; i < self.model.titles.count; i++){ | |
| 119 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*i, 50+self.model.margin, btnWidth, btnHeight) title:self.model.titles[i] image:self.model.images[i] tag:10000+i]; | |
| 118 | + for(int i = 0; i < self.model.buttons.count; i++){ | |
| 119 | + CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | |
| 120 | + UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*i, 50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | |
| 120 | 121 | [self addSubview:btn]; |
| 121 | 122 | |
| 122 | 123 | } |
| ... | ... | @@ -155,10 +156,11 @@ |
| 155 | 156 | CGFloat btnWidth = width/4.0; |
| 156 | 157 | CGFloat btnHeight = 60; |
| 157 | 158 | |
| 158 | - for(int i = 0; i < self.model.titles.count; i++){ | |
| 159 | + for(int i = 0; i < self.model.buttons.count; i++){ | |
| 160 | + CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | |
| 159 | 161 | NSInteger row = i % 4; |
| 160 | 162 | NSInteger col = floorf(i / 4.0); |
| 161 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:self.model.titles[i] image:self.model.images[i] tag:10000+i]; | |
| 163 | + UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | |
| 162 | 164 | [self addSubview:btn]; |
| 163 | 165 | |
| 164 | 166 | } |
| ... | ... | @@ -197,7 +199,8 @@ |
| 197 | 199 | CGFloat btnHeight = 80; |
| 198 | 200 | |
| 199 | 201 | // 电子票 |
| 200 | - UIButton *btn = [self createButtonWithFrame:CGRectMake((width-btnWidth)/2.0, self.model.margin+50, btnWidth, btnHeight) title:self.model.titles[0] image:self.model.images[0] tag:10000]; | |
| 202 | + CNLiveMineButtonModel *buttonModel = self.model.buttons[0]; | |
| 203 | + UIButton *btn = [self createButtonWithFrame:CGRectMake((width-btnWidth)/2.0, self.model.margin+50, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000]; | |
| 201 | 204 | [self addSubview:btn]; |
| 202 | 205 | |
| 203 | 206 | } |
| ... | ... | @@ -236,10 +239,11 @@ |
| 236 | 239 | CGFloat btnWidth = width/4.0; |
| 237 | 240 | CGFloat btnHeight = 60; |
| 238 | 241 | |
| 239 | - for(int i = 0; i < self.model.titles.count; i++){ | |
| 242 | + for(int i = 0; i < self.model.buttons.count; i++){ | |
| 243 | + CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | |
| 240 | 244 | NSInteger row = i % 4; |
| 241 | 245 | NSInteger col = floorf(i / 4.0); |
| 242 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:self.model.titles[i] image:self.model.images[i] tag:10000+i]; | |
| 246 | + UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | |
| 243 | 247 | [self addSubview:btn]; |
| 244 | 248 | |
| 245 | 249 | } | ... | ... |