Commit d6a1be2664e0a63369ea3281b0188c3e16fe72f6

Authored by 梁星国
1 parent b80a53b3

提交原版

Showing 29 changed files with 4628 additions and 0 deletions

Too many changes to show.

To preserve performance only 29 of 84 files are displayed.

CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxNoticeTipView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxNoticeTipView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/22.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBoxNoticeTipView : UIView
  14 +
  15 +@property (strong, nonatomic) UILabel *contentL;
  16 +
  17 +@property (strong, nonatomic) UIButton *cancelBtn;
  18 +
  19 +
  20 +@property (strong, nonatomic) NSDictionary *dic;
  21 +
  22 +
  23 ++ (CNLiveBoxNoticeTipView *)showAlertAddedTo:(UIView *)view dic:(NSDictionary *)dic;
  24 +
  25 +- (void)showAlerView;
  26 +- (void)hiddenAlerView;
  27 +
  28 +@end
  29 +
  30 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxNoticeTipView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxNoticeTipView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/22.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxNoticeTipView.h"
  10 +
  11 +@implementation CNLiveBoxNoticeTipView
  12 +
  13 ++ (CNLiveBoxNoticeTipView *)showAlertAddedTo:(UIView *)view dic:(NSDictionary *)dic{
  14 +
  15 + CNLiveBoxNoticeTipView *noticeView = [[CNLiveBoxNoticeTipView alloc] initWithFrame:CGRectMake(10, KScreenHeight, KScreenWidth - 20, 45)];
  16 + [view addSubview:noticeView];
  17 + noticeView.dic = dic;
  18 + if ([noticeView.dic containsObjectForKey:@"text"]) {
  19 + noticeView.contentL.text = [NSString stringWithFormat:@"%@",noticeView.dic[@"text"]];
  20 + }
  21 +
  22 + return noticeView;
  23 +}
  24 +
  25 +- (instancetype)initWithFrame:(CGRect)frame
  26 +{
  27 + self = [super initWithFrame:frame];
  28 + if (self) {
  29 + self.backgroundColor = RGBACOLOR(51, 51, 51,0.7);
  30 + self.layer.masksToBounds = YES;
  31 + self.layer.cornerRadius = 7.5;
  32 + [self setupUI];
  33 + [self layoutUI];
  34 + [self showAlerView];
  35 + __weak typeof(self) weakSelf = self;
  36 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  37 + [weakSelf hiddenAlerView];
  38 + });
  39 + }
  40 + return self;
  41 +}
  42 +
  43 +- (void)showAlerView {
  44 +
  45 +
  46 + [UIView animateWithDuration:0.3 animations:^{
  47 + self.frame = CGRectMake(10, KScreenHeight - 55, KScreenWidth - 20, 45);
  48 + }];
  49 +
  50 +
  51 +}
  52 +
  53 +- (void)hiddenAlerView {
  54 +
  55 + [UIView animateWithDuration:0.3 animations:^{
  56 + self.alpha = 0.3;
  57 + if (self) {
  58 + [self removeFromSuperview];
  59 + }
  60 +
  61 + }];
  62 +}
  63 +
  64 +- (void)setupUI {
  65 + [self addSubview:self.contentL];
  66 + [self addSubview:self.cancelBtn];
  67 +}
  68 +
  69 +- (void)layoutUI {
  70 +
  71 + self.cancelBtn.frame = CGRectMake(KScreenWidth - 20 - 44, 0, 44, 44);
  72 +
  73 + self.contentL.frame = CGRectMake(10, 10, self.cancelBtn.left - 20, 24);
  74 +}
  75 +
  76 +#pragma mark - 事件实现
  77 +
  78 +- (void)checkBtnAction:(UIButton *)btn {
  79 + [self hiddenAlerView];
  80 +
  81 +
  82 +}
  83 +
  84 +
  85 +#pragma mark - 属性
  86 +
  87 +- (UILabel *)contentL {
  88 + if (!_contentL) {
  89 + _contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  90 + _contentL.text = @"您被好友解除绑定亲情关系";
  91 + _contentL.textColor = [UIColor whiteColor];
  92 + _contentL.font = [UIFont systemFontOfSize:15];
  93 +
  94 + }
  95 + return _contentL;
  96 +}
  97 +
  98 +- (UIButton *)cancelBtn {
  99 + if (!_cancelBtn) {
  100 + _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  101 + [_cancelBtn setImage:[UIImage imageNamed:@"device_header_cancle"] forState:UIControlStateNormal];
  102 + _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  103 + [_cancelBtn addTarget:self action:@selector(checkBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  104 + }
  105 + return _cancelBtn;
  106 +
  107 +}
  108 +
  109 +
  110 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxNoticeView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxNoticeView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/18.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBoxNoticeView : UIView
  14 +
  15 +
  16 +@property (strong, nonatomic) UILabel *contentL;
  17 +
  18 +@property (strong, nonatomic) UIButton *ignoreBtn;
  19 +
  20 +@property (strong, nonatomic) UIButton *checkBtn;
  21 +
  22 +@property (strong, nonatomic) UIView *lineV;
  23 +
  24 +@property (strong, nonatomic) NSDictionary *dic;
  25 +
  26 +
  27 ++ (CNLiveBoxNoticeView *)showAlertAddedTo:(UIView *)view dic:(NSDictionary *)dic;
  28 +
  29 +- (void)showAlerView;
  30 +- (void)hiddenAlerView;
  31 +
  32 +/*** 切换 ***/
  33 +@property (nonatomic, copy) void(^clickCheckBtnBlock)(CNLiveBoxNoticeView *view,UIButton *checkBtn);
  34 +
  35 +@end
  36 +
  37 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxNoticeView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxNoticeView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/18.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxNoticeView.h"
  10 +#import "CNBoxUserManagerController.h"
  11 +
  12 +@interface CNLiveBoxNoticeView ()
  13 +
  14 +@end
  15 +
  16 +
  17 +@implementation CNLiveBoxNoticeView
  18 +
  19 ++ (CNLiveBoxNoticeView *)showAlertAddedTo:(UIView *)view dic:(NSDictionary *)dic{
  20 +
  21 + CNLiveBoxNoticeView *noticeView = [[CNLiveBoxNoticeView alloc] initWithFrame:CGRectMake(10, KScreenHeight, KScreenWidth - 20, 45)];
  22 + [view addSubview:noticeView];
  23 + noticeView.dic = dic;
  24 + if ([noticeView.dic containsObjectForKey:@"text"]) {
  25 + noticeView.contentL.text = [NSString stringWithFormat:@"%@",noticeView.dic[@"text"]];
  26 + }
  27 +
  28 + return noticeView;
  29 +}
  30 +
  31 +- (instancetype)initWithFrame:(CGRect)frame
  32 +{
  33 + self = [super initWithFrame:frame];
  34 + if (self) {
  35 + self.backgroundColor = RGBACOLOR(51, 51, 51,0.7);
  36 + self.layer.masksToBounds = YES;
  37 + self.layer.cornerRadius = 7.5;
  38 + [self setupUI];
  39 + [self layoutUI];
  40 + [self showAlerView];
  41 + __weak typeof(self) weakSelf = self;
  42 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  43 + [weakSelf hiddenAlerView];
  44 + });
  45 + }
  46 + return self;
  47 +}
  48 +
  49 +- (void)showAlerView {
  50 +
  51 +
  52 + [UIView animateWithDuration:0.3 animations:^{
  53 + self.frame = CGRectMake(10, KScreenHeight - 55, KScreenWidth - 20, 45);
  54 + }];
  55 +
  56 +
  57 +}
  58 +
  59 +- (void)hiddenAlerView {
  60 +
  61 + [UIView animateWithDuration:0.3 animations:^{
  62 + self.alpha = 0.3;
  63 + if (self) {
  64 + [self removeFromSuperview];
  65 + }
  66 +
  67 + }];
  68 +}
  69 +
  70 +- (void)setupUI {
  71 + [self addSubview:self.contentL];
  72 + [self addSubview:self.ignoreBtn];
  73 + [self addSubview:self.lineV];
  74 + [self addSubview:self.checkBtn];
  75 +}
  76 +
  77 +- (void)layoutUI {
  78 +
  79 + self.checkBtn.frame = CGRectMake(KScreenWidth - 20 - 44, 0, 44, 44);
  80 +
  81 + self.lineV.frame = CGRectMake(self.checkBtn.left - 1, 10, 1, 25);
  82 + self.ignoreBtn.frame = CGRectMake(self.lineV.left - 44, 0, 44, 44);
  83 + self.contentL.frame = CGRectMake(10, 10, self.ignoreBtn.left - 20, 24);
  84 +}
  85 +
  86 +#pragma mark - 事件实现
  87 +- (void)ignoreBtnAction:(UIButton *)btn {
  88 + [self hiddenAlerView];
  89 +}
  90 +
  91 +- (void)checkBtnAction:(UIButton *)btn {
  92 + [self hiddenAlerView];
  93 + NSLog(@"去查看");
  94 + if (!self.dic) {
  95 + [QMUITips showWithText:@"参数不全" inView:AppKeyWindow hideAfterDelay:0.5];
  96 + return;
  97 + }
  98 +
  99 +// if ([self.dic containsObjectForKey:@"familyId"]) {
  100 +// self.contentL.text = [NSString stringWithFormat:@"%@",self.dic[@"familyId"]];
  101 +// }
  102 +
  103 + if (self.clickCheckBtnBlock) {
  104 + self.clickCheckBtnBlock(self, btn);
  105 + }
  106 +
  107 +
  108 +}
  109 +
  110 +
  111 +#pragma mark - 属性
  112 +
  113 +- (UILabel *)contentL {
  114 + if (!_contentL) {
  115 + _contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  116 + _contentL.text = @"您被好友绑定成为了亲情关系";
  117 + _contentL.textColor = [UIColor whiteColor];
  118 + _contentL.font = [UIFont systemFontOfSize:15];
  119 +
  120 + }
  121 + return _contentL;
  122 +}
  123 +
  124 +- (UIView *)lineV {
  125 + if (!_lineV) {
  126 + _lineV = [[UIView alloc]initWithFrame:CGRectZero];
  127 + [_lineV setBackgroundColor:[UIColor whiteColor]];
  128 + }
  129 + return _lineV;
  130 +
  131 +}
  132 +
  133 +- (UIButton *)ignoreBtn {
  134 + if (!_ignoreBtn) {
  135 + _ignoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  136 + [_ignoreBtn setTitle:@"忽略" forState:UIControlStateNormal];
  137 + _ignoreBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  138 + [_ignoreBtn addTarget:self action:@selector(ignoreBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  139 + }
  140 + return _ignoreBtn;
  141 +
  142 +}
  143 +
  144 +- (UIButton *)checkBtn {
  145 + if (!_checkBtn) {
  146 + _checkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  147 + [_checkBtn setTitle:@"查看" forState:UIControlStateNormal];
  148 + _checkBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  149 + [_checkBtn addTarget:self action:@selector(checkBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  150 + }
  151 + return _checkBtn;
  152 +
  153 +}
  154 +
  155 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxPlayingView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxPlayingView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by cnliveJunBo on 2019/10/19.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBoxPlayingView : UIView
  14 +
  15 +@property (strong, nonatomic) UILabel *contentL;
  16 +
  17 +@property (strong, nonatomic) UIButton *ignoreBtn;
  18 +
  19 ++ (void)showAlertAddedTo:(UIView *)view;
  20 +
  21 ++ (void)hideAlerView;
  22 +
  23 +@end
  24 +
  25 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxPlayingView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxPlayingView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by cnliveJunBo on 2019/10/19.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxPlayingView.h"
  10 +#import "CNGCDDelay.h"
  11 +
  12 +static CNLiveBoxPlayingView * instance = nil;
  13 +
  14 +@interface CNLiveBoxPlayingView ()
  15 +
  16 +@property (nonatomic, strong) CNGCDDelay * delay;
  17 +
  18 +@end
  19 +
  20 +@implementation CNLiveBoxPlayingView
  21 +
  22 ++ (CNLiveBoxPlayingView *)sharedInstance {
  23 + static dispatch_once_t onceToken;
  24 + dispatch_once(&onceToken, ^{
  25 + instance = [[self alloc] initWithFrame:CGRectMake(10, KScreenHeight, KScreenWidth - 20, 45)];
  26 + instance.delay = [[CNGCDDelay alloc] init];
  27 + });
  28 + return instance;
  29 +}
  30 +
  31 ++ (void)showAlertAddedTo:(UIView *)view{
  32 +
  33 + if (![CNLiveBoxPlayingView sharedInstance].superview) {
  34 + [view addSubview:[CNLiveBoxPlayingView sharedInstance]];
  35 + [[CNLiveBoxPlayingView sharedInstance] showAlerView];
  36 + } else {
  37 +
  38 + [[CNLiveBoxPlayingView sharedInstance].delay gcdCancel];
  39 + [[CNLiveBoxPlayingView sharedInstance].delay gcdDelay:3.0 task:^{
  40 + [[CNLiveBoxPlayingView sharedInstance] hiddenAlerView];
  41 + }];
  42 + }
  43 +
  44 +}
  45 +
  46 ++ (void)hideAlerView {
  47 +
  48 + [[CNLiveBoxPlayingView sharedInstance] hiddenAlerView];
  49 +}
  50 +
  51 +- (instancetype)initWithFrame:(CGRect)frame
  52 +{
  53 + self = [super initWithFrame:frame];
  54 + if (self) {
  55 + self.backgroundColor = RGBACOLOR(51, 51, 51,0.7);
  56 + self.layer.masksToBounds = YES;
  57 + self.layer.cornerRadius = 7.5;
  58 + [self setupUI];
  59 + }
  60 + return self;
  61 +}
  62 +
  63 +- (void)showAlerView {
  64 +
  65 + self.alpha = 1;
  66 + [UIView animateWithDuration:0.3 animations:^{
  67 + self.frame = CGRectMake(10, KScreenHeight - kVerticalBottomSafeHeight - 45, KScreenWidth - 20, 45);
  68 + } completion:^(BOOL finished) {
  69 + weakself
  70 + [self.delay gcdDelay:3.0 task:^{
  71 + [weakSelf hiddenAlerView];
  72 + }];
  73 + }];
  74 +}
  75 +
  76 +- (void)hiddenAlerView {
  77 +
  78 + [UIView animateWithDuration:0.3 animations:^{
  79 + self.alpha = 0.0;
  80 +
  81 + } completion:^(BOOL finished) {
  82 + if (self) {
  83 + [self removeFromSuperview];
  84 + self.frame = CGRectMake(10, KScreenHeight, KScreenWidth - 20, 45);
  85 + }
  86 + }];
  87 +}
  88 +
  89 +- (void)setupUI {
  90 +
  91 + [self addSubview:self.contentL];
  92 + [self addSubview:self.ignoreBtn];
  93 +
  94 + self.contentL.frame = CGRectMake(10, 14, KScreenWidth-70, 17);
  95 + self.ignoreBtn.frame = CGRectMake(KScreenWidth-51, 10, 25, 25);
  96 +}
  97 +
  98 +#pragma mark - 事件实现
  99 +- (void)ignoreBtnAction:(UIButton *)btn {
  100 + [self hiddenAlerView];
  101 +}
  102 +
  103 +#pragma mark - Getter
  104 +
  105 +- (UILabel *)contentL {
  106 + if (!_contentL) {
  107 + _contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  108 + _contentL.text = @"正使用音箱播放,打开“更多 > 远程控制”关闭";
  109 + _contentL.textColor = [UIColor whiteColor];
  110 + _contentL.font = [UIFont systemFontOfSize:15];
  111 + _contentL.adjustsFontSizeToFitWidth = YES;
  112 + }
  113 + return _contentL;
  114 +}
  115 +
  116 +- (UIButton *)ignoreBtn {
  117 + if (!_ignoreBtn) {
  118 + _ignoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  119 + [_ignoreBtn setImage:[UIImage imageNamed:@"远程播放提示关闭"] forState:UIControlStateNormal];
  120 + [_ignoreBtn addTarget:self action:@selector(ignoreBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  121 + _ignoreBtn.touchAreaInsets = UIEdgeInsetsMake(10, 10, 10, 10);
  122 + }
  123 + return _ignoreBtn;
  124 +
  125 +}
  126 +
  127 +- (void)dealloc {
  128 + NSLog(@"");
  129 +}
  130 +
  131 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxRoleAlertView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxRoleAlertView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/15.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxUserModel.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNLiveBoxRoleAlertView : UIView
  15 +
  16 +@property (strong, nonatomic) UIView *contentView;
  17 +
  18 +@property (strong, nonatomic) UILabel *tipL;
  19 +
  20 +@property (strong, nonatomic) UIView *lineV;
  21 +
  22 +@property (strong, nonatomic) UIImageView *userImgV;
  23 +
  24 +@property (strong, nonatomic) UILabel *userNameL;
  25 +
  26 +@property (strong, nonatomic) UICollectionView *collectionV;
  27 +
  28 +@property (strong, nonatomic) UIButton *cancleBtn;
  29 +
  30 +@property (strong, nonatomic) UIButton *sureBtn;
  31 +
  32 +@property (strong, nonatomic) UIView *horizontalLine;
  33 +
  34 +@property (strong, nonatomic) UIView *verticalLine;
  35 +
  36 +@property (strong, nonatomic) NSMutableArray *dataArray;
  37 +
  38 +@property (strong, nonatomic) CNBoxUserModel *boxUserModel;
  39 +
  40 +@property (strong, nonatomic) NSString *selectRole;
  41 +@property (strong, nonatomic) NSString *selectRoleName;
  42 +
  43 +
  44 +/*** 切换 ***/
  45 +@property (nonatomic, copy) void(^clickSureBtnBlock)(CNLiveBoxRoleAlertView *view,UIButton *sureBtn);
  46 +
  47 ++ (CNLiveBoxRoleAlertView *)showAlertAddedTo:(UIView *)view;
  48 +- (void)showAlerView;
  49 +- (void)hiddenAlerView;
  50 +
  51 +
  52 +@end
  53 +
  54 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxRoleAlertView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxRoleAlertView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/15.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxRoleAlertView.h"
  10 +#import "CNBOXInviteCollectionViewCell.h"
  11 +
  12 +
  13 +@interface CNLiveBoxRoleAlertView ()<UICollectionViewDelegate,UICollectionViewDataSource>
  14 +
  15 +@property (nonatomic, strong) UIView *showView;
  16 +
  17 +
  18 +@end
  19 +
  20 +@implementation CNLiveBoxRoleAlertView
  21 +
  22 +//提示
  23 ++ (CNLiveBoxRoleAlertView *)showAlertAddedTo:(UIView *)view{
  24 +
  25 + CNLiveBoxRoleAlertView *alertView = [[CNLiveBoxRoleAlertView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  26 + [view addSubview:alertView];
  27 + alertView.alpha = 0.5;
  28 + alertView.showView = view;
  29 +
  30 + return alertView;
  31 +}
  32 +
  33 +- (void)showAlerView {
  34 +
  35 + self.alpha = 0.5;
  36 + [UIView animateWithDuration:0.2 animations:^{
  37 + self.alpha = 1;
  38 + self.contentView.frame = CGRectMake((KScreenWidth - 280)/2, (KScreenHeight - 336)/2, 280, 336);
  39 + }];
  40 +}
  41 +
  42 +- (void)hiddenAlerView {
  43 +
  44 + [UIView animateWithDuration:0.5 animations:^{
  45 + self.alpha = 0.5;
  46 + [self removeFromSuperview];
  47 + }];
  48 +}
  49 +
  50 +
  51 +- (instancetype)initWithFrame:(CGRect)frame
  52 +{
  53 + self = [super initWithFrame:frame];
  54 + if (self) {
  55 + self.backgroundColor = RGBACOLOR(51, 51, 51, 0.3);
  56 +
  57 + [self setupUI];
  58 + [self layoutUI];
  59 +
  60 + }
  61 + return self;
  62 +}
  63 +
  64 +- (void)setupUI {
  65 + [self addSubview:self.contentView];
  66 + [self.contentView addSubview:self.tipL];
  67 + [self.contentView addSubview:self.lineV];
  68 + [self.contentView addSubview:self.userImgV];
  69 + [self.contentView addSubview:self.userNameL];
  70 + [self.contentView addSubview:self.collectionV];
  71 + [self.contentView addSubview:self.cancleBtn];
  72 + [self.contentView addSubview:self.sureBtn];
  73 + [self.contentView addSubview:self.horizontalLine];
  74 + [self.contentView addSubview:self.verticalLine];
  75 +
  76 +}
  77 +
  78 +- (void)layoutUI {
  79 +
  80 + self.contentView.frame = CGRectMake((KScreenWidth - 280)/2, (KScreenHeight - 336)/2 + 200, 280, 336);
  81 +
  82 + self.tipL.frame = CGRectMake(24, 24, 280 - 48, 20);
  83 + self.lineV.frame = CGRectMake(24, self.tipL.bottom + 23, 280 - 48, 0.5);
  84 + self.userImgV.frame = CGRectMake(56, self.lineV.bottom + 16, 40, 40);
  85 + self.userNameL.frame = CGRectMake(self.userImgV.right + 12, self.userImgV.centerY - 9, 280 - (self.userImgV.right + 12) - 24, 18);
  86 + self.collectionV.frame = CGRectMake(10, self.userImgV.bottom + 6, 280 - 20, 155);
  87 + self.horizontalLine.frame = CGRectMake(0, 336 - 44, 280, 0.5);
  88 + self.verticalLine.frame = CGRectMake(280/2, 336 - 44, 0.5, 44);
  89 + self.cancleBtn.frame = CGRectMake(0, 336 - 43, 278/2, 43);
  90 + self.sureBtn.frame = CGRectMake(282/2, 336 - 43, 278/2, 43);
  91 +
  92 +}
  93 +
  94 +#pragma mark - <UICollectionViewDelegate,UICollectionViewDataSource>
  95 +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  96 + return 1;
  97 +}
  98 +
  99 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  100 + return self.dataArray.count;
  101 +}
  102 +
  103 +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  104 +
  105 + CNBOXInviteCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCNBOXInviteCollectionViewCell forIndexPath:indexPath];
  106 + CNLiveBoxRoleModel *model = [self.dataArray objectAtIndex:indexPath.row];
  107 + [cell eidtBOXUIWithModel:model];
  108 +
  109 + return cell;
  110 +}
  111 +
  112 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  113 +
  114 + CNLiveBoxRoleModel *model = [self.dataArray objectAtIndex:indexPath.row];
  115 + if ([model.allowUse isEqualToString:@"0"]) {
  116 + return;
  117 + }
  118 +
  119 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  120 + CNLiveBoxRoleModel *model = obj;
  121 + if ([model.allowUse isEqualToString:@"1"]) {
  122 + if ([model.isSelect isEqualToString:@"1"]) {
  123 + model.isSelect = @"0";
  124 + }
  125 + }
  126 +
  127 + }];
  128 +
  129 +
  130 + if ([model.allowUse isEqualToString:@"1"]) {
  131 + model.isSelect = @"1";
  132 +
  133 + }else {
  134 +
  135 + }
  136 +
  137 + self.selectRole = model.ID;
  138 + self.selectRoleName = model.roleName;
  139 +
  140 + [self.collectionV reloadData];
  141 +
  142 +
  143 +}
  144 +
  145 +
  146 +#pragma mark - 实现
  147 +- (void)cancleBtnAction:(UIButton *)sender {
  148 + [self hiddenAlerView];
  149 +}
  150 +
  151 +- (void)sureBtnAction:(UIButton *)sender {
  152 +
  153 + NSLog(@"输出内容");
  154 +
  155 + if (self.clickSureBtnBlock) {
  156 + self.clickSureBtnBlock(self, sender);
  157 + }
  158 +
  159 + [self hiddenAlerView];
  160 +}
  161 +
  162 +#pragma mark - 属性
  163 +
  164 +- (void)setDataArray:(NSMutableArray *)dataArray {
  165 + _dataArray = dataArray;
  166 + [self.collectionV reloadData];
  167 +}
  168 +
  169 +- (void)setBoxUserModel:(CNBoxUserModel *)boxUserModel {
  170 +
  171 + if (!boxUserModel) {
  172 + return;
  173 + }
  174 +
  175 + _boxUserModel = boxUserModel;
  176 + if (boxUserModel.userMsg) {
  177 + NSString *userImgStr = [NSString stringWithFormat:@"%@",boxUserModel.userMsg.image];
  178 + [self.userImgV sd_setImageWithURL:[NSURL URLWithString:userImgStr] placeholderImage:kDefaultUserIcon];
  179 + self.userNameL.text = [NSString stringWithFormat:@"%@",boxUserModel.userMsg.nickName];
  180 + }
  181 + self.selectRoleName = [NSString stringWithFormat:@"%@",boxUserModel.roleName ?: @""];
  182 + self.selectRole = [NSString stringWithFormat:@"%@",boxUserModel.roleId ?: @""];
  183 +
  184 + if (self.dataArray) {
  185 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  186 +
  187 + CNLiveBoxRoleModel *roleModel = obj;
  188 + if ([roleModel.allowUse isEqualToString:@"0"]) {
  189 + if ([roleModel.ID isEqualToString:boxUserModel.roleId]) {
  190 + roleModel.isSelect = @"1";
  191 + roleModel.allowUse = @"1";
  192 + }
  193 + }else {
  194 + if ([roleModel.ID isEqualToString:boxUserModel.roleId]) {
  195 + roleModel.isSelect = @"1";
  196 + }else {
  197 + roleModel.isSelect = @"0";
  198 + }
  199 +
  200 + }
  201 +
  202 + }];
  203 + }
  204 +
  205 + [self.collectionV reloadData];
  206 +}
  207 +
  208 +- (UIView *)contentView {
  209 + if (!_contentView) {
  210 + _contentView = [[UIView alloc]initWithFrame:CGRectZero];
  211 + [_contentView setBackgroundColor:[UIColor whiteColor]];
  212 + _contentView.layer.masksToBounds = YES;
  213 + _contentView.layer.cornerRadius = 15;
  214 + }
  215 + return _contentView;
  216 +}
  217 +
  218 +- (UILabel *)tipL {
  219 + if (!_tipL) {
  220 + _tipL = [[UILabel alloc]initWithFrame:CGRectZero];
  221 + _tipL.font = [UIFont systemFontOfSize:20];
  222 + _tipL.text = @"编辑角色";
  223 + _tipL.textAlignment = NSTextAlignmentCenter;
  224 + }
  225 + return _tipL;
  226 +}
  227 +
  228 +- (UIView *)lineV {
  229 + if (!_lineV) {
  230 + _lineV = [[UIView alloc]initWithFrame:CGRectZero];
  231 + [_lineV setBackgroundColor:RGBCOLOR(199, 199, 199)];
  232 + }
  233 + return _lineV;
  234 +}
  235 +
  236 +- (UIImageView *)userImgV {
  237 + if (!_userImgV) {
  238 + _userImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
  239 + }
  240 + return _userImgV;
  241 +}
  242 +
  243 +- (UILabel *)userNameL {
  244 + if (!_userNameL) {
  245 + _userNameL = [[UILabel alloc]initWithFrame:CGRectZero];
  246 + _userNameL.textColor = [UIColor blackColor];
  247 + _userNameL.font = [UIFont systemFontOfSize:17];
  248 + }
  249 + return _userNameL;
  250 +}
  251 +
  252 +
  253 +- (UICollectionView *)collectionV {
  254 + if (!_collectionV) {
  255 +
  256 + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  257 + // 最小行间距,默认是0
  258 + layout.minimumLineSpacing = 10;
  259 + // 最小左右间距,默认是10
  260 + layout.minimumInteritemSpacing = 27;
  261 + // 区域内间距,默认是 UIEdgeInsetsMake(0, 0, 0, 0)
  262 + layout.itemSize = CGSizeMake((280 - 20 - 3*27)/3, 24);
  263 + layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
  264 + _collectionV = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
  265 + _collectionV.backgroundColor = [UIColor whiteColor];
  266 + [_collectionV registerClass:[CNBOXInviteCollectionViewCell class] forCellWithReuseIdentifier:kCNBOXInviteCollectionViewCell];
  267 + _collectionV.delegate = self;
  268 + _collectionV.dataSource = self;
  269 + _collectionV.scrollEnabled = NO;
  270 +
  271 + }
  272 + return _collectionV;
  273 +
  274 +}
  275 +
  276 +- (UIView *)horizontalLine {
  277 +
  278 + if (!_horizontalLine) {
  279 + _horizontalLine = [[UIView alloc]initWithFrame:CGRectZero];
  280 + [_horizontalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
  281 + }
  282 + return _horizontalLine;
  283 +}
  284 +
  285 +- (UIView *)verticalLine {
  286 +
  287 + if (!_verticalLine) {
  288 + _verticalLine = [[UIView alloc]initWithFrame:CGRectZero];
  289 + [_verticalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
  290 + }
  291 + return _verticalLine;
  292 +
  293 +}
  294 +
  295 +- (UIButton *)cancleBtn {
  296 + if (!_cancleBtn) {
  297 + _cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  298 + [_cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
  299 + [_cancleBtn setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
  300 + _cancleBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  301 + _cancleBtn.backgroundColor = [UIColor clearColor];
  302 + [_cancleBtn addTarget:self action:@selector(cancleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  303 + }
  304 + return _cancleBtn;
  305 +
  306 +}
  307 +
  308 +
  309 +- (UIButton *)sureBtn {
  310 + if (!_sureBtn) {
  311 + _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  312 + [_sureBtn setTitle:@"保存" forState:UIControlStateNormal];
  313 + [_sureBtn setTitleColor:RGBCOLOR(11, 190, 6) forState:UIControlStateNormal];
  314 + _sureBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  315 + _sureBtn.backgroundColor = [UIColor clearColor];
  316 + [_sureBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  317 + }
  318 + return _sureBtn;
  319 +
  320 +}
  321 +
  322 +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  323 +
  324 + //获取手指触摸view是的任意一个触摸对象
  325 + UITouch * touch = [touches anyObject];
  326 + //获取是手指触摸的view
  327 + UIView *view = [touch view];
  328 + if ([view isEqual:self]) {
  329 + [self hiddenAlerView];
  330 + }
  331 +
  332 +
  333 +}
  334 +
  335 +
  336 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxSuccessView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxSuccessView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/18.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBoxSuccessView : UIView
  14 +
  15 +@property (strong, nonatomic) UIView *contentView;
  16 +
  17 +@property (strong, nonatomic) UIImageView *successImgV;
  18 +
  19 +@property (strong, nonatomic) UIButton *cancleBtn;
  20 +
  21 +
  22 ++ (CNLiveBoxSuccessView *)showAlertAddedTo:(UIView *)view;
  23 +- (void)showAlerView;
  24 +- (void)hiddenAlerView;
  25 +
  26 +@end
  27 +
  28 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxSuccessView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxSuccessView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/18.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxSuccessView.h"
  10 +
  11 +#define kTipViewW 357
  12 +#define kTipViewH 400
  13 +
  14 +@implementation CNLiveBoxSuccessView
  15 +
  16 +//提示
  17 ++ (CNLiveBoxSuccessView *)showAlertAddedTo:(UIView *)view{
  18 +
  19 + CNLiveBoxSuccessView *alertView = [[CNLiveBoxSuccessView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  20 + alertView.alpha = 0.5;
  21 + [view addSubview:alertView];
  22 +
  23 + return alertView;
  24 +}
  25 +
  26 +- (void)showAlerView {
  27 +
  28 + self.alpha = 0.5;
  29 + [UIView animateWithDuration:0.3 animations:^{
  30 + self.alpha = 1;
  31 + }];
  32 +
  33 +
  34 +}
  35 +
  36 +- (void)hiddenAlerView {
  37 +
  38 + [UIView animateWithDuration:0.3 animations:^{
  39 + self.alpha = 0.3;
  40 + [self removeFromSuperview];
  41 + }];
  42 +}
  43 +
  44 +
  45 +- (instancetype)initWithFrame:(CGRect)frame
  46 +{
  47 + self = [super initWithFrame:frame];
  48 + if (self) {
  49 + self.backgroundColor = RGBACOLOR(51, 51, 51,0.7);
  50 + [self setupUI];
  51 + [self layoutUI];
  52 + }
  53 + return self;
  54 +}
  55 +
  56 +- (void)setupUI {
  57 + [self addSubview:self.contentView];
  58 + [self.contentView addSubview:self.successImgV];
  59 + [self.contentView addSubview:self.cancleBtn];
  60 +
  61 +}
  62 +
  63 +- (void)layoutUI {
  64 +
  65 + self.contentView.frame = CGRectMake((KScreenWidth - kTipViewW)/2, (KScreenHeight - kTipViewH)/2, kTipViewW, kTipViewH);
  66 + self.successImgV.frame = CGRectMake(0, 0, kTipViewW, 326);
  67 + self.cancleBtn.frame = CGRectMake((kTipViewW - 44)/2, self.successImgV.bottom + 10, 44, 44);
  68 +
  69 +}
  70 +
  71 +#pragma mark - 实现
  72 +
  73 +- (void)cancleBtnAction:(UIButton *)sender {
  74 + [self hiddenAlerView];
  75 +}
  76 +
  77 +
  78 +#pragma mark - 属性
  79 +
  80 +- (UIView *)contentView {
  81 + if (!_contentView) {
  82 + _contentView = [[UIView alloc]initWithFrame:CGRectZero];
  83 + }
  84 + return _contentView;
  85 +}
  86 +
  87 +
  88 +- (UIView *)successImgV {
  89 + if (!_successImgV) {
  90 + _successImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
  91 + _successImgV.image = [UIImage imageNamed:@"device_gift"];
  92 + }
  93 + return _successImgV;
  94 +}
  95 +
  96 +- (UIButton *)cancleBtn {
  97 + if (!_cancleBtn) {
  98 + _cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  99 + [_cancleBtn setImage:[UIImage imageNamed:@"device_cancle"] forState:UIControlStateNormal];
  100 + [_cancleBtn addTarget:self action:@selector(cancleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  101 + }
  102 + return _cancleBtn;
  103 +
  104 +}
  105 +
  106 +
  107 +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  108 +
  109 + //获取手指触摸view是的任意一个触摸对象
  110 + UITouch * touch = [touches anyObject];
  111 + //获取是手指触摸的view
  112 + UIView *view = [touch view];
  113 + if ([view isEqual:self]) {
  114 + [self hiddenAlerView];
  115 + }
  116 +
  117 +}
  118 +
  119 +
  120 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxWIFITipAlertView.h 0 → 100644
  1 +//
  2 +// CNLiveBoxTipAlertView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/9/19.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveBoxWIFITipAlertView : UIView
  14 +
  15 +@property (strong, nonatomic) UIView *bgView;
  16 +
  17 +@property (strong, nonatomic) UILabel *contenL;
  18 +
  19 +@property (strong, nonatomic) UITextField *enterTF;
  20 +
  21 +@property (strong, nonatomic) UIButton *showPWBtn;
  22 +
  23 +@property (strong, nonatomic) UIView *bottomLineV;
  24 +
  25 +
  26 +@property (strong, nonatomic) UIButton *cancleBtn;
  27 +
  28 +@property (strong, nonatomic) UIButton *sureBtn;
  29 +
  30 +@property (strong, nonatomic) UIView *horizontalLine;
  31 +
  32 +@property (strong, nonatomic) UIView *verticalLine;
  33 +
  34 ++ (CNLiveBoxWIFITipAlertView *)showAlertAddedTo:(UIView *)view;
  35 +- (void)showAlerView;
  36 +- (void)hiddenAlerView;
  37 +
  38 +
  39 +
  40 +@end
  41 +
  42 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/AlertController/CNLiveBoxWIFITipAlertView.m 0 → 100644
  1 +//
  2 +// CNLiveBoxTipAlertView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/9/19.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveBoxWIFITipAlertView.h"
  10 +
  11 +#define kWIFITipViewW 270
  12 +#define kWIFITipViewH 151
  13 +
  14 +@implementation CNLiveBoxWIFITipAlertView
  15 +//提示
  16 ++ (CNLiveBoxWIFITipAlertView *)showAlertAddedTo:(UIView *)view{
  17 +
  18 + CNLiveBoxWIFITipAlertView *alertView = [[CNLiveBoxWIFITipAlertView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  19 + alertView.alpha = 0.5;
  20 + [view addSubview:alertView];
  21 +
  22 + return alertView;
  23 +}
  24 +
  25 +- (void)showAlerView {
  26 +
  27 + self.alpha = 0.5;
  28 + [UIView animateWithDuration:0.3 animations:^{
  29 + self.alpha = 1;
  30 + }];
  31 +
  32 +
  33 +}
  34 +
  35 +- (void)hiddenAlerView {
  36 +
  37 + [UIView animateWithDuration:0.3 animations:^{
  38 + self.alpha = 0.3;
  39 + [self removeFromSuperview];
  40 + }];
  41 +}
  42 +
  43 +
  44 +- (instancetype)initWithFrame:(CGRect)frame
  45 +{
  46 + self = [super initWithFrame:frame];
  47 + if (self) {
  48 + self.backgroundColor = RGBACOLOR(51, 51, 51, 0.3);
  49 + [self setupUI];
  50 + [self layoutUI];
  51 + }
  52 + return self;
  53 +}
  54 +
  55 +- (void)setupUI {
  56 + [self addSubview:self.bgView];
  57 + [self.bgView addSubview:self.enterTF];
  58 + [self.bgView addSubview:self.showPWBtn];
  59 + [self.bgView addSubview:self.bottomLineV];
  60 + [self.bgView addSubview:self.contenL];
  61 + [self.bgView addSubview:self.cancleBtn];
  62 + [self.bgView addSubview:self.sureBtn];
  63 + [self.bgView addSubview:self.horizontalLine];
  64 + [self.bgView addSubview:self.verticalLine];
  65 +
  66 +}
  67 +
  68 +- (void)layoutUI {
  69 +
  70 + self.bgView.frame = CGRectMake((KScreenWidth - kWIFITipViewW)/2, (KScreenHeight - kWIFITipViewH)/2, kWIFITipViewW, kWIFITipViewH);
  71 + self.contenL.frame = CGRectMake(10, 21, kWIFITipViewW - 20, 17);
  72 + self.showPWBtn.frame = CGRectMake(kWIFITipViewW - 50 , self.contenL.bottom + 15, 40, 38);
  73 + self.enterTF.frame = CGRectMake(20, self.showPWBtn.centerY - 19, kWIFITipViewW - 80, 38);
  74 + self.bottomLineV.frame = CGRectMake(20, self.showPWBtn.bottom + 1, kWIFITipViewW - 40, 0.5);
  75 +
  76 + self.horizontalLine.frame = CGRectMake(0, kWIFITipViewH - 44, kWIFITipViewW, 0.5);
  77 + self.verticalLine.frame = CGRectMake(kWIFITipViewW/2, kWIFITipViewH - 44, 0.5, 44);
  78 + self.cancleBtn.frame = CGRectMake(0, kWIFITipViewH - 43, kWIFITipViewW/2, 43);
  79 + self.sureBtn.frame = CGRectMake(kWIFITipViewW/2, kWIFITipViewH - 43, kWIFITipViewW/2, 43);
  80 +
  81 + [self.bgView setBackgroundColor:[UIColor whiteColor]];
  82 +
  83 +}
  84 +
  85 +#pragma mark - 实现
  86 +- (void)showPWBtnAction:(UIButton *)sender {
  87 +
  88 +}
  89 +
  90 +- (void)sureBtnAction:(UIButton *)sender {
  91 +
  92 +}
  93 +
  94 +- (void)cancleBtnAction:(UIButton *)sender {
  95 +
  96 +}
  97 +
  98 +
  99 +#pragma mark - 属性
  100 +
  101 +- (UIView *)bgView {
  102 + if (!_bgView) {
  103 + _bgView = [[UIView alloc]initWithFrame:CGRectZero];
  104 + [_bgView setBackgroundColor:[UIColor whiteColor]];
  105 + _bgView.layer.masksToBounds = YES;
  106 + _bgView.layer.cornerRadius = 15;
  107 + }
  108 + return _bgView;
  109 +}
  110 +
  111 +- (UITextField *)enterTF {
  112 + if (!_enterTF) {
  113 + _enterTF = [[UITextField alloc]initWithFrame:CGRectZero];
  114 +
  115 + }
  116 + return _enterTF;
  117 +}
  118 +
  119 +- (UIButton *)showPWBtn {
  120 + if (!_showPWBtn) {
  121 + _showPWBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  122 + [_showPWBtn setTitle:@"取消" forState:UIControlStateNormal];
  123 + [_showPWBtn setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
  124 + _showPWBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  125 + _showPWBtn.backgroundColor = [UIColor clearColor];
  126 + [_showPWBtn addTarget:self action:@selector(showPWBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  127 + }
  128 + return _cancleBtn;
  129 +
  130 +}
  131 +
  132 +- (UIView *)bottomLineV {
  133 + if (!_bottomLineV) {
  134 + _bottomLineV = [[UIView alloc]initWithFrame:CGRectZero];
  135 + }
  136 + return _bottomLineV;
  137 +}
  138 +
  139 +- (UILabel *)contenL {
  140 + if (!_contenL) {
  141 + _contenL = [[UILabel alloc]initWithFrame:CGRectZero];
  142 + _contenL.textColor = [UIColor blackColor];
  143 + _contenL.font = [UIFont systemFontOfSize:17];
  144 + }
  145 + return _contenL;
  146 +}
  147 +
  148 +
  149 +- (UIView *)horizontalLine {
  150 +
  151 + if (!_horizontalLine) {
  152 + _horizontalLine = [[UIView alloc]initWithFrame:CGRectZero];
  153 + [_horizontalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
  154 + }
  155 + return _horizontalLine;
  156 +}
  157 +
  158 +- (UIView *)verticalLine {
  159 +
  160 + if (!_verticalLine) {
  161 + _verticalLine = [[UIView alloc]initWithFrame:CGRectZero];
  162 + [_verticalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
  163 + }
  164 + return _verticalLine;
  165 +
  166 +}
  167 +
  168 +- (UIButton *)cancleBtn {
  169 + if (!_cancleBtn) {
  170 + _cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  171 + [_cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
  172 + [_cancleBtn setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
  173 + _cancleBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  174 + _cancleBtn.backgroundColor = [UIColor clearColor];
  175 + [_cancleBtn addTarget:self action:@selector(cancleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  176 + }
  177 + return _cancleBtn;
  178 +
  179 +}
  180 +
  181 +
  182 +- (UIButton *)sureBtn {
  183 + if (!_sureBtn) {
  184 + _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  185 + [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
  186 + [_sureBtn setTitleColor:RGBCOLOR(11, 190, 6) forState:UIControlStateNormal];
  187 + _sureBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  188 + _sureBtn.backgroundColor = [UIColor clearColor];
  189 + [_sureBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  190 + }
  191 + return _sureBtn;
  192 +
  193 +}
  194 +
  195 +
  196 +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  197 +
  198 + //获取手指触摸view是的任意一个触摸对象
  199 + UITouch * touch = [touches anyObject];
  200 + //获取是手指触摸的view
  201 + UIView *view = [touch view];
  202 + if ([view isEqual:self]) {
  203 + [self hiddenAlerView];
  204 + }
  205 +
  206 +}
  207 +
  208 +
  209 +
  210 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBOXFirmwareUpdateController.h 0 → 100644
  1 +//
  2 +// CNBOXFirmwareUpdateController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNBOXFirmwareUpdateController : CNCommonViewController
  14 +
  15 +@property (strong, nonatomic) NSString *versionStr;
  16 +
  17 +@property (strong, nonatomic) NSString *updateVerStr;
  18 +
  19 +@end
  20 +
  21 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBOXFirmwareUpdateController.m 0 → 100644
  1 +//
  2 +// CNBOXFirmwareUpdateController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/10.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBOXFirmwareUpdateController.h"
  10 +
  11 +@interface CNBOXFirmwareUpdateController ()
  12 +
  13 +/*** 音箱图片 ***/
  14 +@property (strong, nonatomic) UIImageView *deviceImageV;
  15 +
  16 +/*** 当前版本 ***/
  17 +@property (strong, nonatomic) UILabel *currentL;
  18 +
  19 +/*** 最新版本 ***/
  20 +@property (strong, nonatomic) UILabel *updateL;
  21 +
  22 +/*** 保存按钮 ***/
  23 +@property (strong, nonatomic) UIButton *checkBtn;
  24 +
  25 +@end
  26 +
  27 +@implementation CNBOXFirmwareUpdateController
  28 +
  29 +- (void)viewDidLoad {
  30 + [super viewDidLoad];
  31 +
  32 + [self.view setBackgroundColor:[UIColor whiteColor]];
  33 + self.title = @"固件升级";
  34 +
  35 + [self setupUI];
  36 + [self layoutUI];
  37 +}
  38 +
  39 +- (void)setupUI {
  40 +
  41 + [self.view addSubview:self.deviceImageV];
  42 + [self.view addSubview:self.currentL];
  43 + [self.view addSubview:self.updateL];
  44 + [self.view addSubview:self.checkBtn];
  45 +
  46 + self.currentL.text = [NSString stringWithFormat:@"%@%@",@"当前版本v:",self.versionStr];
  47 + self.updateL.text = [NSString stringWithFormat:@"%@%@",@"最新版本v:",self.versionStr];
  48 +
  49 +
  50 +}
  51 +
  52 +- (void)layoutUI {
  53 + __weak typeof(self) weakSelf = self;
  54 + [self.deviceImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  55 + make.top.equalTo(weakSelf.view.mas_top).offset(62);
  56 + make.centerX.equalTo(weakSelf.view.mas_centerX);
  57 + make.width.mas_equalTo(274);
  58 + make.height.mas_equalTo(159);
  59 + }];
  60 +
  61 + [self.currentL mas_makeConstraints:^(MASConstraintMaker *make) {
  62 + make.top.equalTo(weakSelf.deviceImageV.mas_bottom).offset(40);
  63 + make.centerX.equalTo(weakSelf.view.mas_centerX);
  64 + make.width.mas_equalTo(KScreenWidth);
  65 + make.height.mas_equalTo(20);
  66 + }];
  67 +
  68 + [self.updateL mas_makeConstraints:^(MASConstraintMaker *make) {
  69 + make.top.equalTo(weakSelf.currentL.mas_bottom).offset(22);
  70 + make.centerX.equalTo(weakSelf.view.mas_centerX);
  71 + make.width.mas_equalTo(KScreenWidth);
  72 + make.height.mas_equalTo(20);
  73 + }];
  74 +
  75 + [self.checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  76 + make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-78);
  77 + make.centerX.equalTo(weakSelf.view.mas_centerX);
  78 + make.width.mas_equalTo(215);
  79 + make.height.mas_equalTo(45);
  80 + }];
  81 +
  82 +
  83 +}
  84 +
  85 +
  86 +#pragma mark - 事件实现
  87 +- (void)checkBtnAction:(UIButton *)sender {
  88 +
  89 + [QMUITips showWithText:@"已经是最新版本了" inView:self.view hideAfterDelay:0.5];
  90 +}
  91 +
  92 +
  93 +#pragma mark - 属性
  94 +
  95 +- (UIImageView *)deviceImageV {
  96 + if (!_deviceImageV) {
  97 + _deviceImageV = [[UIImageView alloc]initWithFrame:CGRectZero];
  98 + _deviceImageV.image = [UIImage imageNamed:@"device_ImageV"];
  99 + }
  100 + return _deviceImageV;
  101 +}
  102 +
  103 +- (UILabel *)currentL {
  104 + if (!_currentL) {
  105 + _currentL = [[UILabel alloc]initWithFrame:CGRectZero];
  106 + _currentL.font = [UIFont systemFontOfSize:15];
  107 + _currentL.textAlignment = NSTextAlignmentCenter;
  108 +
  109 + }
  110 + return _currentL;
  111 +}
  112 +
  113 +- (UIView *)updateL {
  114 + if (!_updateL) {
  115 + _updateL = [[UILabel alloc] initWithFrame:CGRectZero];
  116 + _updateL.textAlignment = NSTextAlignmentCenter;
  117 + _updateL.font = [UIFont systemFontOfSize:15];
  118 + }
  119 + return _updateL;
  120 +}
  121 +
  122 +- (UIButton *)checkBtn {
  123 + if (!_checkBtn) {
  124 + _checkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  125 + _checkBtn.layer.masksToBounds = YES;
  126 + _checkBtn.layer.cornerRadius = 22.5;
  127 + [_checkBtn setTitle:@"检查更新" forState:UIControlStateNormal];
  128 + _checkBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  129 + [_checkBtn addTarget:self action:@selector(checkBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  130 + [_checkBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  131 + _checkBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  132 + _checkBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  133 +
  134 + }
  135 + return _checkBtn;
  136 +
  137 +}
  138 +
  139 +
  140 +
  141 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBOXInviteFriendsController.h 0 → 100644
  1 +//
  2 +// CNBOXInviteFriendsController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/11.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxDeviceModel.h"
  11 +#import "CNLiveAllVoiceBoxModel.h"
  12 +
  13 +NS_ASSUME_NONNULL_BEGIN
  14 +
  15 +@interface CNBOXInviteFriendsController : CNCommonViewController
  16 +
  17 +@property (strong, nonatomic) NSMutableArray *inviteFriendsArr;
  18 +
  19 +@property (strong, nonatomic) NSMutableArray *familyTypeArr;
  20 +
  21 +@property (copy, nonatomic) NSString *familyID;
  22 +
  23 +
  24 +@end
  25 +
  26 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBOXInviteFriendsController.m 0 → 100644
  1 +//
  2 +// CNBOXInviteFriendsController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/11.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBOXInviteFriendsController.h"
  10 +#import "CNBOXInviteFriendsCell.h"
  11 +#import "CNBOXIMUser.h"
  12 +#import "CNLiveBoxRoleModel.h"
  13 +#import "CNLiveVoiceBoxModelHelper.h"
  14 +#import "CNBoxUserManagerController.h"
  15 +#import "CNBoxSelectFriendsController.h"
  16 +
  17 +
  18 +typedef NS_ENUM(NSUInteger, CNBOXInviteFriendsStatus) {
  19 + //将一个变成选中 -> (当前人的这个角色为选中 其他人这个角色都为不可选)
  20 + CNBOXInviteFriendsNormalChangeSelect,
  21 + //将选中的变为不可选中 -> (点击了同一个人的同一个角色 当前人的这个角色未选中 其他人这个角色都为可选且默认)
  22 + CNBOXInviteFriendsSelectChangeNormal,
  23 + //将有选中角色的用户,一个有选中角色的人选择不同角色 ->(点击同个人的不同角色 当前角色变为选中, 其他人不可选这个角色 之前角色变为可选,其他人都可选 )
  24 + CNBOXInviteFriendsSelectOtherNormalChangeSelect,
  25 +};
  26 +
  27 +@interface CNBOXInviteFriendsController ()<UITableViewDelegate,UITableViewDataSource>
  28 +
  29 +/*** 头部headerView ***/
  30 +@property (strong, nonatomic) UIView *tableViewHeaderV;
  31 +
  32 +/*** 列表 ***/
  33 +@property (strong, nonatomic) UITableView *tableView;
  34 +
  35 +/*** 下一步 ***/
  36 +@property (nonatomic, strong) UIButton *inviteBtn;
  37 +
  38 +@property (nonatomic, strong) NSMutableArray *dataArray;
  39 +
  40 +@property (nonatomic, assign) CGFloat cellHeight;
  41 +
  42 +@end
  43 +
  44 +@implementation CNBOXInviteFriendsController
  45 +
  46 +- (void)viewDidLoad {
  47 + [super viewDidLoad];
  48 + // Do any additional setup after loading the view.
  49 + self.title = @"设置角色";
  50 + self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
  51 +
  52 + self.dataArray = [NSMutableArray array];
  53 + __weak typeof(self) weakSelf = self;
  54 + [self.inviteFriendsArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  55 +
  56 + IMAUser *user = obj;
  57 + CNBOXIMUser *boxIMUser = [[CNBOXIMUser alloc]init];
  58 + boxIMUser.user = user;
  59 +
  60 + NSMutableArray *dataArr = [[NSMutableArray alloc] init];
  61 + [self.familyTypeArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  62 + NSDictionary *dic = obj;
  63 + CNLiveBoxRoleModel *model = [CNLiveBoxRoleModel mj_objectWithKeyValues:dic];
  64 + model.isSelect = @"0";
  65 + model.isCurrentUse = @"1";
  66 +
  67 + [dataArr addObject:model];
  68 + }];
  69 +
  70 + boxIMUser.roles = dataArr;
  71 + [weakSelf.dataArray addObject:boxIMUser];
  72 + }];
  73 +
  74 + CGFloat height = 65;
  75 + NSInteger remainder = self.familyTypeArr.count % 4;
  76 + NSInteger count = self.familyTypeArr.count /4;
  77 + if (remainder >0) {
  78 + count ++;
  79 + }
  80 + height += count *24 + (count + 1)*10;
  81 + self.cellHeight = height;
  82 +
  83 + [self setupUI];
  84 + [self layoutUI];
  85 +}
  86 +
  87 +- (void)setupUI {
  88 +
  89 + [self.view addSubview:self.tableView];
  90 + [self.view addSubview:self.inviteBtn];
  91 +
  92 +
  93 +}
  94 +
  95 +- (void)layoutUI {
  96 + if (@available(iOS 11.0, *)) {
  97 + self.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight -104);
  98 + }else {
  99 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight -104 - kNavigationBarHeight);
  100 + }
  101 + self.inviteBtn.frame = CGRectMake((KScreenWidth - 275)/2, KScreenHeight - 94, 275, 45);
  102 +}
  103 +
  104 +
  105 +#pragma mark - <UITableViewDelegate,UITableViewDataSource>
  106 +
  107 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  108 + return self.dataArray.count;
  109 +}
  110 +
  111 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  112 + return 1;
  113 +
  114 +}
  115 +
  116 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  117 +
  118 + CNBOXInviteFriendsCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNBOXInviteFriendsCell forIndexPath:indexPath];
  119 + CNBOXIMUser *user = self.dataArray [indexPath.section];
  120 + if (user) {
  121 + [cell editUI:user indexPath:indexPath];
  122 + }
  123 + __weak typeof(self) weakSelf = self;
  124 + cell.clickFriendsTypes = ^(CNBOXInviteFriendsCell * _Nonnull cell, NSIndexPath * _Nonnull indexPath, NSInteger selectCount) {
  125 + [weakSelf editData:cell indexPath:indexPath selectCount:selectCount];
  126 + };
  127 +
  128 + return cell;
  129 +
  130 +}
  131 +
  132 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  133 +
  134 + return self.cellHeight;
  135 +}
  136 +
  137 +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  138 + if (section == 0) {
  139 + return 0.01;
  140 + }else {
  141 + return 10;
  142 + }
  143 +
  144 +}
  145 +
  146 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  147 +
  148 +
  149 +
  150 +}
  151 +
  152 +#pragma mark - 点击编辑数据
  153 +- (void)editData:(CNBOXInviteFriendsCell *) cell indexPath:(NSIndexPath *)indexPath selectCount:(NSInteger) selectCount {
  154 +
  155 +
  156 + NSLog(@"输出点击了");
  157 +
  158 + CNBOXIMUser *user = self.dataArray [indexPath.section];//取人
  159 + NSMutableArray *rolesArray = user.roles;
  160 +
  161 + __block CNLiveBoxRoleModel *selectModel = nil;//一个cell的选中model
  162 + [rolesArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  163 + CNLiveBoxRoleModel *model = obj;
  164 + if ([model.isSelect isEqualToString:@"1"]) {
  165 + selectModel = model;
  166 + }
  167 +
  168 + }];
  169 +
  170 + if (selectModel) {// 取人含有角色
  171 +
  172 + CNLiveBoxRoleModel *model = user.roles[selectCount];
  173 +
  174 + if ([model.allowUse isEqualToString:@"1"]) {
  175 +
  176 + if ([model.isCurrentUse isEqualToString:@"1"]) {
  177 +
  178 + if ([model.isSelect isEqualToString:@"1"]) {
  179 + [self editStatus:CNBOXInviteFriendsSelectChangeNormal indexPath:indexPath selectCount:selectCount];
  180 + }else {
  181 + [self editStatus:CNBOXInviteFriendsSelectOtherNormalChangeSelect indexPath:indexPath selectCount:selectCount];
  182 + }
  183 +
  184 + }else {
  185 + NSLog(@"输出角色在页面之后已经使用");
  186 + return;
  187 + }
  188 +
  189 + }else {//不可选
  190 + NSLog(@"输出角色在页面之前已经使用");
  191 + return;
  192 + }
  193 +
  194 + }else {
  195 + CNLiveBoxRoleModel *model = user.roles[selectCount];
  196 +
  197 + if ([model.allowUse isEqualToString:@"1"]) {
  198 +
  199 + if ([model.isCurrentUse isEqualToString:@"1"]) {
  200 +
  201 + [self editStatus:CNBOXInviteFriendsNormalChangeSelect indexPath:indexPath selectCount:selectCount];
  202 +
  203 + }else {
  204 + NSLog(@"输出角色在页面之后已经使用");
  205 + return;
  206 + }
  207 +
  208 + }else {//不可选
  209 + NSLog(@"输出角色在页面之前已经使用");
  210 + return;
  211 + }
  212 + }
  213 +
  214 +
  215 + [self.tableView reloadData];
  216 +
  217 +
  218 + if ([self checkAllSelect]) {
  219 +
  220 + self.inviteBtn.enabled = YES;
  221 + self.inviteBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  222 +
  223 + }else {
  224 + self.inviteBtn.enabled = NO;
  225 + self.inviteBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  226 + }
  227 +
  228 +
  229 +}
  230 +
  231 +/*** 判断是否全部有角色 ***/
  232 +- (BOOL)checkAllSelect {
  233 +
  234 + __block BOOL isAllSelect = YES;
  235 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  236 +
  237 + CNBOXIMUser *user = obj;
  238 + NSMutableArray *roles = user.roles;
  239 + __block BOOL isSelect = NO;
  240 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  241 +
  242 + CNLiveBoxRoleModel *model = roles[idx];
  243 + if ([model.isSelect isEqualToString:@"1"]) {
  244 + isSelect = YES;
  245 + }
  246 +
  247 +
  248 + }];
  249 +
  250 + if (!isSelect) {
  251 + isAllSelect = NO;
  252 + *stop = YES;
  253 +
  254 + }
  255 +
  256 + }];
  257 + return isAllSelect;
  258 +
  259 +}
  260 +
  261 +
  262 +
  263 +- (void)editStatus:(CNBOXInviteFriendsStatus) status indexPath:(NSIndexPath *)indexPath selectCount:(NSInteger)selectCount {
  264 +
  265 +
  266 + if (status == CNBOXInviteFriendsNormalChangeSelect) {//
  267 +
  268 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  269 +
  270 + CNBOXIMUser *user = obj;
  271 + NSMutableArray *roles = user.roles;
  272 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  273 +
  274 + if (idx == selectCount) {
  275 + CNLiveBoxRoleModel *model = roles[idx];
  276 + model.isCurrentUse = @"0";
  277 + }
  278 +
  279 +
  280 + }];
  281 +
  282 + }];
  283 +
  284 + CNBOXIMUser *user = self.dataArray [indexPath.section];//取人
  285 + NSMutableArray *rolesArray = user.roles;
  286 + CNLiveBoxRoleModel *model = rolesArray[selectCount];
  287 + model.isCurrentUse = @"1";
  288 + model.isSelect = @"1";
  289 +
  290 +
  291 + }else if (status == CNBOXInviteFriendsSelectChangeNormal) {
  292 +
  293 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  294 +
  295 + CNBOXIMUser *user = obj;
  296 + NSMutableArray *roles = user.roles;
  297 + if (idx == indexPath.section) {
  298 +
  299 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  300 +
  301 + if (idx == selectCount) {
  302 + CNLiveBoxRoleModel *model = roles[idx];
  303 + model.isSelect = @"0";
  304 + }
  305 +
  306 +
  307 + }];
  308 +
  309 +
  310 + }else {
  311 +
  312 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  313 +
  314 + if (idx == selectCount) {
  315 + CNLiveBoxRoleModel *model = roles[idx];
  316 + model.isCurrentUse = @"1";
  317 + }
  318 +
  319 +
  320 + }];
  321 +
  322 + }
  323 +
  324 + }];
  325 +
  326 + }else {
  327 +
  328 + __block NSInteger selectIndex = -1;
  329 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  330 +
  331 + CNBOXIMUser *user = obj;
  332 + NSMutableArray *roles = user.roles;
  333 +
  334 + if (idx == indexPath.section) {
  335 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  336 +
  337 + CNLiveBoxRoleModel *model = roles[idx];
  338 + if ([model.isSelect isEqualToString:@"1"]) {
  339 + selectIndex = idx;
  340 + }
  341 +
  342 + }];
  343 +
  344 + }
  345 +
  346 + }];
  347 +
  348 +
  349 + if (selectIndex >= 0) {
  350 + __block NSInteger selectIdx = selectIndex;
  351 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  352 +
  353 + CNBOXIMUser *user = obj;
  354 + NSMutableArray *roles = user.roles;
  355 + if (idx == indexPath.section) {
  356 +
  357 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  358 +
  359 + if (idx == selectIdx) {
  360 + CNLiveBoxRoleModel *model = roles[idx];
  361 + model.isSelect = @"0";
  362 + }
  363 +
  364 +
  365 + }];
  366 +
  367 +
  368 + }else {
  369 +
  370 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  371 +
  372 + if (idx == selectIdx) {
  373 + CNLiveBoxRoleModel *model = roles[idx];
  374 + model.isCurrentUse = @"1";
  375 + }
  376 +
  377 +
  378 + }];
  379 +
  380 + }
  381 +
  382 + }];
  383 +
  384 + }else {
  385 + return;
  386 + }
  387 +
  388 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  389 +
  390 + CNBOXIMUser *user = obj;
  391 + NSMutableArray *roles = user.roles;
  392 + [roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  393 +
  394 + if (idx == selectCount) {
  395 + CNLiveBoxRoleModel *model = roles[idx];
  396 + model.isCurrentUse = @"0";
  397 + }
  398 +
  399 +
  400 + }];
  401 +
  402 + }];
  403 +
  404 + CNBOXIMUser *user = self.dataArray [indexPath.section];//取人
  405 + NSMutableArray *rolesArray = user.roles;
  406 + CNLiveBoxRoleModel *model = rolesArray[selectCount];
  407 + model.isCurrentUse = @"1";
  408 + model.isSelect = @"1";
  409 +
  410 +
  411 + }
  412 +
  413 +}
  414 +
  415 +
  416 +#pragma mark - 事件实现
  417 +- (void)rightBtnAction:(UIButton *)sender {
  418 + _tableView.tableHeaderView = [UIView new];
  419 +}
  420 +
  421 +- (void)nextBtnAction:(UIButton *)sender {
  422 + NSLog(@"可以点击了");
  423 + if (!self.familyID) {
  424 + [QMUITips showWithText:@"家庭信息不全" inView:self.view hideAfterDelay:0.5];
  425 + }
  426 +
  427 + NSMutableArray *dicArray = [NSMutableArray array];
  428 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  429 + NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  430 + NSString *familyIdStr = [NSString stringWithFormat:@"%@",self.familyID];
  431 + [dic setValue:familyIdStr forKey:@"familyId"];
  432 + CNBOXIMUser *user = obj;
  433 + NSString *sidStr = [NSString stringWithFormat:@"%@",user.user.userId];
  434 + [dic setValue:sidStr forKey:@"sid"];
  435 + [user.roles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  436 + CNLiveBoxRoleModel *model = obj;
  437 + if ([model.allowUse isEqualToString:@"1"] && [model.isSelect isEqualToString:@"1"]) {
  438 + NSString *roleStr = [NSString stringWithFormat:@"%@",model.ID];
  439 + [dic setValue:roleStr forKey:@"roleId"];
  440 + }
  441 +
  442 + }];
  443 + [dicArray addObject:dic];
  444 + }];
  445 +
  446 + [self familyGroupInviteWithMembers:dicArray];
  447 +}
  448 +
  449 +#pragma mark - 接口
  450 +- (void)familyGroupInviteWithMembers:(NSMutableArray *)members {
  451 +
  452 + __weak typeof(self) weakSelf = self;
  453 + [QMUITips showLoadingInView:self.view];
  454 + [CNLiveVoiceBoxModelHelper familyGroupInviteWithMembers:members completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  455 + [QMUITips hideAllTipsInView:weakSelf.view];
  456 +
  457 + if (error) {
  458 + if (error.code == 4313) {
  459 + NSString *errorMsg = [NSString stringWithFormat:@"%@",error.domain];
  460 + [QMUITips showWithText:errorMsg inView:weakSelf.view hideAfterDelay:1.0];
  461 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  462 +
  463 + UIViewController *target = nil;
  464 + for (UIViewController * controller in self.navigationController.viewControllers) {
  465 + if ([controller isKindOfClass:[CNBoxSelectFriendsController class]]) {
  466 + target = controller;
  467 + CNBoxSelectFriendsController *selectFriendsVC = (CNBoxSelectFriendsController *)controller;
  468 +
  469 + [selectFriendsVC getSelectedFriends];
  470 + }
  471 + }
  472 + if (target) {
  473 + [[AppDelegate sharedAppDelegate] popToViewController:target];
  474 + }else {
  475 + [[AppDelegate sharedAppDelegate] popToRootViewController];
  476 + }
  477 + });
  478 +
  479 + }else {
  480 + [QMUITips showWithText:@"邀请失败" inView:weakSelf.view hideAfterDelay:0.5];
  481 + }
  482 +
  483 + }else {
  484 + [QMUITips showWithText:@"邀请成功" inView:weakSelf.view hideAfterDelay:0.5];
  485 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  486 + UIViewController *target = nil;
  487 + for (UIViewController * controller in self.navigationController.viewControllers) {
  488 + if ([controller isKindOfClass:[CNBoxUserManagerController class]]) {
  489 + target = controller;
  490 + CNBoxUserManagerController *vc = (CNBoxUserManagerController *)controller;
  491 + [vc loadData];
  492 + }
  493 + }
  494 + if (target) {
  495 + [[AppDelegate sharedAppDelegate] popToViewController:target];
  496 + }else {
  497 + [[AppDelegate sharedAppDelegate] popToRootViewController];
  498 + }
  499 + });
  500 +
  501 + }
  502 +
  503 + }];
  504 +
  505 +}
  506 +
  507 +#pragma mark - 属性
  508 +
  509 +- (UITableView *)tableView {
  510 + if (!_tableView) {
  511 + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  512 + _tableView.delegate = self;
  513 + _tableView.dataSource = self;
  514 + [_tableView registerClass:[CNBOXInviteFriendsCell class] forCellReuseIdentifier:kCNBOXInviteFriendsCell];
  515 + [_tableView setBackgroundColor:RGBACOLOR(242, 242, 242, 1)];
  516 + _tableView.tableHeaderView = self.tableViewHeaderV;
  517 + _tableView.tableFooterView = [UIView new];
  518 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  519 +
  520 +
  521 + }
  522 + return _tableView;
  523 +}
  524 +
  525 +- (UIView *)tableViewHeaderV {
  526 + if (!_tableViewHeaderV) {
  527 + _tableViewHeaderV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)];
  528 + [_tableViewHeaderV setBackgroundColor:RGBACOLOR(247, 176, 84, 1)];
  529 + UILabel *textL = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth - 34, 44)];
  530 + textL.textAlignment = NSTextAlignmentCenter;
  531 + textL.textColor = [UIColor whiteColor];
  532 + textL.font = [UIFont systemFontOfSize:15];
  533 + [_tableViewHeaderV addSubview:textL];
  534 + textL.text = @"对已选用户设置角色,确立亲情关系";
  535 + UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  536 + [_tableViewHeaderV addSubview:rightBtn];
  537 + rightBtn.frame = CGRectMake(KScreenWidth - 34, 0, 34, 44);
  538 + [rightBtn setImage:[UIImage imageNamed:@"device_header_cancle"] forState:UIControlStateNormal];
  539 + [rightBtn addTarget:self action:@selector(rightBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  540 +
  541 + }
  542 + return _tableViewHeaderV;
  543 +}
  544 +
  545 +
  546 +- (UIButton *)inviteBtn {
  547 + if (!_inviteBtn) {
  548 + _inviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  549 + _inviteBtn.layer.masksToBounds = YES;
  550 + _inviteBtn.enabled = NO;
  551 + _inviteBtn.layer.cornerRadius = 22;
  552 + [_inviteBtn setTitle:@"一键邀请" forState:UIControlStateNormal];
  553 + [_inviteBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  554 + [_inviteBtn addTarget:self action:@selector(nextBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  555 + _inviteBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  556 + _inviteBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  557 + }
  558 + return _inviteBtn;
  559 +
  560 +}
  561 +
  562 +
  563 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxCodeCardInviteController.h 0 → 100644
  1 +//
  2 +// CNBoxCodeCardInviteController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/14.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNBoxCodeCardInviteController : CNCommonViewController
  14 +
  15 +@property (nonatomic, strong) UIImage *QRImage;
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxCodeCardInviteController.m 0 → 100644
  1 +//
  2 +// CNBoxCodeCardInviteController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/14.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxCodeCardInviteController.h"
  10 +
  11 +@interface CNBoxCodeCardInviteController ()
  12 +
  13 +@property (strong, nonatomic) UIView *shareContentV;
  14 +@property (strong, nonatomic) UIImageView *QRShareImgV;
  15 +@property (strong, nonatomic) UIImageView *userImgV;
  16 +@property (strong, nonatomic) UILabel *userNameL;
  17 +@property (strong, nonatomic) UILabel *roleTipL;
  18 +@property (strong, nonatomic) UIImageView *qrCodeImgV;
  19 +/*** 二维码背景图 ***/
  20 +@property (strong, nonatomic)UIImageView *QRCodeBackImg;
  21 +
  22 +/*** 提示 ***/
  23 +@property (strong, nonatomic) UIView * firstContentV;
  24 +@property (strong, nonatomic) UIView * secondContentV;
  25 +@property (strong, nonatomic) UIView * thirdContentV;
  26 +
  27 +@property (strong, nonatomic) UILabel *qrCodeTipL;
  28 +
  29 +@property (strong, nonatomic) UILabel *saveTipL;
  30 +
  31 +
  32 +@property (strong, nonatomic) UIButton *shareFamilyBtn;
  33 +
  34 +
  35 +@end
  36 +
  37 +@implementation CNBoxCodeCardInviteController
  38 +
  39 +- (void)viewDidLoad {
  40 + [super viewDidLoad];
  41 +
  42 + [self.view setBackgroundColor:[UIColor whiteColor]];
  43 +
  44 + [self setupUI];
  45 + [self layoutUI];
  46 +
  47 + self.qrCodeImgV.image = self.QRImage;
  48 +
  49 +}
  50 +
  51 +- (void)setupUI {
  52 + [self.view addSubview:self.shareContentV];
  53 + [self.shareContentV addSubview:self.QRShareImgV];
  54 + [self.shareContentV addSubview:self.userImgV];
  55 + [self.shareContentV addSubview:self.userNameL];
  56 + [self.shareContentV addSubview:self.roleTipL];
  57 + [self.shareContentV addSubview:self.QRCodeBackImg];
  58 + [self.shareContentV addSubview:self.qrCodeImgV];
  59 + [self.shareContentV addSubview:self.firstContentV];
  60 + [self.shareContentV addSubview:self.secondContentV];
  61 + [self.shareContentV addSubview:self.thirdContentV];
  62 + [self.shareContentV addSubview:self.qrCodeTipL];
  63 + [self.shareContentV addSubview:self.roleTipL];
  64 + [self.shareContentV addSubview:self.saveTipL];
  65 +
  66 + [self.view addSubview:self.shareFamilyBtn];
  67 +
  68 +}
  69 +
  70 +- (void)layoutUI {
  71 +
  72 + self.shareContentV.frame = CGRectMake(20, 13 + kNavigationBarHeight, KScreenWidth - 40, KScreenHeight - 13 - 60 - kNavigationBarHeight);
  73 + self.QRShareImgV.frame = CGRectMake(0, 0, self.shareContentV.width, self.shareContentV.height);
  74 +
  75 + self.userImgV.frame = CGRectMake(76, 20, 37, 37);
  76 + self.userNameL.frame = CGRectMake(self.userImgV.right + 10, self.userImgV.centerY - 8, self.shareContentV.width - 133, 16);
  77 + self.roleTipL.frame = CGRectMake(0, self.userImgV.bottom + 16, self.shareContentV.width, 24);
  78 + self.QRCodeBackImg.frame = CGRectMake((self.shareContentV.width - 170)/2, self.roleTipL.bottom + 16, 170, 170);
  79 + self.qrCodeImgV.frame = CGRectMake((self.shareContentV.width - 166)/2, self.roleTipL.bottom + 18, 166, 166);
  80 + self.secondContentV.frame = CGRectMake((self.shareContentV.width - 75)/2, self.qrCodeImgV.bottom +18, 90, 15);
  81 + self.firstContentV.frame = CGRectMake(self.secondContentV.left - 100, self.qrCodeImgV.bottom +18, 100, 15);
  82 + self.thirdContentV.frame = CGRectMake(self.secondContentV.right , self.qrCodeImgV.bottom +18, 100, 15);
  83 + self.qrCodeTipL.frame = CGRectMake(10, self.secondContentV.bottom + 15, self.shareContentV.width - 20, 16);
  84 + self.saveTipL.frame = CGRectMake(10, self.shareContentV.height - 25, self.shareContentV.width - 20, 16);
  85 +
  86 + self.shareFamilyBtn.frame = CGRectMake((KScreenWidth - 119)/2, KScreenHeight - 45, 119, 30);
  87 +
  88 +}
  89 +
  90 +#pragma mark - 实现
  91 +- (void)shareFamilyBtnAction:(UIButton *)btn {
  92 +
  93 + UIImage *image = [self drawView:self.shareContentV];
  94 + NSArray *imageArray = @[@"sport_china_download"].copy;
  95 + NSArray *titleArray = @[@"保存"].copy;
  96 + __weak typeof(self) weakSelf = self;
  97 + [CNLiveShareManager showShareViewWithParamForShareTitle:nil ShareUrl:nil ShareDesc:nil ShareImage:image ScreenFull:NO HiddenWjj:NO HiddenQQ:NO HiddenWB:NO HiddenWechat:NO HiddenSafari:YES TopImage:imageArray TopTitles:titleArray PlatformType:CNLiveSharePlatformTypeAll TouchActionBlock:^(NSString *title) {
  98 +
  99 + [QMUITips showLoadingInView:weakSelf.view];
  100 + [weakSelf writeLocationWithImage:image];
  101 + [QMUITips hideAllTipsInView:weakSelf.view];
  102 + [QMUITips showInfo:@"下载成功" inView:weakSelf.view hideAfterDelay:0.5];
  103 +
  104 + } CompleterBlock:^(CNLiveShareResultType resultType, CNLiveSharePlatformType platformType, NSString *typtString) {
  105 +
  106 +
  107 +
  108 + }];
  109 +
  110 +}
  111 +
  112 +#pragma mark - 私有方法
  113 +- (UIImage *)drawView:(UIView *)view {
  114 + CGSize size = view.frame.size;
  115 + CGFloat scale = [UIScreen mainScreen].scale;
  116 + UIGraphicsBeginImageContextWithOptions(size, YES, scale);
  117 + [view.layer renderInContext:UIGraphicsGetCurrentContext()];
  118 + UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
  119 + UIGraphicsEndImageContext();
  120 + return image;
  121 +}
  122 +
  123 +- (void)writeLocationWithImage:(UIImage *)image {
  124 +
  125 + [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
  126 + //1,保存图片到系统相册
  127 + [PHAssetChangeRequest creationRequestForAssetFromImage:image];
  128 +
  129 + } completionHandler:^(BOOL success, NSError * _Nullable error) {
  130 + if (!success) return ;
  131 + NSLog(@"保存成功");
  132 +
  133 + }];
  134 +
  135 +}
  136 +
  137 +
  138 +
  139 +#pragma mark - 属性
  140 +
  141 +- (UIView *)shareContentV {
  142 + if (!_shareContentV) {
  143 + _shareContentV = [[UIView alloc]initWithFrame:CGRectZero];
  144 + }
  145 + return _shareContentV;
  146 +}
  147 +
  148 +- (UIImageView *)QRCodeBackImg {
  149 + if (!_QRCodeBackImg) {
  150 + _QRCodeBackImg = [[UIImageView alloc]initWithFrame:CGRectZero];
  151 +
  152 + _QRCodeBackImg.image = [UIImage imageNamed:@"device_QRCodeEdge"];
  153 + }
  154 + return _QRCodeBackImg;
  155 +}
  156 +
  157 +- (UIImageView *)QRShareImgV {
  158 + if (!_QRShareImgV) {
  159 + _QRShareImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
  160 + _QRShareImgV.image = [UIImage imageNamed:@"device_box_QRCodeImg"];
  161 +
  162 + }
  163 + return _QRShareImgV;
  164 +}
  165 +
  166 +- (UIImageView *)userImgV {
  167 + if (!_userImgV) {
  168 + _userImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
  169 + [_userImgV sd_setImageWithURL:[NSURL URLWithString:CNUserShareModel.faceUrl] placeholderImage:kDefaultUserIcon];
  170 + }
  171 + return _userImgV;
  172 +}
  173 +
  174 +- (UILabel *)userNameL {
  175 + if (!_userNameL) {
  176 + _userNameL = [[UILabel alloc] initWithFrame:CGRectZero];
  177 + NSString *string = [NSString stringWithFormat:@"%@ %@",CNUserShareModel.nickname,@"邀请你"];
  178 +
  179 + NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string];
  180 + // 修改富文本中的不同文字的样式
  181 + [attri addAttribute:NSForegroundColorAttributeName value:RGBCOLOR(40, 40, 40) range:[string rangeOfString:CNUserShareModel.nickname]];
  182 + [attri addAttribute:NSForegroundColorAttributeName value:RGBCOLOR(255, 255, 255) range:[string rangeOfString:@"邀请你"]];
  183 + _userNameL.attributedText = attri;
  184 + _userNameL.font = [UIFont systemFontOfSize:15];
  185 +
  186 +
  187 + }
  188 + return _userNameL;
  189 +}
  190 +
  191 +- (UILabel *)roleTipL {
  192 + if (!_roleTipL) {
  193 + _roleTipL = [[UILabel alloc] initWithFrame:CGRectZero];
  194 + _roleTipL.textColor = [UIColor whiteColor];
  195 + _roleTipL.font = [UIFont boldSystemFontOfSize:24];
  196 + _roleTipL.textAlignment = NSTextAlignmentCenter;
  197 + _roleTipL.text = @"扫码和他(她)绑定亲情关系";
  198 + }
  199 + return _roleTipL;
  200 +}
  201 +
  202 +- (UIImageView *)qrCodeImgV {
  203 + if (!_qrCodeImgV) {
  204 + _qrCodeImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
  205 + }
  206 + return _qrCodeImgV;
  207 +}
  208 +
  209 +- (UIView *)firstContentV {
  210 + if (!_firstContentV) {
  211 + _firstContentV = [[UIView alloc]initWithFrame:CGRectZero];
  212 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  213 + [_firstContentV addSubview:countL];
  214 + countL.text = @"1";
  215 + countL.font = [UIFont systemFontOfSize:12];
  216 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  217 + countL.layer.masksToBounds = YES;
  218 + countL.layer.cornerRadius = 7.5;
  219 + countL.textColor = [UIColor whiteColor];
  220 + countL.textAlignment = NSTextAlignmentCenter;
  221 + countL.frame = CGRectMake(0, 0, 15, 15);
  222 +
  223 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  224 + [_firstContentV addSubview:contentL];
  225 + contentL.text = @"下载网家家 >";
  226 + contentL.font = [UIFont systemFontOfSize:12];
  227 + contentL.textAlignment = NSTextAlignmentLeft;
  228 + contentL.frame = CGRectMake(20, 0, 80, 15);
  229 +
  230 +
  231 + }
  232 + return _firstContentV;
  233 +
  234 +}
  235 +
  236 +- (UIView *)secondContentV {
  237 + if (!_secondContentV) {
  238 + _secondContentV = [[UIView alloc]initWithFrame:CGRectZero];
  239 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  240 + [_secondContentV addSubview:countL];
  241 + countL.text = @"2";
  242 + countL.font = [UIFont systemFontOfSize:12];
  243 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  244 + countL.layer.masksToBounds = YES;
  245 + countL.layer.cornerRadius = 7.5;
  246 + countL.textAlignment = NSTextAlignmentCenter;
  247 + countL.textColor = [UIColor whiteColor];
  248 + countL.frame = CGRectMake(0, 0, 15, 15);
  249 +
  250 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  251 + [_secondContentV addSubview:contentL];
  252 + contentL.text = @"注册/登录 >";
  253 + contentL.font = [UIFont systemFontOfSize:12];
  254 + contentL.textAlignment = NSTextAlignmentLeft;
  255 + contentL.frame = CGRectMake(20, 0, 80, 15);
  256 +
  257 + }
  258 + return _secondContentV;
  259 +
  260 +}
  261 +
  262 +- (UIView *)thirdContentV {
  263 + if (!_thirdContentV) {
  264 + _thirdContentV = [[UIView alloc]initWithFrame:CGRectZero];
  265 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  266 + [_thirdContentV addSubview:countL];
  267 + countL.text = @"3";
  268 + countL.font = [UIFont systemFontOfSize:12];
  269 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  270 + countL.layer.masksToBounds = YES;
  271 + countL.layer.cornerRadius = 7.5;
  272 + countL.textColor = [UIColor whiteColor];
  273 + countL.textAlignment = NSTextAlignmentCenter;
  274 + countL.frame = CGRectMake(0, 0, 15, 15);
  275 +
  276 +
  277 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  278 + [_thirdContentV addSubview:contentL];
  279 + contentL.text = @"扫码绑定";
  280 + contentL.font = [UIFont systemFontOfSize:12];
  281 + contentL.textAlignment = NSTextAlignmentLeft;
  282 + contentL.frame = CGRectMake(20, 0, 80, 15);
  283 + }
  284 + return _thirdContentV;
  285 +
  286 +}
  287 +
  288 +- (UILabel *)qrCodeTipL {
  289 + if (!_qrCodeTipL) {
  290 + _qrCodeTipL = [[UILabel alloc]initWithFrame:CGRectZero];
  291 + _qrCodeTipL.text = @"已安装网家家,请直接登录扫码";
  292 + _qrCodeTipL.font = [UIFont systemFontOfSize:15];
  293 + _qrCodeTipL.textAlignment = NSTextAlignmentCenter;
  294 + }
  295 + return _qrCodeTipL;
  296 +}
  297 +
  298 +- (UILabel *)saveTipL {
  299 + if (!_saveTipL) {
  300 + _saveTipL = [[UILabel alloc]initWithFrame:CGRectZero];
  301 + _saveTipL.font = [UIFont systemFontOfSize:15];
  302 + _saveTipL.textAlignment = NSTextAlignmentCenter;
  303 + _saveTipL.text = @"- 保存图片用网家家扫码 -";
  304 + }
  305 + return _saveTipL;
  306 +}
  307 +
  308 +- (UIButton *)shareFamilyBtn {
  309 + if (!_shareFamilyBtn) {
  310 + _shareFamilyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  311 + _shareFamilyBtn.layer.masksToBounds = YES;
  312 + _shareFamilyBtn.layer.cornerRadius = 15;
  313 + [_shareFamilyBtn setTitle:@"分享给家人" forState:UIControlStateNormal];
  314 + [_shareFamilyBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  315 + _shareFamilyBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  316 + [_shareFamilyBtn addTarget:self action:@selector(shareFamilyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  317 + _shareFamilyBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  318 + }
  319 + return _shareFamilyBtn;
  320 +
  321 +}
  322 +
  323 +
  324 +
  325 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxDeviceMessageController.h 0 → 100644
  1 +//
  2 +// CNBoxDeviceMessageController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBOXDeviceDetailModel.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNBoxDeviceMessageController : CNCommonViewController
  15 +
  16 +/*** 内容 ***/
  17 +@property (strong, nonatomic) CNBOXDeviceDetailModel *detailModel;
  18 +
  19 +@end
  20 +
  21 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxDeviceMessageController.m 0 → 100644
  1 +//
  2 +// CNBoxDeviceMessageController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxDeviceMessageController.h"
  10 +#import "CNLiveDeviceManagerCell.h"
  11 +
  12 +@interface CNBoxDeviceMessageController ()<UITableViewDelegate,UITableViewDataSource>
  13 +
  14 +/*** 列表 ***/
  15 +@property (strong, nonatomic) UITableView *tableView;
  16 +
  17 +@end
  18 +
  19 +@implementation CNBoxDeviceMessageController
  20 +
  21 +- (void)viewDidLoad {
  22 + [super viewDidLoad];
  23 +
  24 + [self.view setBackgroundColor:[UIColor whiteColor]];
  25 + self.title = @"设备信息";
  26 + [self setupUI];
  27 + [self layoutUI];
  28 +}
  29 +
  30 +- (void)setupUI {
  31 + [self.view addSubview:self.tableView];
  32 +
  33 + if (@available(iOS 11.0, *)) {
  34 + self.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
  35 + }else {
  36 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - kNavigationBarHeight);
  37 + }
  38 +
  39 +
  40 +
  41 +}
  42 +
  43 +- (void)layoutUI {
  44 +
  45 + __weak typeof(self) weakSelf = self;
  46 +
  47 +}
  48 +
  49 +
  50 +#pragma mark - <UITableViewDelegate,UITableViewDataSource>
  51 +
  52 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  53 + return 1;
  54 +}
  55 +
  56 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  57 + return 3;
  58 +}
  59 +
  60 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  61 +
  62 + CNLiveDeviceMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNLiveDeviceMessageCell forIndexPath:indexPath];
  63 +
  64 + if (indexPath.row == 0) {
  65 + if (self.detailModel) {
  66 + cell.contentL.text = [NSString stringWithFormat:@"%@",self.detailModel.iP ?: @""];
  67 + }
  68 + cell.nameL.text = @"IP地址";
  69 +
  70 + }else if (indexPath.row == 1) {
  71 + cell.nameL.text = @"设备Mac地址";
  72 + if (self.detailModel) {
  73 + cell.contentL.text = [NSString stringWithFormat:@"%@",self.detailModel.mAC ?: @""];
  74 + }
  75 + }else if (indexPath.row == 2) {
  76 + cell.nameL.text = @"SN号";
  77 + if (self.detailModel) {
  78 + cell.contentL.text = [NSString stringWithFormat:@"%@",self.detailModel.sN ?: @""];;
  79 + }
  80 + }
  81 +
  82 + return cell;
  83 +
  84 +
  85 +}
  86 +
  87 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  88 + if (indexPath.section > 3) {
  89 + return 91;
  90 + }
  91 + return 61;
  92 +}
  93 +
  94 +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  95 + return 10;
  96 +}
  97 +
  98 +- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  99 + return 0.01;
  100 +}
  101 +
  102 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  103 +
  104 +
  105 +
  106 +}
  107 +
  108 +
  109 +
  110 +#pragma mark - 属性
  111 +- (UITableView *)tableView {
  112 + if (!_tableView) {
  113 + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  114 + _tableView.delegate = self;
  115 + _tableView.dataSource = self;
  116 + [_tableView registerClass:[CNLiveDeviceMessageCell class] forCellReuseIdentifier:kCNLiveDeviceMessageCell];
  117 + [_tableView setBackgroundColor:RGBACOLOR(242, 242, 242, 1)];
  118 + UIView *footerView = [[UIView alloc] initWithFrame:CGRectZero];
  119 + _tableView.tableFooterView = footerView;
  120 +
  121 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  122 + }
  123 + return _tableView;
  124 +}
  125 +
  126 +
  127 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxEditDeviceNameController.h 0 → 100644
  1 +//
  2 +// CNBoxEditDeviceController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxDeviceModel.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNBoxEditDeviceNameController : CNCommonViewController
  15 +
  16 +@property (strong, nonatomic) NSString *boxNameStr;
  17 +
  18 +@property (copy, nonatomic) NSString *deviceID;
  19 +
  20 +@property (copy, nonatomic) NSString *isMaster;
  21 +
  22 +@end
  23 +
  24 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxEditDeviceNameController.m 0 → 100644
  1 +//
  2 +// CNBoxEditDeviceController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxEditDeviceNameController.h"
  10 +#import "CNLiveVoiceBoxModelHelper.h"
  11 +
  12 +@interface CNBoxEditDeviceNameController ()
  13 +
  14 +/*** 音箱名称 ***/
  15 +@property (strong, nonatomic) UILabel *deviceNameTipL;
  16 +
  17 +/*** 音箱名称输入 ***/
  18 +@property (strong, nonatomic) UITextField *deviceTF;
  19 +
  20 +/*** 线 ***/
  21 +@property (strong, nonatomic) UIView *lineV;
  22 +
  23 +/*** 提示 ***/
  24 +@property (strong, nonatomic) UILabel *tipL;
  25 +
  26 +/*** 保存按钮 ***/
  27 +@property (strong, nonatomic) UIButton *saveBtn;
  28 +
  29 +
  30 +
  31 +@end
  32 +
  33 +@implementation CNBoxEditDeviceNameController
  34 +
  35 +- (void)viewDidLoad {
  36 + [super viewDidLoad];
  37 +
  38 + self.title = @"更改音箱名称";
  39 + [self.view setBackgroundColor:[UIColor whiteColor]];
  40 + [self setupUI];
  41 + [self layoutUI];
  42 +
  43 + self.deviceTF.text = self.boxNameStr;
  44 +
  45 +}
  46 +
  47 +
  48 +- (void)setupUI {
  49 + [self.view addSubview:self.deviceNameTipL];
  50 + [self.view addSubview:self.deviceTF];
  51 + [self.view addSubview:self.lineV];
  52 + [self.view addSubview:self.tipL];
  53 + [self.view addSubview:self.saveBtn];
  54 +
  55 +}
  56 +
  57 +- (void)layoutUI {
  58 +
  59 + __weak typeof(self) weakSelf = self;
  60 + [self.deviceNameTipL mas_makeConstraints:^(MASConstraintMaker *make) {
  61 + make.top.equalTo(weakSelf.view.mas_top).offset(39+kNavigationBarHeight);
  62 + make.left.equalTo(weakSelf.view.mas_left).offset(22);
  63 + make.width.mas_equalTo(65);
  64 + make.height.mas_equalTo(14);
  65 + }];
  66 +
  67 + [self.deviceTF mas_makeConstraints:^(MASConstraintMaker *make) {
  68 + make.centerY.equalTo(weakSelf.deviceNameTipL.mas_centerY);
  69 + make.left.equalTo(weakSelf.deviceNameTipL.mas_right);
  70 + make.right.equalTo(weakSelf.view.mas_right).offset(-10);
  71 + make.height.mas_equalTo(30);
  72 + }];
  73 +
  74 + [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  75 + make.top.equalTo(weakSelf.deviceNameTipL.mas_bottom).offset(15);
  76 + make.left.equalTo(weakSelf.view.mas_left).offset(22);
  77 + make.right.equalTo(weakSelf.view.mas_right).offset(-22);
  78 + make.height.mas_equalTo(0.5);
  79 + }];
  80 +
  81 + [self.tipL mas_makeConstraints:^(MASConstraintMaker *make) {
  82 + make.top.equalTo(weakSelf.lineV.mas_bottom).offset(12);
  83 + make.left.equalTo(weakSelf.view.mas_left).offset(22);
  84 + make.right.equalTo(weakSelf.view.mas_right).offset(-22);
  85 + make.height.mas_equalTo(20);
  86 + }];
  87 +
  88 + [self.saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89 + make.top.equalTo(weakSelf.tipL.mas_bottom).offset(34);
  90 + make.centerX.equalTo(weakSelf.view.mas_centerX);
  91 + make.width.mas_equalTo(280);
  92 + make.height.mas_equalTo(50);
  93 + }];
  94 +
  95 +
  96 +}
  97 +
  98 +#pragma mark - 按钮实现
  99 +- (void)saveBtnAction:(id)sender {
  100 +
  101 + NSLog(@"按钮点击了");
  102 +
  103 + [self changeName];
  104 +
  105 +}
  106 +
  107 +//监听改变方法
  108 +- (void)textFieldTextDidChange:(UITextField *)textChange{
  109 + NSLog(@"文字改变:%@",textChange.text);
  110 +
  111 + if (textChange.text.length > 40) {
  112 + NSString *textStr = [textChange.text substringToIndex:40];
  113 + textChange.text = textStr;
  114 + }
  115 +
  116 + if (textChange.text.length > 2) {
  117 + self.saveBtn.enabled = YES;
  118 + self.saveBtn.backgroundColor = RGBCOLOR(47, 221, 32);
  119 + }else {
  120 + self.saveBtn.enabled = NO;
  121 + self.saveBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  122 + }
  123 +
  124 +}
  125 +
  126 +#pragma mark - 接口
  127 +- (void)changeName {
  128 +// http://apiwjjtest.cnlive.com/Daren/sound/updateDeviceName.action
  129 +
  130 + NSString *deviceID = [NSString stringWithFormat:@"%@",self.deviceID];
  131 + NSString *newName = [NSString stringWithFormat:@"%@",self.deviceTF.text];
  132 + newName = [newName stringByReplacingOccurrencesOfString:@" " withString:@""];
  133 + if (newName.length <= 0 ) {
  134 + [QMUITips showWithText:@"请输入设备名" inView:self.view hideAfterDelay:1.5];
  135 + return;
  136 + }
  137 + NSString *oldName = [NSString stringWithFormat:@"%@",self.boxNameStr?:@""];
  138 +
  139 + [QMUITips showLoadingInView:self.view];
  140 + __weak typeof(self) weakSelf = self;
  141 + [CNLiveVoiceBoxModelHelper updateDeviceNameWithDeviceId:deviceID newName:newName oldName:oldName completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  142 + [QMUITips hideAllTipsInView:weakSelf.view];
  143 +
  144 + __strong typeof(weakSelf) strongSelf = weakSelf;
  145 + if (!strongSelf) {
  146 + return;
  147 + }
  148 +
  149 + if (error) {
  150 +
  151 + NSString *showText = @"更改设备名失败,请重试";
  152 + if (error.code == 4311 || error.code == 403 || error.code == 4318) {//没有网络
  153 + showText = [NSString stringWithFormat:@"%@",error.domain];
  154 + }else {
  155 + showText = @"请求失败,请重试";
  156 + }
  157 +
  158 + [QMUITips showWithText:showText inView:weakSelf.view hideAfterDelay:0.5];
  159 +
  160 + }else {
  161 +
  162 + [[AppDelegate sharedAppDelegate] popViewController];
  163 + }
  164 +
  165 +
  166 + }];
  167 +}
  168 +
  169 +
  170 +
  171 +#pragma mark - 属性
  172 +
  173 +- (UILabel *)deviceNameTipL {
  174 + if (!_deviceNameTipL) {
  175 + _deviceNameTipL = [[UILabel alloc]initWithFrame:CGRectZero];
  176 + _deviceNameTipL.text = @"音箱名称";
  177 + _deviceNameTipL.font = [UIFont systemFontOfSize:15];
  178 + _deviceNameTipL.textColor = [UIColor blackColor];
  179 + }
  180 + return _deviceNameTipL;
  181 +}
  182 +
  183 +- (UITextField *)deviceTF {
  184 + if (!_deviceTF) {
  185 + _deviceTF = [[UITextField alloc]initWithFrame:CGRectZero];
  186 + _deviceTF.font = [UIFont systemFontOfSize:15];
  187 + _deviceTF.clearButtonMode = UITextFieldViewModeWhileEditing;
  188 + //添加监听
  189 + [_deviceTF addTarget:self action:@selector(textFieldTextDidChange:) forControlEvents:UIControlEventEditingChanged];
  190 + }
  191 + return _deviceTF;
  192 +}
  193 +
  194 +- (UIView *)lineV {
  195 + if (!_lineV) {
  196 + _lineV = [[UIView alloc] initWithFrame:CGRectZero];
  197 + [_lineV setBackgroundColor:RGBCOLOR(242, 242, 242)];
  198 + }
  199 + return _lineV;
  200 +}
  201 +
  202 +- (UILabel *)tipL {
  203 + if (!_tipL) {
  204 + _tipL = [[UILabel alloc] initWithFrame:CGRectZero];
  205 + _tipL.textColor = RGBCOLOR(153, 153, 153);
  206 + _tipL.text = @"40个字符以内,支持汉字、字母、数字或下划线";
  207 + _tipL.font = [UIFont systemFontOfSize:12];
  208 +
  209 + }
  210 + return _tipL;
  211 +}
  212 +
  213 +- (UIButton *)saveBtn {
  214 + if (!_saveBtn) {
  215 + _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  216 + _saveBtn.layer.masksToBounds = YES;
  217 + _saveBtn.layer.cornerRadius = 25;
  218 + _saveBtn.enabled = NO;
  219 + [_saveBtn setTitle:@"保存" forState:UIControlStateNormal];
  220 + _saveBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  221 + [_saveBtn addTarget:self action:@selector(saveBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  222 + [_saveBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  223 + _saveBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  224 + _saveBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  225 +
  226 + }
  227 + return _saveBtn;
  228 +
  229 +}
  230 +
  231 +
  232 +
  233 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxEditQRCodeController.h 0 → 100644
  1 +//
  2 +// CNBoxEditQRCodeController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxDeviceModel.h"
  11 +#import "CNLiveAllVoiceBoxModel.h"
  12 +
  13 +NS_ASSUME_NONNULL_BEGIN
  14 +
  15 +@interface CNBoxEditQRCodeController : CNCommonViewController
  16 +
  17 +@property (strong, nonatomic) NSMutableArray *familyTypeArr;
  18 +
  19 +@property (copy, nonatomic) NSString *familyID;
  20 +
  21 +
  22 +@end
  23 +
  24 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxEditQRCodeController.m 0 → 100644
  1 +//
  2 +// CNBoxEditQRCodeController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxEditQRCodeController.h"
  10 +#import "CNBOXInviteCollectionViewCell.h"
  11 +#import "CNBoxCodeCardInviteController.h"
  12 +#import "CNGroupActiveViewModel.h"
  13 +#import "SGQRCodeGenerateManager.h"
  14 +#import "CNLiveVoiceBoxModelHelper.h"
  15 +
  16 +@interface CNBoxEditQRCodeController ()<UICollectionViewDelegate,UICollectionViewDataSource>
  17 +
  18 +
  19 +/*** 盒子名字 ***/
  20 +@property (strong, nonatomic) UILabel *familTipL;
  21 +
  22 +/*** 家庭列表 ***/
  23 +@property (strong, nonatomic) UICollectionView *collectionV;
  24 +
  25 +/*** 选择家人角色二维码Img ***/
  26 +@property (strong, nonatomic)UIImageView *QRCodeImg;
  27 +
  28 +/*** 二维码背景图 ***/
  29 +@property (strong, nonatomic)UIImageView *QRCodeBackImg;
  30 +
  31 +/*** 二维码提示图 ***/
  32 +@property (strong, nonatomic)UILabel *showTextL;
  33 +
  34 +/*** tip ***/
  35 +@property (strong, nonatomic) UILabel *showTip;
  36 +
  37 +/*** 提示 ***/
  38 +@property (strong, nonatomic) UIView * firstContentV;
  39 +
  40 +@property (strong, nonatomic) UIView *secondContentV;
  41 +
  42 +@property (strong, nonatomic) UIView *thirdContentV;
  43 +
  44 +/*** 保存并分享家人 ***/
  45 +@property (nonatomic, strong) UIButton *saveBtn;
  46 +
  47 +/*** 数据 ***/
  48 +@property (strong, nonatomic) NSMutableArray *dataArray;
  49 +
  50 +@property (strong, nonatomic) CNLiveBoxRoleModel *selectModel;
  51 +
  52 +@end
  53 +
  54 +@implementation CNBoxEditQRCodeController
  55 +
  56 +- (void)viewDidLoad {
  57 + [super viewDidLoad];
  58 +
  59 + self.title = @"二维码邀请加入";
  60 + [self.view setBackgroundColor:[UIColor whiteColor]];
  61 +
  62 + self.dataArray = [NSMutableArray array];
  63 +
  64 + [self setupUI];
  65 + [self layoutUI];
  66 + [self QRCodeInviteLoad];
  67 +
  68 +}
  69 +
  70 +- (void)setupUI {
  71 +
  72 + [self.view addSubview:self.familTipL];
  73 + [self.view addSubview:self.collectionV];
  74 + [self.view addSubview:self.QRCodeImg];
  75 + [self.QRCodeImg addSubview:self.QRCodeBackImg];
  76 + [self.QRCodeImg addSubview:self.showTextL];
  77 + [self.view addSubview:self.showTip];
  78 + [self.view addSubview:self.firstContentV];
  79 + [self.view addSubview:self.secondContentV];
  80 + [self.view addSubview:self.thirdContentV];
  81 + [self.view addSubview:self.saveBtn];
  82 +
  83 +
  84 +}
  85 +
  86 +- (void)layoutUI {
  87 + self.familTipL.frame = CGRectMake(24, 12, KScreenWidth-48, 15);
  88 + CGFloat height = 0;
  89 + NSInteger remainder = self.familyTypeArr.count % 4;
  90 + NSInteger count = self.familyTypeArr.count /4;
  91 + if (remainder >0) {
  92 + count ++;
  93 + }
  94 + height += count *24 + (count + 1)*10;
  95 + self.collectionV.frame = CGRectMake(10,kNavigationBarHeight + self.familTipL.bottom +5, KScreenWidth - 20, height);
  96 +
  97 + self.QRCodeImg.frame = CGRectMake((KScreenWidth - 200)/2, self.collectionV.bottom +20, 200, 200);
  98 + self.QRCodeBackImg.frame = CGRectMake(0, 0, 202, 202);
  99 + self.showTextL.frame = CGRectMake(0, 0, 200, 200);
  100 +
  101 + self.showTip.frame = CGRectMake(10, self.QRCodeImg.bottom +35, KScreenWidth - 20, 18);
  102 + self.secondContentV.frame = CGRectMake((KScreenWidth - 75)/2, self.showTip.bottom +20, 90, 15);
  103 + self.firstContentV.frame = CGRectMake(self.secondContentV.left - 100, self.showTip.bottom +20, 100, 15);
  104 + self.thirdContentV.frame = CGRectMake(self.secondContentV.right , self.showTip.bottom +20, 100, 15);
  105 +
  106 + self.saveBtn.frame = CGRectMake((KScreenWidth - 275)/2, self.view.bottom -74, 275, 44);
  107 +
  108 +}
  109 +
  110 +
  111 +#pragma mark - <UICollectionViewDelegate,UICollectionViewDataSource>
  112 +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  113 + return 1;
  114 +}
  115 +
  116 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  117 + return self.dataArray.count;
  118 +}
  119 +
  120 +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  121 +
  122 + CNBOXInviteCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCNBOXInviteCollectionViewCell forIndexPath:indexPath];
  123 + CNLiveBoxRoleModel *model = [self.dataArray objectAtIndex:indexPath.row];
  124 + if (model) {
  125 + [cell eidtUIWithQRCode:model];
  126 + }
  127 + return cell;
  128 +}
  129 +
  130 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  131 +
  132 + CNLiveBoxRoleModel *model = [self.dataArray objectAtIndex:indexPath.row];
  133 + if ([model.allowUse isEqualToString:@"1"]) {
  134 + if ([model.isSelect isEqualToString:@"1"]) {
  135 + return;
  136 + }
  137 +
  138 + }else{//不可寻啊啊
  139 + return;
  140 + }
  141 +
  142 + [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  143 + CNLiveBoxRoleModel *roleModel = obj;
  144 + if ([roleModel.allowUse isEqualToString:@"1"]) {
  145 + roleModel.isSelect = @"0";
  146 + }
  147 +
  148 + }];
  149 +
  150 + if ([model.allowUse isEqualToString:@"1"]) {
  151 + model.isSelect = @"1";
  152 + self.selectModel = model;
  153 + }else {
  154 +
  155 + }
  156 +
  157 + [self.collectionV reloadData];
  158 +
  159 +
  160 + [self addQRCodeWithModel:model];
  161 +
  162 + if (self.selectModel) {
  163 + self.saveBtn.enabled = YES;
  164 + self.saveBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  165 + }
  166 +
  167 +}
  168 +
  169 +
  170 +/*** 进入邀请我二维码界面 ***/
  171 +- (void)QRCodeInviteLoad {
  172 +
  173 + NSString *familyId = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  174 + [QMUITips showLoadingInView:self.view];
  175 + __weak typeof(self) weakSelf = self;
  176 + [CNLiveVoiceBoxModelHelper getSetRoleListWithFamilyId:familyId completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  177 + [QMUITips hideAllTipsInView:weakSelf.view];
  178 +
  179 + if (error) {
  180 + NSString *showText = @"网络连接失败,请稍后再试";
  181 + if (error.code == -1001 || error.code == -1009) {//没有网络
  182 +
  183 + }else {
  184 + showText = @"请求失败,请重试";
  185 + }
  186 +
  187 + [weakSelf showEmptyViewWithImage:[UIImage imageNamed:@"wufalianjie"] text:showText detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(QRCodeInviteLoad)];
  188 + [weakSelf setCNAPIErrorEmptyView];
  189 + weakSelf.emptyView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - kNavigationBarHeight);
  190 + weakSelf.emptyView.backgroundColor = [UIColor whiteColor];
  191 + }else {
  192 + /** 有网络 */
  193 + if (weakSelf.emptyView) {
  194 + [weakSelf hideEmptyView];
  195 + }
  196 + NSDictionary *contentDic = data;
  197 + NSMutableArray *familyTypes = [NSMutableArray array];
  198 + if ([contentDic containsObjectForKey:@"roleList"]) {
  199 + NSMutableArray *roleList = contentDic[@"roleList"];
  200 + [roleList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  201 + NSDictionary *dic = obj;
  202 + [familyTypes addObject:dic];
  203 +
  204 + }];
  205 + }
  206 +
  207 + if (familyTypes.count == 0) {
  208 + [QMUITips showWithText:@"无角色列表" inView:self.view hideAfterDelay:0.5];
  209 + return;
  210 + }
  211 + weakSelf.familyTypeArr = familyTypes;
  212 + weakSelf.dataArray = [NSMutableArray array];
  213 + NSMutableArray *dataArr = [NSMutableArray array];
  214 + [weakSelf.familyTypeArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  215 + NSDictionary *dic = obj;
  216 + CNLiveBoxRoleModel *model = [CNLiveBoxRoleModel mj_objectWithKeyValues:dic];
  217 + model.isSelect = @"0";
  218 + model.isCurrentUse = @"1";
  219 + [dataArr addObject:model];
  220 + }];
  221 + weakSelf.dataArray = dataArr;
  222 + [weakSelf.collectionV reloadData];
  223 + [weakSelf layoutUI];
  224 +
  225 + }
  226 +
  227 + }];
  228 +
  229 +}
  230 +
  231 +
  232 +- (void)addQRCodeWithModel:(CNLiveBoxRoleModel *)model {
  233 + [QMUITips showLoadingInView:self.view];
  234 + __weak typeof(self) weakSelf = self;
  235 + [[CNGroupActiveViewModel sharedCNGroupActiveViewModel] requestServerForDownloadAppActionUrlSourceCompleterBlock:^(NSString *shareUrl) {
  236 + [QMUITips hideAllTipsInView:weakSelf.view];
  237 +
  238 + // http://wjjh5.cnlive.com/apkdownload.html?channelName=530
  239 +
  240 + NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  241 + NSString *roleID = [NSString stringWithFormat:@"%@",model.ID];
  242 + NSString *familyIdStr = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  243 + NSString *UUIDStr = [self getUniqueStrByUUID];
  244 + UUIDStr = [UUIDStr stringByReplacingOccurrencesOfString:@"-" withString:@""];
  245 +
  246 + [dic setValue:roleID forKey:@"roleId"];
  247 + [dic setValue:familyIdStr forKey:@"familyId"];
  248 + [dic setValue:UUIDStr forKey:@"uuid"];
  249 +
  250 +
  251 + NSString *xiajiaContentStr = [dic mj_JSONString];
  252 + NSString *type = @"xiaoJiaSpeakerType";
  253 + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
  254 + long time = [date timeIntervalSince1970]*1000;// *1000 是精确到毫秒,不乘就是精确到秒
  255 + NSString *currentTime = [NSString stringWithFormat:@"%ld",time];
  256 +
  257 + NSString * wjjQr = [EncryptAndDecrypt base64StringFromText:[@{@"xiajiaContent":xiajiaContentStr,@"type":type,@"time":currentTime} mj_JSONString] encryptKey:@"cnliveIm"];
  258 + NSString *shareUrlStr = [NSString stringWithFormat:@"%@wjjQrSkipType=wjjQrXiaojiaBoxType&isWjjQr=%@",shareUrl,wjjQr];
  259 +
  260 + NSString *qrCode = shareUrlStr;
  261 +
  262 + UIImage *qrImage = [SGQRCodeGenerateManager generateWithLogoQRCodeData:qrCode logoImageName:@"ewm_lcon" logoScaleToSuperView:0.2];;
  263 + if (qrImage) {
  264 + weakSelf.QRCodeImg.image = qrImage;
  265 + weakSelf.showTextL.hidden = YES;
  266 + }
  267 +
  268 +
  269 + }];
  270 +}
  271 +
  272 +
  273 +- (NSString *)getUniqueStrByUUID
  274 +{
  275 + CFUUIDRef uuidObj = CFUUIDCreate(nil);//create a new UUID
  276 +
  277 + //get the string representation of the UUID
  278 + CFStringRef uuidString = CFUUIDCreateString(nil, uuidObj);
  279 +
  280 + NSString *str = [NSString stringWithString:(__bridge NSString *)uuidString];
  281 +
  282 + CFRelease(uuidObj);
  283 + CFRelease(uuidString);
  284 +
  285 + return [str lowercaseString];
  286 +}
  287 +
  288 +
  289 +#pragma mark - 实现
  290 +- (void)saveBtnAction:(UIButton *)sender {
  291 +
  292 + if (!self.selectModel) {
  293 + return;
  294 + }
  295 +
  296 + if (!self.QRCodeImg.image) {
  297 + return;
  298 + }
  299 +
  300 + CNBoxCodeCardInviteController *boxCodeCardInviteVC = [[CNBoxCodeCardInviteController alloc]init];
  301 + boxCodeCardInviteVC.QRImage = self.QRCodeImg.image;
  302 + [[AppDelegate sharedAppDelegate] pushViewController:boxCodeCardInviteVC];
  303 +
  304 +
  305 +}
  306 +
  307 +#pragma mark - 属性
  308 +
  309 +- (UILabel *)familTipL {
  310 + if (!_familTipL) {
  311 + _familTipL = [[UILabel alloc]initWithFrame:CGRectZero];
  312 + _familTipL.font = [UIFont systemFontOfSize:16];
  313 + _familTipL.text = @"选择家人角色";
  314 + _familTipL.textAlignment = NSTextAlignmentLeft;
  315 +
  316 + }
  317 + return _familTipL;
  318 +}
  319 +
  320 +- (UICollectionView *)collectionV {
  321 + if (!_collectionV) {
  322 +
  323 + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  324 + // 最小行间距,默认是0
  325 + layout.minimumLineSpacing = 10;
  326 + // 最小左右间距,默认是10
  327 + layout.minimumInteritemSpacing = 27;
  328 + // 区域内间距,默认是 UIEdgeInsetsMake(0, 0, 0, 0)
  329 + layout.itemSize = CGSizeMake((KScreenWidth - 40 - 3*27)/4, 24);
  330 + layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
  331 + _collectionV = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
  332 + [_collectionV registerClass:[CNBOXInviteCollectionViewCell class] forCellWithReuseIdentifier:kCNBOXInviteCollectionViewCell];
  333 + [_collectionV setBackgroundColor:[UIColor whiteColor]];
  334 + _collectionV.delegate = self;
  335 + _collectionV.dataSource = self;
  336 + _collectionV.scrollEnabled = NO;
  337 +
  338 + }
  339 + return _collectionV;
  340 +
  341 +}
  342 +
  343 +- (UIImageView *)QRCodeImg {
  344 + if (!_QRCodeImg) {
  345 + _QRCodeImg = [[UIImageView alloc]initWithFrame:CGRectZero];
  346 + _QRCodeImg.image = [UIImage imageWithColor:RGBCOLOR(225, 249, 215) size:CGSizeMake(200, 200)];
  347 +
  348 + }
  349 + return _QRCodeImg;
  350 +}
  351 +
  352 +- (UIImageView *)QRCodeBackImg {
  353 + if (!_QRCodeBackImg) {
  354 + _QRCodeBackImg = [[UIImageView alloc]initWithFrame:CGRectZero];
  355 +
  356 + _QRCodeBackImg.image = [UIImage imageNamed:@"device_QRCodeEdge"];
  357 + }
  358 + return _QRCodeBackImg;
  359 +}
  360 +
  361 +- (UILabel *)showTextL {
  362 + if (!_showTextL) {
  363 + _showTextL = [[UILabel alloc]initWithFrame:CGRectZero];
  364 + _showTextL.font = [UIFont systemFontOfSize:16];
  365 + _showTextL.textAlignment = NSTextAlignmentCenter;
  366 + _showTextL.textColor = RGBCOLOR(25, 159, 24);
  367 + _showTextL.text = @"选择家人角色\n生成二维码";
  368 + }
  369 + return _showTextL;
  370 +}
  371 +
  372 +- (UILabel *)showTip {
  373 + if (!_showTip) {
  374 + _showTip = [[UILabel alloc]initWithFrame:CGRectZero];
  375 + _showTip.font = [UIFont systemFontOfSize:16];
  376 + _showTip.textAlignment = NSTextAlignmentCenter;
  377 + _showTip.text = @"请对方使用网家家“扫一扫”绑定";
  378 +
  379 + }
  380 + return _showTip;
  381 +}
  382 +
  383 +- (UIView *)firstContentV {
  384 + if (!_firstContentV) {
  385 + _firstContentV = [[UIView alloc]initWithFrame:CGRectZero];
  386 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  387 + [_firstContentV addSubview:countL];
  388 + countL.text = @"1";
  389 + countL.font = [UIFont systemFontOfSize:12];
  390 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  391 + countL.layer.masksToBounds = YES;
  392 + countL.layer.cornerRadius = 7.5;
  393 + countL.textColor = [UIColor whiteColor];
  394 + countL.textAlignment = NSTextAlignmentCenter;
  395 + countL.frame = CGRectMake(0, 0, 15, 15);
  396 +
  397 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  398 + [_firstContentV addSubview:contentL];
  399 + contentL.text = @"下载网家家 >";
  400 + contentL.font = [UIFont systemFontOfSize:12];
  401 + contentL.textAlignment = NSTextAlignmentLeft;
  402 + contentL.frame = CGRectMake(20, 0, 80, 15);
  403 +
  404 +
  405 + }
  406 + return _firstContentV;
  407 +
  408 +}
  409 +
  410 +- (UIView *)secondContentV {
  411 + if (!_secondContentV) {
  412 + _secondContentV = [[UIView alloc]initWithFrame:CGRectZero];
  413 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  414 + [_secondContentV addSubview:countL];
  415 + countL.text = @"2";
  416 + countL.font = [UIFont systemFontOfSize:12];
  417 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  418 + countL.layer.masksToBounds = YES;
  419 + countL.layer.cornerRadius = 7.5;
  420 + countL.textAlignment = NSTextAlignmentCenter;
  421 + countL.textColor = [UIColor whiteColor];
  422 + countL.frame = CGRectMake(0, 0, 15, 15);
  423 +
  424 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  425 + [_secondContentV addSubview:contentL];
  426 + contentL.text = @"注册/登录 >";
  427 + contentL.font = [UIFont systemFontOfSize:12];
  428 + contentL.textAlignment = NSTextAlignmentLeft;
  429 + contentL.frame = CGRectMake(20, 0, 80, 15);
  430 +
  431 + }
  432 + return _secondContentV;
  433 +
  434 +}
  435 +
  436 +- (UIView *)thirdContentV {
  437 + if (!_thirdContentV) {
  438 + _thirdContentV = [[UIView alloc]initWithFrame:CGRectZero];
  439 + UILabel *countL = [[UILabel alloc]initWithFrame:CGRectZero];
  440 + [_thirdContentV addSubview:countL];
  441 + countL.text = @"3";
  442 + countL.font = [UIFont systemFontOfSize:12];
  443 + countL.backgroundColor = RGBCOLOR(25, 159, 24);
  444 + countL.layer.masksToBounds = YES;
  445 + countL.layer.cornerRadius = 7.5;
  446 + countL.textColor = [UIColor whiteColor];
  447 + countL.textAlignment = NSTextAlignmentCenter;
  448 + countL.frame = CGRectMake(0, 0, 15, 15);
  449 +
  450 +
  451 + UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectZero];
  452 + [_thirdContentV addSubview:contentL];
  453 + contentL.text = @"扫码绑定";
  454 + contentL.font = [UIFont systemFontOfSize:12];
  455 + contentL.textAlignment = NSTextAlignmentLeft;
  456 + contentL.frame = CGRectMake(20, 0, 80, 15);
  457 + }
  458 + return _thirdContentV;
  459 +
  460 +}
  461 +
  462 +- (UIButton *)saveBtn {
  463 + if (!_saveBtn) {
  464 + _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  465 + _saveBtn.layer.masksToBounds = YES;
  466 + _saveBtn.enabled = NO;
  467 + _saveBtn.layer.cornerRadius = 22;
  468 + [_saveBtn setTitle:@"生成二维码海报" forState:UIControlStateNormal];
  469 + [_saveBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  470 + [_saveBtn addTarget:self action:@selector(saveBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  471 + _saveBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  472 + _saveBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  473 + }
  474 + return _saveBtn;
  475 +
  476 +}
  477 +
  478 +
  479 +
  480 +
  481 +
  482 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxSelectFriendsController.h 0 → 100644
  1 +//
  2 +// CNBoxSelectFriendsController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxDeviceModel.h"
  11 +#import "CNLiveAllVoiceBoxModel.h"
  12 +
  13 +NS_ASSUME_NONNULL_BEGIN
  14 +
  15 +@interface CNBoxSelectFriendsController : CNCommonViewController
  16 +
  17 +/*** 已选择好友 ***/
  18 +@property (nonatomic, strong) NSMutableArray *selectedFriends;
  19 +/*** 已邀请过 ***/
  20 +@property (nonatomic, strong) NSMutableArray *existedFriends;
  21 +
  22 +@property (copy, nonatomic) NSString *familyID;
  23 +
  24 +/*** 进入邀请好友界面 ***/
  25 +- (void)getSelectedFriends;
  26 +
  27 +
  28 +@end
  29 +
  30 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxSelectFriendsController.m 0 → 100644
  1 +//
  2 +// CNBoxSelectFriendsController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxSelectFriendsController.h"
  10 +#import "CNSearch.h"
  11 +#import "CNLiveBoxSelectFirendsCell.h"
  12 +#import "BAContact.h"
  13 +#import "CNContactHeaderView.h"
  14 +
  15 +#import "IMAGroup+MemberList.h"
  16 +
  17 +#import "CNTopWarningView.h"
  18 +
  19 +#import "CNGroupListAvaterUtil.h"
  20 +#import "NSString+Category.h"
  21 +#import "NSString+IMPinyin.h"
  22 +#import "CNBOXInviteFriendsController.h"
  23 +#import "CNLiveVoiceBoxModelHelper.h"
  24 +#import "CNLiveBoxRoleModel.h"
  25 +
  26 +
  27 +#define kFirendCount 11;
  28 +
  29 +@interface CNBoxSelectFriendsController ()<UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate>{
  30 + UILabel *_noneLab; //没有搜索结果 的提示语
  31 +}
  32 +
  33 +/*** 搜索 ***/
  34 +@property (nonatomic, strong) CNSearch *searchBar;
  35 +/*** 列表 ***/
  36 +@property (nonatomic, strong) UITableView *tableView;
  37 +/*** 下一步 ***/
  38 +@property (nonatomic, strong) UIButton *nextBtn;
  39 +/*** 搜索蒙层 ***/
  40 +@property (nonatomic, strong) UIView *maskView;
  41 +
  42 +@property (nonatomic, assign) BOOL searchStatusActive;
  43 +
  44 +
  45 +
  46 +@property (nonatomic, strong) NSMutableArray *searchResultArr;
  47 +@property (nonatomic, strong) NSArray *rowArr;
  48 +@property (nonatomic, strong) NSArray *sectionArr;
  49 +@property (nonatomic, strong) NSMutableArray *totalArr;
  50 +
  51 +
  52 +
  53 +@end
  54 +
  55 +@implementation CNBoxSelectFriendsController
  56 +
  57 +- (void)dealloc
  58 +{
  59 +
  60 +}
  61 +
  62 +- (void)viewWillAppear:(BOOL)animated
  63 +{
  64 + [super viewWillAppear:animated];
  65 +
  66 +}
  67 +
  68 +- (void)viewDidLoad {
  69 + [super viewDidLoad];
  70 + // Do any additional setup after loading the view.
  71 +
  72 + [self.view setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
  73 + self.title = @"选择好友";
  74 +
  75 + self.selectedFriends = [NSMutableArray array];
  76 + self.searchResultArr = [NSMutableArray array];
  77 + self.totalArr = [NSMutableArray array];
  78 +
  79 + [self.view addSubview:self.searchBar];
  80 + [self.view addSubview:self.tableView];
  81 + [self.view addSubview:self.nextBtn];
  82 + [self.view addSubview:self.maskView];
  83 + [self layoutUI];
  84 +
  85 + [self getSelectedFriends];
  86 +
  87 + //增加监听,当键盘出现或改变时收出消息
  88 + [[NSNotificationCenter defaultCenter] addObserver:self
  89 + selector:@selector(keyboardWillShow:)
  90 + name:UIKeyboardWillShowNotification
  91 + object:nil];
  92 + //增加监听,当键退出时收出消息
  93 + [[NSNotificationCenter defaultCenter] addObserver:self
  94 + selector:@selector(keyboardWillHide:)
  95 + name:UIKeyboardWillHideNotification
  96 + object:nil];
  97 +}
  98 +
  99 +- (void)layoutUI {
  100 +
  101 + self.searchBar.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, 55);
  102 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight + 55, KScreenWidth, KScreenHeight - 55 - 96 - kNavigationBarHeight);
  103 + self.nextBtn.frame = CGRectMake((KScreenWidth - 275)/2, self.tableView.bottom +20, 275, 45);
  104 +
  105 +}
  106 +
  107 +- (void)keyboardWillShow:(NSNotification *)aNotification {
  108 + //获取键盘的高度
  109 + NSDictionary *userInfo = [aNotification userInfo];
  110 + NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
  111 + CGRect keyboardRect = [aValue CGRectValue];
  112 + int height = keyboardRect.size.height;
  113 + // 需要进行的操作
  114 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight + 55, KScreenWidth, KScreenHeight - 55 - 96 - kNavigationBarHeight - height);
  115 + self.nextBtn.frame = CGRectMake((KScreenWidth - 275)/2, self.tableView.bottom +20, 275, 45);
  116 +}
  117 +
  118 +//当键退出时调用
  119 +-(void)keyboardWillHide:(NSNotification *)aNotification {
  120 + // 界面复原
  121 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight + 55, KScreenWidth, KScreenHeight - 55 - 96 - kNavigationBarHeight);
  122 + self.nextBtn.frame = CGRectMake((KScreenWidth - 275)/2, self.tableView.bottom +20, 275, 45);
  123 +
  124 +}
  125 +
  126 +
  127 +#pragma mark -
  128 +#pragma mark - UITableViewDelegate, UITableViewDataSource
  129 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  130 + if (_searchStatusActive) {
  131 + return 1;
  132 + } else {
  133 + return self.sectionArr.count;
  134 + }
  135 +
  136 +}
  137 +
  138 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  139 +
  140 + if (_searchStatusActive) {
  141 + return _searchResultArr.count;
  142 + } else {
  143 + return [self.rowArr[section] count];
  144 + }
  145 +
  146 +}
  147 +
  148 +
  149 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  150 +{
  151 + CNLiveBoxSelectFirendsCell *selectFriendsCell = [tableView dequeueReusableCellWithIdentifier:kCNLiveBoxSelectFirendsCell forIndexPath:indexPath];
  152 +
  153 + if (_searchStatusActive) {
  154 + if (self.searchResultArr.count > 0) {
  155 + IMAUser *user = (IMAUser *)[self.searchResultArr objectAtIndex:indexPath.row];
  156 + if (user) {
  157 + [selectFriendsCell editUI:user];
  158 + }
  159 + }
  160 +
  161 +
  162 + }else {
  163 + if (self.rowArr.count > 0) {
  164 + NSArray *users = self.rowArr[indexPath.section];
  165 + if (users.count > 0) {
  166 + IMAUser *user = users[indexPath.row];
  167 + if (user) {
  168 + [selectFriendsCell editUI:user];
  169 + }
  170 + }
  171 +
  172 + }
  173 +
  174 + }
  175 +
  176 + return selectFriendsCell;
  177 +
  178 +}
  179 +
  180 +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  181 +
  182 + if (_searchStatusActive) {
  183 + return [UIView new];
  184 + } else {
  185 + CNContactHeaderView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"CNContactHeaderView"];
  186 + [view setText:self.sectionArr[section]];
  187 + return view;
  188 + }
  189 +
  190 +}
  191 +
  192 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  193 +
  194 +
  195 + return 60;
  196 +}
  197 +
  198 +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  199 +
  200 + if (_searchStatusActive) {
  201 + return 0.1;
  202 + } else {
  203 + return 23;
  204 + }
  205 +}
  206 +
  207 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  208 +
  209 +
  210 + NSInteger selectTotalCount = kFirendCount;
  211 + selectTotalCount = selectTotalCount - self.existedFriends.count;
  212 + /*** 获取选中人数 ***/
  213 + __block NSInteger selectCount = 0;
  214 + [self.totalArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  215 + IMAUser *user = obj;
  216 + if (user.isSelected) {
  217 + selectCount ++;
  218 + }
  219 + }];
  220 +
  221 +
  222 + if (selectCount == selectTotalCount) {
  223 +
  224 + if (_searchStatusActive) {
  225 + IMAUser *user = (IMAUser *)[self.searchResultArr objectAtIndex:indexPath.row];
  226 + if (user.isInvate) {
  227 + return;
  228 + }else {
  229 +
  230 + if (user.isSelected) {
  231 +
  232 + }else {
  233 + [QMUITips showWithText:@"最多可以邀请10人" inView:self.view hideAfterDelay:0.5];
  234 + return;
  235 + }
  236 + }
  237 +
  238 + }else {
  239 + NSArray *users = self.rowArr[indexPath.section];
  240 + IMAUser *user = users[indexPath.row];
  241 + if (user.isInvate) {
  242 + return;
  243 + }else {
  244 + if (user.isSelected) {
  245 +
  246 + }else {
  247 + [QMUITips showWithText:@"最多可以邀请10人" inView:self.view hideAfterDelay:0.5];
  248 + return;
  249 + }
  250 + }
  251 +
  252 + }
  253 +
  254 + }
  255 +
  256 + if (_searchStatusActive) {
  257 + IMAUser *user = (IMAUser *)[self.searchResultArr objectAtIndex:indexPath.row];
  258 + if (user.isInvate) {
  259 + return;
  260 + }else {
  261 + user.isSelected = !user.isSelected;
  262 + [self.tableView reloadData];
  263 + }
  264 +
  265 + }else {
  266 + NSArray *users = self.rowArr[indexPath.section];
  267 + IMAUser *user = users[indexPath.row];
  268 + if (user.isInvate) {
  269 + return;
  270 + }else {
  271 + user.isSelected = !user.isSelected;
  272 + }
  273 +
  274 + [self.tableView reloadData];
  275 +
  276 + }
  277 +
  278 + __block NSInteger showSelectCount = 0;
  279 + [self.selectedFriends removeAllObjects];
  280 + [self.totalArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  281 + IMAUser *user = obj;
  282 + if (user.isSelected) {
  283 + showSelectCount ++;
  284 + [self.selectedFriends addObject:user];
  285 + }
  286 + }];
  287 +
  288 + if (showSelectCount > 0) {
  289 + self.nextBtn.enabled = YES;
  290 + self.nextBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  291 + }else {
  292 + self.nextBtn.enabled = NO;
  293 + self.nextBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  294 + }
  295 +
  296 + NSString *nextStr = [NSString stringWithFormat:@"%@(%ld)",@"下一步",showSelectCount];
  297 + [self.nextBtn setTitle:nextStr forState:UIControlStateNormal];
  298 +
  299 +
  300 +
  301 +}
  302 +
  303 +- (void)scrollViewDidScroll:(UIScrollView *)scrollView
  304 +{
  305 + [self.view endEditing:YES];
  306 +}
  307 +
  308 +#pragma mark -
  309 +#pragma mark - UISearchBarDelegate
  310 +- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
  311 +
  312 + _searchStatusActive = YES;
  313 + if (_searchResultArr.count > 0) {
  314 +
  315 + }
  316 + else
  317 + {
  318 + _maskView.hidden = NO;
  319 + _noneLab.text = @"";
  320 + }
  321 +
  322 + return YES;
  323 +}
  324 +
  325 +- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
  326 +
  327 + if ([searchText isEqualToString:@""]) {
  328 + _maskView.hidden = NO;
  329 + _noneLab.text = @"";
  330 +
  331 + return;
  332 + }
  333 + searchText = [searchText chineseTransformPinyin:searchText];
  334 + //需要事先情况存放搜索结果的数组
  335 + [self.searchResultArr removeAllObjects];
  336 + [self.tableView reloadData];
  337 + //加个多线程,否则数量量大的时候,有明显的卡顿现象
  338 + dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
  339 + dispatch_async(globalQueue, ^{
  340 + if (searchText != nil && searchText.length > 0) {
  341 +
  342 + //遍历需要搜索的所有内容,其中self.dataArray为存放总数据的数组
  343 +
  344 + [self.totalArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  345 + IMAUser *user = obj;
  346 + NSString *tempStr = [user showTitle];
  347 +
  348 + //----------->把所有的搜索结果转成成拼音
  349 + NSString *pinyin = CNLiveStringTransformToPinyin(tempStr);
  350 +
  351 + if ([pinyin rangeOfString:searchText options:NSCaseInsensitiveSearch].length >0 ) {
  352 + //把搜索结果存放self.resultArray数组
  353 + [self.searchResultArr addObject:user];
  354 + }
  355 + }];
  356 +
  357 + }
  358 +
  359 + //回到主线程
  360 + dispatch_async(dispatch_get_main_queue(), ^{
  361 +
  362 + if (self.searchResultArr.count > 0) {
  363 + _searchStatusActive = YES;
  364 + _maskView.hidden = YES;
  365 + [self.tableView reloadData];
  366 +
  367 + }
  368 + else
  369 + {
  370 + _maskView.hidden = NO;
  371 + _noneLab.text = [NSString stringWithFormat:@"没有找到“%@”相关结果",searchBar.text];
  372 + [self.tableView reloadData];
  373 +
  374 +
  375 + }
  376 +
  377 + });
  378 + });
  379 +
  380 +
  381 +}
  382 +
  383 +#pragma mark - 接口
  384 +/*** 进入邀请好友界面 ***/
  385 +- (void)getSelectedFriends {
  386 +
  387 + self.selectedFriends = [NSMutableArray array];
  388 + self.searchResultArr = [NSMutableArray array];
  389 + self.totalArr = [NSMutableArray array];
  390 +
  391 + NSString *familyIDStr = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  392 + [QMUITips showLoadingInView:self.view];
  393 + __weak typeof(self) weakSelf = self;
  394 + [CNLiveVoiceBoxModelHelper getFamilyMemberWithFamilyId:familyIDStr completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  395 + [QMUITips hideAllTipsInView:weakSelf.view];
  396 +
  397 + if (error) {
  398 +
  399 + NSString *showText = @"网络连接失败,请稍后再试";
  400 + if (error.code == -1001 || error.code == -1009) {//没有网络
  401 +
  402 + }else {
  403 + showText = @"请求失败,请重试";
  404 + }
  405 +
  406 + [weakSelf showEmptyViewWithImage:[UIImage imageNamed:@"wufalianjie"] text:showText detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(getSelectedFriends)];
  407 + [weakSelf setCNAPIErrorEmptyView];
  408 + weakSelf.emptyView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - kNavigationBarHeight);
  409 + weakSelf.emptyView.backgroundColor = [UIColor whiteColor];
  410 +
  411 +
  412 + }else {
  413 +
  414 + /** 有网络 */
  415 + if (weakSelf.emptyView) {
  416 + [weakSelf hideEmptyView];
  417 + }
  418 +
  419 + NSDictionary *dataDic = data;
  420 + NSMutableArray *sidArr = [NSMutableArray array];
  421 + if ([dataDic containsObjectForKey:@"sids"]) {
  422 + sidArr = dataDic[@"sids"];
  423 + }
  424 +
  425 + weakSelf.existedFriends = sidArr;
  426 + [weakSelf loadData];
  427 +
  428 + }
  429 +
  430 +
  431 + }];
  432 +
  433 +}
  434 +
  435 +
  436 +- (void)loadData {
  437 +
  438 + IMASubGroup *subGroup = [[[[IMAPlatform sharedInstance].contactMgr subGroupList] safeArray] objectAtIndex:0];
  439 +
  440 + self.totalArr = [NSMutableArray arrayWithArray:[subGroup.friends safeArray]] ;
  441 +
  442 + for (IMAUser *user in self.totalArr) {
  443 + NSLog(@"nickName = %@",user.nickName);
  444 +
  445 + }
  446 + //把自己加入通讯录
  447 + IMAHost *host = [IMAPlatform sharedInstance].host;
  448 + //如果先把自己移除掉
  449 + [self.totalArr removeObject:host];
  450 +
  451 + NSMutableArray *tempArray = [NSMutableArray array];
  452 + for (IMAUser *user in self.totalArr) {
  453 +
  454 + user.isSelected = NO;
  455 +
  456 + [self.existedFriends enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  457 +
  458 + if ([obj isEqualToString:user.userId]) {
  459 + user.isInvate = YES;
  460 + *stop = YES;
  461 + }else {
  462 + user.isInvate = NO;
  463 + }
  464 +
  465 + }];
  466 +
  467 + NSLog(@"输出是否邀请过 = %ld",user.isInvate);
  468 + [tempArray addObject:user];
  469 +
  470 + }
  471 + self.totalArr = tempArray;
  472 +
  473 + NSDictionary *dict = [BAKit_LocalizedIndexedCollation ba_localizedWithDataArray:self.totalArr localizedNameSEL:@selector(sortName)];
  474 +
  475 + self.sectionArr = dict[kBALocalizedIndexArrayKey];
  476 + self.rowArr = dict[kBALocalizedGroupArrayKey];
  477 +
  478 + [self.tableView reloadData];
  479 +
  480 +}
  481 +
  482 +
  483 +
  484 +#pragma mark - 事件实现
  485 +- (void)nextBtnAction:(UIButton *)sender {
  486 +
  487 + if (self.selectedFriends.count < 0) {
  488 + return;
  489 + }
  490 +
  491 + NSLog(@"输出内容,准备邀请");
  492 +
  493 + NSString *familyId = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  494 + [QMUITips showLoadingInView:self.view];
  495 + __weak typeof(self) weakSelf = self;
  496 + [CNLiveVoiceBoxModelHelper getSetRoleListWithFamilyId:familyId completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  497 + [QMUITips hideAllTipsInView:weakSelf.view];
  498 +
  499 + if (error) {
  500 + [QMUITips showWithText:@"获取角色列表失败" inView:self.view hideAfterDelay:0.5];
  501 + }else {
  502 + NSDictionary *contentDic = data;
  503 + NSMutableArray *familyTypes = [NSMutableArray array];
  504 + if ([contentDic containsObjectForKey:@"roleList"]) {
  505 + NSMutableArray *roleList = contentDic[@"roleList"];
  506 + [roleList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  507 + NSDictionary *dic = obj;
  508 + [familyTypes addObject:dic];
  509 +
  510 + }];
  511 + }
  512 +
  513 + if (familyTypes.count == 0) {
  514 + [QMUITips showWithText:@"无角色列表" inView:self.view hideAfterDelay:0.5];
  515 + return;
  516 + }
  517 + CNBOXInviteFriendsController *inviteVC = [[CNBOXInviteFriendsController alloc]init];
  518 + inviteVC.inviteFriendsArr = self.selectedFriends;
  519 + inviteVC.familyTypeArr = familyTypes;
  520 + inviteVC.familyID = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  521 + [[AppDelegate sharedAppDelegate] pushViewController:inviteVC];
  522 + }
  523 +
  524 + }];
  525 +
  526 +
  527 +}
  528 +
  529 +
  530 +#pragma mark - Tap
  531 +- (void)tapMaskView {
  532 + _searchStatusActive = NO;
  533 + _maskView.hidden = YES;
  534 + [self.searchBar resignFirstResponder];
  535 + [self.tableView reloadData];
  536 +}
  537 +
  538 +- (void)setSearchStatusActive:(BOOL)searchStatusActive {
  539 + _searchStatusActive = searchStatusActive;
  540 + if (_searchStatusActive) {
  541 +
  542 + }else {
  543 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight + 55, KScreenWidth, KScreenHeight - 55 - 96 - kNavigationBarHeight);
  544 + self.nextBtn.frame = CGRectMake((KScreenWidth - 275)/2, self.tableView.bottom +20, 275, 45);
  545 + }
  546 +}
  547 +
  548 +
  549 +#pragma mark - Getter
  550 +- (CNSearch *)searchBar
  551 +{
  552 + if (!_searchBar) {
  553 + _searchBar = [[CNSearch alloc] initWithFrame:CGRectZero];
  554 + _searchBar.placeholder = @"搜索";
  555 + _searchBar.delegate = self;
  556 +
  557 +
  558 + if (@available(iOS 13.0, *)) {
  559 + for (UIView *view in _searchBar.subviews.lastObject.subviews) {
  560 + if ([view isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
  561 + view.layer.contents = nil;
  562 + break;
  563 + }
  564 + }
  565 +
  566 + }else {
  567 +
  568 + //修改背景色,并移除灰色view
  569 + UIView *firstSubView = _searchBar.subviews.firstObject;
  570 + firstSubView.backgroundColor = RGBACOLOR(242, 242, 242, 1);
  571 + UIView *backgroundImageView = [firstSubView.subviews firstObject];
  572 + [backgroundImageView removeFromSuperview];
  573 +
  574 + }
  575 +
  576 + }
  577 + return _searchBar;
  578 +}
  579 +
  580 +- (UITableView *)tableView
  581 +{
  582 + if (!_tableView) {
  583 + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  584 + [_tableView registerClass:[CNContactHeaderView class] forHeaderFooterViewReuseIdentifier:@"CNContactHeaderView"];
  585 + [_tableView registerClass:[CNLiveBoxSelectFirendsCell class] forCellReuseIdentifier:kCNLiveBoxSelectFirendsCell];
  586 + _tableView.tableFooterView = [[UIView alloc] init];
  587 + _tableView.delegate = self;
  588 + _tableView.dataSource = self;
  589 + }
  590 + return _tableView;
  591 +}
  592 +
  593 +- (UIButton *)nextBtn {
  594 + if (!_nextBtn) {
  595 + _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  596 + _nextBtn.layer.masksToBounds = YES;
  597 + _nextBtn.enabled = NO;
  598 + _nextBtn.layer.cornerRadius = 22;
  599 + [_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
  600 + [_nextBtn setTitleColor:RGBCOLOR(255, 255, 255) forState:UIControlStateNormal];
  601 + [_nextBtn addTarget:self action:@selector(nextBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  602 + _nextBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  603 + _nextBtn.backgroundColor = RGBCOLOR(200, 200, 200);
  604 + }
  605 + return _nextBtn;
  606 +
  607 +}
  608 +
  609 +- (UIView *)maskView
  610 +{
  611 + if (!_maskView) {
  612 + NSInteger searchBarH = 55;
  613 + _maskView = [[UIView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight + searchBarH, KScreenWidth, KScreenHeight-kNavigationBarHeight-searchBarH)];
  614 + _maskView.hidden = YES;
  615 +
  616 + UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
  617 + UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
  618 + effectView.frame = _maskView.bounds;
  619 + [_maskView addSubview:effectView];
  620 +
  621 + _noneLab = [[UILabel alloc] initWithFrame:CGRectMake(30, 50, KScreenWidth-60, 20)];
  622 + _noneLab.textAlignment = NSTextAlignmentCenter;
  623 + _noneLab.text = @"暂无标签";
  624 + _noneLab.textColor = KTextBlackColor;
  625 + _noneLab.lineBreakMode = NSLineBreakByTruncatingMiddle;
  626 + [_maskView addSubview:_noneLab];
  627 +
  628 + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMaskView)];
  629 + [_maskView addGestureRecognizer:tap];
  630 + }
  631 + return _maskView;
  632 +}
  633 +
  634 +
  635 +- (NSMutableArray *)searchResultArr
  636 +{
  637 + if (!_searchResultArr) {
  638 + _searchResultArr = [[NSMutableArray alloc] init];
  639 + }
  640 + return _searchResultArr;
  641 +}
  642 +
  643 +
  644 +
  645 +- (void)didReceiveMemoryWarning {
  646 + [super didReceiveMemoryWarning];
  647 + // Dispose of any resources that can be recreated.
  648 +}
  649 +
  650 +
  651 +
  652 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxUserManagerController.h 0 → 100644
  1 +//
  2 +// CNBoxUserManagerController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxDeviceModel.h"
  11 +#import "CNLiveAllVoiceBoxModel.h"
  12 +
  13 +NS_ASSUME_NONNULL_BEGIN
  14 +
  15 +@interface CNBoxUserManagerController : CNCommonViewController
  16 +
  17 +/*** 获取家庭人员列表 ***/
  18 +- (void)loadData;
  19 +
  20 +@property (copy, nonatomic) NSString *familyID;
  21 +
  22 +
  23 +@end
  24 +
  25 +NS_ASSUME_NONNULL_END
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNBoxUserManagerController.m 0 → 100644
  1 +//
  2 +// CNBoxUserManagerController.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/10/9.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNBoxUserManagerController.h"
  10 +#import "FTPopOverMenu.h"
  11 +#import "CNBoxSelectFriendsController.h"
  12 +#import "CNBoxEditQRCodeController.h"
  13 +#import "CNBoxUserMannagerCell.h"
  14 +#import "CNLiveVoiceBoxModelHelper.h"
  15 +#import "CNBoxUserAllModel.h"
  16 +#import "CNLiveBoxRoleAlertView.h"
  17 +#import "CNLiveBoxRoleModel.h"
  18 +#import "CNBoxMasterManager.h"
  19 +
  20 +@interface CNBoxUserManagerController ()<UITableViewDelegate,UITableViewDataSource>
  21 +
  22 +/*** 头部headerView ***/
  23 +@property (strong, nonatomic) UIView *tableViewHeaderV;
  24 +
  25 +/*** 底部footerView ***/
  26 +@property (strong, nonatomic) UIView *tableViewFooterV;
  27 +/*** 邀请网家家好友按钮 ***/
  28 +@property (strong, nonatomic) UIButton *inviteBtn;
  29 +/*** 生成二维码邀请 ***/
  30 +@property (strong, nonatomic) UIButton *inviteCodeBtn;
  31 +
  32 +@property (nonatomic, strong) NSArray<FTPopOverMenuModel *> *menuObjectArray;
  33 +
  34 +@property (nonatomic, strong) NSMutableArray *dataArray;
  35 +
  36 +@property (nonatomic, strong) NSMutableArray *managerArray;
  37 +
  38 +
  39 +/*** 角色数组 ***/
  40 +@property (nonatomic, strong) NSMutableArray *rolesArray;
  41 +
  42 +/*** 列表 ***/
  43 +@property (strong, nonatomic) UITableView *tableView;
  44 +
  45 +
  46 +/*** 是否是主 ***/
  47 +@property (copy, nonatomic) NSString *isMaster;
  48 +
  49 +@property (strong, nonatomic) UIBarButtonItem *rightBarButtonItem;
  50 +
  51 +
  52 +
  53 +@end
  54 +
  55 +@implementation CNBoxUserManagerController
  56 +
  57 +- (void)viewDidLoad {
  58 + [super viewDidLoad];
  59 + // Do any additional setup after loading the view.
  60 + self.navigationController.navigationBarHidden = NO;
  61 + self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
  62 +
  63 + self.title = @"使用者管理";
  64 + /*** 右侧按钮 ***/
  65 + [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:15],NSFontAttributeName, nil] forState:UIControlStateNormal];
  66 +
  67 +
  68 + self.dataArray = [NSMutableArray array];
  69 + self.managerArray = [NSMutableArray array];
  70 + [self setupUI];
  71 + [self layoutUI];
  72 +
  73 +
  74 +}
  75 +
  76 +- (void)viewWillAppear:(BOOL)animated {
  77 + [super viewWillAppear:animated];
  78 + [self loadData];
  79 +}
  80 +
  81 +- (void)setupUI {
  82 +
  83 + [self.view addSubview:self.tableView];
  84 + [self.view addSubview:self.tableViewFooterV];
  85 +
  86 +
  87 +
  88 +}
  89 +
  90 +- (void)layoutUI {
  91 + if (@available(iOS 11.0, *)) {
  92 + self.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight - 200 - kNavigationBarHeight);
  93 + }else {
  94 + self.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - 200 - kNavigationBarHeight);
  95 + }
  96 +
  97 +}
  98 +
  99 +
  100 +#pragma mark - 按钮实现
  101 +- (void)rightButtonItemAction:(id)sender event:(UIEvent *)event{
  102 +
  103 + FTPopOverMenuConfiguration *config = [FTPopOverMenuConfiguration defaultConfiguration];
  104 + config.menuWidth = 140;
  105 + config.menuCornerRadius = 10.f;
  106 + config.separatorInset = UIEdgeInsetsMake(0, 15.f, 0, 15.f);
  107 + config.imageSize = CGSizeMake(16.f, 16.f);
  108 + config.selectedTextColor = [UIColor whiteColor];
  109 +
  110 + [FTPopOverMenu showFromEvent:event withMenuArray:self.menuObjectArray imageArray:@[@"device_invite_friends",@"device_invite_code"] configuration:config doneBlock:^(NSInteger selectedIndex) {
  111 +
  112 + NSLog(@"输出选中 = %ld",selectedIndex);
  113 + if (selectedIndex == 0) {
  114 +
  115 + [self enterSelectFriendsVC];
  116 +
  117 +
  118 +
  119 +
  120 + }else {
  121 +
  122 + [self QRCodeInviteVC];
  123 +
  124 + }
  125 +
  126 +
  127 + }dismissBlock:^{
  128 +
  129 + }];
  130 +
  131 +}
  132 +
  133 +#pragma mark - <UITableViewDelegate,UITableViewDataSource>
  134 +
  135 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  136 + if (self.dataArray.count > 0) {
  137 + return 2;
  138 + }else {
  139 + return 1;
  140 + }
  141 +}
  142 +
  143 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  144 + if (section == 0) {
  145 + return self.managerArray.count;
  146 + }else {
  147 + return self.dataArray.count;
  148 + }
  149 +
  150 +}
  151 +
  152 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  153 +
  154 + if ([self.isMaster isEqualToString:@"1"]) {//isMaster == 1 为主
  155 +
  156 + if (indexPath.section == 0) {
  157 + CNBoxUserMannagerCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNBoxUserMannagerCell forIndexPath:indexPath];
  158 + CNBoxUserModel *model = [self.managerArray objectAtIndex:indexPath.row];
  159 + if (model) {
  160 + [cell editUI:model];
  161 + }
  162 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  163 +
  164 + return cell;
  165 + }else {
  166 + CNBoxOtherUserMannagerCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNBoxOtherUserMannagerCell forIndexPath:indexPath];
  167 + CNBoxUserModel *model = [self.dataArray objectAtIndex:indexPath.row];
  168 + if (model) {
  169 + [cell editUI:model indexPath:indexPath];
  170 + }
  171 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  172 + __weak typeof(self) weakSelf = self;
  173 + cell.clickCancleBtnAction = ^(CNBoxOtherUserMannagerCell * _Nonnull cell, UIButton * _Nonnull cancleBtn) {
  174 +
  175 + CNBoxUserModel *model = [self.dataArray objectAtIndex:cell.indexpath.row];
  176 +
  177 +
  178 + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"移除提示" message:@"移除后,该用户将不再具备管理\n音箱的权限,确定移除吗? " preferredStyle:UIAlertControllerStyleAlert];
  179 +
  180 + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
  181 + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  182 + [weakSelf cancleWith:model.sid indexPath:indexPath];
  183 + }];
  184 +
  185 + [alertController addAction:cancelAction];
  186 + [alertController addAction:okAction];
  187 + [self presentViewController:alertController animated:YES completion:nil];
  188 +
  189 +
  190 + };
  191 + cell.clickEditBtnAction = ^(CNBoxOtherUserMannagerCell * _Nonnull cell, UIButton * _Nonnull editBtn) {
  192 +
  193 + [weakSelf getSetRoleListWithIndePath:cell.indexpath];
  194 +
  195 +
  196 +
  197 + };
  198 + return cell;
  199 + }
  200 +
  201 + }else {
  202 +
  203 + CNBoxUserMannagerCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNBoxUserMannagerCell forIndexPath:indexPath];
  204 +
  205 + if (indexPath.section == 0) {
  206 + CNBoxUserModel *model = [self.managerArray objectAtIndex:indexPath.row];
  207 + if (model) {
  208 + [cell editUI:model];
  209 + }
  210 + }else {
  211 + CNBoxUserModel *model = [self.dataArray objectAtIndex:indexPath.row];
  212 + if (model) {
  213 + [cell editUI:model ];
  214 + }
  215 + }
  216 +
  217 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  218 +
  219 + return cell;
  220 +
  221 +
  222 + }
  223 +
  224 +
  225 +}
  226 +
  227 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  228 + return 68;
  229 +}
  230 +
  231 +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  232 + if (section == 0) {
  233 + return 0.01;
  234 + }else {
  235 + return 10;
  236 + }
  237 +
  238 +}
  239 +
  240 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  241 +
  242 +
  243 +
  244 +}
  245 +
  246 +#pragma mark - 事件实现
  247 +- (void)rightBtnAction:(id)sender {
  248 +
  249 + self.tableView.tableHeaderView = [UIView new];
  250 +
  251 +}
  252 +
  253 +- (void)inviteBtnAction:(id)sender {
  254 +
  255 + [self enterSelectFriendsVC];
  256 +
  257 +
  258 +}
  259 +
  260 +- (void)inviteCodeAction:(id)sender {
  261 +
  262 + [self QRCodeInviteVC];
  263 +
  264 +}
  265 +
  266 +
  267 +#pragma mark - 点击弹框部分
  268 +/*** 进入邀请好友界面 ***/
  269 +- (void)enterSelectFriendsVC {
  270 +
  271 + CNBoxSelectFriendsController *selectVC = [[CNBoxSelectFriendsController alloc]init];
  272 + selectVC.familyID = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  273 + [[AppDelegate sharedAppDelegate] pushViewController:selectVC];
  274 +
  275 +}
  276 +
  277 +/*** 进入邀请我二维码界面 ***/
  278 +- (void)QRCodeInviteVC {
  279 +
  280 + CNBoxEditQRCodeController *qrCodeVC = [[CNBoxEditQRCodeController alloc]init];
  281 + qrCodeVC.familyID = [NSString stringWithFormat:@"%@",self.familyID];
  282 + [[AppDelegate sharedAppDelegate] pushViewController:qrCodeVC];
  283 +
  284 +}
  285 +
  286 +
  287 +#pragma mark - 取得数据
  288 +
  289 +
  290 +#pragma mark - 用于点击Cell部分
  291 +/*** 获取设置角色列表 ***/
  292 +- (void)getSetRoleListWithIndePath:(NSIndexPath *)indexPath {
  293 +
  294 + NSLog(@"输出内容,准备邀请");
  295 +
  296 + NSString *familyId = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  297 + [QMUITips showLoadingInView:self.view];
  298 + __weak typeof(self) weakSelf = self;
  299 + [CNLiveVoiceBoxModelHelper getSetRoleListWithFamilyId:familyId completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  300 + [QMUITips hideAllTipsInView:weakSelf.view];
  301 +
  302 + __strong typeof(weakSelf) strongSelf = weakSelf;
  303 + if (!strongSelf) {
  304 + return;
  305 + }
  306 +
  307 + if (error) {
  308 +
  309 + NSString *showText = @"网络连接失败,请稍后再试";
  310 + if (error.code == -1001 || error.code == -1009) {//没有网络
  311 +
  312 + }else {
  313 + showText = @"获取角色列表失败";
  314 + }
  315 +
  316 + [QMUITips showWithText:showText inView:self.view hideAfterDelay:0.5];
  317 + }else {
  318 + NSDictionary *contentDic = data;
  319 + NSMutableArray *familyTypes = [NSMutableArray array];
  320 + if ([contentDic containsObjectForKey:@"roleList"]) {
  321 + NSMutableArray *roleList = contentDic[@"roleList"];
  322 + [roleList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  323 +
  324 + NSDictionary *dic = obj;
  325 + CNLiveBoxRoleModel *model = [CNLiveBoxRoleModel mj_objectWithKeyValues:dic];
  326 + [familyTypes addObject:model];
  327 +
  328 + }];
  329 + }
  330 +
  331 + if (familyTypes.count == 0) {
  332 + [QMUITips showWithText:@"无角色列表" inView:self.view hideAfterDelay:0.5];
  333 + return;
  334 + }
  335 + strongSelf.rolesArray = familyTypes;
  336 + CNBoxUserModel *model = [strongSelf.dataArray objectAtIndex:indexPath.row];
  337 + [weakSelf showCNLiveBoxTipAlertViewWithModel:model indexPath:indexPath];
  338 +
  339 + }
  340 +
  341 + }];
  342 +
  343 +
  344 +}
  345 +
  346 +/*** 删除成员角色 ***/
  347 +- (void)cancleWith:(NSString *)sid indexPath:(NSIndexPath *)indexPath {
  348 +
  349 + NSString *familyIdStr = [NSString stringWithFormat:@"%@", self.familyID ?: @""];
  350 + NSString *sIdStr = [NSString stringWithFormat:@"%@",sid ?:@""];
  351 + [QMUITips showLoadingInView:self.view];
  352 + __weak typeof(self) weakSelf = self;
  353 + [CNLiveVoiceBoxModelHelper updateFamilyMemberRoleWithFamilyId:familyIdStr sid:sIdStr completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  354 + [QMUITips hideAllTipsInView:weakSelf.view];
  355 + __strong typeof(weakSelf) strongSelf = weakSelf;
  356 + if (!strongSelf) {
  357 + return;
  358 + }
  359 + if (error) {
  360 + [QMUITips showWithText:@"删除失败" inView:weakSelf.view hideAfterDelay:0.5];
  361 + }else {
  362 + [strongSelf.dataArray removeObjectAtIndex:indexPath.row];
  363 +
  364 + if (strongSelf.dataArray.count > 0) {
  365 + strongSelf.tableViewFooterV.hidden = YES;
  366 + if (@available(iOS 11.0, *)) {
  367 + strongSelf.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
  368 + }else {
  369 + strongSelf.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - kNavigationBarHeight);
  370 + }
  371 +
  372 +
  373 + }else {
  374 +
  375 + if (@available(iOS 11.0, *)) {
  376 + strongSelf.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight -200);
  377 + }else {
  378 + strongSelf.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight -200 -kNavigationBarHeight);
  379 + }
  380 + if ([strongSelf.isMaster isEqualToString:@"1"]) {
  381 + strongSelf.tableViewFooterV.hidden = NO;
  382 + }else {
  383 + strongSelf.tableViewFooterV.hidden = YES;
  384 + }
  385 +
  386 + }
  387 + [weakSelf.tableView reloadData];
  388 + }
  389 +
  390 + }];
  391 +
  392 +}
  393 +
  394 +/*** 编辑成员角色 ***/
  395 +- (void)eidtWithSid:(NSString *)sid role:(NSString *)role indexPath:(NSIndexPath *)indexPath roleName:(NSString *)roleName {
  396 +
  397 + if (sid.length <= 0 || roleName <= 0) {
  398 + [QMUITips showWithText:@"未选择角色" inView:self.view hideAfterDelay:1.5];
  399 + return;
  400 + }
  401 +
  402 + NSString *familyIdStr = [NSString stringWithFormat:@"%@", self.familyID ?: @""];
  403 + [QMUITips showLoadingInView:self.view];
  404 + __weak typeof(self) weakSelf = self;
  405 + [CNLiveVoiceBoxModelHelper editFamilyMemberRoleWithFamilyId:familyIdStr sid:sid role:role completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  406 +
  407 + [QMUITips hideAllTipsInView:weakSelf.view];
  408 + __strong typeof(weakSelf) strongSelf = weakSelf;
  409 + if (!strongSelf) {
  410 + return;
  411 + }
  412 + if (error) {
  413 + [QMUITips showWithText:@"编辑失败" inView:weakSelf.view hideAfterDelay:0.5];
  414 + }else {
  415 + CNBoxUserModel *model = [strongSelf.dataArray objectAtIndex:indexPath.row];
  416 + model.roleId = role;
  417 + model.roleName = roleName;
  418 + [weakSelf.tableView reloadData];
  419 + }
  420 +
  421 + }];
  422 +
  423 +}
  424 +
  425 +
  426 +#pragma mark - 进入界面获取管理员家庭成员
  427 +/*** 获取家庭人员列表 ***/
  428 +- (void)loadData {
  429 + [QMUITips showLoadingInView:self.view];
  430 + __weak typeof(self) weakSelf = self;
  431 +
  432 +
  433 + NSString *familyId = [NSString stringWithFormat:@"%@",self.familyID ?: @""];
  434 +
  435 + [CNLiveVoiceBoxModelHelper getFamilyRoleWithFamilyId:familyId completerBlick:^(id _Nonnull data, NSError * _Nonnull error) {
  436 + [QMUITips hideAllTipsInView:weakSelf.view];
  437 + __strong typeof(weakSelf) strongSelf = weakSelf;
  438 + if (!strongSelf) {
  439 + return;
  440 + }
  441 +
  442 + if (error) {
  443 +
  444 + NSString *showText = @"网络连接失败,请稍后再试";
  445 + if (error.code == -1001 || error.code == -1009) {//没有网络
  446 +
  447 + }else {
  448 + showText = @"请求失败,请重试";
  449 + }
  450 +
  451 + [weakSelf showEmptyViewWithImage:[UIImage imageNamed:@"wufalianjie"] text:showText detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(loadData)];
  452 + [weakSelf setCNAPIErrorEmptyView];
  453 + weakSelf.emptyView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight - kNavigationBarHeight);
  454 + weakSelf.emptyView.backgroundColor = [UIColor whiteColor];
  455 +
  456 + }else {
  457 +
  458 + /** 有网络 */
  459 + if (weakSelf.emptyView) {
  460 + [weakSelf hideEmptyView];
  461 + }
  462 +
  463 + CNBoxUserAllModel *allModel = [CNBoxUserAllModel mj_objectWithKeyValues:data];
  464 +
  465 + //这里后台isMaster == 1 是主人 0 不是 前面相反
  466 + if ([allModel.isMaster isEqualToString:@"1"]) {
  467 + strongSelf.isMaster = @"1";
  468 + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"邀请使用者" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonItemAction:event:)];
  469 + }else {
  470 + strongSelf.isMaster = @"0";
  471 + }
  472 + [strongSelf.dataArray removeAllObjects];
  473 + [strongSelf.managerArray removeAllObjects];
  474 + [allModel.familyRoleList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  475 + CNBoxUserModel *userModel = obj;
  476 + if ([userModel.roleId isEqualToString:@"11"]) {//11是管理员
  477 + [strongSelf.managerArray addObject:userModel];
  478 + }else {
  479 + [strongSelf.dataArray addObject:userModel];
  480 + };
  481 +
  482 + }];
  483 +
  484 +
  485 + if (strongSelf.dataArray.count > 0) {
  486 + strongSelf.tableViewFooterV.hidden = YES;
  487 + if (@available(iOS 11.0, *)) {
  488 + strongSelf.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
  489 + }else {
  490 + strongSelf.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight- kNavigationBarHeight);
  491 + }
  492 +
  493 +
  494 + }else {
  495 + if (@available(iOS 11.0, *)) {
  496 + strongSelf.tableView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight -200);
  497 + }else {
  498 + strongSelf.tableView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight -200-kNavigationBarHeight);
  499 + }
  500 +
  501 + if ([strongSelf.isMaster isEqualToString:@"1"]) {
  502 + strongSelf.tableViewFooterV.hidden = NO;
  503 + }else {
  504 + strongSelf.tableViewFooterV.hidden = YES;
  505 + }
  506 + }
  507 +
  508 +
  509 + [strongSelf.tableView reloadData];
  510 +
  511 + }
  512 +
  513 +
  514 + }];
  515 +
  516 +}
  517 +
  518 +#pragma mark - 实现
  519 +- (void)showCNLiveBoxTipAlertViewWithModel:(CNBoxUserModel *)model indexPath:(NSIndexPath *)indexPath {
  520 +
  521 + CNLiveBoxRoleAlertView *alerV = [CNLiveBoxRoleAlertView showAlertAddedTo:AppKeyWindow];
  522 + [alerV showAlerView];
  523 + alerV.dataArray = self.rolesArray;
  524 + alerV.boxUserModel = model;
  525 + __weak typeof(self) weakSelf = self;
  526 + alerV.clickSureBtnBlock = ^(CNLiveBoxRoleAlertView * _Nonnull view, UIButton * _Nonnull sureBtn) {
  527 + NSString *sidStr = [NSString stringWithFormat:@"%@",view.boxUserModel.sid ?: @""];
  528 + NSString *roleStr = [NSString stringWithFormat:@"%@",view.selectRole];
  529 + NSString *roleName = [NSString stringWithFormat:@"%@",view.selectRoleName];
  530 + [weakSelf eidtWithSid:sidStr role:roleStr indexPath:indexPath roleName:roleName];
  531 +
  532 + };
  533 +
  534 +}
  535 +
  536 +
  537 +#pragma mark - 属性
  538 +- (NSArray<FTPopOverMenuModel *> *)menuObjectArray {
  539 + if (!_menuObjectArray) {
  540 + _menuObjectArray = @[[[FTPopOverMenuModel alloc] initWithTitle:@"邀请网家家好友" image:@"device_invite_friends" selected:NO],[[FTPopOverMenuModel alloc] initWithTitle:@"生成二维码邀请" image:@"device_invite_code" selected:NO]];
  541 + }
  542 + return _menuObjectArray;
  543 +}
  544 +
  545 +- (UITableView *)tableView {
  546 + if (!_tableView) {
  547 + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  548 + _tableView.delegate = self;
  549 + _tableView.dataSource = self;
  550 + [_tableView registerClass:[CNBoxUserMannagerCell class] forCellReuseIdentifier:kCNBoxUserMannagerCell];
  551 + [_tableView registerClass:[CNBoxOtherUserMannagerCell class] forCellReuseIdentifier:kCNBoxOtherUserMannagerCell];
  552 + [_tableView setBackgroundColor:RGBACOLOR(242, 242, 242, 1)];
  553 + _tableView.tableHeaderView = self.tableViewHeaderV;
  554 + _tableView.tableFooterView = [UIView new];
  555 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  556 +
  557 +
  558 + }
  559 + return _tableView;
  560 +}
  561 +
  562 +- (UIView *)tableViewHeaderV {
  563 + if (!_tableViewHeaderV) {
  564 + _tableViewHeaderV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)];
  565 + [_tableViewHeaderV setBackgroundColor:RGBACOLOR(247, 176, 84, 1)];
  566 + UILabel *textL = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth - 34, 44)];
  567 + textL.textAlignment = NSTextAlignmentRight;
  568 + textL.textColor = [UIColor whiteColor];
  569 + textL.font = [UIFont systemFontOfSize:15];
  570 + [_tableViewHeaderV addSubview:textL];
  571 + textL.text = @"使用者可以共同管理音箱,最多支持10个人管理";
  572 + UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  573 + [_tableViewHeaderV addSubview:rightBtn];
  574 + rightBtn.frame = CGRectMake(KScreenWidth - 34, 0, 34, 44);
  575 + [rightBtn setImage:[UIImage imageNamed:@"device_header_cancle"] forState:UIControlStateNormal];
  576 + [rightBtn addTarget:self action:@selector(rightBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  577 +
  578 + }
  579 + return _tableViewHeaderV;
  580 +}
  581 +
  582 +- (UIView *)tableViewFooterV {
  583 +
  584 + if (!_tableViewFooterV) {
  585 + _tableViewFooterV = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenHeight - 200, KScreenWidth, 200)];
  586 + [_tableViewFooterV setBackgroundColor:[UIColor clearColor]];
  587 + _inviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  588 + [_tableViewFooterV addSubview:_inviteBtn];
  589 + _inviteBtn.frame = CGRectMake(60, 25, KScreenWidth - 120 , 44);
  590 + [_inviteBtn setTitle:@"邀请网家家好友" forState:UIControlStateNormal];
  591 + [_inviteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  592 + _inviteBtn.layer.masksToBounds = YES;
  593 + _inviteBtn.layer.cornerRadius = 22;
  594 + _inviteBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  595 + _inviteBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  596 + [_inviteBtn addTarget:self action:@selector(inviteBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  597 +
  598 + _inviteCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  599 + [_tableViewFooterV addSubview:_inviteCodeBtn];
  600 + _inviteCodeBtn.layer.masksToBounds = YES;
  601 + _inviteCodeBtn.layer.cornerRadius = 22;
  602 + _inviteCodeBtn.frame = CGRectMake(60, 89, KScreenWidth - 120 , 44);
  603 + [_inviteCodeBtn setTitle:@"生成二维码邀请" forState:UIControlStateNormal];
  604 + [_inviteCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  605 + _inviteCodeBtn.backgroundColor = RGBCOLOR(35, 212, 30);
  606 + _inviteCodeBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  607 + [_inviteCodeBtn addTarget:self action:@selector(inviteCodeAction:) forControlEvents:UIControlEventTouchUpInside];
  608 + }
  609 + return _tableViewFooterV;
  610 +
  611 +}
  612 +
  613 +
  614 +
  615 +
  616 +
  617 +@end
CNLiveVoiceBoxModule/Classes/VoiceBox/Controller/CNConnectWIFISuccessController.h 0 → 100644
  1 +//
  2 +// CNConnectWIFISuccessController.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by 梁星国 on 2019/9/17.
  6 +// Copyright © 2019 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNBoxNetResultModel.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNConnectWIFISuccessController : CNCommonViewController
  15 +
  16 +@property (strong, nonatomic) CNBoxNetResultModel *boxNetResultModel;
  17 +
  18 +@end
  19 +
  20 +NS_ASSUME_NONNULL_END