AccountRechargeVC.m 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. //
  2. // AccountRechargeVC.m
  3. // BuguLive
  4. // 账号充值
  5. // Created by hym on 2016/10/25.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "AccountRechargeVC.h"
  9. #import "AccountRechargeModel.h"
  10. #import "AccountRechargeModel.h"
  11. #import "DisplayTableViewCell.h"
  12. #import "AccountRechargeOthermoneyTBCell.h"
  13. #import "Pay_Model.h"
  14. #import "Mwxpay.h"
  15. //#import "BGInterface.h"
  16. #import "JuBaoModel.h"
  17. #import <StoreKit/StoreKit.h>
  18. #import "AccountItemCell.h"
  19. #define Label_Balances_Tag 10000 //余额
  20. #define Label_Titles_Tag 10001
  21. #define Cell_PayType_Default_Tag 20000
  22. @interface AccountRechargeVC ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,SKPaymentTransactionObserver,SKProductsRequestDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  23. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  24. @property (nonatomic, strong) AccountRechargeModel *model;
  25. @property (nonatomic, strong) NSString *money;
  26. @property (nonatomic, strong) NSString *pro_id;
  27. @property (nonatomic, strong) MBProgressHUD *HUD;
  28. @property (nonatomic, assign) NSInteger row;
  29. @property (nonatomic, assign) BOOL hsClick;
  30. @property (nonatomic, strong) NSMutableArray * ruleListArr;
  31. @property (nonatomic, strong) SKProductsRequest * request;
  32. @property (nonatomic, strong) JuBaoModel * juBaoModel;
  33. @property (nonatomic, strong) UICollectionView *collectionView;
  34. @property(nonatomic, strong) QMUIButton *selectAgreeBtn;
  35. @property(nonatomic, strong) QMUIButton *agreeBtn;
  36. @end
  37. @implementation AccountRechargeVC
  38. - (void)viewDidLoad
  39. {
  40. [super viewDidLoad];
  41. [self doInit];
  42. [self dataStructrue];
  43. [self keyboardConfig];
  44. _ruleListArr = [NSMutableArray array];
  45. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(paySuccess) name:@"PaySuccess" object:nil];
  46. }
  47. - (void)viewWillDisappear:(BOOL)animated
  48. {
  49. [super viewWillDisappear:animated];
  50. [IQKeyboardManager sharedManager].enable = NO;
  51. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  52. [self.HUD hideAnimated:YES];
  53. [SVProgressHUD dismiss];
  54. [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
  55. }
  56. - (void)doInit
  57. {
  58. self.view.backgroundColor =kBackGroundColor;
  59. if (_is_vip)
  60. {
  61. self.title = ASLocalizedString(@"VIP充值");
  62. }
  63. else
  64. {
  65. self.title = ASLocalizedString(@"充值");
  66. }
  67. self.navigationController.navigationBarHidden =NO;
  68. self.navigationItem.hidesBackButton = YES;
  69. self.tableView.delegate = self;
  70. self.tableView.dataSource = self;
  71. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  72. [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
  73. self.money = @"0";
  74. [self.tableView registerNib:[UINib nibWithNibName:@"DisplayTableViewCell" bundle:nil] forCellReuseIdentifier:@"payMoneycellIdentifier"];
  75. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(paySuccess) name:@"PaySuccess" object:nil];
  76. self.row = 0;
  77. self.hsClick = YES;
  78. [self setupBackBtnWithBlock:nil];
  79. }
  80. //数据构造
  81. - (void)dataStructrue
  82. {
  83. self.model = [AccountRechargeModel new];
  84. [self loadNet];
  85. }
  86. - (void)loadNet
  87. {
  88. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  89. if (_is_vip)
  90. {
  91. [parmDict setObject:@"vip_pay" forKey:@"ctl"];
  92. [parmDict setObject:@"purchase" forKey:@"act"];
  93. }
  94. else
  95. {
  96. [parmDict setObject:@"pay" forKey:@"ctl"];
  97. [parmDict setObject:@"recharge" forKey:@"act"];
  98. }
  99. __weak AccountRechargeVC *weakSelf = self;
  100. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  101. weakSelf.model = [AccountRechargeModel mj_objectWithKeyValues:responseJson];
  102. if (weakSelf.model.pay_list.count)
  103. {
  104. PayTypeModel *model = [weakSelf.model.pay_list firstObject];
  105. if (model)
  106. {
  107. model.isSelect = YES;
  108. }
  109. weakSelf.row = 1;
  110. self.ruleListArr = model.rule_list.count>0 ? model.rule_list : weakSelf.model.rule_list;
  111. }
  112. [weakSelf.tableView reloadData];
  113. [weakSelf.collectionView reloadData];
  114. } FailureBlock:^(NSError *error) {
  115. }];
  116. }
  117. //支付成功刷新账户
  118. - (void)paySuccess
  119. {
  120. [self reloadAcount];
  121. }
  122. #pragma marlk 刷新账户
  123. - (void)reloadAcount
  124. {
  125. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  126. if (_is_vip)
  127. {
  128. [parmDict setObject:@"vip_pay" forKey:@"ctl"];
  129. [parmDict setObject:@"purchase" forKey:@"act"];
  130. }
  131. else
  132. {
  133. [parmDict setObject:@"pay" forKey:@"ctl"];
  134. [parmDict setObject:@"recharge" forKey:@"act"];
  135. }
  136. __weak AccountRechargeVC *weakSelf = self;
  137. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  138. {
  139. if ((NSNull *)responseJson != [NSNull null])
  140. {
  141. if (_is_vip)
  142. {
  143. weakSelf.model.vip_expire_time = [responseJson objectForKey:@"vip_expire_time"];
  144. weakSelf.model.is_vip = [responseJson integerForKey:@"is_vip"];
  145. }
  146. else
  147. {
  148. weakSelf.model.diamonds = [[responseJson objectForKey:@"diamonds"] doubleValue];
  149. }
  150. [weakSelf.tableView reloadData];
  151. }
  152. } FailureBlock:^(NSError *error)
  153. {
  154. }];
  155. }
  156. #pragma mark UITableViewDelegate
  157. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  158. {
  159. if (indexPath.section == 0){
  160. return 210.0f;
  161. }else if (indexPath.section == 1){
  162. if ([self hsOnlyIappay]){
  163. return 110.0f;
  164. }
  165. else{
  166. NSInteger rowCount = self.ruleListArr.count % 3 == 0 ? self.ruleListArr.count / 3 : self.ruleListArr.count / 3 + 1;
  167. NSLog(@"(NSInteger rowCount %lu",rowCount);
  168. return indexPath.row == 0 ? 44.0f : (90 * rowCount + 10);
  169. }
  170. }else if (indexPath.section == 2){
  171. return [self hsOnlyIappay] ? 0 : 44.0f;
  172. }else if (indexPath.section == 3){
  173. return 44;
  174. }
  175. return 50.0f;
  176. }
  177. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  178. {
  179. if (section == 1)
  180. {
  181. return [self hsOnlyIappay] ? 0.001f : 10.0f;
  182. }else if (section == 3){
  183. return 10.0f;
  184. }
  185. return 10.0f;
  186. }
  187. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  188. {
  189. NSInteger Sections = [self hsOtherPayMoney] ? 4 : 3;
  190. if (section == Sections) {
  191. return 30.0f;
  192. }
  193. return 0.001f;
  194. }
  195. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  196. {
  197. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  198. if (indexPath.section == 3) {
  199. return;
  200. }
  201. if (indexPath.section == 1)
  202. {
  203. if (indexPath.row == 0 && ![self hsOnlyIappay])
  204. {
  205. return;
  206. }
  207. if (self.hsClick)
  208. {
  209. self.hsClick = NO;
  210. [self payRequestNet:(int)indexPath.row - (int)self.row wxPayNet:1];
  211. __weak AccountRechargeVC *weakSelf = self;
  212. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  213. weakSelf.hsClick = YES;
  214. });
  215. }
  216. }
  217. else if (indexPath.section == 2)
  218. {
  219. if (indexPath.row == 0)
  220. {
  221. return;
  222. }
  223. PayTypeModel *model = self.model.pay_list[indexPath.row - 1];
  224. if (model.isSelect)
  225. {
  226. return;
  227. }
  228. for (PayTypeModel *model in self.model.pay_list)
  229. {
  230. model.isSelect = NO;
  231. }
  232. model.isSelect = YES;
  233. // self.ruleListArr = model.rule_list.count > 0 ? model.rule_list : self.model.rule_list;
  234. [self.tableView reloadData];
  235. [self.collectionView reloadData];
  236. }
  237. }
  238. #pragma mark UITableViewDataSource
  239. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  240. {
  241. if (_is_vip)
  242. {
  243. return 4;
  244. }
  245. else
  246. {
  247. return [self hsOtherPayMoney] ? 5 : 4;
  248. }
  249. }
  250. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  251. {
  252. if (section == 0)
  253. {
  254. return 1;
  255. }
  256. else if (section == 1)
  257. {
  258. return [self hsOnlyIappay] ? self.ruleListArr.count : 2;
  259. }
  260. else if (section == 2)
  261. {
  262. return [self hsOnlyIappay] ? 0 : self.model.pay_list.count + self.row;
  263. }else if (section == 3){
  264. return 1;
  265. }
  266. return self.row;
  267. }
  268. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  269. {
  270. if (indexPath.section == 0)
  271. {
  272. UITableViewCell *cell = [self balancesCellWithTbaleview:tableView cellForRowAtIndexPath:indexPath];
  273. _lbBalance = [cell.contentView viewWithTag:Label_Balances_Tag];
  274. if (!_is_vip)
  275. {
  276. _lbBalance.text = [NSString stringWithFormat:@"%ld",(long)self.model.diamonds];
  277. [_lbBalance mas_makeConstraints:^(MASConstraintMaker *make) {
  278. make.centerY.equalTo(cell.contentView);
  279. make.left.equalTo(_diamImageView.mas_right).with.offset(10);
  280. }];
  281. }
  282. else
  283. {
  284. [_lbBalance mas_makeConstraints:^(MASConstraintMaker *make) {
  285. make.centerY.equalTo(cell.contentView);
  286. make.left.equalTo(_diamImageView.mas_right).with.offset(-20);
  287. }];
  288. if (self.model.is_vip == 0)
  289. {
  290. _lbBalance.textColor = kGrayColor;
  291. _lbBalance.text = self.model.vip_expire_time;
  292. }
  293. else if (self.model.is_vip == 1 && self.model.vip_expire_time.length == 0)
  294. {
  295. _lbBalance.textColor = kAppGrayColor1;
  296. _lbBalance.text = ASLocalizedString(@"永久会员");
  297. }
  298. else
  299. {
  300. _lbBalance.textColor = kAppGrayColor1;
  301. _lbBalance.text = self.model.vip_expire_time;
  302. }
  303. _lbBalance.text = [NSString stringWithFormat:@"%ld",(long)self.model.diamonds];
  304. }
  305. return cell;
  306. }
  307. else if (indexPath.section == 1)
  308. {
  309. if (indexPath.row == 0 && ![self hsOnlyIappay])
  310. {
  311. UITableViewCell *cell = [self titlesCellWithTbaleview:tableView cellForRowAtIndexPath:indexPath];
  312. UILabel *lbTitles = [cell.contentView viewWithTag:Label_Titles_Tag];
  313. if (_is_vip) {
  314. lbTitles.text = ASLocalizedString(@"请选择会员套餐");
  315. }
  316. else
  317. {
  318. lbTitles.text = ASLocalizedString(@"请选择支付金额");
  319. }
  320. // self.collectionView.hidden = YES;
  321. return cell;
  322. }
  323. else
  324. {
  325. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
  326. // if (!_collectionView) {
  327. [cell.contentView addSubview:self.collectionView];
  328. // }
  329. self.collectionView.hidden = NO;
  330. [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  331. make.edges.equalTo(cell.contentView);
  332. }];
  333. return cell;
  334. /*
  335. static NSString * payMoneycellIdentifier = @"payMoneycellIdentifier";
  336. DisplayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:payMoneycellIdentifier];
  337. if (cell == nil)
  338. {
  339. cell = [[DisplayTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:payMoneycellIdentifier];
  340. }
  341. PayMoneyModel *model = self.ruleListArr[indexPath.row - self.row];
  342. if (_is_vip)
  343. {
  344. cell.topLabel.text = model.day_num;
  345. cell.bottomLabel.text = model.name;
  346. cell.diamondImageView.hidden = YES;
  347. cell.diamondImgWidth.constant = 0;
  348. cell.diamondImgRight.constant = 0;
  349. }
  350. else
  351. {
  352. cell.diamondImageView.hidden = NO;
  353. cell.topLabel.text = [NSString stringWithFormat:@"%ld",(long)model.diamonds];
  354. cell.bottomLabel.text = model.name;
  355. }
  356. cell.rightLabel.text = model.money_name;
  357. NSInteger row = self.row == 1 ? 0 : 1;
  358. if (indexPath.row == self.model.rule_list.count - row){
  359. cell.lineView.hidden = YES;
  360. }
  361. return cell;
  362. */
  363. }
  364. }
  365. else if (indexPath.section == 2)
  366. {
  367. UITableViewCell *cell = nil;
  368. if (indexPath.row == 0)
  369. {
  370. cell = [self titlesCellWithTbaleview:tableView cellForRowAtIndexPath:indexPath];
  371. UILabel *lbTitles = [cell.contentView viewWithTag:Label_Titles_Tag];
  372. lbTitles.text = ASLocalizedString(@"请选择支付方式");
  373. }
  374. else
  375. {
  376. cell = [self payTypeCellWithTbaleview:tableView cellForRowAtIndexPath:indexPath];
  377. PayTypeModel *model = self.model.pay_list[indexPath.row - self.row];
  378. UIImageView *imageIcon = [cell viewWithTag:Cell_PayType_Default_Tag];
  379. [imageIcon sd_setImageWithURL:[NSURL URLWithString:model.logo]];
  380. UILabel *lbTitles = [cell.contentView viewWithTag:Cell_PayType_Default_Tag + 1];
  381. lbTitles.text = model.name;
  382. UIImageView *imageSelect = [cell.contentView viewWithTag:Cell_PayType_Default_Tag + 2];
  383. model.isSelect ? [imageSelect setImage:[UIImage imageNamed:@"com_radio_selected_2"]] : [imageSelect setImage:[UIImage imageNamed:@"com_radio_normal_2"]];
  384. if (indexPath.row == self.model.pay_list.count)
  385. {
  386. UIView *line = [cell.contentView viewWithTag:Cell_PayType_Default_Tag + 3];
  387. line.hidden = YES;
  388. }
  389. }
  390. return cell;
  391. }else if (indexPath.section == 3){
  392. UITableViewCell *cell = [UITableViewCell new];
  393. // if (!self.selectAgreeBtn) {
  394. self.selectAgreeBtn.frame = CGRectMake(kRealValue(20),10, 30,30);
  395. self.agreeBtn.frame = CGRectMake(0, 0, kScreenW / 2, kRealValue(44));
  396. self.agreeBtn.centerY = self.selectAgreeBtn.centerY;
  397. self.agreeBtn.left = self.selectAgreeBtn.right;
  398. [cell.contentView addSubview:self.agreeBtn];
  399. [cell.contentView addSubview:self.selectAgreeBtn];
  400. // }
  401. return cell;
  402. }
  403. AccountRechargeOthermoneyTBCell *cell = [AccountRechargeOthermoneyTBCell cellWithTbaleview:tableView];
  404. cell.rate = self.model.rate;
  405. __weak AccountRechargeVC *weakSelf = self;
  406. cell.block = ^(id object) {
  407. weakSelf.money = object;
  408. [weakSelf payRequestNet:0 wxPayNet:0];
  409. };
  410. return cell;
  411. }
  412. #pragma mark UIHelper
  413. - (UITableViewCell *)balancesCellWithTbaleview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  414. {
  415. static NSString * BalancescellIdentifier = @"BalancescellIdentifier";
  416. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:BalancescellIdentifier];
  417. if (cell == nil)
  418. {
  419. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BalancescellIdentifier];
  420. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  421. UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"me_account_back"]];
  422. imageView.frame = CGRectMake(10, 10, kScreenW - 20, 200);
  423. imageView.layer.cornerRadius = 5;
  424. imageView.backgroundColor = kClearColor;
  425. imageView.clipsToBounds = YES;
  426. [cell.contentView addSubview:imageView];
  427. _lbTitles =[UILabel new];
  428. if (_is_vip)
  429. {
  430. _lbTitles.text = ASLocalizedString(@"会员到期日期:");
  431. }
  432. else
  433. {
  434. _lbTitles.text = ASLocalizedString(@"钻石");
  435. }
  436. _lbTitles.font = [UIFont systemFontOfSize:20];
  437. _lbTitles.textColor = kWhiteColor;
  438. _lbTitles.textAlignment = NSTextAlignmentCenter;
  439. [imageView addSubview:_lbTitles];
  440. _lbTitles.hidden = YES;
  441. [_lbTitles mas_makeConstraints:^(MASConstraintMaker *make) {
  442. make.top.equalTo(cell.contentView).offset(60);
  443. make.centerY.mas_equalTo(cell.contentView).offset(10);
  444. make.centerX.equalTo(cell.contentView);
  445. }];
  446. _titleBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  447. [_titleBtn setTitle:_lbTitles.text forState:UIControlStateNormal];
  448. _titleBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  449. [_titleBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  450. [_titleBtn setImagePosition:QMUIButtonImagePositionLeft];
  451. [_titleBtn setImage:[UIImage imageNamed:@"fw_me_charge_diammond"] forState:UIControlStateNormal];
  452. _titleBtn.spacingBetweenImageAndTitle = 2;
  453. [imageView addSubview:_titleBtn];
  454. [_titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  455. make.top.equalTo(cell.contentView).offset(55);
  456. make.centerY.mas_equalTo(cell.contentView).offset(10);
  457. make.centerX.equalTo(cell.contentView);
  458. make.width.mas_equalTo(150);
  459. }];
  460. _diamImageView =[UIImageView new];
  461. if (_is_vip)
  462. {
  463. _diamImageView.hidden = YES;
  464. }
  465. else
  466. {
  467. _diamImageView.hidden = NO;
  468. _diamImageView.image =[UIImage imageNamed:@"com_diamond_1"];
  469. }
  470. _diamImageView.hidden = YES;//没有图标 隐藏掉 MG_4.0.1
  471. [cell.contentView addSubview:_diamImageView];
  472. _lbBalance = [UILabel new];
  473. _lbBalance.tag = Label_Balances_Tag;
  474. _lbBalance.textAlignment =NSTextAlignmentLeft;
  475. _lbBalance.textColor = kWhiteColor;
  476. _lbBalance.font = [UIFont systemFontOfSize:38];
  477. [cell.contentView addSubview:_lbBalance];
  478. [_diamImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  479. make.top.equalTo(_lbTitles.mas_bottom).offset(30);
  480. make.right.equalTo(_lbBalance.mas_left).offset(-5);
  481. if (_is_vip)
  482. {
  483. make.size.mas_equalTo(CGSizeMake(20, 20));
  484. }
  485. else
  486. {
  487. make.size.mas_equalTo(CGSizeMake(18, 14));
  488. }
  489. }];
  490. [_lbBalance mas_makeConstraints:^(MASConstraintMaker *make) {
  491. make.centerY.equalTo(_titleBtn.mas_bottom).offset(15);
  492. make.centerX.equalTo(cell.contentView);
  493. }];
  494. }
  495. return cell;
  496. }
  497. - (UITableViewCell *)titlesCellWithTbaleview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  498. {
  499. static NSString * titlescellIdentifier = @"titlescellIdentifier";
  500. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:titlescellIdentifier];
  501. if (cell == nil) {
  502. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:titlescellIdentifier];
  503. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  504. UILabel *lbTitles = [UILabel new];
  505. lbTitles.font = [UIFont systemFontOfSize:14];
  506. lbTitles.textColor = kAppGrayColor1;
  507. lbTitles.tag = Label_Titles_Tag;
  508. [cell.contentView addSubview:lbTitles];
  509. [lbTitles mas_makeConstraints:^(MASConstraintMaker *make) {
  510. make.centerY.equalTo(cell.contentView);
  511. make.left.equalTo(cell.contentView.mas_left).with.offset(14);
  512. }];
  513. UIView *line = [UIView new];
  514. line.backgroundColor = kBackGroundColor;
  515. [cell.contentView addSubview:line];
  516. [line mas_makeConstraints:^(MASConstraintMaker *make)
  517. {
  518. make.left.equalTo(cell.contentView);
  519. make.right.equalTo(cell.contentView);
  520. make.bottom.equalTo(cell.contentView);
  521. make.height.offset(1);
  522. }];
  523. }
  524. return cell;
  525. }
  526. - (UITableViewCell *)payTypeCellWithTbaleview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  527. {
  528. static NSString * payTypecellIdentifier = @"payTypecellIdentifier";
  529. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:payTypecellIdentifier];
  530. if (cell == nil)
  531. {
  532. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:payTypecellIdentifier];
  533. UIImageView *imageView = [UIImageView new];
  534. imageView.tag = Cell_PayType_Default_Tag;
  535. [cell.contentView addSubview:imageView];
  536. [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  537. make.size.mas_equalTo(CGSizeMake(30, 30));
  538. make.left.equalTo(cell.contentView.mas_left).with.offset(14);
  539. make.centerY.equalTo(cell.contentView);
  540. }];
  541. UILabel *lbTitles =[UILabel new];
  542. lbTitles.font = [UIFont systemFontOfSize:14];
  543. lbTitles.textColor = kAppGrayColor1;
  544. lbTitles.tag = Cell_PayType_Default_Tag + 1;
  545. [cell.contentView addSubview:lbTitles];
  546. [lbTitles mas_makeConstraints:^(MASConstraintMaker *make) {
  547. make.centerY.equalTo(cell.contentView);
  548. make.left.equalTo(imageView.mas_right).with.offset(20);
  549. }];
  550. UIImageView *imageSelect = [UIImageView new];
  551. imageSelect.tag = Cell_PayType_Default_Tag + 2;
  552. [cell.contentView addSubview:imageSelect];
  553. [imageSelect mas_makeConstraints:^(MASConstraintMaker *make) {
  554. make.size.mas_equalTo(CGSizeMake(30, 30));
  555. make.right.equalTo(cell.contentView.mas_right).with.offset( - 14);
  556. make.centerY.equalTo(cell.contentView);
  557. }];
  558. UIView *line = [UIView new];
  559. line.backgroundColor = kBackGroundColor;
  560. line.tag = Cell_PayType_Default_Tag + 3;
  561. [cell.contentView addSubview:line];
  562. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  563. make.left.equalTo(cell.contentView);
  564. make.right.equalTo(cell.contentView);
  565. make.bottom.equalTo(cell.contentView);
  566. make.height.offset(1);
  567. }];
  568. }
  569. return cell;
  570. }
  571. #pragma mark 只有苹果支付
  572. - (BOOL)hsOnlyIappay
  573. {
  574. PayTypeModel *model = [self.model.pay_list firstObject];
  575. if (self.model.pay_list.count == 1 && [model.class_name isEqualToString:@"Iappay"])
  576. {
  577. self.row = 0;
  578. return YES;
  579. }
  580. return NO;
  581. }
  582. - (BOOL)hsOtherPayMoney
  583. {
  584. return [self.model.show_other integerValue] == 1 ? YES : NO;
  585. }
  586. - (void)keyboardConfig
  587. {
  588. IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
  589. manager.enable = YES;
  590. manager.shouldResignOnTouchOutside = YES;
  591. manager.shouldToolbarUsesTextFieldTintColor = YES;
  592. manager.enableAutoToolbar = YES;
  593. }
  594. #pragma mark 支付请求
  595. - (void)payRequestNet:(int)indicate wxPayNet:(int)wxIndicate
  596. {
  597. NSString *payID = @"";
  598. for (PayTypeModel *model in self.model.pay_list)
  599. {
  600. if (model.isSelect)
  601. {
  602. payID = [NSString stringWithFormat:@"%ld",(long)model.payWayID];
  603. }
  604. }
  605. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  606. if (_is_vip)
  607. {
  608. [parmDict setObject:@"vip_pay" forKey:@"ctl"];
  609. }
  610. else
  611. {
  612. [parmDict setObject:@"pay" forKey:@"ctl"];
  613. }
  614. [parmDict setObject:@"pay" forKey:@"act"];
  615. [parmDict setObject:payID forKey:@"pay_id"];
  616. if (wxIndicate == 1 && indicate < self.ruleListArr.count)
  617. {
  618. PayMoneyModel *model = self.ruleListArr[indicate];
  619. [parmDict setObject:[NSString stringWithFormat:@"%ld",(long)model.payID] forKey:@"rule_id"];
  620. [parmDict setObject:[NSString stringWithFormat:@"%@",model.money] forKey:@"money"];
  621. }
  622. else
  623. {
  624. [parmDict setObject:self.money forKey:@"money"];
  625. }
  626. [SVProgressHUD show];
  627. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson){
  628. [SVProgressHUD dismiss];
  629. if ([responseJson toInt:@"status"]==1)
  630. {
  631. NSDictionary *payDic =[responseJson objectForKey:@"pay"];
  632. NSDictionary *sdkDic =[payDic objectForKey:@"sdk_code"];
  633. NSString *sdkType =[sdkDic objectForKey:@"pay_sdk_type"];
  634. // if ([sdkType isEqualToString:@"alipay"])
  635. // {
  636. // //支付宝支付
  637. // NSDictionary *configDic =[sdkDic objectForKey:@"config"];
  638. // Pay_Model * model2 =[Pay_Model mj_objectWithKeyValues: configDic];
  639. // NSString *orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",model2.order_spec, model2.sign, model2.sign_type];
  640. // [self alipay:orderString block:nil];
  641. // }
  642. // else if ([sdkType isEqualToString:@"wxpay"])
  643. // {
  644. // //微信支付
  645. // NSDictionary *configDic =[payDic objectForKey:@"config"];
  646. // NSDictionary *iosDic =[configDic objectForKey:@"ios"];
  647. // Mwxpay * wxmodel =[Mwxpay mj_objectWithKeyValues: iosDic];
  648. // PayReq* req = [[PayReq alloc] init];
  649. // req.openID = wxmodel.appid;
  650. // req.partnerId = wxmodel.partnerid;
  651. // req.prepayId = wxmodel.prepayid;
  652. // req.nonceStr = wxmodel.noncestr;
  653. // req.timeStamp = [wxmodel.timestamp intValue];
  654. // req.package = wxmodel.package;
  655. // req.sign = wxmodel.sign;
  656. //
  657. // [WXApi sendReq:req completion:^(BOOL success) {
  658. //
  659. // }];
  660. //
  661. // }
  662. if ([sdkType isEqualToString:@"JubaoWxsdk"] || [sdkType isEqualToString:@"JubaoAlisdk"])
  663. {
  664. // NSDictionary *configDic =[sdkDic objectForKey:@"config"];
  665. // _juBaoModel = [JuBaoModel mj_objectWithKeyValues: configDic];
  666. // BGParam *param = [[BGParam alloc] init];
  667. // // playerid:用户在第三方平台上的用户名
  668. // param.playerid = _juBaoModel.playerid;
  669. // // goodsname:购买商品名称
  670. // param.goodsname = _juBaoModel.goodsname;
  671. // // amount:购买商品价格,单位是元
  672. // param.amount = _juBaoModel.amount;
  673. // // payid:第三方平台上的订单号,请传真实订单号,方便后续对账,例子里采用随机数,
  674. // param.payid = _juBaoModel.payid;
  675. //
  676. // [BGInterface start:self withParams:param withDelegate:self];
  677. //[BGInterface start:self withParams:param withType:model.withType withDelegate:self];
  678. // 凡伟支付 end
  679. }
  680. else if ([sdkType isEqualToString:@"iappay"])
  681. {
  682. [SVProgressHUD showWithStatus:ASLocalizedString(@"正在提交iTunes Store,请等待...")];
  683. // 监听购买结果
  684. [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
  685. NSMutableDictionary *configDic = [NSMutableDictionary new];
  686. configDic = sdkDic[@"config"];
  687. self.pro_id = configDic[@"product_id"];
  688. //查询是否允许内付费
  689. if ([SKPaymentQueue canMakePayments])
  690. {
  691. // 执行下面提到的第5步:
  692. [self getProductInfowithprotectId:self.pro_id];
  693. }
  694. else
  695. {
  696. [FanweMessage alert:ASLocalizedString(@"您已禁止应用内付费购买商品")];
  697. }
  698. }
  699. else if ([payDic toInt:@"is_wap"] == 1)
  700. {
  701. if ([payDic toInt:@"is_without"] == 1) // 跳转外部浏览器
  702. {
  703. NSURL *url=[NSURL URLWithString:[payDic stringForKey:@"url"]];
  704. [[UIApplication sharedApplication] openURL:url];
  705. }
  706. else
  707. {
  708. BGMainWebViewController *vc = [BGMainWebViewController webControlerWithUrlStr:[payDic stringForKey:@"url"] isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES];
  709. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  710. }
  711. }
  712. else
  713. {
  714. NSLog(ASLocalizedString(@"错误"));
  715. }
  716. }
  717. else
  718. {
  719. NSLog(ASLocalizedString(@"请求失败"));
  720. }
  721. }FailureBlock:^(NSError *error){
  722. [SVProgressHUD dismiss];
  723. }];
  724. }
  725. - (void)returnCenterVC
  726. {
  727. [self.navigationController popViewControllerAnimated:YES];
  728. }
  729. #pragma marlk 支付宝支付
  730. //- (void)alipay:(NSString*)payinfo block:(void(^)(SResBase* resb))block
  731. //{
  732. // NSString *appScheme = AlipayScheme;
  733. //
  734. // [[AlipaySDK defaultService] payOrder:payinfo fromScheme:appScheme callback:^(NSDictionary *resultDic) {
  735. //
  736. // SResBase* retobj = nil;
  737. //
  738. // if ( resultDic )
  739. // {
  740. // if ( [[resultDic objectForKey:@"resultStatus"] intValue] == 9000 )
  741. // {
  742. // retobj = [[SResBase alloc]init];
  743. // retobj.msuccess = YES;
  744. // retobj.mmsg = ASLocalizedString(@"支付成功");
  745. // retobj.mcode = 1;
  746. // // block(retobj);
  747. // [FanweMessage alert:[NSString stringWithFormat:@"%@",retobj.mmsg]];
  748. //
  749. // [self reloadAcount];
  750. // }
  751. // else
  752. // {
  753. // retobj = [SResBase infoWithString: [resultDic objectForKey:@"memo" ]];
  754. // [FanweMessage alert:ASLocalizedString(@"支付失败")];
  755. // }
  756. // }
  757. // else
  758. // {
  759. // retobj = [SResBase infoWithString: ASLocalizedString(@"支付出现异常")];
  760. // [FanweMessage alert:ASLocalizedString(@"支付异常")];
  761. // }
  762. //
  763. // }];
  764. //}
  765. #pragma mark -- 苹果内购服务,下面的ProductId应该是事先在itunesConnect中添加好的,已存在的付费项目。否则查询会失败。
  766. - (void)getProductInfowithprotectId:(NSString *)proId
  767. {
  768. //这里填你的产品id,根据创建的名字
  769. //ProductIdofvip
  770. //ProductId
  771. NSMutableArray *proArr = [NSMutableArray new];
  772. [proArr addObject:proId];
  773. NSSet * set = [NSSet setWithArray:proArr];
  774. self.request = [[SKProductsRequest alloc] initWithProductIdentifiers:set];
  775. self.request.delegate = self;
  776. [self.request start];
  777. NSLog(@"%@",set);
  778. NSLog(ASLocalizedString(@"请求开始请等待..."));
  779. }
  780. #pragma mark - 以上查询的回调函数,以上查询的回调函数
  781. - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
  782. {
  783. NSArray *myProduct = response.products;
  784. if (myProduct.count == 0)
  785. {
  786. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"无法获取产品信息,购买失败。")];
  787. [SVProgressHUD dismiss];
  788. return;
  789. }
  790. NSLog(@"productID:%@", response.invalidProductIdentifiers);
  791. NSLog(ASLocalizedString(@"产品付费数量:%lu"),(unsigned long)[myProduct count]);
  792. SKPayment * payment = [SKPayment paymentWithProduct:myProduct[0]];
  793. [[SKPaymentQueue defaultQueue] addPayment:payment];
  794. }
  795. #pragma mark - others SKPaymentTransactionObserver
  796. - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
  797. {
  798. for (SKPaymentTransaction *transaction in transactions)
  799. {
  800. switch (transaction.transactionState)
  801. {
  802. case SKPaymentTransactionStatePurchased://交易完成
  803. NSLog(@"transactionIdentifier = %@", transaction.transactionIdentifier);
  804. [SVProgressHUD dismiss];
  805. [self completeTransaction:transaction];
  806. //[queue finishTransaction:transaction];
  807. break;
  808. case SKPaymentTransactionStateFailed://交易失败
  809. NSLog(ASLocalizedString(@"交易失败"));
  810. [self failedTransaction:transaction];
  811. //[queue finishTransaction:transaction];
  812. break;
  813. case SKPaymentTransactionStateRestored://恢复已购买商品
  814. NSLog(ASLocalizedString(@"恢复已购买商品"));
  815. [self restoreTransaction:transaction];
  816. [queue finishTransaction:transaction];
  817. break;
  818. case SKPaymentTransactionStatePurchasing://商品添加进列表
  819. NSLog(ASLocalizedString(@"商品添加进列表"));
  820. break;
  821. default:
  822. break;
  823. }
  824. }
  825. }
  826. - (void)completeTransaction:(SKPaymentTransaction *)transaction
  827. {
  828. // Your application should implement these two methods.
  829. NSLog(ASLocalizedString(@"---------进入了这里"));
  830. // NSString * productIdentifier = transaction.payment.productIdentifier;
  831. NSString * productIdentifier = [[NSString alloc] initWithData:transaction.transactionReceipt encoding:NSUTF8StringEncoding];
  832. NSData *data = [productIdentifier dataUsingEncoding:NSUTF8StringEncoding];
  833. NSString *base64String = [data base64EncodedStringWithOptions:0];
  834. if ([productIdentifier length] > 0) {
  835. // 向自己的服务器验证购买凭证
  836. [self shoppingValidation:base64String];
  837. }
  838. // Remove the transaction from the payment queue.
  839. [SVProgressHUD dismiss];
  840. [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  841. }
  842. #pragma mark -- 向自己的服务器验证购买凭证
  843. - (void)shoppingValidation : (NSString *)base64Str
  844. {
  845. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0];
  846. if (_is_vip)
  847. {
  848. [dict setObject:@"vip_pay" forKey:@"ctl"];
  849. }
  850. else
  851. {
  852. [dict setObject:@"pay" forKey:@"ctl"];
  853. }
  854. [dict setObject:@"iappay" forKey:@"act"];
  855. NSString *userid = [IMAPlatform sharedInstance].host.imUserId;
  856. [dict setObject:userid forKey:@"user_id"];
  857. [dict setObject:base64Str forKey:@"receipt-data"];
  858. [self.httpsManager POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  859. [self reloadAcount];
  860. // [FanweMessage alert:ASLocalizedString(@"充值成功")];
  861. } FailureBlock:^(NSError *error) {
  862. }];
  863. }
  864. - (void)failedTransaction:(SKPaymentTransaction *)transaction
  865. {
  866. [SVProgressHUD dismiss];
  867. if(transaction.error.code != SKErrorPaymentCancelled)
  868. {
  869. NSLog(ASLocalizedString(@"购买失败"));
  870. }
  871. else
  872. {
  873. NSLog(ASLocalizedString(@"用户取消交易"));
  874. //[FanweMessage alert:ASLocalizedString(@"您已经取消交易")];
  875. }
  876. [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  877. }
  878. - (void)restoreTransaction:(SKPaymentTransaction *)transaction
  879. {
  880. // 对于已购商品,处理恢复购买的逻辑
  881. //[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  882. [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
  883. }
  884. // 支付结果的通知:
  885. - (void)receiveResult:(NSString*)payid result:(BOOL)success message:(NSString*)message
  886. {
  887. if ( success == YES )
  888. {
  889. [self reloadAcount];
  890. [FanweMessage alert:ASLocalizedString(@"支付成功")];
  891. }
  892. else
  893. {
  894. [FanweMessage alert:ASLocalizedString(@"支付失败")];
  895. }
  896. }
  897. - (void)receiveChannelTypes:(NSArray<NSNumber *>*)types
  898. {
  899. // [BGInterface selectChannel:_juBaoModel.withType];
  900. }
  901. - (BOOL)shouldAutorotate
  902. {
  903. return YES;
  904. }
  905. - (void)didReceiveMemoryWarning
  906. {
  907. [super didReceiveMemoryWarning];
  908. }
  909. - (void)dealloc
  910. {
  911. NSLog(ASLocalizedString(@"释放充值"));
  912. if (self.request)
  913. {
  914. [self.request cancel];
  915. }
  916. [[NSNotificationCenter defaultCenter] removeObserver:self];
  917. [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
  918. }
  919. - (UICollectionView *)collectionView{
  920. if (!_collectionView) {
  921. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  922. _collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
  923. _collectionView.delegate = self;
  924. _collectionView.dataSource = self;
  925. _collectionView.backgroundColor = kWhiteColor;
  926. [_collectionView registerNib:[UINib nibWithNibName:@"AccountItemCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"AccountItemCell"];
  927. }
  928. return _collectionView;
  929. }
  930. #pragma mark - UICollectionViewDelegate UICollectionViewDataSource
  931. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  932. return 1;
  933. }
  934. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  935. return self.ruleListArr.count;
  936. }
  937. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  938. AccountItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AccountItemCell" forIndexPath:indexPath];
  939. if (indexPath.item < self.ruleListArr.count) {
  940. PayMoneyModel *model = self.ruleListArr[indexPath.item];
  941. [cell setModel:model];
  942. return cell;
  943. }
  944. return nil;
  945. }
  946. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  947. return CGSizeMake((kScreenW - 40 ) / 3 - 1, 80);
  948. }
  949. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  950. return UIEdgeInsetsMake(10, 10, 10, 10);
  951. }
  952. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  953. if (!self.selectAgreeBtn.selected) {
  954. [FanweMessage alertHUD:ASLocalizedString(@"请先勾选是否同意用户充值免责协议")];
  955. return;
  956. }
  957. AccountItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AccountItemCell" forIndexPath:indexPath];
  958. cell.selected = !cell.isSelected;
  959. if (self.hsClick)
  960. {
  961. self.hsClick = NO;
  962. [self payRequestNet:(int)indexPath.row wxPayNet:1];
  963. __weak AccountRechargeVC *weakSelf = self;
  964. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  965. weakSelf.hsClick = YES;
  966. });
  967. }
  968. }
  969. -(void)clickAgreenBtn:(UIButton *)sender{
  970. NSString *tmpUrlStr = [GlobalVariables sharedInstance].appModel.h5_url.url_recharge_agreement;
  971. BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:tmpUrlStr isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
  972. [[AppDelegate sharedAppDelegate] pushViewController:tmpController animated:YES];
  973. }
  974. -(void)clickSelectAgreenBtn:(UIButton *)sender{
  975. sender.selected = !sender.selected;
  976. }
  977. -(QMUIButton *)agreeBtn{
  978. if (!_agreeBtn) {
  979. NSString *firstStr = ASLocalizedString(@"同意");
  980. NSString *secondStr = ASLocalizedString(@" 用户充值免责协议");
  981. NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",firstStr,secondStr]];
  982. [attributeString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0, firstStr.length)];
  983. [attributeString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#DE88FF"] range:NSMakeRange(firstStr.length, secondStr.length)];
  984. _agreeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  985. _agreeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  986. [_agreeBtn setAttributedTitle:attributeString forState:UIControlStateNormal];
  987. [_agreeBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  988. _agreeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  989. [_agreeBtn addTarget:self action:@selector(clickAgreenBtn:) forControlEvents:UIControlEventTouchUpInside];
  990. }
  991. return _agreeBtn;
  992. }
  993. -(QMUIButton *)selectAgreeBtn{
  994. if (!_selectAgreeBtn) {
  995. _selectAgreeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  996. _selectAgreeBtn.selected = YES;
  997. [_selectAgreeBtn setImage:[UIImage imageNamed:@"com_radio_selected_1"] forState:UIControlStateNormal];
  998. [_selectAgreeBtn setImage:[UIImage imageNamed:@"com_radio_selected_2"] forState:UIControlStateSelected];
  999. [_selectAgreeBtn addTarget:self action:@selector(clickSelectAgreenBtn:) forControlEvents:UIControlEventTouchUpInside];
  1000. }
  1001. return _selectAgreeBtn;
  1002. }
  1003. @end