123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- //
- // YOUPAIZYXianNvBangVC.m
- // VQU
- //
- // Created by Elaine on 2020/7/25.
- // Copyright © 2020 leo. All rights reserved.
- //
- #import "YOUPAIZYXianNvBangVC.h"
- @interface YOUPAIZYXianNvBangVC ()
- @property(nonatomic,strong)UIImageView *youpaipbkImgV;
- @property(nonatomic,strong)NSMutableArray *youpaipbtnArray;
- @property(nonatomic,strong)NSArray *youpaipnumStrArray;
- @property(nonatomic,strong)UILabel *youpaiptitleLab,*youpaipnoticeLab;
- @property(nonatomic,strong)UIButton *youpaipguardHerBtn;
- @property(nonatomic,strong)UIView *youpaipnumView;
- @property(nonatomic,assign)CGFloat youpaipleftPadding;
- @property(nonatomic,assign)NSInteger youpaiptotalNum;
- @end
- @implementation YOUPAIZYXianNvBangVC
- -(void)viewDidLoad
- {
- [super viewDidLoad];
- _youpaipleftPadding = (self.vWidth-270)/2.0;
- _youpaipnumStrArray = @[@"1个",@"10个",@"77个",@"520个"];
- _youpaipbtnArray = [[NSMutableArray alloc]init];
- _youpaiptotalNum =1;
-
- // [self.view setFrame:CGRectMake(0, 0, self.vWidth, self.vHeight)];
- // [self.view setBackgroundColor:[UIColor whiteColor]];
-
- [self.baseView addSubview:self.youpaipbkImgV];
- [self.baseView addSubview:self.youpaiptitleLab];
- [self.baseView addSubview:self.youpaipnoticeLab];
- [self.baseView addSubview:self.youpaipnumView];
- [self.baseView addSubview:self.youpaipguardHerBtn];
-
- NSString *titleStr = [NSString stringWithFormat:@"花费%ld个钻石给她1个仙女棒",self.youpaipinfoModel.youpaipprice];
- [_youpaiptitleLab setText:titleStr];
- // [_noticeLab setText:[NSString stringWithFormat:@"总榜距离上一名还差%ld个仙女棒",self.infoModel.diff_num]];
- [_youpaipguardHerBtn setTitle:@"赠送" forState:UIControlStateNormal];
-
- [_youpaiptitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.baseView).with.offset(0);
- make.right.equalTo(self.baseView).with.offset(0);
- make.top.equalTo(self->_youpaipbkImgV.mas_bottom).with.offset(18);
- make.height.mas_equalTo(20);
-
- }];
-
- [_youpaipnumView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.baseView).with.offset(self->_youpaipleftPadding);
- make.right.equalTo(self.baseView).with.offset(-self->_youpaipleftPadding);
- make.top.equalTo(self->_youpaiptitleLab.mas_bottom).with.offset(10);
- make.width.mas_equalTo(220);
- make.height.mas_equalTo(28);
- }];
-
- [_youpaipnoticeLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.baseView).with.offset(0);
- make.right.equalTo(self.baseView).with.offset(0);
- make.top.equalTo(self->_youpaipnumView.mas_bottom).with.offset(6);
- make.height.mas_equalTo(15);
- }];
-
- // [_guardHerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(self.view).with.offset(_leftPadding);
- // make.right.equalTo(self.view).with.offset(-_leftPadding);
- // make.top.equalTo(_noticeLab.mas_bottom).with.offset(10);
- // make.bottom.equalTo(self.view.mas_bottom).with.offset(-15);
- // make.height.mas_equalTo(44);
- // }];
-
- //
- // CAShapeLayer *maskLayer = [CAShapeLayer layer];
- // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:25];
- // maskLayer.path = path.CGPath;
- // self.view.layer.mask = maskLayer;
-
-
-
- }
- -(UIImageView *)youpaipbkImgV
- {
- if(!_youpaipbkImgV)
- {
- _youpaipbkImgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.vWidth, (self.vWidth*137)/320.0)];
- [_youpaipbkImgV setImage:[UIImage imageNamed:@"vqu_images_guard_prompt77"]];
-
- }
- return _youpaipbkImgV;
- }
- -(UIView *)youpaipnumView
- {
- if(!_youpaipnumView)
- {
- CGFloat btnWidth = 60,btnHeight = 28,orginx=0,orginy =1,btnspace=10;
- _youpaipnumView = [[UIView alloc]initWithFrame:CGRectMake(_youpaipleftPadding, 0,270, 28)];
- for(int i=0;i<4;i++)
- {
- UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(orginx+(btnWidth+btnspace)*i, orginy, btnWidth, btnHeight)];
- btn.tag = i;
- [btn.titleLabel setFont:[UIFont systemFontOfSize:13]];
- btn.layer.cornerRadius =4;
- btn.layer.borderWidth = 1;
- [btn setTitle:_youpaipnumStrArray[i] forState:UIControlStateNormal];
- if(i==0)
- {
- [btn setTitleColor:LCYellowColor forState:UIControlStateNormal];
- btn.layer.borderColor = LCYellowColor.CGColor;
- }
- else
- {
- btn.layer.borderColor = HexColorFromRGB(0xCCCCCC).CGColor;
- [btn setTitleColor:HexColorFromRGB(0xCCCCCC) forState:UIControlStateNormal];
- }
- [btn addTarget:self action:@selector(youpaifupdateNumView:) forControlEvents:UIControlEventTouchUpInside];
- [_youpaipbtnArray addObject:btn];
- [_youpaipnumView addSubview:btn];
- }
- }
- return _youpaipnumView;
- }
- -(UILabel *)youpaiptitleLab
- {
- if(!_youpaiptitleLab)
- {
- _youpaiptitleLab = [[UILabel alloc]init];
- [_youpaiptitleLab setTextColor:HexColorFromRGB(0x666666)];
- [_youpaiptitleLab setFont:[UIFont systemFontOfSize:14]];
- [_youpaiptitleLab setTextAlignment:NSTextAlignmentCenter];
- }
- return _youpaiptitleLab;
- }
- -(UILabel *)youpaipnoticeLab
- {
- if(!_youpaipnoticeLab)
- {
- _youpaipnoticeLab = [[UILabel alloc]init];
- [_youpaipnoticeLab setTextColor:HexColorFromRGB(0xaaaaaa)];
- [_youpaipnoticeLab setFont:[UIFont systemFontOfSize:12]];
- [_youpaipnoticeLab setTextAlignment:NSTextAlignmentCenter];
- }
- return _youpaipnoticeLab;
- }
- -(UIButton *)youpaipguardHerBtn
- {
- if(!_youpaipguardHerBtn)
- {
- _youpaipguardHerBtn = [[UIButton alloc]init];
- [_youpaipguardHerBtn.titleLabel setFont:[UIFont systemFontOfSize:17]];
- _youpaipguardHerBtn.layer.cornerRadius = 22;
- _youpaipguardHerBtn.layer.masksToBounds = YES;
- [_youpaipguardHerBtn addTarget:self action:@selector(youpaifsendActivitGift) forControlEvents:UIControlEventTouchUpInside];
- [_youpaipguardHerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- // [_guardHerBtn setBackgroundColor:LCYellowColor];
- _youpaipguardHerBtn.frame = CGRectMake(_youpaipleftPadding,self.vHeight-16-44,self.vWidth - _youpaipleftPadding*2, 44);
- [_youpaipguardHerBtn setBackgroundImage:[LCTools ColorImage:self.youpaipguardHerBtn.frame.size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
- //
- //
- }
- return _youpaipguardHerBtn;
- }
- -(void)youpaifupdateNumView:(UIButton *)btn
- {
- NSInteger tag = btn.tag;
- NSArray *totalArray =@[@(1),@(10),@(77),@(520)];
- for(int i=0;i<4;i++)
- {
- UIButton *cacheBtn = [_youpaipbtnArray objectAtIndex:i];
- if(tag == i)
- {
- [cacheBtn setTitleColor:LCYellowColor forState:UIControlStateNormal];
- cacheBtn.layer.borderColor = LCYellowColor.CGColor;
- _youpaiptotalNum = [totalArray[i] integerValue];
-
- NSString *titleStr = [NSString stringWithFormat:@"花费%ld个钻石给她%ld个守护符",self.youpaipinfoModel.youpaipprice*_youpaiptotalNum,_youpaiptotalNum];
- [_youpaiptitleLab setText:titleStr];
- }
- else
- {
- cacheBtn.layer.borderColor = HexColorFromRGB(0xCCCCCC).CGColor;
- [cacheBtn setTitleColor:HexColorFromRGB(0xCCCCCC) forState:UIControlStateNormal];
- }
- }
- }
- -(void)youpaifsendActivitGift
- {
- _youpaipguardHerBtn.userInteractionEnabled = NO;
- //add by leo v1.0.8 视频中守护
- WeakSelf;
- if(_youpaipisRoom)
- {
- [LCHttpHelper requestWithURLString:SendActivitGift parameters:@{@"user_id":self.youpaipuser_id,@"fairy_num":@(_youpaiptotalNum),@"fairy_price":@(_youpaipinfoModel.youpaipprice),@"room_id":self.youpaiproomid} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self dismissViewControllerAnimated:YES completion:nil];
- self.youpaipinfoModel.youpaipdiff_num = [dict[@"data"][@"diff_num"] integerValue];
- self.youpaipinfoModel.youpaipprice = [dict[@"data"][@"price"] integerValue];
- }
- else
- {
- weakSelf.youpaipguardHerBtn.userInteractionEnabled = YES;
- }
- [ZCHUDHelper showTitle:dict[@"message"] showtime:1];
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.mj_JSONString showtime:1];
- [self dismissViewControllerAnimated:YES completion:nil];
- }];
- }
- else
- {
- if (_youpaipisChat) {
- [LCHttpHelper requestWithURLString:SendActivitGift parameters:@{@"user_id":self.youpaipuser_id,@"fairy_num":@(_youpaiptotalNum),@"fairy_price":@(_youpaipinfoModel.youpaipprice),@"is_message":@"1"} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self dismissViewControllerAnimated:YES completion:nil];
- self.youpaipinfoModel.youpaipdiff_num = [dict[@"data"][@"diff_num"] integerValue];
- self.youpaipinfoModel.youpaipprice = [dict[@"data"][@"price"] integerValue];
- }
- else
- {
- weakSelf.youpaipguardHerBtn.userInteractionEnabled = YES;
- }
- [ZCHUDHelper showTitle:dict[@"message"] showtime:1];
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.mj_JSONString showtime:1];
- [self dismissViewControllerAnimated:YES completion:nil];
- }];
- }else{
- [LCHttpHelper requestWithURLString:SendActivitGift parameters:@{@"user_id":self.youpaipuser_id,@"fairy_num":@(_youpaiptotalNum),@"fairy_price":@(_youpaipinfoModel.youpaipprice)} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self dismissViewControllerAnimated:YES completion:nil];
- self.youpaipinfoModel.youpaipdiff_num = [dict[@"data"][@"diff_num"] integerValue];
- self.youpaipinfoModel.youpaipprice = [dict[@"data"][@"price"] integerValue];
- }
- else
- {
- weakSelf.youpaipguardHerBtn.userInteractionEnabled = YES;
- }
- [ZCHUDHelper showTitle:dict[@"message"] showtime:1];
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.mj_JSONString showtime:1];
- [self dismissViewControllerAnimated:YES completion:nil];
- }];
- }
-
- }
-
-
- }
- @end
|