You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.0 KiB
111 lines
4.0 KiB
1 year ago
|
//
|
||
|
// RedFlowerSetVC.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by Apple on 2019/2/25.
|
||
|
// Copyright © 2019年 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "RedFlowerSetVC.h"
|
||
|
|
||
|
@interface RedFlowerSetVC ()
|
||
|
@property(nonatomic, strong) UILabel *showLabel;
|
||
|
@property(nonatomic, strong) UIImageView *showImage;
|
||
|
@property(nonatomic, strong) UIButton *addBtn;
|
||
|
@property(nonatomic, strong) UIButton *reduceBtn;
|
||
|
@property(nonatomic, strong) UIButton *OKBtn;
|
||
|
@property(nonatomic, strong) UILabel *sumLb;
|
||
|
@end
|
||
|
|
||
|
@implementation RedFlowerSetVC
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
self.title = @"爱心奖励";
|
||
|
// Do any additional setup after loading the view.
|
||
|
[self setupViews];
|
||
|
|
||
|
|
||
|
}
|
||
|
- (void)setupViews {
|
||
|
self.view.backgroundColor = [UIColor whiteColor];
|
||
|
|
||
|
_showImage = [[UIImageView alloc] initWithFrame:CGRectMake((ScreenWidth-150)/2, 70, 150, 121)];
|
||
|
_showImage.image = [UIImage imageNamed:@"icon_love_to_reward_bg"];
|
||
|
[self.view addSubview:_showImage];
|
||
|
_showLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _showImage.y+_showImage.height+28, ScreenWidth, 21)];
|
||
|
_showLabel.textAlignment = NSTextAlignmentCenter;
|
||
|
_showLabel.font = [UIFont systemFontOfSize:16];
|
||
|
_showLabel.text = @"宝贝很棒,给TA一点奖励吧!";
|
||
|
[self.view addSubview: _showLabel];
|
||
|
|
||
|
|
||
|
|
||
|
_sumLb = [[UILabel alloc] initWithFrame:CGRectMake(0, _showLabel.y+_showLabel.height + 100, ScreenWidth, 60)];
|
||
|
|
||
|
_sumLb.font = [UIFont boldSystemFontOfSize:70];
|
||
|
_sumLb.textAlignment = NSTextAlignmentCenter;
|
||
|
_sumLb.textColor = mainColor;
|
||
|
_sumLb.text = [NSString stringWithFormat:@"%d",[cUser.cDevice.opFlower intValue]];
|
||
|
[self.view addSubview:_sumLb];
|
||
|
|
||
|
_reduceBtn = [[UIButton alloc] initWithFrame:CGRectMake(57, 0, 48, 48)];
|
||
|
[_reduceBtn setImage:[UIImage imageNamed:@"icon_reduction_reward"] forState:UIControlStateNormal];
|
||
|
[_reduceBtn addTarget:self action:@selector(reduceBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.view addSubview:_reduceBtn];
|
||
|
_addBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - 57 - 48, 0, 48, 48)];
|
||
|
[_addBtn addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[_addBtn setImage:[UIImage imageNamed:@"icon_add_reward"] forState:UIControlStateNormal];
|
||
|
[self.view addSubview:_addBtn];
|
||
|
_reduceBtn.centerY = _sumLb.centerY;
|
||
|
_addBtn.centerY = _sumLb.centerY;
|
||
|
|
||
|
_OKBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth-14*2, 44)];
|
||
|
[self.view addSubview:_OKBtn];
|
||
|
[_OKBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.bottom.mas_offset(-22);
|
||
|
make.left.mas_offset(14);
|
||
|
make.width.mas_offset(ScreenWidth-14*2);
|
||
|
make.height.mas_offset(44);
|
||
|
|
||
|
}];
|
||
|
[_OKBtn addTarget:self action:@selector(clickOKAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[_OKBtn setTitle:@"奖励" forState:UIControlStateNormal];
|
||
|
[_OKBtn setTitleColor:[UIColor whiteColor] forState:0];
|
||
|
[_OKBtn setBackgroundColor:mainColor];
|
||
|
[_OKBtn layerCornerRadius:3.0 masksToBounds:YES];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
- (void)reduceBtnClick {
|
||
|
int index = _sumLb.text.intValue - 1;
|
||
|
if (index < 0) return;
|
||
|
_sumLb.text = [NSString stringWithFormat:@"%d",index];
|
||
|
cUser.cDevice.opFlower = [NSNumber numberWithInt:index];
|
||
|
}
|
||
|
- (void)addBtnClick {
|
||
|
int index = _sumLb.text.intValue + 1;
|
||
|
if (index > 99) {
|
||
|
[SVProgressHUD showErrorWithStatus:@"最大值不能超过99"];
|
||
|
return;
|
||
|
}
|
||
|
if (index < 0) return;
|
||
|
_sumLb.text = [NSString stringWithFormat:@"%d",index];
|
||
|
cUser.cDevice.opFlower = [NSNumber numberWithInt:index];
|
||
|
}
|
||
|
-(void)clickOKAction:(UIButton*)sender{
|
||
|
//调用
|
||
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
||
|
[parameters setValue:cUser.cDevice.opFlower forKey:@"opFlower"];
|
||
|
[cUser.cDevice editOperationDeviceInfoWithParameters:parameters success:^(id responseObject) {
|
||
|
[SVProgressHUD showSuccessWithStatus:@"设置奖励成功"];
|
||
|
} failure:^(id faiObject) {
|
||
|
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
@end
|