Commit c3ad1bee59534db65abdf272c1e49276da59063d
1 parent
2865f827
no message
Showing
6 changed files
with
209 additions
and
5 deletions
CNLiveBUserAgreement.podspec
CNLiveBUserAgreement/Classes/CNLiveUserAgreementController.m
| ... | ... | @@ -7,15 +7,33 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveUserAgreementController.h" |
| 10 | +#import "QMUIKit.h" | |
| 10 | 11 | #import "WKWebViewJavascriptBridge.h" |
| 11 | 12 | |
| 13 | +#import <AVFoundation/AVCaptureDevice.h> | |
| 14 | +#import <AVFoundation/AVMediaFormat.h> | |
| 15 | +#import "XFCameraController.h" | |
| 16 | +#import "TZImagePickerController.h" | |
| 17 | +#import <CNLiveRequestBastKit/CNLiveNetworking.h> | |
| 18 | +#import "CNLiveManager.h" | |
| 19 | + | |
| 12 | 20 | #import "CNLiveWebView.h" |
| 13 | 21 | |
| 14 | -@interface CNLiveUserAgreementController () | |
| 22 | +@interface CNLiveUserAgreementController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate> | |
| 23 | +@property (nonatomic, strong) NSMutableArray * images; | |
| 15 | 24 | |
| 16 | 25 | @end |
| 17 | 26 | |
| 18 | 27 | @implementation CNLiveUserAgreementController |
| 28 | +#define wjjHelpAndFeedbackImage @"wjjHelpAndFeedbackImage" //帮助与反馈->产品建议:添加照片按钮 | |
| 29 | +#define wjjSubmitImage @"wjjSubmitImage" //帮助与反馈->产品建议:点击提交 | |
| 30 | +#define wjjDelegateImage @"wjjDelegateImage" //帮助与反馈->产品建议:删除照片 | |
| 31 | +#define wjjSubmitSuccessFinal @"wjjSubmitSuccessFinal" //反馈提交(成功/失败)后隐藏loading | |
| 32 | +#define wjjFeedbackSuccess @"wjjFeedbackSuccess" //帮助与反馈 提交反馈后点击完成 | |
| 33 | +#define wjjJSGetNetStatusFromClient @"JSGetNetStatusFromClient" //h5主动从客户端获取网络状态 | |
| 34 | +#define OCSendNetStatusToJS @"OCSendNetStatusToJS" //网络状态变化信息 | |
| 35 | +#define wjjSubmitSuccess @"wjjSubmitSuccess" //帮助与反馈->产品建议:App->h5图片urls | |
| 36 | + | |
| 19 | 37 | - (void)createSubViews { |
| 20 | 38 | [super createSubViews]; |
| 21 | 39 | UIColor *color = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; |
| ... | ... | @@ -24,6 +42,84 @@ |
| 24 | 42 | #pragma mark - 交互 |
| 25 | 43 | - (void)interaction { |
| 26 | 44 | [super interaction]; |
| 45 | + __weak typeof(self)weakSelf = self; | |
| 46 | + | |
| 47 | + // 帮助与反馈->产品建议:添加照片按钮 | |
| 48 | + [self.bridge registerHandler:wjjHelpAndFeedbackImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 49 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 50 | + [weakSelf uploadPictures]; | |
| 51 | + responseCallback(data); | |
| 52 | + }]; | |
| 53 | + | |
| 54 | + // 帮助与反馈->产品建议:删除照片 | |
| 55 | + [self.bridge registerHandler:wjjDelegateImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 56 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 57 | + if ([data isKindOfClass:[NSDictionary class]]) { | |
| 58 | + NSString *index = [data objectForKey:@"index"]; | |
| 59 | + [weakSelf.images removeObjectAtIndex:[index integerValue]]; | |
| 60 | + } | |
| 61 | + responseCallback(data); | |
| 62 | + }]; | |
| 63 | + | |
| 64 | + //帮助与反馈->产品建议:点击提交 | |
| 65 | + [self.bridge registerHandler:wjjSubmitImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 66 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 67 | + NSString *text = @""; | |
| 68 | + NSString *mobile = @""; | |
| 69 | + NSString *modeltype = @""; | |
| 70 | + if ([data isKindOfClass:[NSDictionary class]]) { | |
| 71 | + text = [data objectForKey:@"text"]; | |
| 72 | + mobile = [data objectForKey:@"mobile"]; | |
| 73 | + modeltype = [data objectForKey:@"modeltype"]; | |
| 74 | + } | |
| 75 | + if (weakSelf.images.count > 0) { | |
| 76 | +// [weakSelf getimgToken]; | |
| 77 | + } else { | |
| 78 | + NSArray *array = [NSArray array]; | |
| 79 | + id data = @{ @"images": array }; | |
| 80 | + [QMUITips showLoading:@"正在提交" inView:weakSelf.view]; | |
| 81 | + // 帮助与反馈->产品建议App->h5图片urls | |
| 82 | + [weakSelf.bridge callHandler:wjjSubmitSuccess data:data responseCallback:^(id responseData) { | |
| 83 | + NSLog(@"ObjC received response: %@", responseData); | |
| 84 | + }]; | |
| 85 | + } | |
| 86 | + responseCallback(data); | |
| 87 | + }]; | |
| 88 | + | |
| 89 | + // 反馈提交(成功/失败)后隐藏loading | |
| 90 | + [self.bridge registerHandler:wjjSubmitSuccessFinal handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 91 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 92 | + [QMUITips hideAllTipsInView:weakSelf.view]; | |
| 93 | + responseCallback(data); | |
| 94 | + }]; | |
| 95 | + | |
| 96 | + // 帮助与反馈 提交反馈后点击完成 | |
| 97 | + [self.bridge registerHandler:wjjFeedbackSuccess handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 98 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 99 | + [weakSelf.navigationController popViewControllerAnimated:YES]; | |
| 100 | + responseCallback(data); | |
| 101 | + }]; | |
| 102 | + | |
| 103 | + // h5主动从客户端获取网络状态 | |
| 104 | + [self.bridge registerHandler:wjjJSGetNetStatusFromClient handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 105 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 106 | + // 向h5传递网路状态信息 | |
| 107 | + NSInteger networkStatus = 0; | |
| 108 | + if (![CNLiveNetworking isNetworking]) { | |
| 109 | + networkStatus = 0; | |
| 110 | + } | |
| 111 | + else if ([CNLiveNetworking isWWANNetwork]) { | |
| 112 | + networkStatus = 1; | |
| 113 | + } | |
| 114 | + else if ([CNLiveNetworking isWiFiNetwork]) { | |
| 115 | + networkStatus = 2; | |
| 116 | + } | |
| 117 | + id answerData = @{ @"netStatus": [NSString stringWithFormat:@"%ld",(long)networkStatus] }; | |
| 118 | + [weakSelf.bridge callHandler:OCSendNetStatusToJS data:answerData responseCallback:^(id responseData) { | |
| 119 | + NSLog(@"ObjC received response: %@", responseData); | |
| 120 | + }]; | |
| 121 | + responseCallback(data); | |
| 122 | + }]; | |
| 27 | 123 | } |
| 28 | 124 | |
| 29 | 125 | #pragma mark - Setter方法 |
| ... | ... | @@ -34,7 +130,6 @@ |
| 34 | 130 | |
| 35 | 131 | #pragma mark - CNLiveWebViewDelegate |
| 36 | 132 | - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { |
| 37 | - NSLog(@"CNLiveUserAgreementController - didFinishLoad"); | |
| 38 | 133 | if(self.title.length == 0){ |
| 39 | 134 | self.title = webView.title; |
| 40 | 135 | } |
| ... | ... | @@ -44,4 +139,77 @@ |
| 44 | 139 | |
| 45 | 140 | } |
| 46 | 141 | |
| 142 | +#pragma mark - 添加图片 | |
| 143 | +- (void)uploadPictures{ | |
| 144 | + __weak typeof(self) weakSelf = self; | |
| 145 | + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"拍照" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 146 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 147 | + if(!strongSelf) return ; | |
| 148 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 149 | + [CNLiveAuthorizationManager getAVAuthorizationStatus:^{ | |
| 150 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 151 | + if(!strongSelf) return ; | |
| 152 | + XFCameraController *cameraController = [[XFCameraController alloc] init]; | |
| 153 | + cameraController.isCanShootVideo = NO; | |
| 154 | + cameraController.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 155 | + __weak XFCameraController *weakCameraController = cameraController; | |
| 156 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 157 | + cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) { | |
| 158 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 159 | + if(!strongSelf) return ; | |
| 160 | + [strongSelf.images addObject:image]; | |
| 161 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 162 | + [weakCameraController dismissViewControllerAnimated:YES completion:nil]; | |
| 163 | + }); | |
| 164 | + }; | |
| 165 | + [strongSelf presentViewController:cameraController animated:YES completion:nil]; | |
| 166 | + }]; | |
| 167 | + | |
| 168 | + }]; | |
| 169 | + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"从手机相册中选择" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 170 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 171 | + if(!strongSelf) return ; | |
| 172 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 173 | + [CNLiveAuthorizationManager getPHAuthorizationStatus:^{ | |
| 174 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 175 | + if(!strongSelf) return ; | |
| 176 | + TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf]; | |
| 177 | + picker.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 178 | + picker.allowPickingVideo = NO; | |
| 179 | + picker.allowPreview = NO; | |
| 180 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 181 | + [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { | |
| 182 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 183 | + if(!strongSelf) return ; | |
| 184 | + [strongSelf.images addObject:[photos firstObject]]; | |
| 185 | + }]; | |
| 186 | + [strongSelf presentViewController:picker animated:YES completion:nil]; | |
| 187 | + }]; | |
| 188 | + | |
| 189 | + }]; | |
| 190 | + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 191 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 192 | + if(!strongSelf) return ; | |
| 193 | + | |
| 194 | + }]; | |
| 195 | + | |
| 196 | + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet]; | |
| 197 | + [alertController addAction:action1]; | |
| 198 | + [alertController addAction:action2]; | |
| 199 | + [alertController addAction:cancel]; | |
| 200 | + | |
| 201 | + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 202 | + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; | |
| 203 | + | |
| 204 | + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 205 | + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | |
| 206 | + | |
| 207 | + action1.buttonAttributes = titleAttributs; | |
| 208 | + action2.buttonAttributes = titleAttributs; | |
| 209 | + cancel.buttonAttributes = cancelAttributs; | |
| 210 | + | |
| 211 | + [alertController showWithAnimated:YES]; | |
| 212 | + | |
| 213 | +} | |
| 214 | + | |
| 47 | 215 | @end | ... | ... |
CNLiveBUserAgreement/Classes/CNLiveUserAgreementManager.m
| ... | ... | @@ -64,7 +64,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 64 | 64 | } |
| 65 | 65 | else{ |
| 66 | 66 | if ([responseObject isKindOfClass:[NSArray class]]) { |
| 67 | - BOOL closeHidden = NO; | |
| 67 | + BOOL closeHidden = YES; | |
| 68 | 68 | for (NSDictionary *dic in responseObject) { |
| 69 | 69 | |
| 70 | 70 | switch (type) { |
| ... | ... | @@ -102,7 +102,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 102 | 102 | { |
| 103 | 103 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bzfk"]) { |
| 104 | 104 | if (success) { |
| 105 | - success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 105 | + success(dic[@"detailUrl"], dic[@"title"], !closeHidden); | |
| 106 | 106 | return ; |
| 107 | 107 | } |
| 108 | 108 | } | ... | ... |
Example/CNLiveBUserAgreement.xcodeproj/project.pbxproj
| ... | ... | @@ -307,32 +307,58 @@ |
| 307 | 307 | inputPaths = ( |
| 308 | 308 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-frameworks.sh", |
| 309 | 309 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", |
| 310 | + "${BUILT_PRODUCTS_DIR}/CNLiveAVCamera/CNLiveAVCamera.framework", | |
| 310 | 311 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseClass/CNLiveBaseClass.framework", |
| 311 | 312 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", |
| 313 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", | |
| 314 | + "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework", | |
| 312 | 315 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", |
| 316 | + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", | |
| 313 | 317 | "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", |
| 318 | + "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | |
| 319 | + "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework", | |
| 314 | 320 | "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework", |
| 315 | 321 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 316 | 322 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 323 | + "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", | |
| 324 | + "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", | |
| 325 | + "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", | |
| 317 | 326 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", |
| 318 | 327 | "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", |
| 319 | 328 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 329 | + "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", | |
| 330 | + "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework", | |
| 331 | + "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", | |
| 320 | 332 | "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", |
| 333 | + "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", | |
| 321 | 334 | ); |
| 322 | 335 | name = "[CP] Embed Pods Frameworks"; |
| 323 | 336 | outputPaths = ( |
| 324 | 337 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", |
| 338 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveAVCamera.framework", | |
| 325 | 339 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseClass.framework", |
| 326 | 340 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", |
| 341 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", | |
| 342 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework", | |
| 327 | 343 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", |
| 344 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", | |
| 328 | 345 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", |
| 346 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | |
| 347 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework", | |
| 329 | 348 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework", |
| 330 | 349 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 331 | 350 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 351 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", | |
| 352 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", | |
| 353 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", | |
| 332 | 354 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", |
| 333 | 355 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", |
| 334 | 356 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 357 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", | |
| 358 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework", | |
| 359 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", | |
| 335 | 360 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", |
| 361 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", | |
| 336 | 362 | ); |
| 337 | 363 | runOnlyForDeploymentPostprocessing = 0; |
| 338 | 364 | shellPath = /bin/sh; | ... | ... |
Example/CNLiveBUserAgreement/CNLIVEViewController.m
Example/Podfile
| ... | ... | @@ -5,6 +5,9 @@ use_frameworks! |
| 5 | 5 | platform :ios, '9.0' |
| 6 | 6 | target 'CNLiveBUserAgreement_Example' do |
| 7 | 7 | pod 'CNLiveBUserAgreement', :path => '../' |
| 8 | + #依赖三方私有库,如果里面有.a的时候加上这个 | |
| 9 | + pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} | |
| 10 | + end | |
| 8 | 11 | |
| 9 | 12 | target 'CNLiveBUserAgreement_Tests' do |
| 10 | 13 | inherit! :search_paths | ... | ... |