YOUPAIXRWalletVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. //
  2. // YOUPAIXRWalletVC.m
  3. // VQU
  4. //
  5. // Created by 肖浩然的mac on 2021/7/29.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAIXRWalletVC.h"
  9. #import "YOUPAILCRechargeModel.h"
  10. //#import "YOUPAILCIAPHelper.h"
  11. #import "YOUPAILCBillDetailVC.h"
  12. //#import <AlibabaSDK/AlibabaSDK.h>
  13. //#import "WXApi.h"
  14. #import "YOUPAIZYRechargeBtn.h"
  15. #import "UIViewController+TFPresent.h"
  16. //#import "WXApiObject.h"
  17. #import "SDCycleScrollView.h"
  18. #import "YOUPAILCFirstRechargeModel.h"
  19. #import "UIViewController+TFPresent.h"
  20. #import "YOUPAIHRBillDetailVC.h"
  21. #import "IPAManager.h"
  22. static CGFloat const BANNER_HEIGHT = 173.0f;
  23. @interface YOUPAIXRWalletVC ()<SDCycleScrollViewDelegate,UITextViewDelegate>
  24. @property(nonatomic,strong)UILabel* youpaiprechargeTotalLabel;
  25. @property(nonatomic,strong)UIView* youpaiprechargeView;
  26. @property(nonatomic,strong)NSMutableArray* youpaipgoodList;
  27. @property(nonatomic,strong)YOUPAILCRechargeModel* youpaipcurrentModel;
  28. @property(nonatomic,strong)NSMutableArray* youpaipbtnArray;
  29. @property(nonatomic,strong)UIButton* youpaipbuyBtn;
  30. @property(nonatomic,strong)UIScrollView* youpaipscrollView;
  31. @property(nonatomic,strong)SDCycleScrollView* youpaipSDCscrollView;
  32. //@property(nonatomic,strong)UIView* scrollBkgView;
  33. @property(nonatomic,strong)UIButton* youpaipcancelBtn;
  34. @property (strong, nonatomic) YOUPAILCFirstRechargeModel *youpaipfirstRechargeModel;
  35. @property (nonatomic, strong) NSString *youpaipwx_official; // 公众号
  36. @property (nonatomic, strong) NSString *youpaiprecharge_agreement; // 相语欢颜充值服务协议
  37. @property (nonatomic, strong) NSString *youpaipjuvenile_protection; // 相语欢颜未成年人保护计划
  38. @end
  39. @implementation YOUPAIXRWalletVC
  40. - (void)viewWillAppear:(BOOL)animated{
  41. [super viewWillAppear:animated];
  42. [self youpaifinitDataWithType:2];
  43. }
  44. - (UIScrollView *)youpaipscrollView{
  45. if (!_youpaipscrollView) {
  46. _youpaipscrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
  47. _youpaipscrollView.scrollEnabled = YES;
  48. _youpaipscrollView.pagingEnabled = NO;
  49. _youpaipscrollView.bounces = YES;
  50. _youpaipscrollView.showsVerticalScrollIndicator = NO;
  51. _youpaipscrollView.showsHorizontalScrollIndicator = NO;
  52. _youpaipscrollView.backgroundColor = [UIColor whiteColor];
  53. }
  54. return _youpaipscrollView;
  55. }
  56. -(void)viewWillDisappear:(BOOL)animated{
  57. [super viewWillDisappear:animated];
  58. }
  59. - (void)viewDidLoad {
  60. [super viewDidLoad];
  61. [UMengRecordTool umengEventCountWithId:EnterRechargePage];
  62. self.youpaipbtnArray = [NSMutableArray array];
  63. self.title = @"账户余额";
  64. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifApplePaySuccess:) name:@"yqApplePaySuccess" object:nil];
  65. [self youpaifloadFirstRecharge];
  66. [self youpaifsetupUI];
  67. [self youpaifrequestWalleetInfo];
  68. }
  69. -(void)youpaifsetupUI{
  70. [self.view addSubview:self.youpaipscrollView];
  71. self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifrechargeRecordAction) title:LCStr(word5) font:LCFont14 titleColor:LZA3AABEColor highlightedColor:LZA3AABEColor titleEdgeInsets:UIEdgeInsetsZero];//收支明细
  72. // 充值
  73. UIImageView *rechargeV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_P_wallet_profit_bg"]];
  74. [self.youpaipscrollView addSubview:rechargeV];
  75. [rechargeV mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.offset(13.0f+NavBarHeight);
  77. make.left.offset(14);
  78. make.width.offset(KScreenWidth - 28.0f);
  79. make.height.offset(BANNER_HEIGHT - 26.0f);
  80. }];
  81. UILabel *rechargeDescL = [[UILabel alloc] init];
  82. rechargeDescL.font = LCFont14;
  83. rechargeDescL.text = @"我的钻石";
  84. rechargeDescL.textColor = [UIColor whiteColor];
  85. [rechargeV addSubview:rechargeDescL];
  86. [rechargeDescL mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.offset(ScaleSize(28.0f));
  88. make.top.offset(25.5f);
  89. }];
  90. UILabel *rechargeL = [[UILabel alloc] init];
  91. rechargeL.font = LZDinFont(36.0f);
  92. rechargeL.text = @"0";
  93. rechargeL.textColor = [UIColor whiteColor];
  94. [rechargeV addSubview:rechargeL];
  95. self.youpaiprechargeTotalLabel = rechargeL;
  96. [rechargeL mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.offset(ScaleSize(28.0f));
  98. make.top.equalTo(rechargeDescL.mas_bottom).offset(16.0f);
  99. }];
  100. UILabel *labe1 = [[UILabel alloc] init];
  101. [self.youpaipscrollView addSubview:labe1];
  102. [labe1 mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.top.mas_equalTo(rechargeV.mas_bottom).offset(19);
  104. make.left.mas_equalTo(14);
  105. }];
  106. labe1.text = @"请选择充值钻石:";
  107. labe1.textColor = LZA3AABEColor;
  108. labe1.font = LCFont(12);
  109. self.youpaiprechargeView = [[UIView alloc] init];
  110. [self.youpaipscrollView addSubview:self.youpaiprechargeView];
  111. [self.youpaiprechargeView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.mas_equalTo(14);
  113. make.width.mas_equalTo(KScreenWidth - 28.0f);
  114. make.top.mas_equalTo(labe1.mas_bottom).offset(12);
  115. make.height.mas_equalTo(400);
  116. }];
  117. NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@""];
  118. if (![LCSaveData getWhiteVersion]) {
  119. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  120. [paragraphStyle setLineSpacing:6];
  121. NSString *text = @"1、充值即代表已阅读并同意《相语欢颜充值服务协议》\n2、关注“相语欢颜交友”公众号,领取惊喜礼包 复制公众号\n3、前往收支记录,可查询充值订单详情和消费详情\n4、禁止未成年人进行充值,点击详见《相语欢颜未成年人保护计划》\n5、在充值过程中如遇任何问题,可联系官方客服";
  122. str = [[NSMutableAttributedString alloc]initWithString:text];
  123. [str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
  124. [str addAttribute:NSLinkAttributeName value:@"rechargeProtocol://" range:[text rangeOfString:@"《相语欢颜充值服务协议》"]];
  125. [str addAttribute:NSLinkAttributeName value:@"officialAccount://" range:[text rangeOfString:@"复制公众号"]];
  126. [str addAttribute:NSLinkAttributeName value:@"youngProtect://" range:[text rangeOfString:@"《相语欢颜未成年人保护计划》"]];
  127. }
  128. UITextView * textview = [[UITextView alloc]init];
  129. textview.editable = NO;
  130. textview.scrollEnabled = NO;
  131. textview.delegate = self;
  132. textview.backgroundColor = [UIColor clearColor];
  133. textview.font = LCFont(10);
  134. textview.attributedText = str;
  135. textview.textColor = LZA3AABEColor;
  136. // textview.textAlignment = NSTextAlignmentCenter;
  137. textview.linkTextAttributes = @{NSForegroundColorAttributeName:LZ7C69FEColor,
  138. NSUnderlineStyleAttributeName:[NSNumber numberWithInt:NSUnderlineStyleNone]
  139. };
  140. [self.youpaipscrollView addSubview:textview];
  141. [textview mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.left.mas_equalTo(14);
  143. make.width.mas_equalTo(KScreenWidth - 28.0f);
  144. make.top.mas_equalTo(self.youpaiprechargeView.mas_bottom).offset(20.0f);
  145. make.height.offset(130.0f);
  146. }];
  147. UIButton* buyBtn = [[UIButton alloc]init];
  148. [self.view addSubview:buyBtn];
  149. [buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  150. make.bottom.equalTo(-SafeHeight-10);
  151. make.size.mas_equalTo(CGSizeMake(KScreenWidth-120, 48));
  152. make.centerX.mas_equalTo(0);
  153. }];
  154. buyBtn.userInteractionEnabled = NO;
  155. buyBtn.backgroundColor = LCGray;
  156. buyBtn.layer.cornerRadius = 24.0;
  157. buyBtn.layer.masksToBounds = YES;
  158. buyBtn.titleLabel.font = LCFont17;
  159. [buyBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  160. [buyBtn setTitle:@"立即充值" forState:(UIControlStateNormal)];
  161. [buyBtn addTarget:self action:@selector(youpaifbuyBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  162. self.youpaipbuyBtn = buyBtn;
  163. // NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:LCFont(10.0f) forKey:NSFontAttributeName];
  164. // CGSize size = [textview.text boundingRectWithSize:CGSizeMake(MAXFLOAT, 10.0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
  165. // UIView *xiyiBgView = [UIView new];
  166. // [self.view addSubview:xiyiBgView];
  167. // [xiyiBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  168. // make.width.mas_equalTo(size.width+45);
  169. // make.centerX.mas_equalTo(0);
  170. // make.bottom.mas_equalTo(self.view.bottom).offset(-40);
  171. // make.height.mas_equalTo(@30);
  172. // }];
  173. // [xiyiBgView addSubview:textview];
  174. CGFloat contentHeight = CGRectGetMaxY(_youpaiprechargeView.frame) + 100 + 90 + SafeHeight;
  175. contentHeight = contentHeight > KScreenHeight - NavBarHeight + 68.0f ? contentHeight : KScreenHeight - NavBarHeight + 68.0f;
  176. self.youpaipscrollView.contentSize = CGSizeMake(0,contentHeight);
  177. SDCycleScrollView *bannerView1 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(KScreenWidth - 12.0f - 49.0f, KScreenHeight - 12.0f - 49.0f - SafeHeight - 50.0f, 50, 50.0f) delegate:self placeholderImage:[UIImage imageNamed:@""]];
  178. self.youpaipSDCscrollView = bannerView1;
  179. bannerView1.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
  180. bannerView1.autoScrollTimeInterval = 3.0;//2s轮播
  181. bannerView1.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
  182. bannerView1.backgroundColor = [UIColor clearColor];
  183. [self.view addSubview:bannerView1];
  184. }
  185. #pragma mark --UITextViewDelegate
  186. - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
  187. if ([[URL scheme]isEqualToString:@"rechargeProtocol"]) {// 进入《流光花舞充值服务协议》
  188. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  189. vc.contentUrl = self.youpaiprecharge_agreement;
  190. [self.navigationController pushViewController:vc animated:YES];
  191. return NO;
  192. }
  193. if ([[URL scheme]isEqualToString:@"officialAccount"]) {// 复制公众号
  194. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  195. pasteboard.string = self.youpaipwx_official;
  196. [ZCHUDHelper showTitle:@"复制成功"];
  197. return NO;
  198. }
  199. if ([[URL scheme]isEqualToString:@"youngProtect"]) {// 进入《相语欢颜未成年人保护计划》
  200. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  201. vc.contentUrl = self.youpaipjuvenile_protection;
  202. [self.navigationController pushViewController:vc animated:YES];
  203. return NO;
  204. }
  205. return YES;
  206. }
  207. #pragma mark - SDCycleScrollViewDelegate
  208. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
  209. {
  210. YOUPAILCBannerModel* model = self.youpaipfirstRechargeModel.youpaiplist[index];
  211. if (model.youpaiplink_type==1) {
  212. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  213. baseWeb.contentUrl = model.youpaiplink_url;
  214. [self.navigationController pushViewController:baseWeb animated:YES];
  215. }else if (model.youpaiplink_type==2||model.youpaiplink_type==3){
  216. [self youpaifpageToStr:model.youpaiplink_url];
  217. }
  218. }
  219. -(void)youpaifloadFirstRecharge{
  220. [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"2"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  221. NSDictionary* dict = (NSDictionary*)responseObject;
  222. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  223. if (code==0) {//成功
  224. self.youpaipfirstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
  225. NSMutableArray *imgUrlArray = [NSMutableArray new];
  226. for (YOUPAILCBannerModel* model in self.youpaipfirstRechargeModel.youpaiplist) {
  227. [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
  228. }
  229. self.youpaipSDCscrollView.imageURLStringsGroup = imgUrlArray;
  230. if (self.youpaipfirstRechargeModel.youpaipis_open == 1) {
  231. self.youpaipSDCscrollView.hidden = NO;
  232. }else{
  233. self.youpaipSDCscrollView.hidden = YES;
  234. }
  235. }
  236. } failure:^(NSError *error) {}];
  237. }
  238. -(void)youpaifbuyBtnClick{
  239. [self applePay];
  240. }
  241. - (void)applePay{
  242. self.youpaipbuyBtn.userInteractionEnabled = NO;
  243. /// 内购
  244. [ZCHUDHelper showWithStatus:@"支付中..."];
  245. NSLog(@"%@",self.youpaipcurrentModel.youpaipios_product_id);
  246. [[IPAManager shareIAPManager] startPurchWithID:self.youpaipcurrentModel.youpaipios_product_id completeHandle:^(IAPPurchType type, NSString *data) {
  247. NSLog(@"type = %ld",type);
  248. if (type == IAPPurchSuccess) {
  249. [LCSaveData saveReceiptData:data];
  250. [self requestApplePayBack:data];
  251. }else{
  252. dispatch_async(dispatch_get_main_queue(), ^{
  253. self.youpaipbuyBtn.userInteractionEnabled = YES;
  254. });
  255. NSString *title = @"";
  256. switch (type) {
  257. case IAPPurchFailed:
  258. title = @"购买失败";
  259. break;
  260. case IAPPurchCancle:
  261. title = @"已取消购买";
  262. break;
  263. case IAPPurchVerFailed:
  264. title = @"订单校验失败";
  265. break;
  266. // case IAPPurchVerSuccess:
  267. // NSLog(@"订单校验成功");
  268. // break;
  269. case IAPPurchNotArrow:
  270. title = @"不允许程序内付费";
  271. break;
  272. default:
  273. break;
  274. }
  275. if (title.length == 0) {
  276. [ZCHUDHelper dismiss];
  277. }else{
  278. [ZCHUDHelper showTitle:title];
  279. }
  280. }
  281. }];
  282. }
  283. - (void)requestApplePayBack:(NSString *)receipt_data{
  284. [LCHttpHelper requestWithURLString:ApplePayBack parameters:@{@"receipt_data":receipt_data} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  285. NSDictionary* dict = (NSDictionary*)responseObject;
  286. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  287. dispatch_async(dispatch_get_main_queue(), ^{
  288. self.youpaipbuyBtn.userInteractionEnabled = YES;
  289. });
  290. if (code == 0) {
  291. [LCSaveData removeReceiptData:receipt_data];
  292. NSInteger type = 4;
  293. // if (![LCSaveData getOnlineVersion]) {
  294. // type = 4;
  295. // }
  296. [self youpaifinitDataWithType:type];
  297. // if (self.paySuccessBlock != nil) {
  298. // self.paySuccessBlock();
  299. // }
  300. }
  301. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  302. } failure:^(NSError *error) {
  303. dispatch_async(dispatch_get_main_queue(), ^{
  304. self.youpaipbuyBtn.userInteractionEnabled = YES;
  305. });
  306. [ZCHUDHelper showTitle:error.localizedDescription];
  307. }];
  308. }
  309. -(void)youpaifrechargeRecordAction
  310. {
  311. YOUPAIHRBillDetailVC *vc = [YOUPAIHRBillDetailVC new];
  312. vc.youpaipcate_id = 1;
  313. [self.navigationController pushViewController:vc animated:YES];
  314. }
  315. - (void)youpaifupdateView{
  316. if (self.youpaipbtnArray.count>0) {
  317. for (YOUPAIZYRechargeBtn* btn in self.youpaipbtnArray) {
  318. [btn removeFromSuperview];
  319. }
  320. }
  321. [self.youpaipbtnArray removeAllObjects];
  322. for (UIView *view in self.youpaiprechargeView.subviews) {
  323. [view removeFromSuperview];
  324. }
  325. CGFloat space = ScaleSize(6.0f);
  326. CGFloat width = (KScreenWidth - 24.0f - space) / 2.0f;
  327. CGFloat height = ScaleSize(74.0f);
  328. CGFloat rechargeViewHeight = 0.0f;
  329. for (NSInteger i = 0; i<self.youpaipgoodList.count; i++) {
  330. YOUPAILCRechargeModel* model = self.youpaipgoodList[i];
  331. model.youpaipreward = model.youpaipreward.length == 0 ? @"0" : model.youpaipreward;
  332. NSInteger col = i % 2;
  333. NSInteger row = i / 2;
  334. YOUPAIZYRechargeBtn* btn = [[YOUPAIZYRechargeBtn alloc]initWithFrame:CGRectMake(col * width + col * space, row * height + row * space,width,height) model:model];
  335. btn.layer.cornerRadius = ScaleSize(6.0f);
  336. btn.layer.borderWidth = ScaleSize(1.0f);
  337. btn.layer.borderColor = LZF5F4F7Color.CGColor;
  338. btn.youpaippriceLabel.text = [NSString stringWithFormat:@"¥%@",model.youpaipprice];
  339. NSString *amountText = [NSString stringWithFormat:@"%@钻石",model.youpaipamount];
  340. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:amountText];
  341. NSRange range = NSMakeRange(model.youpaipamount.length, 2);
  342. [attrStr addAttribute:NSFontAttributeName value:LCFont(ScaleSize(14.0f)) range:range];
  343. [attrStr addAttribute:NSForegroundColorAttributeName value:LZ273145Color range:range];
  344. btn.youpaipgoodLabel.attributedText = attrStr.copy;
  345. if (model.youpaipbtn_text.count != 0) {
  346. btn.youpaipgiveLabel.text = model.youpaipbtn_text[0];
  347. }
  348. [btn addTarget:self action:@selector(youpaifrechargeBtnClick:) forControlEvents:(UIControlEventTouchUpInside)];
  349. [self.youpaiprechargeView addSubview:btn];
  350. [self.youpaipbtnArray addObject:btn];
  351. if (i==1) {
  352. [self youpaifrechargeBtnClick:btn];
  353. }
  354. rechargeViewHeight = CGRectGetMaxY(btn.frame);
  355. }
  356. // CGRect rechargeRect = self.rechargeView.frame;
  357. // rechargeRect.size.height = rechargeViewHeight;
  358. // self.rechargeView.frame = rechargeRect;
  359. [self.youpaiprechargeView mas_updateConstraints:^(MASConstraintMaker *make) {
  360. make.height.mas_equalTo(rechargeViewHeight);
  361. }];
  362. // [self.buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  363. // make.top.mas_equalTo(self.rechargeView.mas_bottom).offset(35);
  364. // make.size.mas_equalTo(CGSizeMake(KScreenWidth-120, 48));
  365. // make.centerX.mas_equalTo(0);
  366. // }];
  367. [self.view layoutIfNeeded];
  368. CGFloat contentHeight = CGRectGetMaxY(_youpaiprechargeView.frame) + 100 + 90 + SafeHeight;
  369. contentHeight = contentHeight > KScreenHeight - NavBarHeight + 68.0f ? contentHeight : KScreenHeight - NavBarHeight + 68.0f;
  370. self.youpaipscrollView.contentSize = CGSizeMake(0,contentHeight);
  371. }
  372. - (void)youpaifrechargeBtnClick:(YOUPAIZYRechargeBtn*)reBtn{
  373. self.youpaipcurrentModel = reBtn.youpaipreModel;
  374. [self.youpaipbuyBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-120, 48) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  375. self.youpaipbuyBtn.userInteractionEnabled = YES;
  376. for (YOUPAIZYRechargeBtn* btn in self.youpaipbtnArray) {
  377. btn.layer.cornerRadius = ScaleSize(6.0f);
  378. btn.layer.borderWidth = ScaleSize(1.0f);
  379. btn.layer.borderColor = LZF5F4F7Color.CGColor;
  380. btn.selected = NO;
  381. btn.youpaipgoodLabel.textColor = LZ273145Color;
  382. btn.youpaipgiveLabel.textColor = LZA3AABEColor;
  383. btn.youpaippriceLabel.textColor = LZA3AABEColor;
  384. }
  385. reBtn.layer.cornerRadius = ScaleSize(6.0f);
  386. reBtn.layer.borderWidth = ScaleSize(1.5f);
  387. reBtn.layer.borderColor = LZ7C69FEColor.CGColor;
  388. reBtn.selected = YES;
  389. reBtn.youpaipgoodLabel.textColor = LZ7C69FEColor;
  390. reBtn.youpaipgiveLabel.textColor = LZ7C69FEColor;
  391. reBtn.youpaippriceLabel.textColor = LZ273145Color;
  392. }
  393. #pragma mark - Request
  394. - (void)youpaifrequestWalleetInfo{
  395. @weakify(self);
  396. [LCHttpHelper requestWithURLString:WalletInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  397. @strongify(self);
  398. NSDictionary* dict = (NSDictionary*)responseObject;
  399. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  400. if (code==0) {//成功
  401. // CGFloat incomeCoin = [[[[dict objectForKey:@"data"]objectForKey:@"account"]objectForKey:@"income_coin"] floatValue];
  402. self.youpaipwx_official = [[[dict objectForKey:@"data"]objectForKey:@"webUrl"]objectForKey:@"wx_official"];
  403. self.youpaipjuvenile_protection = [[[dict objectForKey:@"data"]objectForKey:@"webUrl"]objectForKey:@"juvenile_protection"];
  404. self.youpaiprecharge_agreement = [[[dict objectForKey:@"data"]objectForKey:@"webUrl"]objectForKey:@"recharge_agreement"];
  405. }
  406. } failure:^(NSError *error) {
  407. }];
  408. }
  409. - (void)youpaifinitDataWithType:(NSInteger)type{
  410. [LCHttpHelper requestWithURLString:WalletGoodList parameters:@{@"type":@(type)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  411. NSDictionary* dict = (NSDictionary*)responseObject;
  412. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  413. if (code==0) {//成功
  414. self.youpaiprechargeTotalLabel.text = [NSString stringWithFormat:@"%.0f",[[[dict objectForKey:@"data"]objectForKey:@"coin"]floatValue]];
  415. self.youpaipgoodList = [YOUPAILCRechargeModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
  416. [self youpaifupdateView];
  417. }
  418. } failure:^(NSError *error) {
  419. }];
  420. }
  421. - (void)youpaifApplePaySuccess:(NSNotification*)noti{
  422. [self youpaifinitDataWithType:4];
  423. }
  424. @end