MyWalletViewController.m 27.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
//
//  MyWalletViewController.m
//  IVTMeLiveTwo
//
//  Created by xrg on 16/10/14.
//  Copyright © 2016年 QLQ. All rights reserved.
//

#import "MyWalletViewController.h"
#import "Masonry.h"
#import "UIColor+IVTMeColor.h"
#import "UIFont+IVTMeFont.h"
#import "HMSegmentedControl.h"
#import "IVTKSYLiveShowViewController.h"
#import "IVTEndLiveViewController.h"
#import "IVTMyAccountViewController.h"

@interface MyWalletViewController ()<UIScrollViewDelegate,UITextViewDelegate,UIGestureRecognizerDelegate>
@property (nonatomic, strong) HMSegmentedControl* segmentedControl;
@property (nonatomic, strong)  UIView *segmentViewBefore;
@property (nonatomic, strong)  UIView *segmentViewAfter;
@property (nonatomic, strong) UIScrollView* scrollView;
@property (nonatomic) BOOL  isClickedSegment;

@property (nonatomic, strong)UIView* lineView;
@property (nonatomic, strong)UIView *backGroundView;
@property (nonatomic, strong)UIImageView *headIcon;
@property (nonatomic, strong)UILabel *name;
@property (nonatomic, strong) UIImageView *sex;
@property (nonatomic, strong) UIImageView *level;
@property (nonatomic, strong)UILabel *fengmi;
@property (nonatomic, strong)UIView *sendView;
@property (nonatomic, strong)UILabel *send;
@property (nonatomic, strong)UITextField *count;
@property (nonatomic, strong)UITextView *commentView;
@property (nonatomic, strong)UILabel *commentLabel;
@property (nonatomic, strong)UIButton *sendButton;
@property (nonatomic, strong)UIButton *groupSendButton;
@property (nonatomic, strong)UIButton *MoneyButton;

@property (nonatomic,strong)UITextField *redPacket;
@property (nonatomic,strong)UITextField *redCount;


@end


@implementation MyWalletViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initViews];
    [self creatBackGound];
    [self sendAnchor];
    [self groupRedPacket];
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewTapped:)];
    tap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tap];
    self.navigationItem.title = @"红包";
}




#pragma mark - ************************************** Init All Views *****************************************

-(void)initViews{
    
    [self initMainView];  //分割栏
}

-(void)initMainView{
    
    _segmentViewBefore =[[UIView alloc]initWithFrame:CGRectMake(0,0,kScreenWidth/3, 40)];
    _segmentViewBefore.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:_segmentViewBefore];
    
    _segmentViewAfter =[[UIView alloc]initWithFrame:CGRectMake(kScreenWidth/3*2+10, 0,kScreenWidth-kScreenWidth/3-130, 40)];
    _segmentViewAfter.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:_segmentViewAfter];
    
    _segmentedControl = [[HMSegmentedControl alloc]initWithFrame:CGRectMake(kScreenWidth/3-20, 0, 170, 40)];
    _segmentedControl.sectionTitles = @[@"送主播",@"群红包"];
    _segmentedControl.selectedSegmentIndex = 0;
    _segmentedControl.backgroundColor = [UIColor whiteColor];
    _segmentedControl.selectionIndicatorColor =[UIColor IVTLightRedColor];
    _segmentedControl.titleTextAttributes = @{ NSForegroundColorAttributeName : [UIColor IVTGrayColor], NSFontAttributeName : [UIFont YXFontOfSize:15.0] };
    _segmentedControl.selectedTitleTextAttributes = @{ NSForegroundColorAttributeName : [UIColor IVTLightRedColor] };
    _segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe;
    _segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
    _segmentedControl.selectionIndicatorHeight = 3.0;
    __weak typeof(self) weakSelf = self;
    [self.segmentedControl setIndexChangeBlock:^(NSInteger index) {
        _isClickedSegment = YES;
        [weakSelf.scrollView scrollRectToVisible:CGRectMake(kScreenWidth * index, 0, kScreenWidth, kScreenHeight - self.segmentedControl.frame.origin.y - self.segmentedControl.bounds.size.height) animated:YES];
    }];
    
    [self.view addSubview:self.segmentedControl];
    
    
    //线
    UIView* lineView = [[UIView alloc] init];
    [self.view addSubview:lineView];
    _lineView = lineView;
    [lineView mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(@(58+40));
        make.left.equalTo(weakSelf.view.mas_left);
        make.right.equalTo(weakSelf.view.mas_right);
        make.height.equalTo(@0.5);
    }];
    lineView.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
    
    
}

