Commit eb5fe0c75845bcb71945530d831be98c33540ebe
1 parent
c9c80a3e
no message
Showing
7 changed files
with
68 additions
and
44 deletions
CNLiveQrCodeModule.podspec
| ... | ... | @@ -29,7 +29,7 @@ TODO: 网家家-二维码模块. |
| 29 | 29 | # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' |
| 30 | 30 | |
| 31 | 31 | s.ios.deployment_target = '9.0' |
| 32 | - | |
| 32 | + | |
| 33 | 33 | # s.source_files = 'CNLiveQrCodeModule/Classes/**/*' |
| 34 | 34 | |
| 35 | 35 | s.resource_bundles = { |
| ... | ... | @@ -75,8 +75,14 @@ TODO: 网家家-二维码模块. |
| 75 | 75 | |
| 76 | 76 | # 服务层 |
| 77 | 77 | s.dependency 'CNLiveServices' |
| 78 | + | |
| 79 | + # 环境 | |
| 80 | + s.dependency 'CNLiveEnvironment' | |
| 81 | + | |
| 82 | + # 数据请求 | |
| 83 | + s.dependency 'CNLiveRequestBastKit' | |
| 78 | 84 | |
| 79 | 85 | # 用户信息本地化 |
| 80 | 86 | s.dependency 'CNLiveUserManagement' |
| 81 | - | |
| 87 | + | |
| 82 | 88 | end | ... | ... |
CNLiveQrCodeModule/Classes/Controller/CNLiveGroupQrCodeController.m
| ... | ... | @@ -11,6 +11,9 @@ |
| 11 | 11 | #import "QMUIKit.h" |
| 12 | 12 | #import "SGQRCode.h"//二维码库 |
| 13 | 13 | |
| 14 | +//#import "CNLiveShareManager.h" | |
| 15 | +//#import "CNLiveShareToolDefine.h" | |
| 16 | + | |
| 14 | 17 | #import "CNLiveQrCodeNavigationBar.h" |
| 15 | 18 | #import "CNLiveGroupQrcodeView.h" |
| 16 | 19 | #import "CNLiveQrCodeNavigationBar.h" |
| ... | ... | @@ -169,12 +172,12 @@ static const NSInteger margin = 10; |
| 169 | 172 | UIImage *image = [self generateImage:self.groupView]; |
| 170 | 173 | NSArray *imageArray = @[@"sport_china_download"].copy; |
| 171 | 174 | NSArray *titleArray = @[@"保存"].copy; |
| 172 | - __weak typeof(self) weakSelf = self; | |
| 173 | 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) { |
| 174 | 176 | // |
| 175 | 177 | // } CompleterBlock:^(CNLiveShareResultType resultType, CNLiveSharePlatformType platformType, NSString *typtString) { |
| 176 | 178 | // |
| 177 | 179 | // }]; |
| 180 | + | |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | 183 | // UIView转UIImage | ... | ... |
CNLiveQrCodeModule/Classes/Controller/CNLiveMyQrCodeController.m
| ... | ... | @@ -116,12 +116,10 @@ static const CGFloat timeValue = 1.5; |
| 116 | 116 | |
| 117 | 117 | } completionHandler:^(BOOL success, NSError * _Nullable error) { |
| 118 | 118 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 119 | - if (error) { | |
| 120 | - NSLog(@"%@",@"保存失败"); | |
| 121 | - [QMUITips showError:@"保存失败" inView:self.view hideAfterDelay:timeValue]; | |
| 122 | - } else { | |
| 123 | - NSLog(@"%@",@"保存成功"); | |
| 119 | + if (success) { | |
| 124 | 120 | [QMUITips showSucceed:@"保存成功" inView:self.view hideAfterDelay:timeValue]; |
| 121 | + } else { | |
| 122 | + [QMUITips showError:@"保存失败" inView:self.view hideAfterDelay:timeValue]; | |
| 125 | 123 | } |
| 126 | 124 | }); |
| 127 | 125 | |
| ... | ... | @@ -180,7 +178,6 @@ static const CGFloat timeValue = 1.5; |
| 180 | 178 | QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { |
| 181 | 179 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 182 | 180 | if(!strongSelf) return ; |
| 183 | - [strongSelf.qrCodeView generateQRCode:@"reset"]; | |
| 184 | 181 | self.navigationBar.right.userInteractionEnabled = YES; |
| 185 | 182 | |
| 186 | 183 | }]; |
| ... | ... | @@ -224,7 +221,7 @@ static const CGFloat timeValue = 1.5; |
| 224 | 221 | } |
| 225 | 222 | - (CNLiveMyQrCodeView *)qrCodeView { |
| 226 | 223 | if (!_qrCodeView) { |
| 227 | - _qrCodeView = [[CNLiveMyQrCodeView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-2*margin, 420)]; | |
| 224 | + _qrCodeView = [[CNLiveMyQrCodeView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-2*margin, SCREEN_WIDTH-2*margin+40)]; | |
| 228 | 225 | _qrCodeView.center = self.view.center; |
| 229 | 226 | } |
| 230 | 227 | return _qrCodeView; | ... | ... |
CNLiveQrCodeModule/Classes/View/CNLiveMyQrCodeView.m
| ... | ... | @@ -12,6 +12,9 @@ |
| 12 | 12 | #import "QMUIKit.h" |
| 13 | 13 | #import "SGQRCode.h"//二维码库 |
| 14 | 14 | |
| 15 | +#import "CNLiveNetworking.h" | |
| 16 | +#import "CNLiveEnvironment.h" | |
| 17 | + | |
| 15 | 18 | @interface CNLiveMyQrCodeView () |
| 16 | 19 | @property (nonatomic, strong) UIImageView *header; |
| 17 | 20 | @property (nonatomic, strong) UILabel *name; |
| ... | ... | @@ -40,7 +43,7 @@ static const CGFloat timeValue = 1.5; |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | - (void)dealloc { |
| 43 | - NSLog(@"XWMyQrCodeView -- dealloc"); | |
| 46 | + NSLog(@"CNLiveMyQrCodeView -- dealloc"); | |
| 44 | 47 | |
| 45 | 48 | } |
| 46 | 49 | |
| ... | ... | @@ -72,11 +75,11 @@ static const CGFloat timeValue = 1.5; |
| 72 | 75 | make.height.equalTo(self.name.mas_height); |
| 73 | 76 | |
| 74 | 77 | }]; |
| 75 | - | |
| 78 | + | |
| 76 | 79 | [_qrCode mas_makeConstraints:^(MASConstraintMaker *make) { |
| 77 | 80 | make.centerX.equalTo(self.mas_centerX).with.offset(0); |
| 78 | 81 | make.top.equalTo(self.header.mas_bottom).with.offset(margin); |
| 79 | - make.width.height.equalTo(self.mas_width).with.offset(-4*margin); | |
| 82 | + make.width.height.equalTo(self.mas_width).with.offset(-6*margin); | |
| 80 | 83 | |
| 81 | 84 | }]; |
| 82 | 85 | |
| ... | ... | @@ -91,35 +94,39 @@ static const CGFloat timeValue = 1.5; |
| 91 | 94 | |
| 92 | 95 | // 重置二维码 |
| 93 | 96 | - (void)generateQRCode:(NSString *)type{ |
| 94 | -// NSDictionary *params = @{ | |
| 95 | -// @"appId":@"AppId", | |
| 96 | -// @"sid":@"uid", | |
| 97 | -// @"type":type | |
| 98 | -// }; | |
| 99 | -// __weak typeof(self) weakSelf = self; | |
| 100 | -// [GetViewData POST:XWGenOrResetCodeUrl params:params success:^(NSString * _Nullable code, id _Nullable dataObj) { | |
| 101 | -// if (dataObj) { | |
| 102 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 103 | -// if(!strongSelf) return ; | |
| 104 | -// NSDictionary *dic = @{@"content":[XWCryptoDES encryptUseDES:[self dictionaryToJsonString:@{@"name":@"张晓文",@"id":@"1243124"}] key:AppDESKey],@"type":@"user"}; | |
| 105 | -// NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; | |
| 106 | -// NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | |
| 107 | -// UIImage *image = [UIImage xw_getImageName:@"qr_code_icon" bundle:@"XWMyModule.bundle/XWMyModule" targetClass:[XWMyQrCodeView class]]; | |
| 108 | -// strongSelf.qrCode.image = [SGQRCodeObtain generateQRCodeWithData:jsonStr size:180.0 logoImage:image ratio:0.2]; | |
| 109 | -// }else{ | |
| 110 | -// [XWAlertView alertErrorViewWithTextMessage:@"生成失败" view:XW_AppKeyWindow]; | |
| 111 | -// | |
| 112 | -// } | |
| 113 | -// } failure:^(NSError * _Nullable error) { | |
| 114 | -// [XWAlertView alertErrorViewWithTextMessage:@"生成失败" view:XW_AppKeyWindow]; | |
| 115 | -// | |
| 116 | -// }]; | |
| 117 | -// NSDictionary *dic = @{@"content":[XWCryptoDES encryptUseDES:[self dictionaryToJsonString:@{@"name":@"张晓文",@"id":@"1243124"}] key:AppDESKey],@"type":@"user"}; | |
| 118 | -// NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; | |
| 119 | -// NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | |
| 120 | -// UIImage *image = [self xw_getImageName:@"qr_code_icon" bundleName:@"XWMyModule.bundle/XWMyModule" targetClass:[XWMyQrCodeView class]]; | |
| 121 | -// self.qrCode.image = [SGQRCodeObtain generateQRCodeWithData:jsonStr size:180.0 logoImage:image ratio:0.2]; | |
| 122 | -// | |
| 97 | + NSDictionary *params = @{ | |
| 98 | + @"appId":AppId, | |
| 99 | + @"sid":@"10514405", | |
| 100 | + @"type":type | |
| 101 | + }; | |
| 102 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 103 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 104 | + [QMUITips showLoadingInView:self]; | |
| 105 | + __weak typeof(self) weakSelf = self; | |
| 106 | + | |
| 107 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGenOrResetCodeUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 108 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 109 | + if(!strongSelf) return; | |
| 110 | + [QMUITips hideAllToastInView:strongSelf animated:YES]; | |
| 111 | + if(!error){ | |
| 112 | + //对content 先加密 再转为 json 字符串 | |
| 113 | +// NSDictionary *dic = @{@"content":[EncryptAndDecrypt base64StringFromText:data[@"qrcode"] encryptKey:AppDESKey],@"type":@"user"}; | |
| 114 | +// NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; | |
| 115 | +// NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | |
| 116 | + | |
| 117 | + strongSelf.qrCode.image = [SGQRCodeObtain generateQRCodeWithData:@"群组id" size:SCREEN_WIDTH-12*margin logoImage:nil ratio:0.2]; | |
| 118 | + if([type isEqualToString:@"reset"]){ | |
| 119 | + [QMUITips showSucceed:@"重置成功" inView:strongSelf hideAfterDelay:timeValue]; | |
| 120 | + } | |
| 121 | + | |
| 122 | + }else{ | |
| 123 | + if([type isEqualToString:@"reset"]){ | |
| 124 | + [QMUITips showError:@"重置失败" inView:strongSelf hideAfterDelay:timeValue]; | |
| 125 | + } | |
| 126 | + | |
| 127 | + } | |
| 128 | + }]; | |
| 129 | + | |
| 123 | 130 | } |
| 124 | 131 | |
| 125 | 132 | // 字典转json字符串 |
| ... | ... | @@ -144,7 +151,6 @@ static const CGFloat timeValue = 1.5; |
| 144 | 151 | - (UIImageView *)header { |
| 145 | 152 | if (!_header) { |
| 146 | 153 | _header = [[UIImageView alloc] init]; |
| 147 | - _header.backgroundColor = [UIColor redColor]; | |
| 148 | 154 | _header.layer.masksToBounds = YES; |
| 149 | 155 | _header.layer.cornerRadius = 5; |
| 150 | 156 | UIImage *xw_image = [self xw_getImageName:@"default_avatar_f" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveMyQrCodeView class]]; | ... | ... |
Example/CNLiveQrCodeModule.xcodeproj/project.pbxproj
| ... | ... | @@ -349,8 +349,11 @@ |
| 349 | 349 | ); |
| 350 | 350 | inputPaths = ( |
| 351 | 351 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveQrCodeModule_Example/Pods-CNLiveQrCodeModule_Example-frameworks.sh", |
| 352 | + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", | |
| 352 | 353 | "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", |
| 354 | + "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | |
| 353 | 355 | "${BUILT_PRODUCTS_DIR}/CNLiveQrCodeModule/CNLiveQrCodeModule.framework", |
| 356 | + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | |
| 354 | 357 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 355 | 358 | "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", |
| 356 | 359 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", |
| ... | ... | @@ -361,8 +364,11 @@ |
| 361 | 364 | ); |
| 362 | 365 | name = "[CP] Embed Pods Frameworks"; |
| 363 | 366 | outputPaths = ( |
| 367 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", | |
| 364 | 368 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", |
| 369 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | |
| 365 | 370 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveQrCodeModule.framework", |
| 371 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | |
| 366 | 372 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 367 | 373 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", |
| 368 | 374 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", | ... | ... |
Example/CNLiveQrCodeModule/CNLIVEAppDelegate.m
| ... | ... | @@ -11,6 +11,10 @@ |
| 11 | 11 | #import "CNLiveScanQrCodeController.h" |
| 12 | 12 | #import "CNLiveGroupQrCodeController.h" |
| 13 | 13 | #import "CNLiveScanResultController.h" |
| 14 | +#import "CNLiveEnvironmentManager.h" | |
| 15 | + | |
| 16 | +#import "CNLiveNetworking.h" | |
| 17 | +#import "CNLiveEnvironment.h" | |
| 14 | 18 | |
| 15 | 19 | @implementation CNLIVEAppDelegate |
| 16 | 20 | |
| ... | ... | @@ -18,6 +22,8 @@ |
| 18 | 22 | { |
| 19 | 23 | // Override point for customization after application launch. |
| 20 | 24 | |
| 25 | + [CNLiveEnvironmentManager setEnvironment:CNLiveDebugAppStore]; | |
| 26 | +// [self networkParamAction]; | |
| 21 | 27 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; |
| 22 | 28 | |
| 23 | 29 | CNLiveMyQrCodeController *vc = [[CNLiveMyQrCodeController alloc] init]; | ... | ... |