GainsWithdrawVC.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. //
  2. // GainsWithdrawVC.m
  3. // BuguLive
  4. //
  5. // Created by hym on 2016/11/29.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "GainsWithdrawVC.h"
  9. #import "IncomeViewController.h"
  10. #import "ReactiveObjC.h"
  11. #import "SChargerVC.h"
  12. #import "ReceiverRecordViewController.h"
  13. @interface GainsWithdrawVC ()<UITextFieldDelegate>
  14. @property (weak, nonatomic) IBOutlet UILabel *lbAllTickets;
  15. @property (weak, nonatomic) IBOutlet UILabel *lbTodayTickets;
  16. @property (weak, nonatomic) IBOutlet UITextField *tfWithdrawTickets;
  17. @property (weak, nonatomic) IBOutlet UIButton *btnAffirm;
  18. @property (weak, nonatomic) IBOutlet UILabel *lbRatioTickets;
  19. @property (assign, nonatomic) CGFloat ratio;
  20. @property (nonatomic, strong) NetHttpsManager *httpManager;
  21. @property (weak, nonatomic) IBOutlet UILabel *canGetLbl;
  22. @property (weak, nonatomic) IBOutlet UILabel *totalLbl;
  23. @property (weak, nonatomic) IBOutlet UILabel *withdrawDepositLbl;
  24. @property (weak, nonatomic) IBOutlet UILabel *labArrivalTime;
  25. @property(nonatomic, strong) NSString *withdrawalType;
  26. @property (weak, nonatomic) IBOutlet UIButton *editBtn;
  27. @property (weak, nonatomic) IBOutlet UITextField *drawTF;
  28. @end
  29. @implementation GainsWithdrawVC
  30. - (void)viewWillAppear:(BOOL)animated {
  31. [super viewWillAppear:animated];
  32. self.navigationController.navigationBar.hidden = YES;
  33. }
  34. - (void)viewDidLoad
  35. {
  36. [super viewDidLoad];
  37. [self withdrawDeposit];
  38. UIButton *releaseButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  39. [releaseButton setTitle:ASLocalizedString(@"提现记录") forState:normal];
  40. [releaseButton addTarget:self action:@selector(releaseInfo) forControlEvents:UIControlEventTouchUpInside];
  41. UIBarButtonItem *releaseButtonItem = [[UIBarButtonItem alloc] initWithCustomView:releaseButton];
  42. self.navigationItem.rightBarButtonItem = releaseButtonItem;
  43. [releaseButton setTitleColor:RGB(11, 11, 11) forState:UIControlStateNormal];
  44. self.title = ASLocalizedString(@"提现");
  45. self.navigationItem.leftBarButtonItem = [UIBarButtonItem
  46. itemWithTarget:self
  47. action:@selector(backToVC)
  48. image:@"com_arrow_vc_back"
  49. highImage:@"com_arrow_vc_back"];
  50. // self.btnAffirm.layer.borderColor = kAppMainColor.CGColor;
  51. // [self.btnAffirm setBackgroundColor:kAppMainColor];
  52. // [self.btnAffirm setBackgroundImage:[UIImage imageNamed:@"mg_button_global"] forState:UIControlStateNormal];
  53. [self.btnAffirm setTitleColor:[UIColor whiteColor]
  54. forState:UIControlStateNormal];
  55. // self.btnAffirm.layer.borderWidth = 1.0f;
  56. // self.btnAffirm.layer.cornerRadius = self.btnAffirm.frame.size.height/2.0f;
  57. // self.btnAffirm.layer.masksToBounds = YES;
  58. // [self.editBtn setBackgroundImage:[UIImage imageNamed:@"mg_button_global"] forState:UIControlStateNormal];
  59. [self.editBtn setTitleColor:[UIColor whiteColor]
  60. forState:UIControlStateNormal];
  61. // self.btnAffirm.layer.borderWidth = 1.0f;
  62. // self.editBtn.layer.cornerRadius = self.editBtn.frame.size.height/2.0f;
  63. // self.editBtn.layer.masksToBounds = YES;
  64. self.drawTF.placeholder = ASLocalizedString(@"请输入要提现的额度");
  65. self.tfWithdrawTickets.keyboardType = UIKeyboardTypeDecimalPad;
  66. self.view.backgroundColor = kBackGroundColor;
  67. self.lbRatioTickets.text = @"0";
  68. self.tfWithdrawTickets.delegate = self;
  69. // [self.tfWithdrawTickets addTarget:self action:@selector(passConTextChange:) forControlEvents:UIControlEventEditingChanged];
  70. //注意:事件类型是:`UIControlEventEditingChanged`
  71. _httpManager = [NetHttpsManager manager];
  72. //添加手势
  73. self.labArrivalTime.userInteractionEnabled = YES;
  74. UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer:)];
  75. [self.labArrivalTime addGestureRecognizer:tapGesture];
  76. // [RACObserve(self, withdrawalType) subscribeNext:^(NSString *x) {
  77. // if([x isEqualToString:@"1"])
  78. // {
  79. // self.labArrivalTime.text = @"48小时到账";
  80. // }
  81. // else
  82. // {
  83. // self.labArrivalTime.text = @"一周到账";
  84. // }
  85. //
  86. // [self passConTextChange:nil];
  87. // }];
  88. self.withdrawalType = @"1"; //一周到账
  89. [self reqData];
  90. [self setUpLocalizationString];
  91. }
  92. - (IBAction)editInfo:(id)sender {
  93. NSString *url = [NSString stringWithFormat:@"%@",[GlobalVariables sharedInstance].appModel.h5_url.withdrawal_account_url];
  94. BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:url isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
  95. [self.navigationController pushViewController:tmpController animated:NO];
  96. }
  97. - (IBAction)tixianjilu:(id)sender {
  98. [self releaseInfo];
  99. }
  100. - (void)releaseInfo {
  101. ReceiverRecordViewController *receiveVC =[[ReceiverRecordViewController alloc]init];
  102. [[AppDelegate sharedAppDelegate] pushViewController:receiveVC animated:YES];
  103. // SChargerVC *chargerVC = [[SChargerVC alloc]init];
  104. // chargerVC.recordIndex = 0;
  105. // chargerVC.feeIndex = [GlobalVariables sharedInstance].appModel.live_pay_time ? 0:1;
  106. // [[AppDelegate sharedAppDelegate] pushViewController:chargerVC animated:YES];
  107. // NSString *tmpUrlStr = [GlobalVariables sharedInstance].appModel.h5_url.withdrawal_account_url;
  108. // BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:tmpUrlStr isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
  109. // [[AppDelegate sharedAppDelegate] pushViewController:tmpController animated:YES];
  110. }
  111. - (void)handleTapGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer {
  112. FDActionSheet *alert = [[FDActionSheet alloc] initWithTitle:@"" message:nil];
  113. [alert addAction:[FDAction actionWithTitle:@"一周到账" type:FDActionTypeDefault CallBack:^{
  114. self.withdrawalType = @"2";
  115. }]];
  116. [alert addAction:[FDAction actionWithTitle:@"48小时到账" type:FDActionTypeDefault CallBack:^{
  117. self.withdrawalType = @"1";
  118. }]];
  119. [alert addAction:[FDAction actionWithTitle:@"取消" type:FDActionTypeCancel CallBack:^{
  120. }]];
  121. [alert show:self.view];
  122. }
  123. - (void)withdrawDeposit
  124. {
  125. NSString *ticketName = [GlobalVariables sharedInstance].appModel.ticket_name;
  126. // self.totalLbl.text = [NSString stringWithFormat:ASLocalizedString(@"%@"),ticketName];
  127. self.canGetLbl.text = [NSString stringWithFormat:ASLocalizedString(@"今日可领%@数"),ticketName];
  128. // self.withdrawDepositLbl.text = [NSString stringWithFormat:ASLocalizedString(@"%@提现金额"),ticketName];
  129. }
  130. - (IBAction)backlastVC:(id)sender {
  131. [self backToVC];
  132. }
  133. - (void)backToVC {
  134. [self.navigationController popViewControllerAnimated:YES];
  135. }
  136. - (void)reqData {
  137. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  138. [parmDict setObject:@"user_center" forKey:@"ctl"];
  139. [parmDict setObject:@"money_carry_alipay" forKey:@"act"];
  140. [parmDict setObject:@"type" forKey:self.withdrawalType];;
  141. [_httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  142. {
  143. if ([responseJson toInt:@"status"] ==1) {
  144. _ratio = [responseJson toFloat:@"ratio"];
  145. _lbAllTickets.text = [NSString stringWithFormat:@"%d",([responseJson toInt:@"can_use_ticket"])];
  146. _lbTodayTickets.text = [responseJson toString:@"day_ticket_max"];
  147. }else {
  148. }
  149. } FailureBlock:^(NSError *error)
  150. {
  151. }];
  152. }
  153. - (void)didReceiveMemoryWarning {
  154. [super didReceiveMemoryWarning];
  155. }
  156. - (void)viewWillDisappear:(BOOL)animated {
  157. [super viewWillDisappear:animated];
  158. [self.tfWithdrawTickets resignFirstResponder];
  159. }
  160. - (IBAction)onClick:(id)sender
  161. {
  162. if ([_tfWithdrawTickets.text integerValue] == 0)
  163. {
  164. // [FanweMessage alertHUD:[NSString stringWithFormat:ASLocalizedString(@"请输入要提现的%@数"),[GlobalVariables sharedInstance].appModel.ticket_name]];
  165. [FanweMessage alert:[NSString stringWithFormat:ASLocalizedString(@"请输入要提现的%@数"),[GlobalVariables sharedInstance].appModel.ticket_name]];
  166. return;
  167. }
  168. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  169. [parmDict setObject:@"user_center" forKey:@"ctl"];
  170. [parmDict setObject:@"submit_refund_alipay" forKey:@"act"];
  171. [parmDict setObject:_tfWithdrawTickets.text forKey:@"ticket"];
  172. [_httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  173. {
  174. if ([responseJson toInt:@"status"] ==1)
  175. {
  176. for (UIViewController *vc in self.navigationController.viewControllers)
  177. {
  178. if ([vc isKindOfClass:[IncomeViewController class]])
  179. {
  180. [self.navigationController popToViewController:vc animated:YES];
  181. }
  182. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"提现成功")];
  183. }
  184. }
  185. } FailureBlock:^(NSError *error)
  186. {
  187. }];
  188. }
  189. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  190. return [self validateNumber:string];
  191. }
  192. - (BOOL)validateNumber:(NSString*)number {
  193. BOOL res = YES;
  194. NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
  195. int i = 0;
  196. while (i < number.length) {
  197. NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
  198. NSRange range = [string rangeOfCharacterFromSet:tmpSet];
  199. if (range.length == 0) {
  200. res = NO;
  201. break;
  202. }
  203. i++;
  204. }
  205. if (res) {
  206. }
  207. return res;
  208. }
  209. //- (void)passConTextChange:(id)sender{
  210. // if ([self.tfWithdrawTickets.text length] == 0) {
  211. // _lbRatioTickets.text = ASLocalizedString(@"0元");
  212. // }else {
  213. // float ratio2 = self.model.ticket_catty_ratio.floatValue;
  214. //
  215. // if([self.withdrawalType isEqualToString:@"2"])
  216. // {
  217. // ratio2 = self.model.week_ticket_catty_ratio.floatValue;
  218. // }
  219. //
  220. // _lbRatioTickets.text = [NSString stringWithFormat:ASLocalizedString(@"%0.2lf元"),(ratio2 * [self.tfWithdrawTickets.text integerValue])];
  221. // }
  222. //
  223. //}
  224. /*
  225. #pragma mark - Navigation
  226. // In a storyboard-based application, you will often want to do a little preparation before navigation
  227. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  228. // Get the new view controller using [segue destinationViewController].
  229. // Pass the selected object to the new view controller.
  230. }
  231. */
  232. @end