#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView*)scrollView
{
    if (scrollView.isDragging == YES) {
        if (scrollView.contentOffset.x) {
            CGFloat pageWidth = scrollView.frame.size.width;
            NSInteger page = scrollView.contentOffset.x / pageWidth;
            [self.segmentedControl setSelectedSegmentIndex:page animated:YES];
        }
    }
    else {
        if (_isClickedSegment == NO) {
            if (scrollView.contentOffset.x) {
                CGFloat pageWidth = scrollView.frame.size.width;
                NSInteger page = scrollView.contentOffset.x / pageWidth;
                [self.segmentedControl setSelectedSegmentIndex:page animated:YES];
            }
        }
    }
}

//大背景view
-(void)creatBackGound{
    
    CGFloat scrollHeight = 0.5 + self.segmentedControl.frame.origin.y + self.segmentedControl.bounds.size.height;
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, scrollHeight, kScreenWidth, kScreenHeight - scrollHeight)];
    _scrollView.backgroundColor = [UIColor redColor];
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.contentSize = CGSizeMake(kScreenWidth *2, kScreenHeight - scrollHeight);
    _scrollView.alwaysBounceVertical = NO;
    _scrollView.alwaysBounceHorizontal = NO;
    _scrollView.delegate = self;
    _scrollView.bounces = NO;
    _scrollView.pagingEnabled = YES;
    [_scrollView scrollRectToVisible:CGRectMake(0, scrollHeight, kScreenWidth, kScreenHeight - scrollHeight) animated:YES];
    [self.view addSubview:self.scrollView];
    
    
}
//送主播
-(void)sendAnchor{
    
    CGFloat scrollHeight = 0.5 + self.segmentedControl.frame.origin.y + self.segmentedControl.bounds.size.height;
    UIView *backGroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-scrollHeight)];
    backGroundView.backgroundColor = [UIColor IVTBackgroundColor];
    [self.scrollView addSubview:backGroundView];
    _backGroundView  = backGroundView;
    
    
    UILabel *redP = [[UILabel alloc]init];
    redP.text = @"TA将立即获得你发出的红包";
    redP.textColor =[UIColor IVTAssistColor];
    redP.font = [UIFont YXFontOfSize:13];
    [backGroundView addSubview:redP];
    [redP mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView.mas_bottom).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(200, 15));
        make.leading.equalTo(backGroundView.mas_leading).with.offset(23);
        
    }];
    
    
    UIView *backIconView = [[UIView alloc]init];
    backIconView.backgroundColor = [UIColor whiteColor];
    [backGroundView addSubview:backIconView];
    [backIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView.mas_bottom).with.offset(38);
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.height.equalTo(@(58));
    }];
    
    _headIcon = [[UIImageView alloc] init];
    [_headIcon sd_setImageWithURL:[NSURL URLWithString:self.zhuboAvatar]];
    _headIcon.contentMode = UIViewContentModeScaleAspectFill;
    CGRect rect = self.headIcon.frame;
    self.headIcon.layer.cornerRadius = rect.size.width/2;
    self.headIcon.layer.masksToBounds = YES;
    [backIconView addSubview:_headIcon];
    [_headIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(backGroundView.mas_leading).with.offset(10);
        make.centerY.equalTo(backIconView);
        make.size.mas_equalTo(CGSizeMake(41, 40.5));
    }];
    
    
    
    _name = [[UILabel alloc]init];
    [backIconView addSubview:_name];
    _name.backgroundColor = [UIColor clearColor];
    _name.textColor = [UIColor YXColorWithHexCode:@"#272727"];
    _name.font = [UIFont YXFontOfSize:15];
    _name.text = [self.zhuboName base64DecodedToString];
    
    _name.textAlignment = NSTextAlignmentLeft;
    [_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backIconView);
        make.left.equalTo(_headIcon.mas_right).with.offset(13);
        make.size.mas_equalTo(CGSizeMake(100, 18));
    }];
    
    
    _sex = [[UIImageView alloc]init];
    _sex.image = [UIImage imageNamed:@"性别"];
    [backIconView addSubview:_sex];
    [_sex mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backIconView);
        make.left.equalTo(_name.mas_right).with.offset(3);
        make.size.mas_equalTo(CGSizeMake(11.5, 14));
    }];
    
    _level = [[UIImageView alloc] init];
    
    [backIconView addSubview:_level];
    [_level mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backIconView);
        make.left.equalTo(_sex.mas_right).with.offset(2);
        make.size.mas_equalTo(CGSizeMake(11.5, 14));
    }];
    
    
    
    _fengmi = [[UILabel alloc]init];
    _fengmi.text = @"您当前的中国币";
    _fengmi.textColor =[UIColor IVTAssistColor];
    _fengmi.font = [UIFont YXFontOfSize:13];
    [ backGroundView addSubview: _fengmi];
    [ _fengmi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backIconView.mas_bottom).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(200, 12));
        make.leading.equalTo(backGroundView.mas_leading).with.offset(23);
        
    }];
    
    _sendView = [[UIView alloc]init];
    [backGroundView addSubview:_sendView];
    _sendView.backgroundColor = [UIColor whiteColor];
    [_sendView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backIconView.mas_bottom).with.offset(39);
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.height.equalTo(@(37));
    }];
    
    
    _send = [[UILabel alloc]init];
    [_sendView addSubview:_send];
    _send.textColor = [UIColor YXColorWithHexCode:@"#272727"];
    _send.font = [UIFont IVTH3Font];
    _send.text = @"共发送";
    [_send mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_sendView);
        make.left.equalTo(_sendView.mas_left).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(80, 15));
    }];
    
    
    _count= [[UITextField alloc]init];
    _count.backgroundColor = [UIColor whiteColor];
    _count.textAlignment = 2;
    _count.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    _count.placeholder =@"填写数量";
    _count.font = [UIFont YXFontOfSize:13];
    _count.textColor = [UIColor YXColorWithHexCode:@"b3b3b3"];
    [_sendView addSubview:_count];
    [_count mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_sendView);
        make.right.equalTo(_sendView.mas_right).with.offset(-21);
        make.size.mas_equalTo(CGSizeMake(58, 19));
    }];
    
    //    //标注
    //    _commentView= [[UITextView alloc]init];
    //    _commentView.backgroundColor = [UIColor whiteColor];
    //    _commentView.font = [UIFont YXFontOfSize:13];
    //    _commentView.textColor = [UIColor IVTAssistColor];
    //    [backGroundView addSubview:_commentView];
    //    [_commentView mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.top.equalTo(_sendView.mas_bottom).with.offset(28);
    //        make.left.equalTo(backGroundView.mas_left).with.offset(4);
    //        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
    //        make.height.equalTo(@(65));
    //
    //    }];
    //
    
    
    _sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backGroundView addSubview:_sendButton];
    [_sendButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.top.equalTo(_count.mas_bottom).with.offset(33);
    }];
    [_sendButton setBackgroundImage:[UIImage imageNamed:@"红包-送主播-发送红包按钮"] forState:UIControlStateNormal];
    [_sendButton setTitle:@"发送红包" forState:UIControlStateNormal];
    [_sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _sendButton.titleLabel.font = [UIFont YXFontOfSize:14];
    [_sendButton addTarget:self action:@selector(sendClickFunc:) forControlEvents:UIControlEventTouchUpInside];
    
    _MoneyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_MoneyButton setTitle:@"去充值>" forState:UIControlStateNormal];
    [_MoneyButton setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    _MoneyButton.titleLabel.font = [UIFont YXFontOfSize:12];
    [backGroundView addSubview:_MoneyButton];
    [_MoneyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_sendButton.mas_bottom).with.offset(34);
        make.trailing.equalTo(backGroundView.mas_trailing).with.offset(-19);
        make.size.mas_equalTo(CGSizeMake(70, 30));
    }];
    [_MoneyButton addTarget:self action:@selector(giveMoney:) forControlEvents:UIControlEventTouchUpInside];
}


