Commit 91798ff491fa70d99f4c98baf10db84591a64735

Authored by zhangxiaowen
1 parent c421b988

no message

CNLiveQrCodeModule/Classes/Controller/CNLiveGroupQrCodeController.m
... ... @@ -89,7 +89,7 @@ static const CGFloat timeValue = 1.5;
89 89 }
90 90 - (CNLiveGroupQrCodeView *)groupView {
91 91 if (!_groupView) {
92   - _groupView = [[CNLiveGroupQrCodeView alloc] initWithFrame:CGRectMake(0, 0, 310, 342)];
  92 + _groupView = [[CNLiveGroupQrCodeView alloc] initWithFrame:CGRectMake(0, 0, 310, 450)];
93 93 _groupView.center = CGPointMake(self.view.center.x, self.view.center.y-20);
94 94 _groupView.layer.masksToBounds = YES;
95 95 _groupView.layer.cornerRadius = 10;
... ... @@ -172,8 +172,6 @@ static const CGFloat timeValue = 1.5;
172 172 #pragma mark - 分享二维码
173 173 - (void)shareDidClicked:(UIButton *)btn{
174 174 UIImage *image = [self generateImage:self.groupView];
175   - NSArray *imageArray = @[@"sport_china_download"].copy;
176   - NSArray *titleArray = @[@"保存"].copy;
177 175 // [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) {
178 176 //
179 177 // } CompleterBlock:^(CNLiveShareResultType resultType, CNLiveSharePlatformType platformType, NSString *typtString) {
... ...
CNLiveQrCodeModule/Classes/View/CNLiveGroupQrCodeView.m
... ... @@ -11,6 +11,7 @@
11 11 #import <SDWebImage/SDWebImage.h>
12 12 #import "QMUIKit.h"
13 13 #import "SGQRCode.h"//二维码库
  14 +#import "MJExtension.h"
14 15  
15 16 #import "CNUserInfoManager.h"
16 17 #import "CNLiveCategory.h"
... ... @@ -22,7 +23,7 @@
22 23 @interface CNLiveGroupQrCodeView()
23 24 @property (nonatomic, strong) UIImageView *groupHead;
24 25 @property (nonatomic, strong) UILabel *groupName;
25   -@property (nonatomic, strong) UIImageView *qrcode;
  26 +@property (nonatomic, strong) UIImageView *qrCode;
26 27 @property (nonatomic, strong) UILabel *desc;
27 28  
28 29 @end
... ... @@ -56,8 +57,8 @@ static const NSInteger margin = 15;
56 57  
57 58 }];
58 59  
59   - [self addSubview:self.qrcode];
60   - [self.qrcode mas_makeConstraints:^(MASConstraintMaker *make) {
  60 + [self addSubview:self.qrCode];
  61 + [self.qrCode mas_makeConstraints:^(MASConstraintMaker *make) {
61 62 make.centerX.mas_equalTo(self.mas_centerX);
62 63 make.top.mas_equalTo(self.groupName.mas_bottom).mas_offset(margin);
63 64 make.width.mas_equalTo(220.0);
... ... @@ -68,8 +69,8 @@ static const NSInteger margin = 15;
68 69 [self.desc mas_makeConstraints:^(MASConstraintMaker *make) {
69 70 make.left.mas_equalTo(self.mas_left).mas_offset(margin);
70 71 make.right.mas_equalTo(self.mas_right).mas_offset(-margin);
71   - make.top.mas_equalTo(self.qrcode.mas_bottom).mas_offset(0);
72   - make.bottom.mas_equalTo(self.mas_bottom).mas_offset(-0);
  72 + make.top.mas_equalTo(self.qrCode.mas_bottom);
  73 + make.bottom.mas_equalTo(self.mas_bottom);
73 74  
74 75 }];
75 76 }
... ... @@ -86,23 +87,22 @@ static const NSInteger margin = 15;
86 87 _group = group;
87 88 if(group.avatorIcon){
88 89 _groupHead.image = group.avatorIcon;
  90 +
89 91 }else{
90 92 // [_groupHead setImageWithGroupId:group.groupInfo.groupId];
91 93  
92 94 }
93 95 _groupName.text = group.groupInfo.groupName;
94 96  
95   -// [QMUITips showLoadingInView:self];
96   -// [[CNGroupActiveViewModel sharedCNGroupActiveViewModel] requestServerForDownloadAppActionUrlSourceCompleterBlock:^(NSString *shareUrl) {
97   -// [QMUITips hideAllTipsInView:self];
98   -// NSString *wjjQr = [EncryptAndDecrypt base64StringFromText:[@{@"content":[@{@"groupId":CNLiveStringIsEmpty(group.groupInfo.groupId)?@"":group.groupInfo.groupId,@"groupName":group.groupInfo.groupName} mj_JSONString],@"type":@"groupQrType"} mj_JSONString] encryptKey:@"cnliveIm"];
99   -// NSString *qrCode = [NSString stringWithFormat:@"%@wjjQrSkipType=wjjQrPublicGroupType&isWjjQr=%@",shareUrl,wjjQr];
100   -// self.qrcode.image = [SGQRCodeGenerateManager generateWithLogoQRCodeData:qrCode logoImageName:nil logoScaleToSuperView:0.2];
101   -//
102   -// UIImage *xw_image = [self getImageWithImageName:@"qr_code_icon" bundleName:@"CNLiveQrCodeModule" targetClass:[self class]];
103   -// [strongSelf.qrCode sd_setImageWithURL:nil placeholderImage:[SGQRCodeObtain generateQRCodeWithData:jsonStr size:SCREEN_WIDTH-12*margin logoImage:xw_image ratio:0.2]];
104   -//
105   -// }];
  97 + NSString *groupId = CNLiveStringIsEmpty(group.groupInfo.groupId)?@"":group.groupInfo.groupId;
  98 + NSString *wjjQr = [NSString base64StringFromText:[@{@"content":[@{@"groupId":groupId,@"groupName":@"group.groupInfo.groupName"} mj_JSONString],@"type":@"groupQrType"} mj_JSONString] encryptKey:@"cnliveIm"];
  99 + NSString *jsonStr = [NSString stringWithFormat:@"%@wjjQrSkipType=wjjQrPublicGroupType&isWjjQr=%@",@"shareUrl",wjjQr];
  100 + UIImage *xw_image = [self getImageWithImageName:@"qr_code_icon" bundleName:@"CNLiveQrCodeModule" targetClass:[self class]];
  101 + UIImage *image = [SGQRCodeObtain generateQRCodeWithData:jsonStr size:220.0 logoImage:xw_image ratio:0.2];
  102 +
  103 + _qrCode.image = image;
  104 + [[SDImageCache sharedImageCache] storeImage:image forKey:groupId toDisk:YES completion:NULL];
  105 +
106 106 }
107 107  
108 108 #pragma mark - Getter
... ... @@ -111,8 +111,7 @@ static const NSInteger margin = 15;
111 111 _groupHead = [[UIImageView alloc] init];
112 112 _groupHead.backgroundColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
113 113 UIImage *xw_image = [self getImageWithImageName:@"default_avatar_f" bundleName:@"CNLiveQrCodeModule" targetClass:[self class]];
114   - [_groupHead sd_setImageWithURL:[NSURL URLWithString:CNUserShareModel.faceUrl] placeholderImage:xw_image];
115   -
  114 + _groupHead.image = xw_image;
116 115 }
117 116 return _groupHead;
118 117 }
... ... @@ -123,18 +122,20 @@ static const NSInteger margin = 15;
123 122 _groupName.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
124 123 _groupName.font = UIFontMake(15);
125 124 _groupName.numberOfLines = 1;
126   - _groupName.text = @"张晓文";
  125 + _groupName.text = @"";
127 126 }
128 127 return _groupName;
129 128 }
130 129  
131   -- (UIImageView *)qrcode {
132   - if (!_qrcode) {
133   - _qrcode = [[UIImageView alloc] init];
134   - _qrcode.backgroundColor = [UIColor greenColor];
135   - _qrcode.image = [SGQRCodeObtain generateQRCodeWithData:@"群组id" size:220.0 logoImage:nil ratio:0.2];
  130 +- (UIImageView *)qrCode {
  131 + if (!_qrCode) {
  132 + _qrCode = [[UIImageView alloc] init];
  133 + _qrCode.backgroundColor = [UIColor greenColor];
  134 + NSString *groupId = CNLiveStringIsEmpty(self.group.groupInfo.groupId)?@"":self.group.groupInfo.groupId;
  135 + UIImage *image = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:groupId];
  136 + _qrCode.image = image;
136 137 }
137   - return _qrcode;
  138 + return _qrCode;
138 139 }
139 140  
140 141 - (UILabel *)desc {
... ... @@ -142,9 +143,10 @@ static const NSInteger margin = 15;
142 143 _desc = [[UILabel alloc] init];
143 144 _desc.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
144 145 _desc.font = UIFontMake(15);
145   - _desc.numberOfLines = 1;
146   - _desc.text = @"用“网家家”扫描二维码,加入该群";
147   - _desc.textAlignment = NSTextAlignmentCenter;
  146 + _desc.numberOfLines = 0;
  147 + _desc.lineBreakMode = NSLineBreakByWordWrapping;
  148 + _desc.textAlignment = NSTextAlignmentLeft;
  149 + _desc.text = @">>保存到手机:用户有网家家客户端前提下,可以直接识别二维码进群聊天\n\n>>分享二维码:用户需先点击识别二维 码下载网家家客户端后,在已登录状态下,直接进入申请加群界面,点击“申请加群”按钮,进群聊天";
148 150 }
149 151 return _desc;
150 152 }
... ...
CNLiveQrCodeModule/Classes/View/CNLiveMyQrCodeView.m
... ... @@ -140,7 +140,7 @@ static const CGFloat timeValue = 1.5;
140 140 UIImage *xw_image = [self getImageWithImageName:@"qr_code_icon" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveMyQrCodeView class]];
141 141  
142 142 UIImage *image = [SGQRCodeObtain generateQRCodeWithData:jsonStr size:SCREEN_WIDTH-12*margin logoImage:xw_image ratio:0.2];
143   - [strongSelf.qrCode sd_setImageWithURL:nil placeholderImage:image];
  143 + strongSelf.qrCode.image = image;
