JLApplyForWithdrawalViewController.m 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. //
  2. // JLApplyForWithdrawalViewController.m
  3. // shiku_im
  4. //
  5. // Created by JayLuo on 2020/1/13.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JLApplyForWithdrawalViewController.h"
  9. #import "JLWithdrawalRecordViewController.h"
  10. #import "GALCaptcha.h"
  11. #define HEIGHT 50
  12. @interface JLApplyForWithdrawalViewController ()
  13. @property (nonatomic, strong) GALCaptcha *imgCodeImg;
  14. @property (nonatomic, strong) UIButton *btn;
  15. @end
  16. @implementation JLApplyForWithdrawalViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view from its nib.
  20. self.title = @"申请提现";
  21. self.isGotoBack = YES;
  22. self.heightFooter = 0;
  23. self.heightHeader = JX_SCREEN_TOP;
  24. [self createHeadAndFoot];
  25. [self setupUI];
  26. }
  27. - (void)setupUI {
  28. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  29. label.font = g_factory.font14;
  30. label.text = @"提现记录";
  31. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:label];
  32. [label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rightButtonClick)]];
  33. label.userInteractionEnabled = YES;
  34. [self setRightBarButtonItem:item];
  35. [self createCustomView];
  36. }
  37. - (void)rightButtonClick {
  38. JLWithdrawalRecordViewController *vc = [[JLWithdrawalRecordViewController alloc] init];
  39. [g_navigation pushViewController:vc animated:YES];
  40. }
  41. - (void)createCustomView {
  42. int h = 0;
  43. JXImageView* iv;
  44. iv = [[JXImageView alloc]init];
  45. iv.frame = self.tableBody.bounds;
  46. iv.delegate = self;
  47. iv.didTouch = @selector(hideKeyBoardToView);
  48. [self.tableBody addSubview:iv];
  49. iv = [self createButton:@"平台名称:" drawTop:YES drawBottom:YES must:NO click:nil];
  50. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  51. _platformName = [self createTextField:iv default:@"" hint:@"请输入平台名称" keyboardType:(UIKeyboardTypeDefault)];
  52. h+=iv.frame.size.height;
  53. iv = [self createButton:@"会员账号:" drawTop:YES drawBottom:YES must:NO click:nil];
  54. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  55. _account = [self createTextField:iv default:@"" hint:@"请输入会员账号"keyboardType:(UIKeyboardTypeDefault)];
  56. h+=iv.frame.size.height;
  57. iv = [self createButton:@"提现金额:" drawTop:YES drawBottom:YES must:NO click:nil];
  58. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  59. _amount = [self createTextField:iv default:@"" hint:@"请输入提现金额"keyboardType:(UIKeyboardTypeDecimalPad)];
  60. h+=iv.frame.size.height;
  61. iv = [self createButton:@"提现理由:" drawTop:YES drawBottom:YES must:NO click:nil];
  62. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  63. _reason = [self createTextField:iv default:@"" hint:@"请输入提现理由"keyboardType:(UIKeyboardTypeDefault)];
  64. h+=iv.frame.size.height;
  65. iv = [self createButton:@"描述:" drawTop:YES drawBottom:YES must:NO click:nil];
  66. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  67. _remark = [self createTextField:iv default:@"" hint:@"请输入描述"keyboardType:(UIKeyboardTypeDefault)];
  68. h+=iv.frame.size.height;
  69. iv = [self createButton:@"验证码:" drawTop:YES drawBottom:YES must:NO click:nil];
  70. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  71. // _verifyCode = [self createTextField:iv default:@"" hint:@"请输入验证码"];
  72. h+=iv.frame.size.height+INSETS;
  73. //图片验证码
  74. _verifyCode = [UIFactory createTextFieldWith:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/4,HEIGHT-INSETS*2) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:@"请输入验证码" font:g_factory.font15];
  75. _verifyCode.keyboardType = UIKeyboardTypeASCIICapable;
  76. _verifyCode.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  77. _verifyCode.borderStyle = UITextBorderStyleNone;
  78. _verifyCode.clearButtonMode = UITextFieldViewModeWhileEditing;
  79. [iv addSubview:_verifyCode];
  80. _imgCodeImg = [[GALCaptcha alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_verifyCode.frame)+INSETS, 0, 70, 35)];
  81. _imgCodeImg.center = CGPointMake(_imgCodeImg.center.x, _verifyCode.center.y);
  82. _imgCodeImg.userInteractionEnabled = YES;
  83. [iv addSubview:_imgCodeImg];
  84. _btn = [UIFactory createCommonButton:@"提交" target:self action:@selector(submit)];
  85. [_btn.titleLabel setFont:g_factory.font16];
  86. _btn.frame = CGRectMake(10, h, JX_SCREEN_WIDTH-10*2, 40);
  87. _btn.layer.masksToBounds = YES;
  88. _btn.layer.cornerRadius = 5;
  89. [self.tableBody addSubview:_btn];
  90. }
  91. - (void)submit {
  92. _btn.userInteractionEnabled = NO;
  93. [_wait show];
  94. [self hideKeyBoardToView];
  95. if (![_imgCodeImg.CatString.lowercaseString isEqualToString:_verifyCode.text.lowercaseString]) {
  96. [g_App showAlert:@"验证码错误"];
  97. _btn.userInteractionEnabled = YES;
  98. [_wait stop];
  99. return;
  100. }
  101. // 检查所有输入是否为空
  102. if(_platformName.text.length<1 || _account.text.length<1 || _amount.text.length<1 || _reason.text.length<1 || _verifyCode.text.length<1){
  103. [g_App showAlert:@"请您填写完整的信息"];
  104. _btn.userInteractionEnabled = YES;
  105. [_wait stop];
  106. return;
  107. }
  108. NSString *userId = [g_default objectForKey:kMY_USER_ID];
  109. NSString *userName = [g_default objectForKey:kMY_USER_NICKNAME];
  110. [g_server addWithdrawlPlatformName:_platformName.text account:_account.text amount:_amount.text reason:_reason.text remark:_remark.text verifyCode:_verifyCode.text userId:userId userName:userName toView:self];
  111. }
  112. -(void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  113. [_wait stop];
  114. if([aDownload.action isEqualToString:act_addWithdrawl]){
  115. [JXMyTools showTipView:@"提交成功"];
  116. _platformName.text = @"";
  117. _account.text = @"";
  118. _amount.text = @"";
  119. _reason.text = @"";
  120. _remark.text = @"";
  121. _verifyCode.text = @"";
  122. [_imgCodeImg refresh];
  123. _btn.userInteractionEnabled = YES;
  124. JLWithdrawalRecordViewController *vc = [[JLWithdrawalRecordViewController alloc] init];
  125. [g_App.navigation pushViewController:vc animated:YES];
  126. }
  127. }
  128. - (void)hideKeyBoardToView {
  129. [self.tableBody endEditing:YES];
  130. }
  131. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click{
  132. JXImageView* btn = [[JXImageView alloc] init];
  133. btn.backgroundColor = [UIColor whiteColor];
  134. btn.userInteractionEnabled = YES;
  135. if(click)
  136. btn.didTouch = click;
  137. else
  138. btn.didTouch = @selector(hideKeyBoardToView);
  139. btn.delegate = self;
  140. [self.tableBody addSubview:btn];
  141. if(must){
  142. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
  143. p.text = @"*";
  144. p.font = g_factory.font18;
  145. p.backgroundColor = [UIColor clearColor];
  146. p.textColor = [UIColor redColor];
  147. p.textAlignment = NSTextAlignmentCenter;
  148. [btn addSubview:p];
  149. }
  150. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(20, 0, 130, HEIGHT)];
  151. p.text = title;
  152. p.font = g_factory.font15;
  153. p.backgroundColor = [UIColor clearColor];
  154. p.textColor = [UIColor blackColor];
  155. [btn addSubview:p];
  156. if(drawTop){
  157. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,0.5)];
  158. line.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  159. [btn addSubview:line];
  160. }
  161. if(drawBottom){
  162. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,HEIGHT-0.5,JX_SCREEN_WIDTH,0.5)];
  163. line.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  164. [btn addSubview:line];
  165. }
  166. if(click){
  167. UIImageView* iv;
  168. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-20-3, 15, 20, 20)];
  169. iv.image = [UIImage imageNamed:@"set_list_next"];
  170. [btn addSubview:iv];
  171. }
  172. return btn;
  173. }
  174. -(UITextField*)createTextField:(UIView*)parent default:(NSString*)s hint:(NSString*)hint keyboardType:(UIKeyboardType)keyboardType {
  175. UITextField* p = [[UITextField alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2,HEIGHT-INSETS*2)];
  176. p.delegate = self;
  177. p.autocorrectionType = UITextAutocorrectionTypeNo;
  178. p.autocapitalizationType = UITextAutocapitalizationTypeNone;
  179. p.enablesReturnKeyAutomatically = YES;
  180. p.borderStyle = UITextBorderStyleNone;
  181. p.returnKeyType = UIReturnKeyDone;
  182. p.clearButtonMode = UITextFieldViewModeAlways;
  183. p.textAlignment = NSTextAlignmentRight;
  184. p.userInteractionEnabled = YES;
  185. p.text = s;
  186. p.placeholder = hint;
  187. p.font = g_factory.font15;
  188. p.keyboardType = keyboardType;
  189. [parent addSubview:p];
  190. return p;
  191. }
  192. @end