#pragma mark - 发送私包Func
- (void)sendClickFunc:(UIButton *)sender
{
    sender.enabled = NO;
    if ([[IVTAccountTool getChineseCoinTotal] integerValue] <= 0) {
        [SVProgressHUD setMinimumDismissTimeInterval:3.0f];
        [SVProgressHUD showErrorWithStatus:@"余额不足请充值"];
        sender.enabled = YES;
    }
    else if([_count.text integerValue] *100 > [[IVTAccountTool getChineseCoinTotal] integerValue]){
        [SVProgressHUD setMinimumDismissTimeInterval:3.0f];
        [SVProgressHUD showErrorWithStatus:@"余额不足以支付此次红包!请充值"];
        sender.enabled = YES;
    }
    else if([[IVTAccountTool getChineseCoinTotal] integerValue] > 0 && [[IVTAccountTool getChineseCoinTotal] integerValue] - [_count.text integerValue]*100 > 100){
        if ([_count.text integerValue] >= 10 && [_count.text integerValue] <= 1000) {
            NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
            [dict setObject:[IVTAccountTool getUserId] forKey:@"fromUserId"];
            [dict setObject:self.zhuBoId forKey:@"toUserId"];
            [dict setObject:self.liveID forKey:@"liveId"];
            [dict setObject:@"1" forKey:@"giftId"];
            [dict setObject:_count.text forKey:@"count"];
            
            [[IVTNetworkAPIClient sharedClient] sendGift:dict success:^(NSDictionary *successData) {
                
                NSInteger coinNumber = [[IVTAccountTool getChineseCoinTotal] integerValue] - [_count.text integerValue]*100;
                [IVTAccountTool setChineseCoinTotal:[NSString stringWithFormat:@"%ld",(long)coinNumber]];
                                
                NSMutableDictionary *paramDict = [[NSMutableDictionary alloc] init];
                [paramDict setValue:_count.text forKey:@"count"];
                
                NSNotification *notification = [NSNotification notificationWithName:@"privateRedPacket" object:nil userInfo:paramDict];
                [[NSNotificationCenter defaultCenter]postNotification:notification];
                
                [self.navigationController popViewControllerAnimated:YES];
            } error:^(NSDictionary *successData) {
                NSString *msg = successData[@"description"];
                
                [SVProgressHUD setMinimumDismissTimeInterval:2];
                [SVProgressHUD showErrorWithStatus:msg];
            } failure:^(NSError *failureError) {

            }];
        }
        else{
            UIAlertController *sheet = [UIAlertController alertControllerWithTitle:@"提示" message:@"每次只能发送10~1000个红包!" preferredStyle:UIAlertControllerStyleAlert];
            [sheet addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                
            }]];
            [self presentViewController:sheet animated:YES completion:^{
                sender.enabled = YES;
            }];
        }
    }
}

