YOUPAILZSetterGamePriceVC.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // YOUPAILZSetterGamePriceVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/4/28.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZSetterGamePriceVC.h"
  9. #import "YOUPAILZGameModel.h"
  10. #import "LZPickerWindow.h"
  11. #import "PGPickerView.h"
  12. #import "UIViewController+TFPresent.h"
  13. @interface YOUPAILZSetterGamePriceVC ()<LZPickerWindowDelegate,PGPickerViewDelegate,PGPickerViewDataSource>
  14. @property (nonatomic, weak)UILabel *youpaippriceL;
  15. @property (nonatomic, assign)NSInteger youpaippickerSelectedIndex;
  16. @end
  17. @implementation YOUPAILZSetterGamePriceVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.title = self.youpaipgameModel.youpaipname;
  21. self.view.backgroundColor = [UIColor whiteColor];
  22. [self youpaifsetupUI];
  23. }
  24. - (void)youpaifsetupUI{
  25. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  26. btn.frame = CGRectMake(16.0f, NavBarHeight + 20.0f, KScreenWidth - 32.0f, 45.0f);
  27. btn.backgroundColor = HexColorFromRGB(0xF6F6F6);
  28. btn.layer.cornerRadius = 8.0f;
  29. btn.clipsToBounds = YES;
  30. [btn addTarget:self action:@selector(youpaifbtnClick) forControlEvents:UIControlEventTouchUpInside];
  31. UILabel *titleL = [[UILabel alloc] init];
  32. titleL.font = LCFont14;
  33. titleL.textColor = HexColorFromRGB(0x333333);
  34. titleL.text = @"陪玩价格:";
  35. [btn addSubview:titleL];
  36. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.offset(19.0f);
  38. make.top.bottom.offset(0.0f);
  39. }];
  40. UIImageView *arrowImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_game_arrow"]];
  41. [btn addSubview:arrowImgV];
  42. [arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.right.offset(-19.0f);
  44. make.centerY.equalTo(btn);
  45. make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
  46. }];
  47. UILabel *priceL = [[UILabel alloc] init];
  48. priceL.font = LCFont14;
  49. priceL.textColor = HexColorFromRGB(0x333333);
  50. priceL.text = [NSString stringWithFormat:@"%ld",self.youpaipgameModel.youpaipprice];
  51. [btn addSubview:priceL];
  52. self.youpaippriceL = priceL;
  53. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.equalTo(titleL.mas_right);
  55. make.top.bottom.offset(0.0f);
  56. }];
  57. UILabel *descL = [[UILabel alloc] init];
  58. descL.font = LCFont14;
  59. descL.textColor = HexColorFromRGB(0x999999);
  60. descL.text = @"钻石";
  61. [btn addSubview:descL];
  62. [descL mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.right.equalTo(arrowImgV.mas_left).offset(-10.0f);
  64. make.top.bottom.offset(0.0f);
  65. }];
  66. [self.view addSubview:btn];
  67. }
  68. - (void)youpaifbtnClick{
  69. LZPickerWindow *vc = [[LZPickerWindow alloc] init];
  70. vc.isTouchDismiss = YES;
  71. vc.delegate = self;
  72. [[LCTools getCurrentVC] TFPresentVC:vc completion:^{}];
  73. vc.pickerView.dataSource = self;
  74. vc.pickerView.delegate = self;
  75. }
  76. #pragma mark - PGPickerViewDataSource
  77. // returns the number of 'columns' to display.
  78. - (NSInteger)numberOfComponentsInPickerView:(PGPickerView *)pickerView{
  79. return 1;
  80. }
  81. // returns the # of rows in each component..
  82. - (NSInteger)pickerView:(PGPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
  83. return self.youpaipgameModel.youpaipprices.count;
  84. }
  85. - (NSString *)pickerView:(PGPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
  86. return self.youpaipgameModel.youpaipprices[row].youpaipname;
  87. }
  88. #pragma mark - PGPickerViewDelegate
  89. - (void)pickerView:(PGPickerView *)pickerView title:(NSString *)title didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
  90. self.youpaippickerSelectedIndex = row;
  91. }
  92. #pragma mark - LZPickerWindowDelegate
  93. - (void)confirmClick{
  94. self.youpaipgameModel.youpaipselectedPrice = self.youpaipgameModel.youpaipprices[self.youpaippickerSelectedIndex];
  95. self.youpaippriceL.text = self.youpaipgameModel.youpaipselectedPrice.youpaipname;
  96. NSDictionary *params = @{
  97. @"game_id":self.youpaipgameModel.youpaipid,
  98. @"price":self.youpaipgameModel.youpaipselectedPrice.youpaipid
  99. };
  100. [LCHttpHelper requestWithURLString:GameSetterPrice parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  101. [ZCHUDHelper dismiss];
  102. NSDictionary* dict = (NSDictionary*)responseObject;
  103. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  104. if (code==0) {
  105. self.youpaipgameModel.youpaipprice = [self.youpaipgameModel.youpaipselectedPrice.youpaipname integerValue];
  106. }else{
  107. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  108. }
  109. } failure:^(NSError *error) {
  110. [ZCHUDHelper showTitle:error.localizedDescription];
  111. }];
  112. }
  113. @end