CardAmplificationViewController.m 3.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
//
//  CardAmplificationViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/10/20.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "CardAmplificationViewController.h"

11
@interface CardAmplificationViewController ()<MDScratchImageViewDelegate>
12 13 14 15 16 17 18

@end

@implementation CardAmplificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
19 20
    
    [self addMaskView];
21 22
}

23 24
#pragma mark - 添加遮罩层
- (void)addMaskView
25
{
26 27 28 29 30 31 32 33
    _maskView = [[MDScratchImageView alloc]init];
    [self.view addSubview:_maskView];
    [_maskView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cardPasswordLabel);
        make.top.equalTo(self.cardPasswordLabel);
        make.size.equalTo(self.cardPasswordLabel);
    }];
    _maskView.delegate = self;
34
    [_maskView setImage:TCImage(@"mask") radius:20];
35 36
}

37 38
- (void)viewWillAppear:(BOOL)animated
{
曹云霄's avatar
曹云霄 committed
39
    [super viewWillAppear:animated];
40 41
    self.view.superview.layer.cornerRadius = 15;
}
42 43 44 45 46 47 48 49 50 51

#pragma mark - 取消
- (IBAction)cancelButtonClickAction:(UIButton *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - 确认
- (IBAction)sureButtonClickAction:(UIButton *)sender {
    
52 53
    WS(weakSelf);
    [self CreateMBProgressHUDLoding];
54
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(RECEIVEJDECARD),self.cardModel.cardNumber] WithRequestType:ZERO WithParameter:nil WithReturnValueBlock:^(id returnValue) {
55 56 57 58
        
        [weakSelf RemoveMBProgressHUDLoding];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            if (weakSelf.refreshJDCardList) {
59
                weakSelf.refreshJDCardList(YES,weakSelf.cardModel.cardNumber);
60 61 62
            }
        }else
        {
63
            if (weakSelf.refreshJDCardList) {
64
                weakSelf.refreshJDCardList(NO,weakSelf.cardModel.cardNumber);
65
            }
66 67 68 69 70 71 72 73 74 75
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:NETWORK];
    } WithFailureBlock:^(NSError *error) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:error.localizedDescription];
    }];
    [self dismissViewControllerAnimated:YES completion:nil];
76 77
}

78 79 80 81 82 83 84
- (void)setCardModel:(TOJingdongEcardEntity *)cardModel
{
    _cardModel = cardModel;
    self.backgroundImageView.image = [BaseViewController getCorrespondingPictures:_cardModel.denomation];
    self.cardNumberLabel.text = _cardModel.cardNumber;
    self.cardPasswordLabel.text = _cardModel.cardPassword;
    //是否已查看
曹云霄's avatar
曹云霄 committed
85
    if ([_cardModel.state isEqualToString:LOOKED]) {
86 87 88 89
        [self.maskView removeFromSuperview];
    }
    self.amountLabel.text = [NSString stringWithFormat:@"¥%ld",_cardModel.denomation];
}
90

91 92 93 94 95
#pragma mark - <MDScratchImageViewDelegate>
- (void)mdScratchImageView:(MDScratchImageView *)scratchImageView didChangeMaskingProgress:(CGFloat)maskingProgress
{
    NSLog(@"%f",maskingProgress);
}
96 97 98 99 100 101 102 103 104

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end