#pragma mark - 发送群红包Func
-(void)sendRedPacket:(id)sender{
    
    if ([[IVTAccountTool getChineseCoinTotal] integerValue] <= 0) {
        [SVProgressHUD setMinimumDismissTimeInterval:3.0f];
        [SVProgressHUD showErrorWithStatus:@"余额不足请充值!"];
    }else if([_redCount.text integerValue] * 100  > [[IVTAccountTool getChineseCoinTotal] integerValue]){
        [SVProgressHUD setMinimumDismissTimeInterval:3.0f];
        [SVProgressHUD showErrorWithStatus:@"余额不足以支付此次红包!请充值"];
    }else if([[IVTAccountTool getChineseCoinTotal] integerValue] > 0 && [[IVTAccountTool getChineseCoinTotal] integerValue] - [_redCount.text integerValue] * 100 > 100){
        if ([_redCount.text integerValue] >= 10 && [_redCount.text integerValue] <= 1000 ) {
            _groupSendButton.enabled = NO;
            IVTKSYLiveShowViewController * liveVC = [[IVTKSYLiveShowViewController alloc] init];
            
            NSMutableDictionary *SendPacketDict = [[NSMutableDictionary alloc] init];
            [SendPacketDict setObject:[IVTAccountTool getUserId] forKey:@"userId"];
            [SendPacketDict setObject:self.liveID forKey:@"liveId"];
            [SendPacketDict setObject:_redPacket.text forKey:@"count"];
            [SendPacketDict setObject:_redCount.text forKey:@"money"];
            
            [[IVTNetworkAPIClient sharedClient] sendRedEnvelop:SendPacketDict success:^(NSDictionary *successData) {
                NSInteger coinNumber = [[IVTAccountTool getChineseCoinTotal] integerValue] - [_redCount.text integerValue]*100;
                [IVTAccountTool setChineseCoinTotal:[NSString stringWithFormat:@"%ld",(long)coinNumber]];
                
                NSMutableDictionary *sendPacketDict = [successData copy];
                
                NSString *redID = [NSString stringWithFormat:@"%@",[sendPacketDict objectForKey:@"redId"]];
                liveVC.isKSY = YES;
                
                NSMutableDictionary *redPacketDict = [[NSMutableDictionary alloc]init];
                [redPacketDict setObject:redID forKey:@"redPacket"];
                
                NSNotification *notification = [NSNotification notificationWithName:@"redPacket" object:nil userInfo:redPacketDict];
                [[NSNotificationCenter defaultCenter]postNotification:notification];
                
                [self.navigationController popViewControllerAnimated:YES];
                
            } error:^(NSDictionary *successData) {
                NSString *msg = successData[@"description"];
                
                [SVProgressHUD setMinimumDismissTimeInterval:2];
                [SVProgressHUD showErrorWithStatus:msg];
            } failure:^(NSError *failureError) {

            }];
        }
        else{
            UIAlertController *sheet = [UIAlertController alertControllerWithTitle:@"提示" message:@"每次只能发送10~1000个红包!" preferredStyle:UIAlertControllerStyleAlert];
            [sheet addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                
            }]];
            [self presentViewController:sheet animated:YES completion:^{
            }];
        }
    }
}

