ShopHomeVC.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // ShopHomeVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/1/16.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "ShopHomeVC.h"
  9. #import "BuyerView.h"
  10. #import "SellerView.h"
  11. @interface ShopHomeVC ()
  12. {
  13. UILabel *_titleL;
  14. UIButton *changeBtn; //切换按钮
  15. UIButton *backBtn;
  16. BOOL isBuger;
  17. }
  18. @property (nonatomic, strong)BuyerView *buyerView;
  19. @property (nonatomic, strong)SellerView *sellerView;
  20. @end
  21. @implementation ShopHomeVC
  22. -(void)viewWillAppear:(BOOL)animated
  23. {
  24. [super viewWillAppear:YES];
  25. if (isBuger) {
  26. [self.buyerView requstData];
  27. }else{
  28. [self.sellerView requstData];
  29. // [self.sellerView getUnreadCount];
  30. }
  31. }
  32. -(void)doReturn{
  33. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.view.backgroundColor = RGB(250, 250, 250);
  38. isBuger = YES;
  39. [self.view addSubview:self.buyerView];
  40. [self.view addSubview:self.sellerView];
  41. [self creatHeader];
  42. }
  43. -(void)creatHeader{
  44. backBtn = [UIButton buttonWithType:0];
  45. backBtn.frame = CGRectMake(0, 24+statusbarHeight, 40, 40);
  46. [backBtn setImage:[UIImage imageNamed:@"pub_back"] forState:0];
  47. [backBtn addTarget:self action:@selector(doReturn) forControlEvents:UIControlEventTouchUpInside];
  48. [self.view addSubview:backBtn];
  49. _titleL = [[UILabel alloc]initWithFrame:CGRectMake(_window_width/2-130, 34+statusbarHeight, 260, 20)];
  50. _titleL.font =[UIFont boldSystemFontOfSize:15];
  51. _titleL.textColor = [UIColor whiteColor];
  52. _titleL.textAlignment = NSTextAlignmentCenter;
  53. _titleL.text = self.shop_name;
  54. [self.view addSubview:_titleL];
  55. changeBtn = [UIButton buttonWithType:0];
  56. changeBtn.frame = CGRectMake(_window_width-50, 24+statusbarHeight, 40, 40);
  57. [changeBtn addTarget:self action:@selector(changeBtnClick) forControlEvents:UIControlEventTouchUpInside];
  58. [changeBtn setImage:[UIImage imageNamed:@"shop_切换"] forState:0];
  59. [self.view addSubview:changeBtn];
  60. if ([self.shop_switch isEqual:@"1"]) {
  61. [self changeBtnClick];
  62. }else{
  63. changeBtn.hidden = YES;
  64. [self.buyerView requstData];
  65. }
  66. }
  67. -(void)changeBtnClick{
  68. isBuger = !isBuger;
  69. if (isBuger) {
  70. self.buyerView.hidden = NO;
  71. self.sellerView.hidden = YES;
  72. [self.buyerView requstData];
  73. NSString *name =[NSString stringWithFormat:@"%@%@",self.shop_name,YZMsg(@"(买家端)")];
  74. NSMutableAttributedString *contentStr = [[NSMutableAttributedString alloc] initWithString:name];
  75. NSRange redRange = NSMakeRange(name.length-5, 5);
  76. [contentStr addAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]} range:redRange];
  77. _titleL.attributedText =contentStr;
  78. }else{
  79. self.buyerView.hidden = YES;
  80. self.sellerView.hidden = NO;
  81. [self.sellerView requstData];
  82. NSString *name =[NSString stringWithFormat:@"%@%@",self.shop_name,YZMsg(@"(卖家端)")];
  83. NSMutableAttributedString *contentStr = [[NSMutableAttributedString alloc] initWithString:name];
  84. NSRange redRange = NSMakeRange(name.length-5, 5);
  85. [contentStr addAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]} range:redRange];
  86. _titleL.attributedText =contentStr;
  87. }
  88. }
  89. -(UIView *)buyerView{
  90. if (!_buyerView) {
  91. _buyerView = [[BuyerView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  92. _buyerView.backgroundColor = [UIColor clearColor];
  93. }
  94. return _buyerView;
  95. }
  96. -(UIView *)sellerView{
  97. if (!_sellerView) {
  98. _sellerView = [[SellerView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  99. _sellerView.backgroundColor = [UIColor clearColor];
  100. _sellerView.hidden = YES;
  101. }
  102. return _sellerView;
  103. }
  104. @end