JXApplyViewController.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. //
  2. // JXApplyViewController.m
  3. // shiku_im
  4. //
  5. // Created by qiudezheng on 2020/4/28.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXApplyViewController.h"
  9. #import "JXApplyTableViewCell.h"
  10. #import "JXExamViewController.h"
  11. #import "JXSignViewController.h"
  12. #import "JXQuestionnVc.h"
  13. #import "JXShowDayFulLiVc.h"
  14. #import "JXBigReelVc.h"
  15. #import "JXTFuLiCell.h"
  16. #import "JXRelayVC.h"
  17. #import "JXActiveDetailVc.h"
  18. #import "UUMarqueeView.h"
  19. #import "JXActiveDetial2Vc.h"
  20. #import "JXMeiRiShowView.h"
  21. #import "JXMoneyShareView.h"
  22. #import "JXQuestionnnnVc.h"
  23. @interface JXApplyViewController ()<UIAlertViewDelegate>
  24. @property(strong,nonatomic)UIView * navigationView;
  25. @property(strong,nonatomic)UIView * progress;
  26. @property(strong,nonatomic)UIButton * backButton;
  27. @property(strong,nonatomic)UIButton * withdrawButton;
  28. @property(strong,nonatomic)UILabel * myCoinLabel;
  29. @property(strong,nonatomic)NSString * coin;
  30. @property(strong,nonatomic)NSString * withDrawMoney;
  31. @property(strong,nonatomic)UILabel * customerLabel;
  32. @property(strong,nonatomic)UITableView * signTable;
  33. @property(strong,nonatomic)NSArray * dataArray;
  34. @property(strong,nonatomic)UIButton * postButton;
  35. @property(strong,nonatomic)UIView * footerView;
  36. @property (nonatomic,strong) NSMutableArray *dataArr;
  37. @property(strong,nonatomic)NSString * shareContent;
  38. @property (nonatomic,strong) JXShowDayFulLiVc *dayFuliView;
  39. @property (nonatomic,copy) NSString *strURL;
  40. @property (nonatomic,weak) UITextView * textView;
  41. @property (nonatomic,weak) UUMarqueeView *leftwardMarqueeView;
  42. @property (nonatomic,weak) UIButton *lingQuBtn;
  43. @end
  44. @implementation JXApplyViewController
  45. - (void)viewDidLoad {
  46. [super viewDidLoad];
  47. self.tableView.alpha = 0.0f; //
  48. _dataArr=[NSMutableArray arrayWithObjects:@"dat",@"yuy",@"qian",@"fay",@"fat", nil];
  49. [self initNavigationView];
  50. [self initComponents];
  51. _dictStatus=[NSDictionary dictionary];
  52. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshMethod) name:@"refreshes" object:nil];
  53. _dayFuliView=[[JXShowDayFulLiVc alloc]init];
  54. _dayFuliView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7];
  55. _dayFuliView.frame=[UIScreen mainScreen].bounds;
  56. [[UIApplication sharedApplication].keyWindow addSubview:_dayFuliView];
  57. _dayFuliView.hidden=YES;
  58. _dayFuliView.userInteractionEnabled=YES;
  59. [_dayFuliView.tongYiBtn addTarget:self action:@selector(shareButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  60. [g_notify addObserver:self selector:@selector(tongyong) name:@"tongyong" object:nil];
  61. [g_notify addObserver:self selector:@selector(comeback) name:@"comeBack" object:nil];
  62. }
  63. - (void)tongyong{
  64. [JXMeiRiShowView showView];
  65. // 恭喜您,您成功领取了今日任务奖励,赶紧去我的即信钱包查看。如果长时间未到账,请联系在线客服!
  66. long time = (long)[[NSDate date] timeIntervalSince1970];
  67. time = (time *1000 + g_server.timeDifference);
  68. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  69. [g_server getUserTaskDailyBySalt:salt andToView:self];
  70. }
  71. - (void)comeback{
  72. JXMessageObject *msg=[[JXMessageObject alloc] init];
  73. msg.type = [NSNumber numberWithInt:kWCMessageTypeText];
  74. //msg.toUserId = _user.userId;
  75. msg.fromUserId = MY_USER_ID;
  76. msg.fromUserName = g_server.myself.userNickname;
  77. // msg.content = [NSString stringWithFormat:@"%@%@%@",@"我在每日任务获得",_coinStringS,@"即信币,快来一起参与"];
  78. msg.content = [NSString stringWithFormat:@"分享领取即信币"];
  79. msg.timeSend = [NSDate date];
  80. JXRelayVC * relay = [[JXRelayVC alloc] init];
  81. NSMutableArray *array = [NSMutableArray arrayWithObject:msg];
  82. relay.relayMsgArray = array;
  83. relay.isUrl = NO;
  84. relay.pushType = @"messageContent";
  85. relay.yunMoney=@"30";
  86. [g_navigation pushViewController:relay animated:YES];
  87. }
  88. -(void)viewWillAppear:(BOOL)animated{
  89. [super viewWillAppear:animated];
  90. [SVProgressHUD showWithStatus:@"加载中"];
  91. long time = (long)[[NSDate date] timeIntervalSince1970];
  92. time = (time *1000 + g_server.timeDifference);
  93. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  94. [g_server getUserTaskDailyBySalt:salt andToView:self];
  95. //[g_server gainAllAward:salt andToView:self];
  96. }
  97. -(void)postButtonClickeds:(UIButton *)sender
  98. {
  99. if ([_dictStatus[@"status"] intValue]==3) {
  100. [JXMeiRiShowView showView];
  101. }else{
  102. [g_notify addObserver:self selector:@selector(tongyong) name:@"tongyong" object:nil];
  103. [JXMoneyShareView showView];
  104. }
  105. }
  106. -(void)shareButtonClicked:(UIButton *)sender {
  107. long time = (long)[[NSDate date] timeIntervalSince1970];
  108. time = (time *1000 + g_server.timeDifference);
  109. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  110. [g_server getMyCoinsss:salt andToView:self];
  111. }
  112. //刷新
  113. -(void)refreshMethod
  114. {
  115. long time = (long)[[NSDate date] timeIntervalSince1970];
  116. time = (time *1000 + g_server.timeDifference);
  117. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  118. [g_server getUserTaskDailyBySalt:salt andToView:self];
  119. //[g_server getMyCoinsss:salt andToView:self];
  120. }
  121. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  122. [SVProgressHUD dismiss];
  123. if([aDownload.action isEqualToString:act_GetTaskRecord])
  124. {
  125. self.dataArray = array1;
  126. [self.signTable reloadData];
  127. _dictStatus=[array1 firstObject];
  128. int count = 0;
  129. // if([_dictStatus[@"status"] intValue]==3){
  130. //
  131. // self.lingQuBtn.userInteractionEnabled=YES;
  132. // [self.lingQuBtn setImage:[UIImage imageNamed:@"红色按钮"] forState:UIControlStateNormal];
  133. //
  134. // return;
  135. // }else{
  136. int aaaaaa=0;
  137. NSMutableArray *temparr=[NSMutableArray arrayWithCapacity:0];
  138. for(NSDictionary * dict in _dataArray)
  139. {
  140. NSString * balanceProgress = [NSString stringWithFormat:@"%@",[dict objectForKey:@"surplus"]];
  141. if ([dict[@"status"] intValue]==2 ) {
  142. aaaaaa++;
  143. [temparr addObject:@"1"];
  144. }
  145. if(balanceProgress.intValue == 0)
  146. {
  147. count ++;
  148. }
  149. }
  150. if(temparr.count==_dataArray.count ||[_dictStatus[@"status"] intValue]==3)
  151. {
  152. self.lingQuBtn.userInteractionEnabled=YES;
  153. [self.lingQuBtn setImage:[UIImage imageNamed:@"红色按钮"] forState:UIControlStateNormal];
  154. }else{
  155. self.lingQuBtn.userInteractionEnabled=NO;
  156. [self.lingQuBtn setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal];
  157. }
  158. }
  159. if([aDownload.action isEqualToString:act_GetMyCoin])
  160. {
  161. self.coin = [NSString stringWithFormat:@"%@",[dict objectForKey:@"coin"]];
  162. _strURL=[NSString stringWithFormat:@"%@",[dict objectForKey:@"coin"]];
  163. self.myCoinLabel.text = [NSString stringWithFormat:@"我的即信币:%@",[dict objectForKey:@"coin"]];
  164. }
  165. if([aDownload.action isEqualToString:act_GainContinueAward])
  166. {
  167. [SVProgressHUD showSuccessWithStatus:@"提现成功"];
  168. }
  169. if([aDownload.action isEqualToString:act_GainAllAward])
  170. {
  171. NSString *coinStr=[NSString stringWithFormat:@"%@",dict[@"totalCoin"]];
  172. if ([coinStr floatValue]<=0) {
  173. //[SVProgressHUD showSuccessWithStatus:@"已领取您的即信币"];
  174. // [SVProgressHUD dismissWithDelay:1];
  175. self.lingQuBtn.userInteractionEnabled=NO;
  176. [self.lingQuBtn setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal];
  177. return;
  178. }
  179. _coinStringS=coinStr;
  180. // [_dayFuliView.coinBtn setTitle:coinStr forState:UIControlStateNormal];
  181. //[SVProgressHUD setMaximumDismissTimeInterval:2.0f];
  182. // [SVProgressHUD showSuccessWithStatus:@"获得所有任务即信币成功"];
  183. //self.postButton.alpha = 0.0f;
  184. }
  185. [SVProgressHUD dismiss];
  186. }
  187. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  188. [SVProgressHUD dismiss];
  189. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  190. if([errorCode isEqualToString:@"权限验证失败"])
  191. {
  192. long time = (long)[[NSDate date] timeIntervalSince1970];
  193. time = (time *1000 + g_server.timeDifference);
  194. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  195. if([aDownload.action isEqualToString:act_GetTaskRecord])
  196. {
  197. [g_server getUserTaskDailyBySalt:salt andToView:self];
  198. }
  199. if([aDownload.action isEqualToString:act_GetMyCoin])
  200. {
  201. [g_server getMyCoinsss:salt andToView:self];
  202. }
  203. if([aDownload.action isEqualToString:act_GainContinueAward])
  204. {
  205. [g_server withDrawCoinBySalt:salt andCoin:self.withDrawMoney andToView:self];
  206. }
  207. if([aDownload.action isEqualToString:act_GainAllAward])
  208. {
  209. [g_server gainAllAward:salt andToView:self];
  210. }
  211. }
  212. else
  213. {
  214. [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]];
  215. }
  216. if( [aDownload.action isEqualToString:act_UserLogout] ){
  217. }
  218. [SVProgressHUD dismiss];
  219. return hide_error;
  220. }
  221. -(void)viewWillDisappear:(BOOL)animated
  222. {
  223. [SVProgressHUD dismiss];
  224. }
  225. -(void)initNavigationView
  226. {
  227. self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT>=812?88:64)];
  228. self.navigationView.backgroundColor = [UIColor whiteColor];
  229. [self.view addSubview:self.navigationView];
  230. UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 40, JX_SCREEN_WIDTH, 40)];
  231. titleLabel.text = @"每日任务";
  232. titleLabel.textColor = [UIColor blackColor];
  233. titleLabel.font = [UIFont systemFontOfSize:18.0f];
  234. titleLabel.textAlignment = NSTextAlignmentCenter;
  235. [self.navigationView addSubview:titleLabel];
  236. self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
  237. self.backButton.frame = CGRectMake(15, 30, 30, 30);
  238. if(JX_SCREEN_HEIGHT >= 812)
  239. {
  240. self.backButton.frame = CGRectMake(15, 45, 30, 30);
  241. } // meirirenwu
  242. [self.backButton setImage:[UIImage imageNamed:@"title_back_black"] forState:UIControlStateNormal];
  243. [self.backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  244. [self.navigationView addSubview:self.backButton];
  245. }
  246. -(void)withDrawButtonClicked:(UIButton *)sender
  247. {
  248. if(self.coin.intValue <= 0)
  249. {
  250. [SVProgressHUD setMaximumDismissTimeInterval:2.0];
  251. [SVProgressHUD showErrorWithStatus:@"当前没有提现金额"];
  252. }
  253. else
  254. {
  255. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"提现" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
  256. alert.alertViewStyle =UIAlertViewStylePlainTextInput;//最主要的是这个
  257. UITextField *barcodeTextField=[alert textFieldAtIndex:0];//获得对应的文本框,
  258. barcodeTextField.keyboardType=UIKeyboardTypeNumberPad;//设置数值类型
  259. barcodeTextField.placeholder = @"请输入提现金额";
  260. [alert show];
  261. }
  262. }
  263. - (void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger) buttonIndex {
  264. if(buttonIndex == 1)
  265. {
  266. UITextField *barcodeTextField=[alertView textFieldAtIndex:0];
  267. NSLog(@"textval:%@",barcodeTextField.text);
  268. self.withDrawMoney = barcodeTextField.text;
  269. long time = (long)[[NSDate date] timeIntervalSince1970];
  270. time = (time *1000 + g_server.timeDifference);
  271. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  272. [g_server withDrawCoinBySalt:salt andCoin:barcodeTextField.text andToView:self];
  273. }
  274. }
  275. -(void)initComponents
  276. {
  277. // 每日福利背景 view
  278. UIImageView * backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP)];
  279. backImageView.userInteractionEnabled=YES;
  280. backImageView.image = [UIImage imageNamed:@"applyBackImage2"];
  281. backImageView.contentMode=UIViewContentModeScaleToFill;
  282. [self.view addSubview:backImageView];
  283. UIImageView * titleIMG = [[UIImageView alloc]init];
  284. titleIMG.image = [UIImage imageNamed:@"每日福利"];
  285. [backImageView addSubview:titleIMG];
  286. [titleIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  287. make.top.mas_equalTo(1);
  288. make.centerX.mas_equalTo(backImageView.mas_centerX);
  289. }];
  290. UIImageView * titleIMG1 = [[UIImageView alloc]init];
  291. titleIMG1.image = [UIImage imageNamed:@"每日完成任务"];
  292. [backImageView addSubview:titleIMG1];
  293. [titleIMG1 mas_makeConstraints:^(MASConstraintMaker *make) {
  294. make.top.mas_equalTo(titleIMG.mas_bottom).mas_offset(27);
  295. make.left.mas_equalTo(20);
  296. }];
  297. UIImageView * titleIMG2 = [[UIImageView alloc]init];
  298. titleIMG2.image = [UIImage imageNamed:@"巨额现金领不停"];
  299. [backImageView addSubview:titleIMG2];
  300. [titleIMG2 mas_makeConstraints:^(MASConstraintMaker *make) {
  301. make.top.mas_equalTo(titleIMG1.mas_bottom).mas_offset(15);
  302. make.left.mas_equalTo(20);
  303. }];
  304. UIImageView * titleIMG3 = [[UIImageView alloc]init];
  305. titleIMG3.image = [UIImage imageNamed:@"每日Line"];
  306. [backImageView addSubview:titleIMG3];
  307. [titleIMG3 mas_makeConstraints:^(MASConstraintMaker *make) {
  308. make.top.mas_equalTo(titleIMG2.mas_bottom).mas_offset(1);
  309. make.centerX.mas_equalTo(backImageView.mas_centerX);
  310. }];
  311. self.postButton = [UIButton buttonWithType:UIButtonTypeCustom];
  312. //[self.postButton setImage:[UIImage imageNamed:@"mrflBtn"] forState:UIControlStateNormal];
  313. self.postButton.userInteractionEnabled=NO;
  314. [self.postButton setImage:[UIImage imageNamed:@"灰色按钮2"] forState:UIControlStateNormal];
  315. [self.postButton addTarget:self action:@selector(postButtonClickeds:) forControlEvents:UIControlEventTouchUpInside];
  316. [backImageView addSubview:self.postButton];
  317. self.lingQuBtn=_postButton;
  318. [self.postButton mas_makeConstraints:^(MASConstraintMaker *make) {
  319. make.centerX.mas_equalTo(titleIMG3.mas_centerX).mas_offset(0);
  320. make.bottom.mas_equalTo(0);
  321. }];
  322. self.signTable = [[UITableView alloc]init];
  323. self.signTable.dataSource = self;
  324. self.signTable.delegate = self;
  325. self.signTable.separatorStyle = UITableViewCellSeparatorStyleNone;
  326. self.signTable.backgroundColor = [UIColor clearColor];
  327. [backImageView addSubview:self.signTable];
  328. [self.signTable mas_makeConstraints:^(MASConstraintMaker *make) {
  329. make.top.mas_equalTo(titleIMG3.mas_bottom).mas_offset(15);
  330. make.left.right.mas_equalTo(0);
  331. make.bottom.mas_equalTo(self.postButton.mas_top);
  332. }];
  333. }
  334. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  335. {
  336. return self.dataArray.count;
  337. }
  338. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  339. {
  340. JXTFuLiCell *cellX=[JXTFuLiCell cellWithTableView:tableView];
  341. NSDictionary * dictionary = [_dataArray objectAtIndex:[indexPath row]];
  342. cellX.dict=dictionary;
  343. cellX.leftIMG.image=[UIImage imageNamed:_dataArr[indexPath.row]];
  344. return cellX;
  345. }
  346. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  347. {
  348. return 70.0f;
  349. }
  350. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  351. {
  352. NSDictionary * dictionary = [self.dataArray objectAtIndex:[indexPath row]];
  353. NSString * status = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"status"]];
  354. if ([status intValue]==2||[status intValue]==3) {
  355. return;
  356. }
  357. NSString * title = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"titleAbbr"]];
  358. if([title isEqualToString:@"答"])
  359. {
  360. NSString * balance = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"surplus"]];
  361. //JXExamViewController JXQuestionnnnVc JXQuestionnVc
  362. JXQuestionnnnVc * exam = [[JXQuestionnnnVc alloc]init];
  363. if(balance.intValue == 0)
  364. {
  365. exam.ifAnswer = @"NO";
  366. }
  367. [g_navigation pushViewController:exam animated:YES];
  368. }
  369. if([title isEqualToString:@"签"])
  370. {
  371. JXSignViewController * sign = [[JXSignViewController alloc]init];
  372. [g_navigation pushViewController:sign animated:YES];
  373. }
  374. }
  375. -(void)backButtonClicked:(UIButton *)sender
  376. {
  377. [g_navigation dismissViewController:self animated:YES];
  378. }
  379. @end