-(void)viewTapped:(UITapGestureRecognizer *)tap
{
    [self.view endEditing:YES];
}

-(void)taped{
    
    [self.commentView resignFirstResponder];
    [self.count resignFirstResponder];
}




#pragma mark - 发送群红包
-(void)groupRedPacket{
    
    
    UIView *backGroundView = [[UIView alloc]initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth,self.scrollView.bounds.size.height)];
    backGroundView.backgroundColor = [UIColor IVTBackgroundColor];
    [self.scrollView addSubview:backGroundView];
    _backGroundView  = backGroundView;
    
    
    UILabel *redP = [[UILabel alloc]init];
    redP.text = @"一次最多可以发送100个红包";
    redP.textColor =[UIColor IVTAssistColor];
    redP.font = [UIFont YXFontOfSize:11];
    [backGroundView addSubview:redP];
    [redP mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView.mas_bottom).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(150, 15));
        make.leading.equalTo(backGroundView.mas_leading).with.offset(23);
        
    }];
    
    
    UIView *redPacketView = [[UIView alloc]init];
    redPacketView.backgroundColor = [UIColor whiteColor];
    [backGroundView addSubview:redPacketView];
    [redPacketView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView.mas_bottom).with.offset(38);
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.height.equalTo(@(36));
    }];
    
    UILabel *redPacketNum = [[UILabel alloc]init];
    [redPacketView addSubview:redPacketNum];
    redPacketNum.textColor = [UIColor YXColorWithHexCode:@"#272727"];
    redPacketNum.font = [UIFont YXFontOfSize:13];
    redPacketNum.text = @"红包个数";
    [redPacketNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(redPacketView);
        make.left.equalTo(redPacketView.mas_left).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(55, 15));
    }];
    
    _redPacket= [[UITextField alloc]init];
    _redPacket.backgroundColor = [UIColor whiteColor];
    _redPacket.textAlignment = 2;
    _redPacket.keyboardType = UIKeyboardTypeNumberPad;
    _redPacket.placeholder =@"填写红包个数";
    _redPacket.font = [UIFont YXFontOfSize:13];
    _redPacket.textColor = [UIColor YXColorWithHexCode:@"b3b3b3"];
    [redPacketView addSubview:_redPacket];
    [_redPacket mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(redPacketView);
        make.right.equalTo(redPacketView.mas_right).with.offset(-21);
        make.size.mas_equalTo(CGSizeMake(80, 19));
    }];
    
    UILabel  *fengmi = [[UILabel alloc]init];
    fengmi.text = @"您当前的中国币";
    fengmi.textColor =[UIColor IVTAssistColor];
    fengmi.font = [UIFont YXFontOfSize:13];
    [ backGroundView addSubview: fengmi];
    [ fengmi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(redPacketView.mas_bottom).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(200, 12));
        make.leading.equalTo(backGroundView.mas_leading).with.offset(23);
        
    }];
    
    UIView *sendView = [[UIView alloc]init];
    [backGroundView addSubview:sendView];
    sendView.backgroundColor = [UIColor whiteColor];
    [sendView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(redPacketView.mas_bottom).with.offset(39);
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.height.equalTo(@(37));
        
    }];
    
    
    UILabel  *send = [[UILabel alloc]init];
    send.textColor = [UIColor YXColorWithHexCode:@"#272727"];
    send.font = [UIFont IVTH3Font];
    send.text = @"共发送";
    [sendView addSubview:send];
    [send mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(sendView);
        make.left.equalTo(sendView.mas_left).with.offset(21);
        make.size.mas_equalTo(CGSizeMake(80, 15));
        
    }];
    
    
    _redCount= [[UITextField alloc]init];
    _redCount.backgroundColor = [UIColor whiteColor];
    _redCount.textAlignment = 2;
    _redCount.keyboardType = UIKeyboardTypeNumberPad;
    _redCount.placeholder =@"填写数量";
    _redCount.font = [UIFont YXFontOfSize:13];
    _redCount.textColor = [UIColor YXColorWithHexCode:@"b3b3b3"];
    [sendView addSubview:_redCount];
    [_redCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(sendView);
        make.right.equalTo(sendView.mas_right).with.offset(-21);
        make.size.mas_equalTo(CGSizeMake(58, 19));
    }];
    
    //    //标注
    //  UITextView  *commentView= [[UITextView alloc]init];
    //    commentView.backgroundColor = [UIColor whiteColor];
    //    commentView.font = [UIFont YXFontOfSize:13];
    //    commentView.textColor = [UIColor IVTAssistColor];
    //    [backGroundView addSubview:commentView];
    //    [commentView mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.top.equalTo(sendView.mas_bottom).with.offset(28);
    //        make.left.equalTo(backGroundView.mas_left).with.offset(4);
    //        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
    //        make.height.equalTo(@(65));
    //
    //    }];
    
    
    
    _groupSendButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backGroundView addSubview:_groupSendButton];
    [_groupSendButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backGroundView.mas_left).with.offset(4);
        make.right.equalTo(backGroundView.mas_right).with.offset(-4);
        make.top.equalTo(_count.mas_bottom).with.offset(33);
    }];
    [_groupSendButton setBackgroundImage:[UIImage imageNamed:@"红包-送主播-发送红包按钮"] forState:UIControlStateNormal];
    [_groupSendButton setTitle:@"发送红包" forState:UIControlStateNormal];
    [_groupSendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _groupSendButton.titleLabel.font = [UIFont YXFontOfSize:14];
    [_groupSendButton addTarget:self action:@selector(sendRedPacket:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *MoneyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [MoneyButton setTitle:@"去充值>" forState:UIControlStateNormal];
    [MoneyButton setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    MoneyButton.titleLabel.font = [UIFont YXFontOfSize:12];
    [backGroundView addSubview:MoneyButton];
    [MoneyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_groupSendButton.mas_bottom).with.offset(34);
        make.trailing.equalTo(backGroundView.mas_trailing).with.offset(-19);
        make.size.mas_equalTo(CGSizeMake(70, 30));
    }];
    [MoneyButton addTarget:self action:@selector(giveMoney:) forControlEvents:UIControlEventTouchUpInside];

    UILabel *tips = [[UILabel alloc]init];
    [backGroundView addSubview:tips];
    tips.text = @"超过24小时红包未领取,将自动退款";
    tips.textColor = [UIColor IVTAssistColor];
    tips.font = [UIFont YXFontOfSize:10];
    [tips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(backGroundView.mas_bottom).with.offset(-183);
        make.centerX.equalTo(backGroundView);
        make.size.mas_equalTo(CGSizeMake(180, 16));
    }];
}

//去充值
-(void)giveMoney:(UIButton *)sender{
    
    IVTMyAccountViewController *myCount = [[IVTMyAccountViewController alloc]init];
    [self.navigationController pushViewController:myCount animated:YES];
    
}

//返回按钮点击
-(void)backToTopPage:(id)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}



- (void)textViewDidChange:(UITextView *)textView
{
    if(textView.text.length == 0){
        self.commentLabel.hidden = NO;
    }else{
        if (textView.text.length > 50) {
            
        }
        self.commentLabel.hidden = YES;
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end