//
//  RDSAddMemberVC.m
//  Temperature
//
//  Created by RD on 2023/2/2.
//

#import "RDSAddMemberVC.h"

@interface RDSAddMemberVC ()
@property (weak, nonatomic) IBOutlet UITextField *phoneTF;


@end

@implementation RDSAddMemberVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"邀请家庭成员";
}


- (IBAction)onSureBtnClick:(id)sender {
    
    if(kNULLString(_phoneTF.text)){
        [RDSHudShower showBottomToast:@"输入手机号"];
        return;
    }
    
    RDS_WEAKSELF(weakSelf)
    [RDSDemoApiHelper rds_addMemberWithHomeId:_homeId phone:_phoneTF.text success:^(id responseObject) {
        if ([responseObject[@"code"] intValue] == 0) {
            [RDSHudShower showCenterToast:@"邀请成功"];
            [weakSelf popViewControllerAnimated:YES];
        } else{
            [RDSHudShower showErrorWithStatus:responseObject[@"message"]];
        }
    } failure:^(NSError *error) {
        [RDSHudShower showBottomToast:@"连接服务器失败"];
    }];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

@end