144 144 [[SDImageCache sharedImageCache] storeImage:image forKey:CNUserShareModel.uid toDisk:YES completion:NULL];
145 145  
146 146 if([type isEqualToString:@"reset"]){
... ... @@ -184,8 +184,7 @@ static const CGFloat timeValue = 1.5;
184 184 _header = [[UIImageView alloc] init];
185 185 _header.layer.masksToBounds = YES;
186 186 _header.layer.cornerRadius = 5;
187   - UIImage *xw_image = [self getImageWithImageName:@"default_avatar_f" bundleName:@"CNLiveQrCodeModule" targetClass:[self class]];
188   - [_header sd_setImageWithURL:[NSURL URLWithString:CNUserShareModel.faceUrl] placeholderImage:xw_image];
  187 + _header.image = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:CNUserShareModel.uid];
189 188 }
190 189 return _header;
191 190 }
... ...
Example/CNLiveQrCodeModule/CNLIVEAppDelegate.m
... ... @@ -63,7 +63,7 @@
63 63 }];
64 64 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
65 65  
66   - CNLiveMyQrCodeController *vc = [[CNLiveMyQrCodeController alloc] init];
  66 + CNLiveGroupQrCodeController *vc = [[CNLiveGroupQrCodeController alloc] init];
67 67 // vc.ID = @"http://www.baidu.com";
68 68 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
69 69  
... ...