JXMyMoneyViewController.m 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //
  2. // JXMyMoneyViewController.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 17/10/27.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXMyMoneyViewController.h"
  9. #import "UIImage+Color.h"
  10. #import "JXCashWithDrawViewController.h"
  11. #import "JXRechargeViewController.h"
  12. #import "JXRecordCodeVC.h"
  13. #import "JXMoneyMenuViewController.h"
  14. #import "JXShenQinTiMoneyVc.h"
  15. @interface JXMyMoneyViewController ()
  16. @property (nonatomic, strong) UIButton * listButton;
  17. @property (nonatomic, strong) UIImageView * iconView;
  18. @property (nonatomic, strong) UILabel * myMoneyLabel;
  19. @property (nonatomic, strong) UILabel * balanceLabel;
  20. @property (nonatomic, strong) UIButton * rechargeBtn;
  21. @property (nonatomic, strong) UIButton * withdrawalsBtn;
  22. //@property (nonatomic, strong) UIButton * problemBtn;
  23. @end
  24. @implementation JXMyMoneyViewController
  25. -(instancetype)init{
  26. if (self = [super init]) {
  27. self.heightHeader = JX_SCREEN_TOP;
  28. self.heightFooter = 0;
  29. self.isGotoBack = YES;
  30. self.title = @"即信钱包";//Localized(@"JXMoney_pocket");
  31. [g_notify addObserver:self selector:@selector(doRefresh:) name:kUpdateUserNotifaction object:nil];
  32. }
  33. return self;
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. [self createHeadAndFoot];
  38. // self.tableBody.backgroundColor = HEXCOLOR(0xefeff4);
  39. self.tableBody.alwaysBounceVertical = YES;
  40. [self.tableHeader addSubview:self.listButton];
  41. [self.tableBody addSubview:self.iconView];
  42. [self.tableBody addSubview:self.myMoneyLabel];
  43. [self.tableBody addSubview:self.balanceLabel];
  44. [self.tableBody addSubview:self.rechargeBtn];
  45. [self.tableBody addSubview:self.withdrawalsBtn];
  46. // [self.tableBody addSubview:self.problemBtn];
  47. // [self updateBalanceLabel];
  48. }
  49. - (void)viewWillAppear:(BOOL)animated {
  50. [super viewWillAppear:animated];
  51. [g_server getUserMoenyToView:self];
  52. }
  53. -(void)dealloc{
  54. [g_notify removeObserver:self];
  55. }
  56. -(UIButton *)listButton{
  57. if(!_listButton){
  58. _listButton = [UIButton buttonWithType:UIButtonTypeCustom];
  59. _listButton.frame = CGRectMake(JX_SCREEN_WIDTH-24-15, JX_SCREEN_TOP - 35, 24, 24);
  60. // [_listButton setTitle:Localized(@"JXMoney_list") forState:UIControlStateNormal];
  61. // [_listButton setTitle:Localized(@"JXMoney_list") forState:UIControlStateHighlighted];
  62. // _listButton.titleLabel.font = g_factory.font14;
  63. [_listButton setImage:THESIMPLESTYLE ? [UIImage imageNamed:@"money_menu_black"] : [UIImage imageNamed:@"money_menu"] forState:UIControlStateNormal];
  64. _listButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  65. [_listButton addTarget:self action:@selector(listButtonAction) forControlEvents:UIControlEventTouchUpInside];
  66. }
  67. return _listButton;
  68. }
  69. //-(UIImageView *)iconView{
  70. // if (!_iconView) {
  71. // _iconView = [[UIImageView alloc] init];
  72. // _iconView.frame = CGRectMake(0, 65, 90, 90);
  73. // _iconView.center = CGPointMake(JX_SCREEN_WIDTH/2, _iconView.center.y);
  74. // _iconView.image = [UIImage imageNamed:@"weixinpayyue"];
  75. //
  76. // }
  77. // return _iconView;
  78. //}
  79. -(UILabel *)myMoneyLabel{
  80. if (!_myMoneyLabel) { //。 Localized(@"JXMoney_myPocket")
  81. _myMoneyLabel = [UIFactory createLabelWith:CGRectZero text:@"我的即信币" font:g_factory.font16 textColor:[UIColor blackColor] backgroundColor:nil];
  82. _myMoneyLabel.textAlignment = NSTextAlignmentCenter;
  83. _myMoneyLabel.frame = CGRectMake(0, 99, JX_SCREEN_WIDTH, 20);
  84. }
  85. return _myMoneyLabel;
  86. }
  87. -(UILabel *)balanceLabel{
  88. if (!_balanceLabel) {
  89. NSString * moneyStr = [NSString stringWithFormat:@"¥%.2f",g_App.myMoney];
  90. _balanceLabel = [UIFactory createLabelWith:CGRectZero text:moneyStr font:g_factory.font28 textColor:[UIColor blackColor] backgroundColor:nil];
  91. _balanceLabel.textAlignment = NSTextAlignmentCenter;
  92. _balanceLabel.font = SYSFONT(40);
  93. _balanceLabel.frame = CGRectMake(0, CGRectGetMaxY(_myMoneyLabel.frame)+23, JX_SCREEN_WIDTH, 40);
  94. }
  95. return _balanceLabel;
  96. }
  97. -(UIButton *)rechargeBtn{
  98. if (!_rechargeBtn) {
  99. _rechargeBtn = [UIFactory createButtonWithRect:CGRectZero title:Localized(@"JXLiveVC_Recharge") titleFont:g_factory.font16 titleColor:[UIColor whiteColor] normal:nil selected:nil selector:@selector(rechargeBtnAction:) target:self];
  100. _rechargeBtn.frame = CGRectMake(15, CGRectGetMaxY(_balanceLabel.frame)+60, JX_SCREEN_WIDTH-15*2, 40);
  101. [_rechargeBtn setBackgroundImage:[UIImage createImageWithColor:THEMECOLOR] forState:UIControlStateNormal];
  102. _rechargeBtn.layer.cornerRadius = 7;
  103. _rechargeBtn.clipsToBounds = YES;
  104. }
  105. return _rechargeBtn;
  106. }
  107. -(UIButton *)withdrawalsBtn{
  108. if (!_withdrawalsBtn) {
  109. _withdrawalsBtn = [UIFactory createButtonWithRect:CGRectZero title:Localized(@"JXMoney_withdrawals") titleFont:g_factory.font16 titleColor:[UIColor whiteColor] normal:nil selected:nil selector:@selector(withdrawalsBtnAction:) target:self];
  110. _withdrawalsBtn.frame = CGRectMake(15, CGRectGetMaxY(_rechargeBtn.frame)+20, CGRectGetWidth(_rechargeBtn.frame), CGRectGetHeight(_rechargeBtn.frame));
  111. [_withdrawalsBtn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
  112. [_withdrawalsBtn setBackgroundImage:[UIImage createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
  113. _withdrawalsBtn.layer.cornerRadius = 7;
  114. _withdrawalsBtn.clipsToBounds = YES;
  115. _withdrawalsBtn.layer.borderColor = THEMECOLOR.CGColor;
  116. _withdrawalsBtn.layer.borderWidth = 1.f;
  117. }
  118. return _withdrawalsBtn;
  119. }
  120. //-(UIButton *)problemBtn{
  121. // if (!_problemBtn) {
  122. // _problemBtn = [UIFactory createButtonWithRect:CGRectZero title:Localized(@"JXMoney_FAQ") titleFont:g_factory.font14 titleColor:HEXCOLOR(0x576b95) normal:nil selected:nil selector:@selector(problemBtnAction) target:self];
  123. // CGFloat drawWidth = [_problemBtn.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:_problemBtn.titleLabel.font}].width;
  124. // _problemBtn.frame = CGRectMake(0, self.tableBody.frame.size.height-72, drawWidth, 25);
  125. // _problemBtn.center = CGPointMake(JX_SCREEN_WIDTH/2, _problemBtn.center.y);
  126. // }
  127. // return _problemBtn;
  128. //}
  129. -(void)updateBalanceLabel{
  130. NSString * moneyStr = [NSString stringWithFormat:@"¥%.2f",g_App.myMoney];
  131. self.balanceLabel.text = moneyStr;
  132. CGFloat Width = [self.balanceLabel.text sizeWithAttributes:@{NSFontAttributeName:self.balanceLabel.font}].width;
  133. CGRect frame = self.balanceLabel.frame;
  134. frame.size.width = Width;
  135. self.balanceLabel.frame = frame;
  136. self.balanceLabel.center = CGPointMake(self.iconView.center.x, self.balanceLabel.center.y);
  137. }
  138. - (void)didReceiveMemoryWarning {
  139. [super didReceiveMemoryWarning];
  140. // Dispose of any resources that can be recreated.
  141. }
  142. /*
  143. #pragma mark - Navigation
  144. // In a storyboard-based application, you will often want to do a little preparation before navigation
  145. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  146. // Get the new view controller using [segue destinationViewController].
  147. // Pass the selected object to the new view controller.
  148. }
  149. */
  150. #pragma mark Action
  151. -(void)listButtonAction{
  152. _listButton.enabled = NO;
  153. [self performSelector:@selector(delayButtonReset) withObject:nil afterDelay:0.5];
  154. JXMoneyMenuViewController *monVC = [[JXMoneyMenuViewController alloc] init];
  155. [g_navigation pushViewController:monVC animated:YES];
  156. // JXRecordCodeVC * recordVC = [[JXRecordCodeVC alloc]init];
  157. //// [g_window addSubview:recordVC.view];
  158. // [g_navigation pushViewController:recordVC animated:YES];
  159. }
  160. -(void)rechargeBtnAction:(UIButton *)button{
  161. _rechargeBtn.enabled = NO;
  162. [self performSelector:@selector(delayButtonReset) withObject:nil afterDelay:0.5];
  163. JXRechargeViewController * rechargeVC = [[JXRechargeViewController alloc] init];
  164. // [g_window addSubview:rechargeVC.view];
  165. [g_navigation pushViewController:rechargeVC animated:YES];
  166. }
  167. -(void)withdrawalsBtnAction:(UIButton *)button{
  168. _withdrawalsBtn.enabled = NO;
  169. [self performSelector:@selector(delayButtonReset) withObject:nil afterDelay:0.5];
  170. //JXCashWithDrawViewController
  171. JXShenQinTiMoneyVc * cashWithVC = [[JXShenQinTiMoneyVc alloc] init];
  172. // [g_window addSubview:cashWithVC.view];
  173. cashWithVC.moneyL=g_App.myMoney;
  174. [g_navigation pushViewController:cashWithVC animated:YES];
  175. }
  176. -(void)problemBtnAction{
  177. // _problemBtn.enabled = NO;
  178. [self performSelector:@selector(delayButtonReset) withObject:nil afterDelay:0.5];
  179. }
  180. -(void)delayButtonReset{
  181. _rechargeBtn.enabled = YES;
  182. _withdrawalsBtn.enabled = YES;
  183. // _problemBtn.enabled = YES;
  184. _listButton.enabled = YES;
  185. }
  186. -(void)doRefresh:(NSNotification *)notifacation{
  187. _balanceLabel.text = [NSString stringWithFormat:@"¥%.2f",g_App.myMoney];
  188. }
  189. //服务端返回数据
  190. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  191. [_wait hide];
  192. if ([aDownload.action isEqualToString:act_getUserMoeny]) {
  193. g_App.myMoney = [dict[@"balance"] doubleValue];
  194. NSString * moneyStr = [NSString stringWithFormat:@"¥%.2f",g_App.myMoney];
  195. _balanceLabel.text = moneyStr;
  196. }if ([aDownload.action isEqualToString:act_GetMyCoin]) {
  197. }
  198. }
  199. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  200. //[_wait hide]; return 0;
  201. if( [aDownload.action isEqualToString:act_UserGet] ){
  202. }
  203. return hide_error;
  204. }
  205. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{
  206. if( [aDownload.action isEqualToString:act_UserGet] ){
  207. }
  208. return hide_error;
  209. }
  210. @end