YOUPAILZProfitVC.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. //
  2. // YOUPAILZProfitVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/7/30.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZProfitVC.h"
  9. #import "YOUPAILZProfitListVC.h"
  10. #import "YOUPAIHRBillDetailVC.h"
  11. #import "YOUPAILZWithdrawBtn.h"
  12. #import "IQKeyboardManager.h"
  13. #import "YOUPAILZProfitTransformCoinVC.h"
  14. #import "LZAlertWindow.h"
  15. #import "UIViewController+TFPresent.h"
  16. @interface YOUPAILZProfitVC ()<UIScrollViewDelegate>
  17. @property (nonatomic, weak) UIScrollView *youpaipscrollView;
  18. @property (nonatomic, weak) UILabel *youpaipprofitDescL;
  19. @property (nonatomic, weak) UILabel *youpaipprofitL; // 收益 金币
  20. @property (nonatomic, weak) UIView *youpaipwithdrawBgV; // 提现中
  21. @property (nonatomic, weak) UILabel *youpaipwithdrawL;
  22. @property (nonatomic, weak) UILabel* botLabel;
  23. @property (nonatomic, weak) UIView *moneyItemsBgV; /// 选择提现金额背景
  24. @property (nonatomic, strong) NSMutableArray <YOUPAILZWithdrawBtn *>*moneyItems;
  25. @property (nonatomic, strong) UITextField *youpaipnameTextField;
  26. @property (nonatomic, strong) UITextField *youpaipaccountTextField;
  27. //@property (nonatomic, strong) UITextField *youpaipmoneyTextField;
  28. @property (nonatomic, strong) UIButton *youpaipwithdrawBtn;
  29. @property(nonatomic,assign)NSInteger youpaipmin_money;//收益的余额
  30. @property(nonatomic,assign)CGFloat youpaipincome_money;//收益的余额
  31. @property(nonatomic,strong)NSMutableArray* youpaipmoneyArray;
  32. @property (nonatomic, assign) NSInteger selectedMoney; /// 选中提现的金额
  33. @property(nonatomic,strong)NSString* youpaipname;//真实姓名
  34. @property(nonatomic,strong)NSString* youpaipaccount;//账号
  35. @property(nonatomic,assign)NSInteger youpaipverify;//账户是否通过认证
  36. @property (nonatomic, strong) NSString *youpaipselectedMoney;
  37. @end
  38. @implementation YOUPAILZProfitVC
  39. - (void)viewWillAppear:(BOOL)animated {
  40. [super viewWillAppear:animated];
  41. [[IQKeyboardManager sharedManager] setEnable:YES];
  42. [self youpaifrequestWalleetInfo];
  43. }
  44. - (void)viewWillDisappear:(BOOL)animated {
  45. [super viewWillDisappear:animated];
  46. [[IQKeyboardManager sharedManager] setEnable:NO];
  47. }
  48. - (void)youpaifinitData{
  49. @weakify(self);
  50. [LCHttpHelper requestWithURLString:WalletWithdraw parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  51. @strongify(self);
  52. NSDictionary* dict = (NSDictionary*)responseObject;
  53. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  54. if (code==0) {//成功
  55. self.youpaipverify = [[[dict objectForKey:@"data"]objectForKey:LCStr(word39) ] integerValue];
  56. self.youpaipmin_money = [[[dict objectForKey:@"data"]objectForKey:@"min_money"] integerValue];
  57. self.youpaipmoneyArray = [[dict objectForKey:@"data"]objectForKey:@"list"];
  58. self.youpaipaccount = [[dict objectForKey:@"data"]objectForKey:LCStr(word40)];
  59. self.youpaipname = [[dict objectForKey:@"data"]objectForKey:LCStr(word41)];
  60. self.youpaipincome_money = [[[dict objectForKey:@"data"]objectForKey:@"income_money"] floatValue];
  61. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  62. [paragraphStyle setLineSpacing:6];
  63. NSString *text = [[dict objectForKey:@"data"]objectForKey:@"des"];
  64. NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:text];
  65. [str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
  66. self.botLabel.attributedText = str;
  67. NSInteger cash = [[[dict objectForKey:@"data"]objectForKey:@"cash"] integerValue];
  68. self.youpaipwithdrawL.text = [NSString stringWithFormat:@"%@%@金币",LCStr(word47),@(cash)];
  69. if (cash <= 0) {
  70. self.youpaipwithdrawBgV.hidden = YES;
  71. [self.youpaipprofitL mas_remakeConstraints:^(MASConstraintMaker *make) {
  72. make.top.equalTo(self.youpaipprofitDescL.mas_bottom).offset(6.0f);
  73. make.left.right.bottom.offset(0.0f);
  74. }];
  75. [self.youpaipwithdrawBgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  76. make.left.offset(0.0f);
  77. make.bottom.offset(0.0f);
  78. }];
  79. }else{
  80. [self.youpaipprofitL mas_remakeConstraints:^(MASConstraintMaker *make) {
  81. make.left.offset(0.0f);
  82. make.top.equalTo(self.youpaipprofitDescL.mas_bottom).offset(6.0f);
  83. make.right.offset(0.0f);
  84. }];
  85. [self.youpaipwithdrawBgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  86. make.left.offset(0.0f);
  87. make.top.equalTo(self.youpaipprofitL.mas_bottom).offset(6.0f);
  88. make.bottom.offset(0.0f);
  89. }];
  90. }
  91. [self youpaifupdateData];
  92. }
  93. }failure:^(NSError *error) {
  94. }];
  95. }
  96. - (void)youpaifupdateData{
  97. self.moneyItems = [NSMutableArray array];
  98. for (UIView *subv in self.moneyItemsBgV.subviews) {
  99. [subv removeFromSuperview];
  100. }
  101. NSInteger colCount = 3;
  102. CGFloat itemWidth = (KScreenWidth - 28.0f - 12.0f) / colCount;
  103. CGFloat itemHeight = 68.0f;
  104. CGFloat space = 6.0f;
  105. for (NSInteger i = 0; i < self.youpaipmoneyArray.count; i ++) {
  106. NSInteger money = [[self.youpaipmoneyArray[i]objectForKey:@"money"] integerValue];
  107. YOUPAILZWithdrawBtn *btn = [[YOUPAILZWithdrawBtn alloc] init];
  108. btn.backgroundColor = [UIColor whiteColor];
  109. NSInteger col = i % colCount;
  110. NSInteger row = i / colCount;
  111. btn.frame = CGRectMake(col * itemWidth + col * space, row * itemHeight + row * space, itemWidth, itemHeight);
  112. btn.youpaipquickV.hidden = YES;
  113. btn.tag = money;
  114. [btn.action addTarget:self action:@selector(youpaifwithdrawBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  115. [self.moneyItemsBgV addSubview:btn];
  116. [self.moneyItems addObject:btn];
  117. // if (money > self.youpaipincome_money) {
  118. // btn.youpaipMoneyL.attributedText = [LCTools setRichTextFormat:@[
  119. // [YOUPAILZRichTextStyle richTextStyleWithText:@"¥" font:LCFont(12.0f) color:LZD3D1D7Color],
  120. // [YOUPAILZRichTextStyle richTextStyleWithText:[NSString stringWithFormat:@"%@",@(money)] font:LZDinFont(32.0f) color:LZD3D1D7Color]
  121. // ]];
  122. // btn.layer.borderWidth = 1.0f;
  123. // btn.layer.borderColor = LZF5F4F7Color.CGColor;
  124. // btn.backgroundColor = [UIColor whiteColor];
  125. // btn.userInteractionEnabled = NO;
  126. // }else{
  127. btn.youpaipMoneyL.attributedText = [LCTools setRichTextFormat:@[
  128. // [YOUPAILZRichTextStyle richTextStyleWithText:@"¥" font:LCFont(12.0f) color:LZ273145Color],
  129. [YOUPAILZRichTextStyle richTextStyleWithText:[NSString stringWithFormat:@"%@元",@(money)] font:[UIFont fontWithName:@"DINAlternate-Bold" size:WHScreenEqualWidth(24)] color:LZ273145Color]
  130. ]];
  131. btn.layer.borderWidth = 1.0f;
  132. btn.layer.borderColor = LZF5F4F7Color.CGColor;
  133. btn.backgroundColor = [UIColor whiteColor];
  134. btn.userInteractionEnabled = YES;
  135. // }
  136. btn.youpaipSelectedImgV.hidden = YES;
  137. btn.selected = NO;
  138. }
  139. if (self.youpaipincome_money>self.youpaipmin_money) {
  140. [self youpaifwithdrawBtnClick:self.moneyItems[0]];
  141. }
  142. CGFloat totalRow = (self.youpaipmoneyArray.count + (colCount - 1))/colCount;
  143. CGFloat totalHeight = totalRow * itemHeight + space * (totalRow - 1);
  144. [self.moneyItemsBgV mas_updateConstraints:^(MASConstraintMaker *make) {
  145. make.height.offset(totalHeight);
  146. }];
  147. [self.youpaipscrollView layoutIfNeeded];
  148. CGFloat height = CGRectGetMaxY(self.youpaipwithdrawBtn.frame) + 40.0f + SafeHeight;
  149. if (height < KScreenHeight - NavBarHeight) {
  150. height = KScreenHeight - NavBarHeight + 1;
  151. }
  152. self.youpaipscrollView.contentSize = CGSizeMake(KScreenWidth, height);
  153. self.youpaipnameTextField.text = self.youpaipname;
  154. self.youpaipaccountTextField.text = self.youpaipaccount;
  155. if (self.youpaipaccount.length >0 && self.youpaipverify==1) {
  156. self.youpaipnameTextField.enabled = NO;
  157. self.youpaipaccountTextField.enabled = NO;
  158. }else{
  159. self.youpaipnameTextField.enabled = YES;
  160. self.youpaipaccountTextField.enabled = YES;
  161. }
  162. [self youpaifverifyWithdrawBtn];
  163. }
  164. - (void)youpaifwithdrawBtnClick:(YOUPAILZWithdrawBtn *)sender{
  165. for (YOUPAILZWithdrawBtn *btn in self.moneyItems) {
  166. NSInteger money = [[self.youpaipmoneyArray[btn.tag]objectForKey:@"money"] integerValue];
  167. // if (money > self.youpaipincome_money) {
  168. // btn.youpaipMoneyL.attributedText = [LCTools setRichTextFormat:@[
  169. // [YOUPAILZRichTextStyle richTextStyleWithText:@"¥" font:LCFont(12.0f) color:LZD3D1D7Color],
  170. // [YOUPAILZRichTextStyle richTextStyleWithText:[NSString stringWithFormat:@"%@",@(money)] font:LZDinFont(32.0f) color:LZD3D1D7Color]
  171. // ]];
  172. // btn.layer.borderWidth = 1.0f;
  173. // btn.layer.borderColor = LZF5F4F7Color.CGColor;
  174. // btn.backgroundColor = [UIColor whiteColor];
  175. // btn.userInteractionEnabled = NO;
  176. // }else{
  177. btn.youpaipMoneyL.attributedText = [LCTools setRichTextFormat:@[
  178. // [YOUPAILZRichTextStyle richTextStyleWithText:@"¥" font:LCFont(12.0f) color:LZ273145Color],
  179. [YOUPAILZRichTextStyle richTextStyleWithText:[NSString stringWithFormat:@"%@元",@(money)] font:[UIFont fontWithName:@"DINAlternate-Bold" size:WHScreenEqualWidth(24)] color:LZ273145Color]
  180. ]];
  181. btn.layer.borderWidth = 1.0f;
  182. btn.layer.borderColor = LZF5F4F7Color.CGColor;
  183. btn.backgroundColor = [UIColor whiteColor];
  184. btn.userInteractionEnabled = YES;
  185. // }
  186. btn.youpaipSelectedImgV.hidden = YES;
  187. btn.selected = NO;
  188. }
  189. sender.selected = YES;
  190. sender.layer.borderColor = LZFE66A4Color.CGColor;
  191. sender.layer.borderWidth = 1.5f;
  192. // sender.youpaipSelectedImgV.hidden = NO;
  193. sender.backgroundColor = [LZFE66A4Color colorWithAlphaComponent:0.04f];
  194. self.selectedMoney = [[self.youpaipmoneyArray[sender.tag]objectForKey:@"money"] integerValue];
  195. }
  196. - (void)youpaifverifyWithdrawBtn{
  197. if ( [self.youpaipnameTextField.text isEqualToString:@""]||[self.youpaipaccountTextField.text isEqualToString:@""]||self.selectedMoney <= 0){
  198. [self.youpaipwithdrawBtn setBackgroundImage:nil forState:(UIControlStateNormal)];
  199. self.youpaipwithdrawBtn.userInteractionEnabled = NO;
  200. }else{
  201. [self.youpaipwithdrawBtn setBackgroundImage:[LCTools ColorImage:self.youpaipwithdrawBtn.frame.size FromColors:@[LZFFB5DBColor,LZFE66A4Color] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  202. self.youpaipwithdrawBtn.userInteractionEnabled = YES;
  203. }
  204. }
  205. - (void)viewDidLoad {
  206. [super viewDidLoad];
  207. self.youpaipmoneyArray = [NSMutableArray array];
  208. self.title = LCStr(word9);//@"我的收益";
  209. [IQKeyboardManager sharedManager].enableAutoToolbar = NO; // 控制是否显示键盘上的工具条
  210. [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = NavBarHeight; //
  211. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  212. self.selectedMoney = 0;
  213. self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifprofitAction) title:LCStr(word5) font:LCFont14 titleColor:LZA3AABEColor highlightedColor:LZA3AABEColor titleEdgeInsets:UIEdgeInsetsZero];//收支明细
  214. self.view.backgroundColor = [UIColor whiteColor];
  215. [self youpaifinitUI];
  216. [self youpaifinitData];
  217. }
  218. - (void)youpaifinitUI{
  219. UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0f, NavBarHeight, KScreenWidth, KScreenHeight - NavBarHeight)];
  220. scrollView.showsVerticalScrollIndicator = NO;
  221. scrollView.showsHorizontalScrollIndicator = NO;
  222. scrollView.delegate = self;
  223. [self.view addSubview:scrollView];
  224. self.youpaipscrollView = scrollView;
  225. UIImageView *headerImgV = [[UIImageView alloc] init];
  226. headerImgV.userInteractionEnabled = YES;
  227. headerImgV.image = [UIImage imageNamed:@"vqu_images_profit_bg"];
  228. [scrollView addSubview:headerImgV];
  229. [headerImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  230. make.left.offset(14.0f);
  231. make.width.offset(KScreenWidth - 28.0f);
  232. make.top.offset(10.0f);
  233. make.height.offset(128.0f);
  234. }];
  235. UIView *profitBgV = [[UIView alloc] init];
  236. [headerImgV addSubview:profitBgV];
  237. [profitBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  238. make.left.offset(20.0f);
  239. make.centerY.equalTo(headerImgV);
  240. }];
  241. UILabel *profitDescL = [[UILabel alloc] init];
  242. profitDescL.font = LCFont14;
  243. profitDescL.text = @"我的金币"; //LCStr(word46);//@"我的收益";
  244. profitDescL.textColor = [UIColor whiteColor];
  245. [profitBgV addSubview:profitDescL];
  246. self.youpaipprofitDescL = profitDescL;
  247. [profitDescL mas_makeConstraints:^(MASConstraintMaker *make) {
  248. make.left.offset(0);
  249. make.top.offset(0.0f);
  250. make.right.offset(0.0f);
  251. }];
  252. UILabel *profitL = [[UILabel alloc] init];
  253. profitL.font = LCFont(36.0f);
  254. profitL.attributedText = [LCTools setRichTextFormat:@[
  255. [YOUPAILZRichTextStyle richTextStyleWithText:@"0" font:LZDinFont(36.0f) color:[UIColor whiteColor]],
  256. [YOUPAILZRichTextStyle richTextStyleWithText:@"金币" font:LCFont(14.0f) color:[UIColor whiteColor]]
  257. ]];
  258. profitL.textColor = [UIColor whiteColor];
  259. [profitBgV addSubview:profitL];
  260. self.youpaipprofitL = profitL;
  261. [profitL mas_makeConstraints:^(MASConstraintMaker *make) {
  262. make.left.offset(0.0f);
  263. make.top.equalTo(profitDescL.mas_bottom).offset(6.0f);
  264. make.right.bottom.offset(0.0f);
  265. }];
  266. UIView *youpaipwithdrawBgV = [[UIView alloc] init];
  267. youpaipwithdrawBgV.backgroundColor = LZFE66A4Color;
  268. youpaipwithdrawBgV.layer.cornerRadius = 6.0f;
  269. youpaipwithdrawBgV.clipsToBounds = YES;
  270. youpaipwithdrawBgV.hidden = YES;
  271. [profitBgV addSubview:youpaipwithdrawBgV];
  272. self.youpaipwithdrawBgV = youpaipwithdrawBgV;
  273. [youpaipwithdrawBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  274. make.left.offset(0.0f);
  275. // make.top.equalTo(profitL.mas_bottom).offset(6.0f);
  276. make.bottom.offset(0.0f);
  277. }];
  278. UILabel *youpaipwithdrawL = [[UILabel alloc] init];
  279. youpaipwithdrawL.font = LCFont(10);
  280. youpaipwithdrawL.text = [NSString stringWithFormat:@"%@%@金币",LCStr(word47),@(0)];//@"提现中";
  281. youpaipwithdrawL.textColor = [UIColor whiteColor];
  282. [youpaipwithdrawBgV addSubview:youpaipwithdrawL];
  283. self.youpaipwithdrawL = youpaipwithdrawL;
  284. [youpaipwithdrawL mas_makeConstraints:^(MASConstraintMaker *make) {
  285. make.left.top.offset(4);
  286. make.right.bottom.offset(-4);
  287. }];
  288. UIButton *transformCoinBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  289. transformCoinBtn.backgroundColor = [UIColor whiteColor];
  290. transformCoinBtn.layer.cornerRadius = 15.0f;
  291. transformCoinBtn.clipsToBounds = YES;
  292. [transformCoinBtn setTitle:@"兑换钻石" forState:UIControlStateNormal];
  293. [transformCoinBtn setTitleColor:LZFE66A4Color forState:UIControlStateNormal];
  294. transformCoinBtn.titleLabel.font = LCFont12;
  295. [transformCoinBtn addTarget:self action:@selector(transformCoinBtnClick) forControlEvents:UIControlEventTouchUpInside];
  296. [headerImgV addSubview:transformCoinBtn];
  297. [transformCoinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  298. make.right.offset(-12.0f);
  299. make.centerY.equalTo(profitBgV);
  300. make.size.mas_offset(CGSizeMake(68.0f, 30.0f));
  301. }];
  302. UILabel* moneyTip = [[UILabel alloc]init];
  303. moneyTip.textColor = LZA3AABEColor;
  304. moneyTip.font = LCFont(12);
  305. moneyTip.text = LCStr(word17);//请选择提现金额
  306. [scrollView addSubview:moneyTip];
  307. [moneyTip mas_makeConstraints:^(MASConstraintMaker *make) {
  308. make.left.offset(14.0f);
  309. make.top.equalTo(headerImgV.mas_bottom).offset(20.0f);
  310. }];
  311. UIView *moneyItemsBgV = [[UIView alloc] init];
  312. [scrollView addSubview:moneyItemsBgV];
  313. self.moneyItemsBgV = moneyItemsBgV;
  314. [moneyItemsBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  315. make.top.equalTo(moneyTip.mas_bottom).offset(15.0f);
  316. make.left.offset(14.0f);
  317. make.width.offset(KScreenWidth - 28.0f);
  318. make.height.offset(0.0f);
  319. }];
  320. UILabel *labe1 = [[UILabel alloc] init];
  321. labe1.text = LCStr(word6);// @"请输入提现支付宝账户:";
  322. labe1.textColor = LZA3AABEColor;
  323. labe1.font = LCFont(12);
  324. [scrollView addSubview:labe1];
  325. [labe1 mas_makeConstraints:^(MASConstraintMaker *make) {
  326. make.left.offset(14.0f);
  327. make.top.equalTo(moneyItemsBgV.mas_bottom).offset(20.0f);
  328. }];
  329. UIView *nameView = [[UIView alloc] init];
  330. nameView.backgroundColor = LZF7F8FAColor;
  331. nameView.layer.cornerRadius = 6;
  332. nameView.layer.masksToBounds = YES;
  333. [scrollView addSubview:nameView];
  334. [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
  335. make.left.offset(14.0f);
  336. make.top.equalTo(labe1.mas_bottom).offset(15.0f);
  337. make.width.offset(KScreenWidth - 28.0f);
  338. make.height.offset(48.0f);
  339. }];
  340. UILabel* nameTipLabel = [[UILabel alloc]init];
  341. nameTipLabel.text = LCStr(word48); //支付宝实名:
  342. nameTipLabel.textColor = LZ273145Color;
  343. nameTipLabel.font = LCFont14;
  344. [nameView addSubview:nameTipLabel];
  345. [nameTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  346. make.left.offset(12.0f);
  347. make.top.bottom.offset(0.0f);
  348. make.width.offset(84.0f);
  349. }];
  350. UITextField* nameTextField = [[UITextField alloc]init];
  351. self.youpaipnameTextField = nameTextField;
  352. nameTextField.tintColor = LZ7C69FEColor;
  353. nameTextField.textColor = LZ273145Color;
  354. nameTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
  355. [[nameTextField valueForKey:@"_clearButton"] setImage:[UIImage imageNamed:@"vqu_images_D_nick_clean"] forState:UIControlStateNormal];
  356. [nameTextField addTarget:self action:@selector(textFieldDidEditing:) forControlEvents:UIControlEventEditingChanged];
  357. NSMutableAttributedString* attrStrName = [[NSMutableAttributedString alloc]initWithString:LCStr(word42)];//@"请输入支付宝认证名字"
  358. [attrStrName addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, attrStrName.length)];
  359. [attrStrName addAttribute:NSForegroundColorAttributeName value:LZD3D1D7Color range:NSMakeRange(0, attrStrName.length)];
  360. nameTextField.attributedPlaceholder = attrStrName;
  361. [nameView addSubview:nameTextField];
  362. [nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  363. make.left.equalTo(nameTipLabel.mas_right).offset(0.0f);
  364. make.top.bottom.offset(0.0f);
  365. make.right.offset(-12.0f);
  366. }];
  367. UIView *accountView = [[UIView alloc] init];
  368. accountView.backgroundColor = LZF7F8FAColor;
  369. accountView.layer.cornerRadius = 6;
  370. accountView.layer.masksToBounds = YES;
  371. [scrollView addSubview:accountView];
  372. [accountView mas_makeConstraints:^(MASConstraintMaker *make) {
  373. make.left.offset(14.0f);
  374. make.top.equalTo(nameView.mas_bottom).offset(8.0f);
  375. make.width.offset(KScreenWidth - 28.0f);
  376. make.height.offset(48.0f);
  377. }];
  378. UILabel* accountTipLabel = [[UILabel alloc]init];
  379. accountTipLabel.text = LCStr(word7);//@"支付宝账号:";
  380. accountTipLabel.textColor = LZ273145Color;
  381. accountTipLabel.font = LCFont14;
  382. [accountView addSubview:accountTipLabel];
  383. [accountTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  384. make.left.offset(12.0f);
  385. make.top.bottom.offset(0.0f);
  386. make.width.offset(84.0f);
  387. }];
  388. UITextField* accountTextField = [[UITextField alloc]init];
  389. self.youpaipaccountTextField = accountTextField;
  390. accountTextField.tintColor = LZ7C69FEColor;
  391. accountTextField.textColor = LZ273145Color;
  392. accountTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
  393. [[accountTextField valueForKey:@"_clearButton"] setImage:[UIImage imageNamed:@"vqu_images_D_nick_clean"] forState:UIControlStateNormal];
  394. [accountTextField addTarget:self action:@selector(textFieldDidEditing:) forControlEvents:UIControlEventEditingChanged];
  395. NSMutableAttributedString* attrStrAccount = [[NSMutableAttributedString alloc]initWithString:LCStr(word8)];//请输入支付宝账号
  396. [attrStrAccount addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, attrStrAccount.length)];
  397. [attrStrAccount addAttribute:NSForegroundColorAttributeName value:LZD3D1D7Color range:NSMakeRange(0, attrStrAccount.length)];
  398. accountTextField.attributedPlaceholder = attrStrAccount;
  399. [accountView addSubview:accountTextField];
  400. [accountTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  401. make.left.equalTo(accountTipLabel.mas_right).offset(0.0f);
  402. make.top.bottom.offset(0.0f);
  403. make.right.offset(-12.0f);
  404. }];
  405. UILabel* botLabel = [[UILabel alloc]init];
  406. // botLabel.text = LCStr(word26);//注:真实姓名需与支付宝实名认证相同,否则无法到账
  407. botLabel.textColor = LZA3AABEColor;
  408. botLabel.font = LCFont(10);
  409. botLabel.numberOfLines = 0;
  410. botLabel.textAlignment = NSTextAlignmentLeft;
  411. [scrollView addSubview:botLabel];
  412. self.botLabel = botLabel;
  413. [botLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  414. make.left.offset(14.0f);
  415. make.width.offset(KScreenWidth - 28.0f);
  416. make.top.equalTo(accountView.mas_bottom).offset(20.0f);
  417. }];
  418. UIButton* withdrawBtn = [[UIButton alloc]initWithFrame:CGRectMake(48, CGRectGetMaxY(botLabel.frame)+30.0f, KScreenWidth-96, 48)];
  419. withdrawBtn.uxy_acceptEventInterval = 3.0;
  420. withdrawBtn.userInteractionEnabled = NO;
  421. withdrawBtn.backgroundColor = LZD3D1D7Color;
  422. withdrawBtn.layer.cornerRadius = 24.0;
  423. withdrawBtn.layer.masksToBounds = YES;
  424. withdrawBtn.titleLabel.font = LCFont16;
  425. [withdrawBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  426. [withdrawBtn setTitle:LCStr(word18) forState:(UIControlStateNormal)];//立即提现
  427. [withdrawBtn addTarget:self action:@selector(youpaifapplyWithdraw) forControlEvents:(UIControlEventTouchUpInside)];
  428. [scrollView addSubview:withdrawBtn];
  429. [withdrawBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  430. make.left.offset(48);
  431. make.width.offset(KScreenWidth - 96);
  432. make.top.equalTo(botLabel.mas_bottom).offset(30.0f);
  433. make.height.offset(48);
  434. }];
  435. self.youpaipwithdrawBtn = withdrawBtn;
  436. [scrollView layoutIfNeeded];
  437. CGFloat height = CGRectGetMaxY(self.youpaipwithdrawBtn.frame) + 40.0f + SafeHeight;
  438. if (height < KScreenHeight - NavBarHeight) {
  439. height = KScreenHeight - NavBarHeight + 1;
  440. }
  441. scrollView.contentSize = CGSizeMake(KScreenWidth, height);
  442. }
  443. /// 兑换钻石
  444. - (void)transformCoinBtnClick{
  445. YOUPAILZProfitTransformCoinVC *vc = [[YOUPAILZProfitTransformCoinVC alloc] init];
  446. [self.navigationController pushViewController:vc animated:YES];
  447. }
  448. - (void)youpaifprofitAction{
  449. YOUPAIHRBillDetailVC *vc = [YOUPAIHRBillDetailVC new];
  450. [self.navigationController pushViewController:vc animated:YES];
  451. }
  452. - (void)youpaipbindAccount{
  453. @weakify(self);
  454. //先绑定账户再提现
  455. [LCHttpHelper requestWithURLString:WalletZFBBind parameters:@{@"card_account":self.youpaipaccountTextField.text,@"card_name":self.youpaipnameTextField.text} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  456. @strongify(self);
  457. NSDictionary* dict = (NSDictionary*)responseObject;
  458. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  459. if (code==0) {//成功
  460. [self youpaifshowWithdrawConfirmAlert];
  461. }
  462. }failure:^(NSError *error) {
  463. }];
  464. }
  465. - (void)youpaifshowWithdrawConfirmAlert{
  466. @weakify(self);
  467. /// 获取提现到账金额
  468. [LCHttpHelper requestWithURLString:GetWithdrawPrice parameters:@{@"money":@(self.selectedMoney)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  469. @strongify(self);
  470. NSDictionary* dict = (NSDictionary*)responseObject;
  471. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  472. if (code==0) {//成功
  473. NSDictionary *data = [dict objectForKey:@"data"];
  474. NSString *withdraw_money = [data objectForKey:@"withdraw_money"];
  475. NSString *receive_money = [data objectForKey:@"receive_money"];
  476. NSString *account_name = [data objectForKey:@"account_name"];
  477. NSString *account = [data objectForKey:@"account"];
  478. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  479. }];
  480. cancelAction.cornerRadius = 24.0f;
  481. cancelAction.color = LZ273145Color;
  482. cancelAction.bgColor = LZF5F4F7Color;
  483. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"提交" handler:^(LZAlertAction *action) {
  484. @strongify(self);
  485. [self youpaifWithdraw];
  486. }];
  487. confimAction.cornerRadius = 24.0f;
  488. confimAction.color = [UIColor whiteColor];
  489. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZFFB5DBColor,LZFE66A4Color] ByGradientType:GradientLeftToRight]];
  490. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"申请提现AA" content:@"" action:@[cancelAction,confimAction] contentStyleBlock:^(UILabel *contentL) {
  491. NSString *contentText = [NSString stringWithFormat:@"提现 %@ 金币,实际到账 %@ 金币\n收款账号:%@(%@)",withdraw_money,receive_money,account_name,account];
  492. NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:contentText];
  493. [str addAttribute:NSForegroundColorAttributeName value: HexColorFromRGB(0xFF3B30) range:[contentText rangeOfString:withdraw_money]];
  494. [str addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFF3B30) range:[contentText rangeOfString:receive_money]];
  495. contentL.attributedText = str;
  496. }];
  497. alert.contentTextAlignment = NSTextAlignmentCenter;
  498. [self TFPresentVC:alert completion:^{}];
  499. }
  500. }failure:^(NSError *error) {
  501. }];
  502. }
  503. - (void)youpaifWithdraw{
  504. //直接提现
  505. @weakify(self);
  506. [LCHttpHelper requestWithURLString:WithDrawApply parameters:@{@"money":@(self.selectedMoney)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  507. @strongify(self);
  508. NSDictionary* dict = (NSDictionary*)responseObject;
  509. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  510. if (code==0) {//成功
  511. [ZCHUDHelper showTitle:LCStr(word19)];//提现已申请成功,请耐心等待
  512. [self.navigationController popViewControllerAnimated:YES];
  513. }
  514. }failure:^(NSError *error) {
  515. }];
  516. }
  517. - (void)youpaifapplyWithdraw{
  518. if (self.youpaipaccount.length >0 && self.youpaipverify==1) {
  519. [self youpaifshowWithdrawConfirmAlert];
  520. }else{
  521. [self youpaipbindAccount];
  522. }
  523. }
  524. -(void)textFieldDidEditing:(UITextField *)textField{
  525. if ( [self.youpaipnameTextField.text isEqualToString:@""]||[self.youpaipaccountTextField.text isEqualToString:@""]||self.selectedMoney <= 0){
  526. [self.youpaipwithdrawBtn setBackgroundImage:nil forState:(UIControlStateNormal)];
  527. self.youpaipwithdrawBtn.userInteractionEnabled = NO;
  528. }else{
  529. [self.youpaipwithdrawBtn setBackgroundImage:[LCTools ColorImage:self.youpaipwithdrawBtn.frame.size FromColors:@[LZFFB5DBColor,LZFE66A4Color] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  530. self.youpaipwithdrawBtn.userInteractionEnabled = YES;
  531. }
  532. }
  533. #pragma mark - Request
  534. - (void)youpaifrequestWalleetInfo{
  535. @weakify(self);
  536. [LCHttpHelper requestWithURLString:WalletInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  537. @strongify(self);
  538. NSDictionary* dict = (NSDictionary*)responseObject;
  539. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  540. if (code==0) {//成功
  541. // CGFloat incomeCoin = [[[[dict objectForKey:@"data"]objectForKey:@"account"]objectForKey:@"income_coin"] floatValue];
  542. NSString *incomeMoney = [[[dict objectForKey:@"data"]objectForKey:@"account"]objectForKey:@"income_coin"];
  543. self.youpaipprofitL.attributedText = [LCTools setRichTextFormat:@[
  544. [YOUPAILZRichTextStyle richTextStyleWithText:[NSString stringWithFormat:@"%@",incomeMoney] font:LZDinFont(36.0f) color:[UIColor whiteColor]],
  545. [YOUPAILZRichTextStyle richTextStyleWithText:@"金币" font:LCFont(14.0f) color:[UIColor whiteColor]]
  546. ]];
  547. }
  548. } failure:^(NSError *error) {
  549. }];
  550. }
  551. @end