123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // YXMemberInfoViewController.m
- // Temperature
- //
- // Created by TC on 2025/2/16.
- //
- #import "YXMemberInfoViewController.h"
- #import <SDWebImage/SDWebImage.h>
- #import "RDSRootControl.h"
- @interface YXMemberInfoViewController ()
- @property (weak, nonatomic) IBOutlet UIImageView *picImgView;
- @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
- @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
- @property (weak, nonatomic) IBOutlet UILabel *markLabel;
- @end
- @implementation YXMemberInfoViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"成员信息";
-
- [self createFooterView];
-
- self.picImgView.layer.cornerRadius = 27.5;
- self.picImgView.clipsToBounds = YES;
- [self.picImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", TheApiHelper.baseUrlHeadImg, self.model.photo]] placeholderImage:[UIImage imageNamed:@"my_pic"]];
- self.nameLabel.text = self.model.user_name;
-
- NSString *timeStr = @"";
- if (_isCreator) {
- timeStr = [NSString stringWithFormat:@"%@创建家庭",self.model.created_at];
- }else{
- timeStr = [NSString stringWithFormat:@"%@加入家庭",self.model.created_at];
- }
- self.timeLabel.text = timeStr;
-
- self.markLabel.text = self.model.remark.length == 0 ? @"未设置" : self.model.remark;
- self.markLabel.userInteractionEnabled = YES;
-
- UITapGestureRecognizer *addTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(markTapAction)];
- [self.markLabel addGestureRecognizer:addTap];
-
- }
- -(void)createFooterView
- {
- UIView *footerView = [[UIView alloc]init];
- footerView.backgroundColor = [UIColor clearColor];
- [self.view addSubview:footerView];
- [footerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@100);
- make.right.equalTo(@0);
- make.left.equalTo(@0);
- make.bottom.equalTo(@0);
- }];
-
- UIButton *deletBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [deletBtn setTitle:@"删除成员" forState:UIControlStateNormal];
- [deletBtn addTarget:self action:@selector(deletBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- [deletBtn setTitleColor:[UIColor colorWithHexString:@"#E50023"] forState:UIControlStateNormal];
- deletBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
- deletBtn.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
- [footerView addSubview:deletBtn];
- [deletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@45);
- make.left.equalTo(@15);
- make.right.equalTo(@-15);
- make.top.equalTo(@20);
- }];
- deletBtn.layer.cornerRadius = 22.5;
-
- }
- -(void)markTapAction
- {
- [self alertWithText:@"备注"];
- }
- -(void)alertWithText:(NSString *)text
- {
- RDS_WEAKSELF(weakSelf)
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:text message:nil preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"完成" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- UITextField *textFeild = [alertController.textFields objectAtIndex:0];
- NSLog(@"%@",textFeild.text);
- if (textFeild.text.length > 0) {
- self.markLabel.text = textFeild.text;
- [self changeRemark:textFeild.text];
- }
- }];
- [alertController addAction:sureAction];
-
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alertController addAction:cancelAction];
-
- [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.text = weakSelf.model.remark;
- textField.placeholder = [NSString stringWithFormat:@"请输入%@",text];
- }];
-
- [self presentViewController:alertController animated:YES completion:nil];
- }
- -(void)deletBtnAction:(UIButton *)btn
- {
- RDS_WEAKSELF(weakSelf)
- [RDSDemoApiHelper rds_delMemberWithHomeId:self.model.home_id user_id:self.model.user_id success:^(id responseObject) {
- if ([responseObject[@"code"] intValue] == 9999) {
- [RDSRootControl shareControl].isLoginSuccess = NO;
- TheDataManager.token = @"";
- }
-
- if ([responseObject[@"code"] intValue] == 0) {
- [RDSHudShower showCenterToast:@"删除成功"];
- [weakSelf popViewControllerAnimated:YES];
- } else{
- [RDSHudShower showErrorWithStatus:responseObject[@"message"]];
- }
-
- } failure:^(NSError *error) {
- [RDSHudShower showBottomToast:@"连接服务器失败"];
- }];
- }
- -(void)changeRemark:(NSString *)remarkStr
- {
- RDS_WEAKSELF(weakSelf)
- [RDSDemoApiHelper rds_putMemberWithId:self.model.record_id remark:remarkStr success:^(id responseObject) {
- if ([responseObject[@"code"] intValue] == 0) {
- [RDSHudShower showCenterToast:@"设置成功"];
- } else{
- [RDSHudShower showErrorWithStatus:responseObject[@"message"]];
- }
- } failure:^(NSError *error) {
- [RDSHudShower showBottomToast:@"连接服务器失败"];
- }];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|