YOUPAILZVipCoinWalletVC.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // YOUPAILZVipCoinWalletVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/25.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZVipCoinWalletVC.h"
  9. #import "YOUPAILZVipCoinTransformVC.h"
  10. #import "YOUPAILZVipCoinRechargeVC.h"
  11. #import "YOUPAILCIMSessionVC.h"
  12. #import "YOUPAIHRCoinDetailVC.h"
  13. @interface YOUPAILZVipCoinWalletVC ()
  14. @property (nonatomic,weak) UILabel *youpaipbalanceL;
  15. @end
  16. @implementation YOUPAILZVipCoinWalletVC
  17. - (void)dealloc{
  18. [[NSNotificationCenter defaultCenter] removeObserver:self];
  19. }
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.title = @"贵族币钱包";
  23. [self youpaifinitUI];
  24. [self youpaifrequestVipCoinInfo];
  25. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifApplePaySuccess:) name:@"yqApplePaySuccess" object:nil];
  26. }
  27. - (void)youpaifApplePaySuccess:(NSNotification*)noti{
  28. [self youpaifrequestVipCoinInfo];
  29. }
  30. - (void)youpaifinitUI{
  31. // detailClick
  32. self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifdetailClick) title:@"明细" font:[UIFont systemFontOfSize:14] titleColor:[UIColor whiteColor] highlightedColor:[UIColor whiteColor] titleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
  33. UIImageView *balanceImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_coin_wallet_bg"]];
  34. [self.view addSubview:balanceImgV];
  35. [balanceImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.offset(ScaleSize(14.0f));
  37. make.top.offset(NavBarHeight + ScaleSize(10.0f));
  38. make.right.offset(ScaleSize(-14.0f));
  39. make.height.offset(ScaleSize(128.0f));
  40. }];
  41. UILabel *coinDescL = [[UILabel alloc] init];
  42. coinDescL.text = @"贵族币";
  43. coinDescL.textColor = HexColorFromRGB(0xFDCC88);
  44. coinDescL.font = LCFont(14.0f);
  45. [balanceImgV addSubview:coinDescL];
  46. [coinDescL mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.offset(ScaleSize(28.0f));
  48. make.top.offset(ScaleSize(30.0f));
  49. }];
  50. UILabel *balanceL = [[UILabel alloc] init];
  51. balanceL.text = @"0";
  52. balanceL.textColor = HexColorFromRGB(0xFDCC88);
  53. balanceL.font = LCFont(36.0f);
  54. [balanceImgV addSubview:balanceL];
  55. self.youpaipbalanceL = balanceL;
  56. [balanceL mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.offset(ScaleSize(28.0f));
  58. make.top.equalTo(coinDescL.mas_bottom).offset(ScaleSize(16.0f));
  59. }];
  60. UIView *serviceBgV = [[UIView alloc] init];
  61. serviceBgV.backgroundColor = LZF7F8FAColor;
  62. serviceBgV.layer.cornerRadius = ScaleSize(6.0f);
  63. serviceBgV.clipsToBounds = YES;
  64. [self.view addSubview:serviceBgV];
  65. [serviceBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.offset(ScaleSize(14.0f));
  67. make.top.equalTo(balanceImgV.mas_bottom).offset(ScaleSize(20.0f));
  68. make.right.offset(ScaleSize(-14.0f));
  69. make.height.offset(ScaleSize(68.0f));
  70. }];
  71. UIButton *serviceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  72. serviceBtn.layer.cornerRadius = ScaleSize(27.0f) / 2.0f;
  73. serviceBtn.clipsToBounds = YES;
  74. [serviceBtn setTitle:LCStr(word34) forState:UIControlStateNormal];//人工通道
  75. [serviceBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  76. serviceBtn.titleLabel.font = LCFont12;
  77. serviceBtn.backgroundColor = HexColorFromRGB(0x4F4B5B);
  78. [serviceBtn addTarget:self action:@selector(youpaifserviceBtnClick) forControlEvents:UIControlEventTouchUpInside];
  79. [serviceBgV addSubview:serviceBtn];
  80. [serviceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.centerY.equalTo(serviceBgV);
  82. make.right.offset(ScaleSize(-12.0f));
  83. make.size.mas_offset(CGSizeMake(ScaleSize(76.0f), ScaleSize(27.0f)));
  84. }];
  85. UILabel *contentL = [[UILabel alloc] init];
  86. contentL.font = LCFont12;
  87. contentL.textColor = LZ273145Color;
  88. contentL.numberOfLines = 0;
  89. NSString *str =LCStr(word35); //@"为方便大额用户,贵族币与人民币比例为1:1可以用于购买贵族、兑换钻石";
  90. NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str];
  91. NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  92. paragraphStyle1.alignment=NSTextAlignmentJustified;
  93. NSDictionary * dic =@{
  94. NSParagraphStyleAttributeName:paragraphStyle1,
  95. NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone],
  96. };
  97. [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)];
  98. [contentL setAttributedText:attributedString1];
  99. [serviceBgV addSubview:contentL];
  100. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.offset(ScaleSize(12.0f));
  102. make.centerY.equalTo(serviceBgV);
  103. make.right.equalTo(serviceBtn.mas_left).offset(ScaleSize(-22.0f));
  104. }];
  105. UIButton *rechargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  106. rechargeBtn.layer.cornerRadius = 24.0f;
  107. rechargeBtn.clipsToBounds = YES;
  108. [rechargeBtn setTitle:@"立即充值" forState:UIControlStateNormal];
  109. [rechargeBtn setTitleColor:HexColorFromRGB(0x75170A) forState:UIControlStateNormal];
  110. rechargeBtn.titleLabel.font = LCFont16;
  111. [rechargeBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 80.0f, 48.0f) FromColors:@[HexColorFromRGB(0xFBD893),HexColorFromRGB(0xD66F47)] ByGradientType:GradientTopToBottom] forState:UIControlStateNormal];
  112. [rechargeBtn addTarget:self action:@selector(youpaifrechargeBtnClick) forControlEvents:UIControlEventTouchUpInside];
  113. [self.view addSubview:rechargeBtn];
  114. [rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.bottom.offset(-30.0f-SafeHeight);
  116. make.centerX.equalTo(self.view);
  117. make.size.mas_offset(CGSizeMake(KScreenWidth - 80.0f, 48.0f));
  118. }];
  119. UIButton *conversionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  120. conversionBtn.layer.cornerRadius = 24.0f;
  121. conversionBtn.clipsToBounds = YES;
  122. [conversionBtn setTitle:@"兑换钻石" forState:UIControlStateNormal];
  123. [conversionBtn setTitleColor:HexColorFromRGB(0xD66F47) forState:UIControlStateNormal];
  124. conversionBtn.titleLabel.font = LCFont16;
  125. conversionBtn.layer.borderWidth = 1.0f;
  126. conversionBtn.layer.borderColor = HexColorFromRGB(0xD66F47).CGColor;
  127. [conversionBtn addTarget:self action:@selector(youpaifconversionBtnClick) forControlEvents:UIControlEventTouchUpInside];
  128. [self.view addSubview:conversionBtn];
  129. [conversionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.bottom.equalTo(rechargeBtn.mas_top).offset(-15.0f);
  131. make.centerX.equalTo(self.view);
  132. make.size.mas_offset(CGSizeMake(KScreenWidth - 80.0f, 48.0f));
  133. }];
  134. if ([LCSaveData getWhiteVersion]) {
  135. serviceBgV.hidden = YES;
  136. }
  137. }
  138. /// 明细
  139. -(void)youpaifdetailClick{
  140. YOUPAIHRCoinDetailVC *vc = [YOUPAIHRCoinDetailVC new];
  141. [self.navigationController pushViewController:vc animated:YES];
  142. }
  143. - (void)youpaifserviceBtnClick{
  144. NIMSession *session = [NIMSession session:@"4" type:NIMSessionTypeP2P];
  145. @weakify(self);
  146. [ZCHUDHelper show];
  147. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  148. @strongify(self);
  149. [ZCHUDHelper dismiss];
  150. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  151. [self.navigationController pushViewController:vc animated:YES];
  152. }];
  153. }
  154. - (void)youpaifrechargeBtnClick{
  155. YOUPAILZVipCoinRechargeVC *vc = [[YOUPAILZVipCoinRechargeVC alloc] init];
  156. [self.navigationController pushViewController:vc animated:YES];
  157. }
  158. - (void)youpaifconversionBtnClick{
  159. YOUPAILZVipCoinTransformVC *vc = [[YOUPAILZVipCoinTransformVC alloc] init];
  160. [self.navigationController pushViewController:vc animated:YES];
  161. }
  162. - (void)youpaifrequestVipCoinInfo{
  163. @weakify(self);
  164. [LCHttpHelper requestWithURLString:GetNobleToCoinRate parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  165. @strongify(self);
  166. NSDictionary* dict = (NSDictionary*)responseObject;
  167. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  168. if (code == 0) {
  169. NSInteger user_noble_coin = [[[dict objectForKey:@"data"]objectForKey:@"user_noble_coin"] integerValue];
  170. self.youpaipbalanceL.text = [NSString stringWithFormat:@"%@",@(user_noble_coin)];
  171. }
  172. } failure:^(NSError *error) {
  173. }];
  174. }
  175. @end