123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // YOUPAILZSetterGamePriceVC.m
- // VQU
- //
- // Created by CY on 2021/4/28.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZSetterGamePriceVC.h"
- #import "YOUPAILZGameModel.h"
- #import "LZPickerWindow.h"
- #import "PGPickerView.h"
- #import "UIViewController+TFPresent.h"
- @interface YOUPAILZSetterGamePriceVC ()<LZPickerWindowDelegate,PGPickerViewDelegate,PGPickerViewDataSource>
- @property (nonatomic, weak)UILabel *youpaippriceL;
- @property (nonatomic, assign)NSInteger youpaippickerSelectedIndex;
- @end
- @implementation YOUPAILZSetterGamePriceVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = self.youpaipgameModel.youpaipname;
- self.view.backgroundColor = [UIColor whiteColor];
-
- [self youpaifsetupUI];
- }
- - (void)youpaifsetupUI{
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(16.0f, NavBarHeight + 20.0f, KScreenWidth - 32.0f, 45.0f);
- btn.backgroundColor = HexColorFromRGB(0xF6F6F6);
- btn.layer.cornerRadius = 8.0f;
- btn.clipsToBounds = YES;
- [btn addTarget:self action:@selector(youpaifbtnClick) forControlEvents:UIControlEventTouchUpInside];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.font = LCFont14;
- titleL.textColor = HexColorFromRGB(0x333333);
- titleL.text = @"陪玩价格:";
- [btn addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(19.0f);
- make.top.bottom.offset(0.0f);
- }];
-
- UIImageView *arrowImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_game_arrow"]];
- [btn addSubview:arrowImgV];
- [arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-19.0f);
- make.centerY.equalTo(btn);
- make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
- }];
-
- UILabel *priceL = [[UILabel alloc] init];
- priceL.font = LCFont14;
- priceL.textColor = HexColorFromRGB(0x333333);
- priceL.text = [NSString stringWithFormat:@"%ld",self.youpaipgameModel.youpaipprice];
- [btn addSubview:priceL];
- self.youpaippriceL = priceL;
- [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(titleL.mas_right);
- make.top.bottom.offset(0.0f);
- }];
-
- UILabel *descL = [[UILabel alloc] init];
- descL.font = LCFont14;
- descL.textColor = HexColorFromRGB(0x999999);
- descL.text = @"钻石";
- [btn addSubview:descL];
- [descL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(arrowImgV.mas_left).offset(-10.0f);
- make.top.bottom.offset(0.0f);
- }];
-
- [self.view addSubview:btn];
- }
- - (void)youpaifbtnClick{
- LZPickerWindow *vc = [[LZPickerWindow alloc] init];
- vc.isTouchDismiss = YES;
- vc.delegate = self;
- [[LCTools getCurrentVC] TFPresentVC:vc completion:^{}];
- vc.pickerView.dataSource = self;
- vc.pickerView.delegate = self;
- }
- #pragma mark - PGPickerViewDataSource
- // returns the number of 'columns' to display.
- - (NSInteger)numberOfComponentsInPickerView:(PGPickerView *)pickerView{
- return 1;
- }
- // returns the # of rows in each component..
- - (NSInteger)pickerView:(PGPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
- return self.youpaipgameModel.youpaipprices.count;
- }
- - (NSString *)pickerView:(PGPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
- return self.youpaipgameModel.youpaipprices[row].youpaipname;
- }
- #pragma mark - PGPickerViewDelegate
- - (void)pickerView:(PGPickerView *)pickerView title:(NSString *)title didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
- self.youpaippickerSelectedIndex = row;
- }
- #pragma mark - LZPickerWindowDelegate
- - (void)confirmClick{
- self.youpaipgameModel.youpaipselectedPrice = self.youpaipgameModel.youpaipprices[self.youpaippickerSelectedIndex];
- self.youpaippriceL.text = self.youpaipgameModel.youpaipselectedPrice.youpaipname;
- NSDictionary *params = @{
- @"game_id":self.youpaipgameModel.youpaipid,
- @"price":self.youpaipgameModel.youpaipselectedPrice.youpaipid
- };
- [LCHttpHelper requestWithURLString:GameSetterPrice parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- [ZCHUDHelper dismiss];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- self.youpaipgameModel.youpaipprice = [self.youpaipgameModel.youpaipselectedPrice.youpaipname integerValue];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- @end
|