MyOrderController.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // MyOrderController.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/17.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 我的订单
  8. #import "MyOrderController.h"
  9. #import "VideoOrderController.h"
  10. #import "SkillOrderController.h"
  11. #import "MyOrderCell.h"
  12. @interface MyOrderController ()<UITableViewDelegate, UITableViewDataSource>
  13. @property (nonatomic, strong) UITableView *tableView;
  14. @property (nonatomic, strong) NSArray *orderArr; //订单数组
  15. @end
  16. @implementation MyOrderController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. if ([[ModelUser user].modelpk isEqualToString:@"51"]) {
  20. self.orderArr = @[@{@"iconName":@"jineng-1",@"title":@"技能订单"}];
  21. }else{
  22. self.orderArr = @[@{@"iconName":@"shipin",@"title":@"视频订单"},@{@"iconName":@"jineng-1",@"title":@"技能订单"}];
  23. }
  24. //设置导航条
  25. [self creatNavBar];
  26. //设置子试图
  27. [self creatSubViews];
  28. }
  29. - (void)didReceiveMemoryWarning {
  30. [super didReceiveMemoryWarning];
  31. // Dispose of any resources that can be recreated.
  32. }
  33. - (void)creatNavBar {
  34. self.title = @"我的订单";
  35. //
  36. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  37. btn.frame = CGRectMake(0, 0, 40, 40);
  38. [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
  39. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
  40. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  41. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  42. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  43. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  44. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  45. }
  46. - (void)backClick {
  47. [self.navigationController popViewControllerAnimated:YES];
  48. }
  49. - (void)creatSubViews {
  50. //
  51. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
  52. self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  53. self.tableView.delegate = self;
  54. self.tableView.dataSource = self;
  55. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  56. self.tableView.tableFooterView = [[UIView alloc] init];
  57. [self.view addSubview:self.tableView];
  58. }
  59. #pragma mark -- UITableViewDelegate, UITableViewDataSource
  60. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  61. return self.orderArr.count;
  62. }
  63. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  64. static NSString *cellid = @"OrderCell";
  65. MyOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
  66. if (!cell) {
  67. cell = [[MyOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
  68. }
  69. if (indexPath.row == 1) {
  70. cell.lineView.hidden = YES;
  71. }
  72. [cell setMyOrderCellValueWithDic:self.orderArr[indexPath.row] titleStr:@"myOrder"];
  73. return cell;
  74. }
  75. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  76. return 75;
  77. }
  78. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  79. if ([[ModelUser user].modelpk isEqualToString:@"51"]) {
  80. SkillOrderController *videoVC = [[SkillOrderController alloc] init];
  81. [self.navigationController pushViewController:videoVC animated:YES];
  82. }else{
  83. if (indexPath.row == 0) {
  84. VideoOrderController *videoVC = [[VideoOrderController alloc] init];
  85. [self.navigationController pushViewController:videoVC animated:YES];
  86. } else {
  87. SkillOrderController *videoVC = [[SkillOrderController alloc] init];
  88. [self.navigationController pushViewController:videoVC animated:YES];
  89. }
  90. }
  91. }
  92. @end