// // JXApplyViewController.m // shiku_im // // Created by qiudezheng on 2020/4/28. // Copyright © 2020 Reese. All rights reserved. // #import "JXApplyViewController.h" #import "JXApplyTableViewCell.h" #import "JXExamViewController.h" #import "JXSignViewController.h" #import "JXQuestionnVc.h" #import "JXShowDayFulLiVc.h" #import "JXBigReelVc.h" #import "JXTFuLiCell.h" #import "JXRelayVC.h" #import "JXActiveDetailVc.h" #import "UUMarqueeView.h" #import "JXActiveDetial2Vc.h" #import "JXMeiRiShowView.h" #import "JXMoneyShareView.h" #import "JXQuestionnnnVc.h" @interface JXApplyViewController () @property(strong,nonatomic)UIView * navigationView; @property(strong,nonatomic)UIView * progress; @property(strong,nonatomic)UIButton * backButton; @property(strong,nonatomic)UIButton * withdrawButton; @property(strong,nonatomic)UILabel * myCoinLabel; @property(strong,nonatomic)NSString * coin; @property(strong,nonatomic)NSString * withDrawMoney; @property(strong,nonatomic)UILabel * customerLabel; @property(strong,nonatomic)UITableView * signTable; @property(strong,nonatomic)NSArray * dataArray; @property(strong,nonatomic)UIButton * postButton; @property(strong,nonatomic)UIView * footerView; @property (nonatomic,strong) NSMutableArray *dataArr; @property(strong,nonatomic)NSString * shareContent; @property (nonatomic,strong) JXShowDayFulLiVc *dayFuliView; @property (nonatomic,copy) NSString *strURL; @property (nonatomic,weak) UITextView * textView; @property (nonatomic,weak) UUMarqueeView *leftwardMarqueeView; @property (nonatomic,weak) UIButton *lingQuBtn; @end @implementation JXApplyViewController - (void)viewDidLoad { [super viewDidLoad]; self.tableView.alpha = 0.0f; // _dataArr=[NSMutableArray arrayWithObjects:@"dat",@"yuy",@"qian",@"fay",@"fat",@"damaa",@"damaa", nil]; [self initNavigationView]; [self initComponents]; _dictStatus=[NSDictionary dictionary]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshMethod) name:@"refreshes" object:nil]; _dayFuliView=[[JXShowDayFulLiVc alloc]init]; _dayFuliView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7]; _dayFuliView.frame=[UIScreen mainScreen].bounds; [[UIApplication sharedApplication].keyWindow addSubview:_dayFuliView]; _dayFuliView.hidden=YES; _dayFuliView.userInteractionEnabled=YES; [_dayFuliView.tongYiBtn addTarget:self action:@selector(shareButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; [g_notify addObserver:self selector:@selector(tongyong) name:@"tongyong" object:nil]; [g_notify addObserver:self selector:@selector(comeback) name:@"comeBack" object:nil]; } - (void)tongyong{ [JXMeiRiShowView showView]; // 恭喜您,您成功领取了今日任务奖励,赶紧去我的即信钱包查看。如果长时间未到账,请联系在线客服! long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getUserTaskDailyBySalt:salt andToView:self]; } - (void)comeback{ JXMessageObject *msg=[[JXMessageObject alloc] init]; msg.type = [NSNumber numberWithInt:kWCMessageTypeText]; //msg.toUserId = _user.userId; msg.fromUserId = MY_USER_ID; msg.fromUserName = g_server.myself.userNickname; // msg.content = [NSString stringWithFormat:@"%@%@%@",@"我在每日任务获得",_coinStringS,@"即信币,快来一起参与"]; msg.content = [NSString stringWithFormat:@"分享领取即信币"]; msg.timeSend = [NSDate date]; JXRelayVC * relay = [[JXRelayVC alloc] init]; NSMutableArray *array = [NSMutableArray arrayWithObject:msg]; relay.relayMsgArray = array; relay.isUrl = NO; relay.pushType = @"messageContent"; relay.yunMoney=@"30"; [g_navigation pushViewController:relay animated:YES]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [SVProgressHUD showWithStatus:@"加载中"]; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getUserTaskDailyBySalt:salt andToView:self]; //[g_server gainAllAward:salt andToView:self]; } -(void)postButtonClickeds:(UIButton *)sender { if ([_dictStatus[@"status"] intValue]==3) { [JXMeiRiShowView showView]; }else{ [g_notify addObserver:self selector:@selector(tongyong) name:@"tongyong" object:nil]; [JXMoneyShareView showView]; } } -(void)shareButtonClicked:(UIButton *)sender { long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getMyCoinsss:salt andToView:self]; } //刷新 -(void)refreshMethod { long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getUserTaskDailyBySalt:salt andToView:self]; //[g_server getMyCoinsss:salt andToView:self]; } -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ [SVProgressHUD dismiss]; if([aDownload.action isEqualToString:act_GetTaskRecord]) { self.dataArray = array1; [self.signTable reloadData]; _dictStatus=[array1 firstObject]; int count = 0; // if([_dictStatus[@"status"] intValue]==3){ // // self.lingQuBtn.userInteractionEnabled=YES; // [self.lingQuBtn setImage:[UIImage imageNamed:@"红色按钮"] forState:UIControlStateNormal]; // // return; // }else{ int aaaaaa=0; NSMutableArray *temparr=[NSMutableArray arrayWithCapacity:0]; for(NSDictionary * dict in _dataArray) { NSString * balanceProgress = [NSString stringWithFormat:@"%@",[dict objectForKey:@"surplus"]]; if ([dict[@"status"] intValue]==2 ) { aaaaaa++; [temparr addObject:@"1"]; } if(balanceProgress.intValue == 0) { count ++; } } if(temparr.count==_dataArray.count ||[_dictStatus[@"status"] intValue]==3) { self.lingQuBtn.userInteractionEnabled=YES; [self.lingQuBtn setImage:[UIImage imageNamed:@"红色按钮"] forState:UIControlStateNormal]; }else{ self.lingQuBtn.userInteractionEnabled=NO; [self.lingQuBtn setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal]; } } if([aDownload.action isEqualToString:act_GetMyCoin]) { self.coin = [NSString stringWithFormat:@"%@",[dict objectForKey:@"coin"]]; _strURL=[NSString stringWithFormat:@"%@",[dict objectForKey:@"coin"]]; self.myCoinLabel.text = [NSString stringWithFormat:@"我的即信币:%@",[dict objectForKey:@"coin"]]; } if([aDownload.action isEqualToString:act_GainContinueAward]) { [SVProgressHUD showSuccessWithStatus:@"提现成功"]; } if([aDownload.action isEqualToString:act_GainAllAward]) { NSString *coinStr=[NSString stringWithFormat:@"%@",dict[@"totalCoin"]]; if ([coinStr floatValue]<=0) { //[SVProgressHUD showSuccessWithStatus:@"已领取您的即信币"]; // [SVProgressHUD dismissWithDelay:1]; self.lingQuBtn.userInteractionEnabled=NO; [self.lingQuBtn setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal]; return; } _coinStringS=coinStr; // [_dayFuliView.coinBtn setTitle:coinStr forState:UIControlStateNormal]; //[SVProgressHUD setMaximumDismissTimeInterval:2.0f]; // [SVProgressHUD showSuccessWithStatus:@"获得所有任务即信币成功"]; //self.postButton.alpha = 0.0f; } [SVProgressHUD dismiss]; } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ [SVProgressHUD dismiss]; NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; if([aDownload.action isEqualToString:act_GetTaskRecord]) { [g_server getUserTaskDailyBySalt:salt andToView:self]; } if([aDownload.action isEqualToString:act_GetMyCoin]) { [g_server getMyCoinsss:salt andToView:self]; } if([aDownload.action isEqualToString:act_GainContinueAward]) { [g_server withDrawCoinBySalt:salt andCoin:self.withDrawMoney andToView:self]; } if([aDownload.action isEqualToString:act_GainAllAward]) { [g_server gainAllAward:salt andToView:self]; } } else { [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]]; } if( [aDownload.action isEqualToString:act_UserLogout] ){ } [SVProgressHUD dismiss]; return hide_error; } -(void)viewWillDisappear:(BOOL)animated { [SVProgressHUD dismiss]; } -(void)initNavigationView { self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT>=812?88:64)]; self.navigationView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.navigationView]; UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 40, JX_SCREEN_WIDTH, 40)]; titleLabel.text = @"每日任务"; titleLabel.textColor = [UIColor blackColor]; titleLabel.font = [UIFont systemFontOfSize:18.0f]; titleLabel.textAlignment = NSTextAlignmentCenter; [self.navigationView addSubview:titleLabel]; self.backButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.backButton.frame = CGRectMake(15, 30, 30, 30); if(JX_SCREEN_HEIGHT >= 812) { self.backButton.frame = CGRectMake(15, 45, 30, 30); } // meirirenwu [self.backButton setImage:[UIImage imageNamed:@"title_back_black"] forState:UIControlStateNormal]; [self.backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.navigationView addSubview:self.backButton]; } -(void)withDrawButtonClicked:(UIButton *)sender { if(self.coin.intValue <= 0) { [SVProgressHUD setMaximumDismissTimeInterval:2.0]; [SVProgressHUD showErrorWithStatus:@"当前没有提现金额"]; } else { UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"提现" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil]; alert.alertViewStyle =UIAlertViewStylePlainTextInput;//最主要的是这个 UITextField *barcodeTextField=[alert textFieldAtIndex:0];//获得对应的文本框, barcodeTextField.keyboardType=UIKeyboardTypeNumberPad;//设置数值类型 barcodeTextField.placeholder = @"请输入提现金额"; [alert show]; } } - (void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger) buttonIndex { if(buttonIndex == 1) { UITextField *barcodeTextField=[alertView textFieldAtIndex:0]; NSLog(@"textval:%@",barcodeTextField.text); self.withDrawMoney = barcodeTextField.text; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server withDrawCoinBySalt:salt andCoin:barcodeTextField.text andToView:self]; } } -(void)initComponents { // 每日福利背景 view UIImageView * backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP)]; backImageView.userInteractionEnabled=YES; backImageView.image = [UIImage imageNamed:@"applyBackImage2"]; backImageView.contentMode=UIViewContentModeScaleToFill; [self.view addSubview:backImageView]; UIImageView * titleIMG = [[UIImageView alloc]init]; titleIMG.image = [UIImage imageNamed:@"每日福利"]; [backImageView addSubview:titleIMG]; [titleIMG mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(1); make.centerX.mas_equalTo(backImageView.mas_centerX); }]; UIImageView * titleIMG1 = [[UIImageView alloc]init]; titleIMG1.image = [UIImage imageNamed:@"每日完成任务"]; [backImageView addSubview:titleIMG1]; [titleIMG1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleIMG.mas_bottom).mas_offset(27); make.left.mas_equalTo(20); }]; UIImageView * titleIMG2 = [[UIImageView alloc]init]; titleIMG2.image = [UIImage imageNamed:@"巨额现金领不停"]; [backImageView addSubview:titleIMG2]; [titleIMG2 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleIMG1.mas_bottom).mas_offset(15); make.left.mas_equalTo(20); }]; UIImageView * titleIMG3 = [[UIImageView alloc]init]; titleIMG3.image = [UIImage imageNamed:@"每日Line"]; [backImageView addSubview:titleIMG3]; [titleIMG3 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleIMG2.mas_bottom).mas_offset(1); make.centerX.mas_equalTo(backImageView.mas_centerX); }]; self.postButton = [UIButton buttonWithType:UIButtonTypeCustom]; //[self.postButton setImage:[UIImage imageNamed:@"mrflBtn"] forState:UIControlStateNormal]; self.postButton.userInteractionEnabled=NO; [self.postButton setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal]; [self.postButton addTarget:self action:@selector(postButtonClickeds:) forControlEvents:UIControlEventTouchUpInside]; [backImageView addSubview:self.postButton]; self.lingQuBtn=_postButton; [self.postButton mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(titleIMG3.mas_centerX).mas_offset(0); make.bottom.mas_equalTo(0); }]; self.signTable = [[UITableView alloc]init]; self.signTable.dataSource = self; self.signTable.delegate = self; self.signTable.separatorStyle = UITableViewCellSeparatorStyleNone; self.signTable.backgroundColor = [UIColor clearColor]; [backImageView addSubview:self.signTable]; [self.signTable mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleIMG3.mas_bottom).mas_offset(15); make.left.right.mas_equalTo(0); make.bottom.mas_equalTo(self.postButton.mas_top); }]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArray.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { JXTFuLiCell *cellX=[JXTFuLiCell cellWithTableView:tableView]; NSDictionary * dictionary = [_dataArray objectAtIndex:[indexPath row]]; cellX.dict=dictionary; cellX.leftIMG.image=[UIImage imageNamed:_dataArr[indexPath.row]]; return cellX; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70.0f; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary * dictionary = [self.dataArray objectAtIndex:[indexPath row]]; NSString * status = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"status"]]; if ([status intValue]==2||[status intValue]==3) { return; } NSString * title = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"titleAbbr"]]; if([title isEqualToString:@"答"]) { NSString * balance = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"surplus"]]; //JXExamViewController JXQuestionnnnVc JXQuestionnVc JXQuestionnnnVc * exam = [[JXQuestionnnnVc alloc]init]; if(balance.intValue == 0) { exam.ifAnswer = @"NO"; } [g_navigation pushViewController:exam animated:YES]; } if([title isEqualToString:@"签"]) { JXSignViewController * sign = [[JXSignViewController alloc]init]; [g_navigation pushViewController:sign animated:YES]; } } -(void)backButtonClicked:(UIButton *)sender { [g_navigation dismissViewController:self animated:YES]; } @end