1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // HSQAccountHeader.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/6/8.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "HSQAccountHeader.h"
- @interface HSQAccountHeader(){
- UILabel *_blanceLabel;
- NSString *_blance;
- BOOL isLinkAliPay;
- }
- @end
- @implementation HSQAccountHeader
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor changeColor];
- [self initSubViews];
- [self request];
- }
- return self;
- }
- - (void)initSubViews {
- // UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(25, 10, 200, 20)];
- // title.text = @"账户余额:";
- // title.font = [UIFont systemFontOfSize:14];
- // title.textColor = [UIColor whiteColor];
- // [self addSubview:title];
-
- _blanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, FITSIZE(10), SCREEN_WIDTH-50, FITSIZE(40))];
- _blanceLabel.textColor = [UIColor whiteColor];
- _blanceLabel.textAlignment=NSTextAlignmentCenter;
- _blanceLabel.font = [UIFont boldSystemFontOfSize:48];
- _blanceLabel.text = @"--.--";
- [self addSubview:_blanceLabel];
-
- UIButton *money = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-42, FITSIZE(65), 84, FITSIZE(22))];
- [money setTitle:@"提现" forState:UIControlStateNormal];
- money.layer.cornerRadius=2;
- money.layer.masksToBounds=YES;
- money.layer.borderColor=[UIColor whiteColor].CGColor;
- money.layer.masksToBounds=YES;
- money.layer.borderWidth=0.5;
-
- [money setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- money.titleLabel.font = [UIFont systemFontOfSize:10];
- [self addSubview:money];
- [money addTarget:self action:@selector(moneyAction) forControlEvents:UIControlEventTouchUpInside];
- }
- - (void)moneyAction {
- if (self.moneyBackBlcok) {
- self.moneyBackBlcok(_blance,isLinkAliPay);
- }
- }
- - (void)reloadData {
- [self request];
- }
- - (void)request{
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/accountPrice",BaseURL];
- [HSQHttp post:url params:nil success:^(id json) {
- if (json[@"data"]) {
- _blance = [NSString stringWithFormat:@"%@",json[@"data"][@"notEnd"]];
- NSString *discount_price = [NSString stringWithFormat:@"¥%.2f",_blance.floatValue];
- NSMutableAttributedString *disAttr = [[NSMutableAttributedString alloc] initWithString:discount_price];
- [disAttr yy_setFont:[UIFont systemFontOfSize:18] range:NSMakeRange(0, 1)];
- [disAttr yy_setFont:[UIFont systemFontOfSize:48] range:NSMakeRange(1, discount_price.length-1)];
- _blanceLabel.attributedText =disAttr;
- if ([json[@"data"][@"accountFlag"] isEqual:@2]) {
- isLinkAliPay = YES;
- }else {
- isLinkAliPay = NO;
- }
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- @end
|