MyOrderViewController.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // MyOrderViewController.m
  3. // BuguLive
  4. //
  5. // Created by yy on 16/11/17.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "MyOrderViewController.h"
  9. NS_ENUM(NSInteger,orderScroll)
  10. {
  11. Eorder_shopping, //购物
  12. Eorder_auction, //竞拍
  13. Eorder_count,
  14. };
  15. @interface MyOrderViewController ()<SegmentViewDelegate,UIScrollViewDelegate>
  16. {
  17. BGMainWebViewController *_shoppingVC; //购物
  18. BGMainWebViewController *_auctionVC; //竞拍
  19. GlobalVariables *_BuguLive;
  20. NSArray *_listItems;
  21. UIView *_headView;
  22. CGRect _listSegmentFrame;
  23. UIScrollView *_tScrollView;
  24. }
  25. @end
  26. @implementation MyOrderViewController
  27. - (void)viewWillAppear:(BOOL)animated
  28. {
  29. [super viewWillAppear:animated];
  30. _headView.hidden = NO;
  31. }
  32. - (void)viewDidLoad
  33. {
  34. [super viewDidLoad];
  35. _BuguLive = [GlobalVariables sharedInstance];
  36. self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(backClick) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  37. self.view.backgroundColor = kNavBarThemeColor;
  38. //分段视图
  39. _listItems =[NSArray arrayWithObjects:ASLocalizedString(@"购物"),ASLocalizedString(@"竞拍"), nil];
  40. [self createHeadView];
  41. }
  42. - (void)viewWillDisappear:(BOOL)animated
  43. {
  44. _headView.hidden = YES;
  45. }
  46. #pragma mark 导航栏部分
  47. - (void)createHeadView
  48. {
  49. _headView = [[UIView alloc]initWithFrame:CGRectMake(kScreenW/4, 0, kScreenW/2, 44)];
  50. _headView.backgroundColor = [UIColor clearColor];
  51. [self.navigationController.navigationBar addSubview:_headView];
  52. _listSegmentFrame =CGRectMake(0, 0, kScreenW/2, 44);
  53. _listSegmentView = [[SegmentView alloc]initWithFrame:_listSegmentFrame andItems:_listItems andSize:17 border:NO isrankingRist:YES];
  54. _listSegmentView.backgroundColor = [UIColor clearColor];
  55. _listSegmentView.delegate = self;
  56. [_listSegmentView setSelectIndex:0];
  57. [_headView addSubview:_listSegmentView];
  58. _tScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-kNavigationBarHeight-kStatusBarHeight )];
  59. _tScrollView.backgroundColor = [UIColor whiteColor];
  60. _tScrollView.contentSize = CGSizeMake(Eorder_count*kScreenW, 0);
  61. _tScrollView.pagingEnabled = YES;
  62. _tScrollView.bounces = NO;
  63. _tScrollView.showsHorizontalScrollIndicator = NO;
  64. _tScrollView.delegate = self;
  65. [self.view addSubview:_tScrollView];
  66. _tScrollView.contentOffset = CGPointMake(0, 0);
  67. // 购物
  68. if (!_shoppingVC)
  69. {
  70. _shoppingVC = [BGMainWebViewController webControlerWithUrlStr:_BuguLive.appModel.h5_url.url_user_order isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES];
  71. _shoppingVC.isFrontRefresh = YES;
  72. _shoppingVC.isViewWillAppearRefresh = YES;
  73. _shoppingVC.view.frame = CGRectMake(kScreenW * Eorder_shopping, 0, kScreenW, _tScrollView.bounds.size.height);
  74. _shoppingVC.view.backgroundColor = [UIColor whiteColor];
  75. [_tScrollView addSubview:_shoppingVC.view];
  76. }
  77. // 竞拍
  78. if (!_auctionVC)
  79. {
  80. _auctionVC = [BGMainWebViewController webControlerWithUrlStr:_BuguLive.appModel.h5_url.url_user_pai isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES];
  81. _auctionVC.isFrontRefresh = YES;
  82. _auctionVC.isViewWillAppearRefresh = YES;
  83. _auctionVC.view.frame = CGRectMake(kScreenW * Eorder_auction, 0, kScreenW, _tScrollView.bounds.size.height );
  84. _auctionVC.view.backgroundColor = [UIColor whiteColor];
  85. [_tScrollView addSubview:_auctionVC.view];
  86. }
  87. }
  88. #pragma mark --SegmentView代理方法
  89. - (void)segmentView:(SegmentView*)segmentView selectIndex:(NSInteger)index{
  90. NSLog(@"index==%d",(int)index);
  91. [UIView animateWithDuration:0.2f animations:^{
  92. _tScrollView.contentOffset = CGPointMake(_tScrollView.frame.size.width*index, 0);
  93. }];
  94. }
  95. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scroll
  96. {
  97. CGPoint offset = _tScrollView.contentOffset;
  98. NSInteger page = (offset.x + _tScrollView.frame.size.width/2) / _tScrollView.frame.size.width;
  99. // self.segmentView.indicatorView.hidden = NO;
  100. [_listSegmentView setSelectIndex:page];
  101. }
  102. //后退返回
  103. - (void)backClick
  104. {
  105. [self.navigationController popViewControllerAnimated:YES];
  106. }
  107. - (void)didReceiveMemoryWarning {
  108. [super didReceiveMemoryWarning];
  109. // Dispose of any resources that can be recreated.
  110. }
  111. @end