Commit fc076ec7e10ebfb06bb0bc5cf7e83a254cb47a64
1 parent
c9f1fff7
no message
Showing
4 changed files
with
390 additions
and
387 deletions
CNLiveBUserAgreement.podspec
CNLiveBUserAgreement/Classes/CNLiveUserAgreementController.h
| ... | ... | @@ -6,13 +6,11 @@ |
| 6 | 6 | // Copyright (c) 2019 153993236@qq.com. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -//#import "CNLiveInteractionWebController.h" | |
| 10 | -#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveInteractionWebController.h" | |
| 11 | 10 | |
| 12 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 13 | 12 | |
| 14 | -//@interface CNLiveUserAgreementController : CNLiveInteractionWebController | |
| 15 | -@interface CNLiveUserAgreementController : UIViewController | |
| 13 | +@interface CNLiveUserAgreementController : CNLiveInteractionWebController | |
| 16 | 14 | |
| 17 | 15 | |
| 18 | 16 | @end | ... | ... |
CNLiveBUserAgreement/Classes/CNLiveUserAgreementController.m
| ... | ... | @@ -7,27 +7,26 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveUserAgreementController.h" |
| 10 | -//#import "QMUIKit.h" | |
| 11 | -////#import "WKWebViewJavascriptBridge.h" | |
| 12 | -//#import "QNUploadManager.h" | |
| 13 | -//#import "QNResponseInfo.h" | |
| 14 | -// | |
| 15 | -//#import <AVFoundation/AVCaptureDevice.h> | |
| 16 | -//#import <AVFoundation/AVMediaFormat.h> | |
| 17 | -//#import "XFCameraController.h" | |
| 18 | -//#import "TZImagePickerController.h" | |
| 19 | -//#import <CNLiveRequestBastKit/CNLiveNetworking.h> | |
| 20 | -//#import "CNLiveManager.h" | |
| 21 | -//#import "CNLiveEnvironment.h" | |
| 22 | -//#import "CNLiveBusinessTools.h" | |
| 23 | -//#import "CNLiveTimeTools.h" | |
| 24 | -//#import "CNLiveCommonCategory.h" | |
| 25 | -//#import "CNUserInfoManager.h" | |
| 10 | +#import "QMUIKit.h" | |
| 11 | +#import "WKWebViewJavascriptBridge.h" | |
| 12 | +#import "QNUploadManager.h" | |
| 13 | +#import "QNResponseInfo.h" | |
| 14 | + | |
| 15 | +#import <AVFoundation/AVCaptureDevice.h> | |
| 16 | +#import <AVFoundation/AVMediaFormat.h> | |
| 17 | +#import "XFCameraController.h" | |
| 18 | +#import "TZImagePickerController.h" | |
| 19 | +#import <CNLiveRequestBastKit/CNLiveNetworking.h> | |
| 20 | +#import "CNLiveManager.h" | |
| 21 | +#import "CNLiveEnvironment.h" | |
| 22 | +#import "CNLiveBusinessTools.h" | |
| 23 | +#import "CNLiveTimeTools.h" | |
| 24 | +#import "CNLiveCommonCategory.h" | |
| 25 | +#import "CNUserInfoManager.h" | |
| 26 | 26 | |
| 27 | -//#import "CNLiveWebView.h" | |
| 27 | +#import "CNLiveWebView.h" | |
| 28 | 28 | |
| 29 | -//@interface CNLiveUserAgreementController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate> | |
| 30 | -@interface CNLiveUserAgreementController () | |
| 29 | +@interface CNLiveUserAgreementController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate> | |
| 31 | 30 | @property (nonatomic, strong) NSMutableArray *images; |
| 32 | 31 | @property (nonatomic, strong) NSMutableArray *pics; |
| 33 | 32 | |
| ... | ... | @@ -43,353 +42,353 @@ |
| 43 | 42 | #define OCSendNetStatusToJS @"OCSendNetStatusToJS" //网络状态变化信息 |
| 44 | 43 | #define wjjSubmitSuccess @"wjjSubmitSuccess" //帮助与反馈->产品建议:App->h5图片urls |
| 45 | 44 | |
| 46 | -//- (void)createSubViews { | |
| 47 | -// [super createSubViews]; | |
| 48 | -// UIColor *color = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; | |
| 49 | -// self.webView.progressViewColor = color; | |
| 50 | -//} | |
| 45 | +- (void)createSubViews { | |
| 46 | + [super createSubViews]; | |
| 47 | + UIColor *color = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; | |
| 48 | + self.webView.progressViewColor = color; | |
| 49 | +} | |
| 51 | 50 | #pragma mark - 交互 |
| 52 | -//- (void)interaction { | |
| 53 | -// [super interaction]; | |
| 54 | -// __weak typeof(self)weakSelf = self; | |
| 55 | -// | |
| 56 | -// // 帮助与反馈->产品建议:添加照片按钮 | |
| 57 | -// [self.bridge registerHandler:wjjHelpAndFeedbackImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 58 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 59 | -// [weakSelf uploadPictures]; | |
| 60 | -// responseCallback(data); | |
| 61 | -// }]; | |
| 62 | -// | |
| 63 | -// // 帮助与反馈->产品建议:删除照片 | |
| 64 | -// [self.bridge registerHandler:wjjDelegateImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 65 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 66 | -// if ([data isKindOfClass:[NSDictionary class]]) { | |
| 67 | -// NSString *index = [data objectForKey:@"index"]; | |
| 68 | -// [weakSelf.images removeObjectAtIndex:[index integerValue]]; | |
| 69 | -// } | |
| 70 | -// responseCallback(data); | |
| 71 | -// }]; | |
| 72 | -// | |
| 73 | -// //帮助与反馈->产品建议:点击提交 | |
| 74 | -// [self.bridge registerHandler:wjjSubmitImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 75 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 76 | -// NSString *text = @""; | |
| 77 | -// NSString *mobile = @""; | |
| 78 | -// NSString *modeltype = @""; | |
| 79 | -// if ([data isKindOfClass:[NSDictionary class]]) { | |
| 80 | -// text = [data objectForKey:@"text"]; | |
| 81 | -// mobile = [data objectForKey:@"mobile"]; | |
| 82 | -// modeltype = [data objectForKey:@"modeltype"]; | |
| 83 | -// } | |
| 84 | -// if (weakSelf.images.count > 0) { | |
| 85 | -// [weakSelf getToken]; | |
| 86 | -// } else { | |
| 87 | -// NSArray *array = [NSArray array]; | |
| 88 | -// id data = @{ @"images": array }; | |
| 89 | -// [QMUITips showLoading:@"正在提交" inView:weakSelf.view]; | |
| 90 | -// // 帮助与反馈->产品建议App->h5图片urls | |
| 91 | -// [weakSelf.bridge callHandler:wjjSubmitSuccess data:data responseCallback:^(id responseData) { | |
| 92 | -// NSLog(@"ObjC received response: %@", responseData); | |
| 93 | -// }]; | |
| 94 | -// } | |
| 95 | -// responseCallback(data); | |
| 96 | -// }]; | |
| 97 | -// | |
| 98 | -// // 反馈提交(成功/失败)后隐藏loading | |
| 99 | -// [self.bridge registerHandler:wjjSubmitSuccessFinal handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 100 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 101 | -// [QMUITips hideAllTipsInView:weakSelf.view]; | |
| 102 | -// responseCallback(data); | |
| 103 | -// }]; | |
| 104 | -// | |
| 105 | -// // 帮助与反馈 提交反馈后点击完成 | |
| 106 | -// [self.bridge registerHandler:wjjFeedbackSuccess handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 107 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 108 | -// [weakSelf.navigationController popViewControllerAnimated:YES]; | |
| 109 | -// responseCallback(data); | |
| 110 | -// }]; | |
| 111 | -// | |
| 112 | -// // h5主动从客户端获取网络状态 | |
| 113 | -// [self.bridge registerHandler:wjjJSGetNetStatusFromClient handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 114 | -// NSLog(@"ObjC Echo called with: %@", data); | |
| 115 | -// // 向h5传递网路状态信息 | |
| 116 | -// NSInteger networkStatus = 0; | |
| 117 | -// if (![CNLiveNetworking isNetworking]) { | |
| 118 | -// networkStatus = 0; | |
| 119 | -// } | |
| 120 | -// else if ([CNLiveNetworking isWWANNetwork]) { | |
| 121 | -// networkStatus = 1; | |
| 122 | -// } | |
| 123 | -// else if ([CNLiveNetworking isWiFiNetwork]) { | |
| 124 | -// networkStatus = 2; | |
| 125 | -// } | |
| 126 | -// id answerData = @{ @"netStatus": [NSString stringWithFormat:@"%ld",(long)networkStatus] }; | |
| 127 | -// [weakSelf.bridge callHandler:OCSendNetStatusToJS data:answerData responseCallback:^(id responseData) { | |
| 128 | -// NSLog(@"ObjC received response: %@", responseData); | |
| 129 | -// }]; | |
| 130 | -// responseCallback(data); | |
| 131 | -// }]; | |
| 132 | -//} | |
| 51 | +- (void)interaction { | |
| 52 | + [super interaction]; | |
| 53 | + __weak typeof(self)weakSelf = self; | |
| 54 | + | |
| 55 | + // 帮助与反馈->产品建议:添加照片按钮 | |
| 56 | + [self.bridge registerHandler:wjjHelpAndFeedbackImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 57 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 58 | + [weakSelf uploadPictures]; | |
| 59 | + responseCallback(data); | |
| 60 | + }]; | |
| 61 | + | |
| 62 | + // 帮助与反馈->产品建议:删除照片 | |
| 63 | + [self.bridge registerHandler:wjjDelegateImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 64 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 65 | + if ([data isKindOfClass:[NSDictionary class]]) { | |
| 66 | + NSString *index = [data objectForKey:@"index"]; | |
| 67 | + [weakSelf.images removeObjectAtIndex:[index integerValue]]; | |
| 68 | + } | |
| 69 | + responseCallback(data); | |
| 70 | + }]; | |
| 71 | + | |
| 72 | + //帮助与反馈->产品建议:点击提交 | |
| 73 | + [self.bridge registerHandler:wjjSubmitImage handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 74 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 75 | + NSString *text = @""; | |
| 76 | + NSString *mobile = @""; | |
| 77 | + NSString *modeltype = @""; | |
| 78 | + if ([data isKindOfClass:[NSDictionary class]]) { | |
| 79 | + text = [data objectForKey:@"text"]; | |
| 80 | + mobile = [data objectForKey:@"mobile"]; | |
| 81 | + modeltype = [data objectForKey:@"modeltype"]; | |
| 82 | + } | |
| 83 | + if (weakSelf.images.count > 0) { | |
| 84 | + [weakSelf getToken]; | |
| 85 | + } else { | |
| 86 | + NSArray *array = [NSArray array]; | |
| 87 | + id data = @{ @"images": array }; | |
| 88 | + [QMUITips showLoading:@"正在提交" inView:weakSelf.view]; | |
| 89 | + // 帮助与反馈->产品建议App->h5图片urls | |
| 90 | + [weakSelf.bridge callHandler:wjjSubmitSuccess data:data responseCallback:^(id responseData) { | |
| 91 | + NSLog(@"ObjC received response: %@", responseData); | |
| 92 | + }]; | |
| 93 | + } | |
| 94 | + responseCallback(data); | |
| 95 | + }]; | |
| 96 | + | |
| 97 | + // 反馈提交(成功/失败)后隐藏loading | |
| 98 | + [self.bridge registerHandler:wjjSubmitSuccessFinal handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 99 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 100 | + [QMUITips hideAllTipsInView:weakSelf.view]; | |
| 101 | + responseCallback(data); | |
| 102 | + }]; | |
| 103 | + | |
| 104 | + // 帮助与反馈 提交反馈后点击完成 | |
| 105 | + [self.bridge registerHandler:wjjFeedbackSuccess handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 106 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 107 | + [weakSelf.navigationController popViewControllerAnimated:YES]; | |
| 108 | + responseCallback(data); | |
| 109 | + }]; | |
| 110 | + | |
| 111 | + // h5主动从客户端获取网络状态 | |
| 112 | + [self.bridge registerHandler:wjjJSGetNetStatusFromClient handler:^(id data, WVJBResponseCallback responseCallback) { | |
| 113 | + NSLog(@"ObjC Echo called with: %@", data); | |
| 114 | + // 向h5传递网路状态信息 | |
| 115 | + NSInteger networkStatus = 0; | |
| 116 | + if (![CNLiveNetworking isNetworking]) { | |
| 117 | + networkStatus = 0; | |
| 118 | + } | |
| 119 | + else if ([CNLiveNetworking isWWANNetwork]) { | |
| 120 | + networkStatus = 1; | |
| 121 | + } | |
| 122 | + else if ([CNLiveNetworking isWiFiNetwork]) { | |
| 123 | + networkStatus = 2; | |
| 124 | + } | |
| 125 | + id answerData = @{ @"netStatus": [NSString stringWithFormat:@"%ld",(long)networkStatus] }; | |
| 126 | + [weakSelf.bridge callHandler:OCSendNetStatusToJS data:answerData responseCallback:^(id responseData) { | |
| 127 | + NSLog(@"ObjC received response: %@", responseData); | |
| 128 | + }]; | |
| 129 | + responseCallback(data); | |
| 130 | + }]; | |
| 131 | +} | |
| 133 | 132 | |
| 134 | 133 | #pragma mark - Setter方法 |
| 135 | -//- (void)setUrl:(NSString *)url{ | |
| 136 | -// if(!url||[url isEqualToString:@""]) return; | |
| 137 | -// | |
| 138 | -// NSString *shortVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; | |
| 139 | -// NSDictionary *params = @{ | |
| 140 | -// @"appId":AppId?AppId:@"", | |
| 141 | -// @"plat":@"i", | |
| 142 | -// @"sid":CNUserShareModel.uid?CNUserShareModel.uid:@"", | |
| 143 | -// @"version":shortVersion?shortVersion:@"", | |
| 144 | -// @"wjjFrom":@"apple", | |
| 145 | -// @"wjjUUID":[CNLiveBusinessTools getUidForStat:[NSDate date]]?[CNLiveBusinessTools getUidForStat:[NSDate date]]:@"", | |
| 146 | -// }; | |
| 147 | -// NSMutableDictionary *para = [CNLiveBusinessTools encryptionSignWithParameter:[NSMutableDictionary dictionaryWithDictionary:params] encryptionKey:APPKey]; | |
| 148 | -// __block NSMutableString * tempString = [[NSMutableString alloc] init]; | |
| 149 | -// [para enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull value, BOOL * _Nonnull stop) { | |
| 150 | -// [tempString appendFormat:@"%@=%@&",key,value]; | |
| 151 | -// }]; | |
| 152 | -// if ([url componentsSeparatedByString:@"?"].count>1) { | |
| 153 | -// url = [NSString stringWithFormat:@"%@&%@",url,[tempString substringToIndex:tempString.length-1]]; | |
| 154 | -// }else{ | |
| 155 | -// url = [NSString stringWithFormat:@"%@?%@",url,[tempString substringToIndex:tempString.length-1]]; | |
| 156 | -// } | |
| 157 | -//// [super setUrl:url]; | |
| 158 | -// | |
| 159 | -//} | |
| 134 | +- (void)setUrl:(NSString *)url{ | |
| 135 | + if(!url||[url isEqualToString:@""]) return; | |
| 136 | + | |
| 137 | + NSString *shortVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; | |
| 138 | + NSDictionary *params = @{ | |
| 139 | + @"appId":AppId?AppId:@"", | |
| 140 | + @"plat":@"i", | |
| 141 | + @"sid":CNUserShareModel.uid?CNUserShareModel.uid:@"", | |
| 142 | + @"version":shortVersion?shortVersion:@"", | |
| 143 | + @"wjjFrom":@"apple", | |
| 144 | + @"wjjUUID":[CNLiveBusinessTools getUidForStat:[NSDate date]]?[CNLiveBusinessTools getUidForStat:[NSDate date]]:@"", | |
| 145 | + }; | |
| 146 | + NSMutableDictionary *para = [CNLiveBusinessTools encryptionSignWithParameter:[NSMutableDictionary dictionaryWithDictionary:params] encryptionKey:APPKey]; | |
| 147 | + __block NSMutableString * tempString = [[NSMutableString alloc] init]; | |
| 148 | + [para enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull value, BOOL * _Nonnull stop) { | |
| 149 | + [tempString appendFormat:@"%@=%@&",key,value]; | |
| 150 | + }]; | |
| 151 | + if ([url componentsSeparatedByString:@"?"].count>1) { | |
| 152 | + url = [NSString stringWithFormat:@"%@&%@",url,[tempString substringToIndex:tempString.length-1]]; | |
| 153 | + }else{ | |
| 154 | + url = [NSString stringWithFormat:@"%@?%@",url,[tempString substringToIndex:tempString.length-1]]; | |
| 155 | + } | |
| 156 | + [super setUrl:url]; | |
| 157 | + | |
| 158 | +} | |
| 160 | 159 | |
| 161 | -//#pragma mark - CNLiveWebViewDelegate | |
| 162 | -//- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { | |
| 163 | -// if(self.title.length == 0){ | |
| 164 | -// self.title = webView.title; | |
| 165 | -// } | |
| 166 | -//} | |
| 167 | -// | |
| 168 | -//- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error { | |
| 169 | -// | |
| 170 | -//} | |
| 160 | +#pragma mark - CNLiveWebViewDelegate | |
| 161 | +- (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { | |
| 162 | + if(self.title.length == 0){ | |
| 163 | + self.title = webView.title; | |
| 164 | + } | |
| 165 | +} | |
| 166 | + | |
| 167 | +- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error { | |
| 168 | + | |
| 169 | +} | |
| 171 | 170 | |
| 172 | 171 | #pragma mark - 添加图片 |
| 173 | -//- (void)uploadPictures{ | |
| 174 | -// __weak typeof(self) weakSelf = self; | |
| 175 | -// QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"拍照" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 176 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 177 | -// if(!strongSelf) return ; | |
| 178 | -// __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 179 | -// [CNLiveAuthorizationManager getAVAuthorizationStatus:^{ | |
| 180 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 181 | -// if(!strongSelf) return ; | |
| 182 | -// XFCameraController *cameraController = [[XFCameraController alloc] init]; | |
| 183 | -// cameraController.isCanShootVideo = NO; | |
| 184 | -// cameraController.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 185 | -// __weak XFCameraController *weakCameraController = cameraController; | |
| 186 | -// __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 187 | -// cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) { | |
| 188 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 189 | -// if(!strongSelf) return ; | |
| 190 | -// [strongSelf handleImage:image]; | |
| 191 | -//// [strongSelf.images addObject:image]; | |
| 192 | -// dispatch_async(dispatch_get_main_queue(), ^{ | |
| 193 | -// [weakCameraController dismissViewControllerAnimated:YES completion:nil]; | |
| 194 | -// }); | |
| 195 | -// }; | |
| 196 | -// [strongSelf presentViewController:cameraController animated:YES completion:nil]; | |
| 197 | -// }]; | |
| 198 | -// | |
| 199 | -// }]; | |
| 200 | -// QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"从手机相册中选择" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 201 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 202 | -// if(!strongSelf) return ; | |
| 203 | -// __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 204 | -// [CNLiveAuthorizationManager getPHAuthorizationStatus:^{ | |
| 205 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 206 | -// if(!strongSelf) return ; | |
| 207 | -// TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf]; | |
| 208 | -// picker.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 209 | -// picker.allowPickingVideo = NO; | |
| 210 | -// picker.allowPreview = NO; | |
| 211 | -// __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 212 | -// [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { | |
| 213 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 214 | -// if(!strongSelf) return ; | |
| 215 | -// [strongSelf handleImage:[photos firstObject]]; | |
| 216 | -//// [strongSelf.images addObject:[photos firstObject]]; | |
| 217 | -// }]; | |
| 218 | -// [strongSelf presentViewController:picker animated:YES completion:nil]; | |
| 219 | -// }]; | |
| 220 | -// | |
| 221 | -// }]; | |
| 222 | -// QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 223 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 224 | -// if(!strongSelf) return ; | |
| 225 | -// | |
| 226 | -// }]; | |
| 227 | -// | |
| 228 | -// QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet]; | |
| 229 | -// [alertController addAction:action1]; | |
| 230 | -// [alertController addAction:action2]; | |
| 231 | -// [alertController addAction:cancel]; | |
| 232 | -// | |
| 233 | -// NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 234 | -// titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; | |
| 235 | -// | |
| 236 | -// NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 237 | -// cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | |
| 238 | -// | |
| 239 | -// action1.buttonAttributes = titleAttributs; | |
| 240 | -// action2.buttonAttributes = titleAttributs; | |
| 241 | -// cancel.buttonAttributes = cancelAttributs; | |
| 242 | -// | |
| 243 | -// [alertController showWithAnimated:YES]; | |
| 244 | -// | |
| 245 | -//} | |
| 246 | -// | |
| 247 | -//- (void)handleImage:(UIImage *)image { | |
| 248 | -// // 固定方向 | |
| 249 | -// image = [image fixOrientation];//这个方法是UIImage+Extras.h中方法 | |
| 250 | -// // 加入数组 | |
| 251 | -// [self.images addObject:image]; | |
| 252 | -// NSData *imageData = [UIImage zipNSDataWithImage:image]; | |
| 253 | -// if (imageData.length > 20*1024.0*1024.0) {//压缩后大于20M | |
| 254 | -// [QMUITips showError:@"图片过大" inView:self.view hideAfterDelay:1.5]; | |
| 255 | -// return; | |
| 256 | -// } | |
| 257 | -// NSString *imageString = [imageData base64EncodedStringWithOptions:0]; | |
| 258 | -// imageString = [self removeSpaceAndNewline:imageString]; | |
| 259 | -// id dataDic = @{ | |
| 260 | -// @"image" : imageString | |
| 261 | -// }; | |
| 262 | -// // 帮助与反馈->产品建议:App提交图片数据给h5展示 | |
| 263 | -//// [self.bridge callHandler:@"wjjCommitImageToJS" data:dataDic responseCallback:^(id responseData) { | |
| 264 | -//// NSLog(@"ObjC received response: %@", responseData); | |
| 265 | -//// }]; | |
| 266 | -// | |
| 267 | -//} | |
| 268 | -// | |
| 269 | -//// 获取图片的token | |
| 270 | -//- (void)getToken { | |
| 271 | -// NSDictionary *param = @{@"appId":AppId, | |
| 272 | -// @"verb":@"POST", | |
| 273 | -// @"storageType":@"2", | |
| 274 | -// @"bucket":API_BucketName | |
| 275 | -// }; | |
| 276 | -// [QMUITips showLoading:@"正在提交" inView:self.view]; | |
| 277 | -// [CNLiveNetworking setAllowRequestDefaultArgument:NO]; | |
| 278 | -// [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNUploadAuthForApp Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 279 | -// NSMutableDictionary *data = [NSMutableDictionary dictionaryWithDictionary:responseObject[@"data"]]; | |
| 280 | -// NSDictionary *dic = (NSDictionary *)data; | |
| 281 | -// if (!error && dic[@"token"]) { | |
| 282 | -// [self QNStartUploadWithtoken:dic[@"token"]]; | |
| 283 | -// }else { | |
| 284 | -// [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 285 | -// [QMUITips showError:error.localizedDescription inView:self.view hideAfterDelay:1.5]; | |
| 286 | -// } | |
| 287 | -// }]; | |
| 288 | -//} | |
| 289 | -// | |
| 290 | -//// 图片开始上传 | |
| 291 | -//- (void)QNStartUploadWithtoken:(NSString *)token { | |
| 292 | -// __weak typeof(self) weakSelf = self; | |
| 293 | -// // 图片视频压缩(LXG) | |
| 294 | -// [_images enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | |
| 295 | -// if (!weakSelf.images[idx]) { | |
| 296 | -// [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 297 | -// [QMUITips showError:@"提交失败" inView:self.view hideAfterDelay:1.5]; | |
| 298 | -// return; | |
| 299 | -// } | |
| 300 | -// NSData *zipData = [UIImage zipNSDataWithImage:weakSelf.images[idx]];//非原图压缩 | |
| 301 | -// if (zipData.length > 20*1024.0*1024.0) {//压缩后大于20M | |
| 302 | -// [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 303 | -// [QMUITips showError:@"图片过大" inView:self.view hideAfterDelay:1.5]; | |
| 304 | -// return; | |
| 305 | -// }else{ | |
| 306 | -// weakSelf.images[idx] = [UIImage imageWithData:zipData]; | |
| 307 | -// } | |
| 308 | -// | |
| 309 | -// }]; | |
| 310 | -// | |
| 311 | -// NSMutableDictionary *picDict = [NSMutableDictionary dictionaryWithCapacity:_images.count]; | |
| 312 | -// NSMutableArray *keyArr = [NSMutableArray arrayWithCapacity:_images.count]; | |
| 313 | -// self.pics = [NSMutableArray arrayWithCapacity:_images.count]; | |
| 314 | -// for (int i = 0; i < _images.count; i++) { | |
| 315 | -// @autoreleasepool { | |
| 316 | -// UIImage *image = _images[i]; | |
| 317 | -// __block NSData *imageData1 = UIImageJPEGRepresentation(image, 1); | |
| 318 | -// NSString *timeTampStr = [CNLiveTimeTools get13tsRandTimeStr]; | |
| 319 | -// // NSString *mineType = @"image/jpeg"; | |
| 320 | -// NSString *qiniuFileName; | |
| 321 | -// qiniuFileName = [NSString stringWithFormat:@"%@/%@.jpg",[self getImageBuketkeyFromServerWithExt], timeTampStr]; | |
| 322 | -// QNUploadManager *uploadManager = [QNUploadManager sharedInstanceWithConfiguration:nil]; | |
| 323 | -// [uploadManager putData:imageData1 key:qiniuFileName token:token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { | |
| 324 | -// if (info.ok) { | |
| 325 | -// NSString *imageUrl = [NSString stringWithFormat:@"%@%@",API_PhotoUrl,key]; | |
| 326 | -// [picDict setObject:imageUrl ? imageUrl: @"" forKey:@"imageUrl"]; | |
| 327 | -// [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.width] forKey:@"imageWidth"]; | |
| 328 | -// [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.height] forKey:@"imageHeight"]; | |
| 329 | -// [keyArr addObject:key]; | |
| 330 | -// NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithDictionary:picDict]; | |
| 331 | -// [self.pics addObject:dict]; | |
| 332 | -// | |
| 333 | -// if (keyArr.count == weakSelf.images.count) { | |
| 334 | -// id imagesArrData = @{ @"images": self.pics.copy }; | |
| 335 | -// [weakSelf.images removeAllObjects]; | |
| 336 | -// // 帮助与反馈->产品建议App->h5图片urls | |
| 337 | -//// [self.bridge callHandler:wjjSubmitSuccess data:imagesArrData responseCallback:^(id responseData) { | |
| 338 | -//// NSLog(@"ObjC received response: %@", responseData); | |
| 339 | -//// }]; | |
| 340 | -// } | |
| 341 | -// } else if (info.broken) { | |
| 342 | -// [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 343 | -// [QMUITips showError:@"网络连接已断开" inView:self.view hideAfterDelay:1.5]; | |
| 344 | -// return ; | |
| 345 | -// } else { | |
| 346 | -// [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 347 | -// [QMUITips showError:info.error.localizedDescription inView:self.view hideAfterDelay:1.5]; | |
| 348 | -// return ; | |
| 349 | -// } | |
| 350 | -// } option:nil]; | |
| 351 | -// } | |
| 352 | -// } | |
| 353 | -// | |
| 354 | -//} | |
| 355 | -// | |
| 356 | -//// 图片转成base64字符串需要先取出所有空格和换行符 | |
| 357 | -//- (NSString *)removeSpaceAndNewline:(NSString *)str{ | |
| 358 | -// NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""]; | |
| 359 | -// temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""]; | |
| 360 | -// temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""]; | |
| 361 | -// return temp; | |
| 362 | -//} | |
| 363 | -// | |
| 364 | -//// 图片的BucketKey,BuketKey为文件路径 | |
| 365 | -//- (NSString *)getImageBuketkeyFromServerWithExt{ | |
| 366 | -// NSString *spid = [CNLiveBusinessTools getSpid]; | |
| 367 | -// NSString *imgBucketKey = [NSString stringWithFormat:@"%@/img", spid]; | |
| 368 | -// NSString *yearTime = [CNLiveTimeTools getyyMMdd]; | |
| 369 | -// NSString *bucketKey = [NSString stringWithFormat:@"%@/%@",imgBucketKey,yearTime]; | |
| 370 | -// return bucketKey; | |
| 371 | -// | |
| 372 | -//} | |
| 373 | -// | |
| 374 | -//- (NSData *)image_TransForm_Data:(UIImage *)image{ | |
| 375 | -// NSData *imageData = UIImageJPEGRepresentation(image, 0.5); | |
| 376 | -// //几乎是按0.5图片大小就降到原来的一半 | |
| 377 | -// return imageData; | |
| 378 | -//} | |
| 379 | -// | |
| 380 | -////压缩图片质量 | |
| 381 | -//-(UIImage *)reduceImage:(UIImage *)image percent:(float)percent{ | |
| 382 | -// NSData *imageData = UIImageJPEGRepresentation(image, percent); | |
| 383 | -// UIImage *newImage = [UIImage imageWithData:imageData]; | |
| 384 | -// return newImage; | |
| 385 | -//} | |
| 386 | -////压缩图片尺寸 | |
| 387 | -//- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize{ | |
| 388 | -// UIGraphicsBeginImageContext(newSize); | |
| 389 | -// [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; | |
| 390 | -// UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
| 391 | -// UIGraphicsEndImageContext(); | |
| 392 | -// return newImage; | |
| 393 | -//} | |
| 172 | +- (void)uploadPictures{ | |
| 173 | + __weak typeof(self) weakSelf = self; | |
| 174 | + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"拍照" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 175 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 176 | + if(!strongSelf) return ; | |
| 177 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 178 | + [CNLiveAuthorizationManager getAVAuthorizationStatus:^{ | |
| 179 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 180 | + if(!strongSelf) return ; | |
| 181 | + XFCameraController *cameraController = [[XFCameraController alloc] init]; | |
| 182 | + cameraController.isCanShootVideo = NO; | |
| 183 | + cameraController.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 184 | + __weak XFCameraController *weakCameraController = cameraController; | |
| 185 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 186 | + cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) { | |
| 187 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 188 | + if(!strongSelf) return ; | |
| 189 | + [strongSelf handleImage:image]; | |
| 190 | +// [strongSelf.images addObject:image]; | |
| 191 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 192 | + [weakCameraController dismissViewControllerAnimated:YES completion:nil]; | |
| 193 | + }); | |
| 194 | + }; | |
| 195 | + [strongSelf presentViewController:cameraController animated:YES completion:nil]; | |
| 196 | + }]; | |
| 197 | + | |
| 198 | + }]; | |
| 199 | + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"从手机相册中选择" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 200 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 201 | + if(!strongSelf) return ; | |
| 202 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 203 | + [CNLiveAuthorizationManager getPHAuthorizationStatus:^{ | |
| 204 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 205 | + if(!strongSelf) return ; | |
| 206 | + TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf]; | |
| 207 | + picker.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 208 | + picker.allowPickingVideo = NO; | |
| 209 | + picker.allowPreview = NO; | |
| 210 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 211 | + [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { | |
| 212 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 213 | + if(!strongSelf) return ; | |
| 214 | + [strongSelf handleImage:[photos firstObject]]; | |
| 215 | +// [strongSelf.images addObject:[photos firstObject]]; | |
| 216 | + }]; | |
| 217 | + [strongSelf presentViewController:picker animated:YES completion:nil]; | |
| 218 | + }]; | |
| 219 | + | |
| 220 | + }]; | |
| 221 | + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 222 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 223 | + if(!strongSelf) return ; | |
| 224 | + | |
| 225 | + }]; | |
| 226 | + | |
| 227 | + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet]; | |
| 228 | + [alertController addAction:action1]; | |
| 229 | + [alertController addAction:action2]; | |
| 230 | + [alertController addAction:cancel]; | |
| 231 | + | |
| 232 | + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 233 | + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]; | |
| 234 | + | |
| 235 | + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 236 | + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | |
| 237 | + | |
| 238 | + action1.buttonAttributes = titleAttributs; | |
| 239 | + action2.buttonAttributes = titleAttributs; | |
| 240 | + cancel.buttonAttributes = cancelAttributs; | |
| 241 | + | |
| 242 | + [alertController showWithAnimated:YES]; | |
| 243 | + | |
| 244 | +} | |
| 245 | + | |
| 246 | +- (void)handleImage:(UIImage *)image { | |
| 247 | + // 固定方向 | |
| 248 | + image = [image fixOrientation];//这个方法是UIImage+Extras.h中方法 | |
| 249 | + // 加入数组 | |
| 250 | + [self.images addObject:image]; | |
| 251 | + NSData *imageData = [UIImage zipNSDataWithImage:image]; | |
| 252 | + if (imageData.length > 20*1024.0*1024.0) {//压缩后大于20M | |
| 253 | + [QMUITips showError:@"图片过大" inView:self.view hideAfterDelay:1.5]; | |
| 254 | + return; | |
| 255 | + } | |
| 256 | + NSString *imageString = [imageData base64EncodedStringWithOptions:0]; | |
| 257 | + imageString = [self removeSpaceAndNewline:imageString]; | |
| 258 | + id dataDic = @{ | |
| 259 | + @"image" : imageString | |
| 260 | + }; | |
| 261 | + // 帮助与反馈->产品建议:App提交图片数据给h5展示 | |
| 262 | + [self.bridge callHandler:@"wjjCommitImageToJS" data:dataDic responseCallback:^(id responseData) { | |
| 263 | + NSLog(@"ObjC received response: %@", responseData); | |
| 264 | + }]; | |
| 265 | + | |
| 266 | +} | |
| 267 | + | |
| 268 | +// 获取图片的token | |
| 269 | +- (void)getToken { | |
| 270 | + NSDictionary *param = @{@"appId":AppId, | |
| 271 | + @"verb":@"POST", | |
| 272 | + @"storageType":@"2", | |
| 273 | + @"bucket":API_BucketName | |
| 274 | + }; | |
| 275 | + [QMUITips showLoading:@"正在提交" inView:self.view]; | |
| 276 | + [CNLiveNetworking setAllowRequestDefaultArgument:NO]; | |
| 277 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNUploadAuthForApp Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 278 | + NSMutableDictionary *data = [NSMutableDictionary dictionaryWithDictionary:responseObject[@"data"]]; | |
| 279 | + NSDictionary *dic = (NSDictionary *)data; | |
| 280 | + if (!error && dic[@"token"]) { | |
| 281 | + [self QNStartUploadWithtoken:dic[@"token"]]; | |
| 282 | + }else { | |
| 283 | + [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 284 | + [QMUITips showError:error.localizedDescription inView:self.view hideAfterDelay:1.5]; | |
| 285 | + } | |
| 286 | + }]; | |
| 287 | +} | |
| 288 | + | |
| 289 | +// 图片开始上传 | |
| 290 | +- (void)QNStartUploadWithtoken:(NSString *)token { | |
| 291 | + __weak typeof(self) weakSelf = self; | |
| 292 | + // 图片视频压缩(LXG) | |
| 293 | + [_images enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | |
| 294 | + if (!weakSelf.images[idx]) { | |
| 295 | + [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 296 | + [QMUITips showError:@"提交失败" inView:self.view hideAfterDelay:1.5]; | |
| 297 | + return; | |
| 298 | + } | |
| 299 | + NSData *zipData = [UIImage zipNSDataWithImage:weakSelf.images[idx]];//非原图压缩 | |
| 300 | + if (zipData.length > 20*1024.0*1024.0) {//压缩后大于20M | |
| 301 | + [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 302 | + [QMUITips showError:@"图片过大" inView:self.view hideAfterDelay:1.5]; | |
| 303 | + return; | |
| 304 | + }else{ | |
| 305 | + weakSelf.images[idx] = [UIImage imageWithData:zipData]; | |
| 306 | + } | |
| 307 | + | |
| 308 | + }]; | |
| 309 | + | |
| 310 | + NSMutableDictionary *picDict = [NSMutableDictionary dictionaryWithCapacity:_images.count]; | |
| 311 | + NSMutableArray *keyArr = [NSMutableArray arrayWithCapacity:_images.count]; | |
| 312 | + self.pics = [NSMutableArray arrayWithCapacity:_images.count]; | |
| 313 | + for (int i = 0; i < _images.count; i++) { | |
| 314 | + @autoreleasepool { | |
| 315 | + UIImage *image = _images[i]; | |
| 316 | + __block NSData *imageData1 = UIImageJPEGRepresentation(image, 1); | |
| 317 | + NSString *timeTampStr = [CNLiveTimeTools get13tsRandTimeStr]; | |
| 318 | + // NSString *mineType = @"image/jpeg"; | |
| 319 | + NSString *qiniuFileName; | |
| 320 | + qiniuFileName = [NSString stringWithFormat:@"%@/%@.jpg",[self getImageBuketkeyFromServerWithExt], timeTampStr]; | |
| 321 | + QNUploadManager *uploadManager = [QNUploadManager sharedInstanceWithConfiguration:nil]; | |
| 322 | + [uploadManager putData:imageData1 key:qiniuFileName token:token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { | |
| 323 | + if (info.ok) { | |
| 324 | + NSString *imageUrl = [NSString stringWithFormat:@"%@%@",API_PhotoUrl,key]; | |
| 325 | + [picDict setObject:imageUrl ? imageUrl: @"" forKey:@"imageUrl"]; | |
| 326 | + [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.width] forKey:@"imageWidth"]; | |
| 327 | + [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.height] forKey:@"imageHeight"]; | |
| 328 | + [keyArr addObject:key]; | |
| 329 | + NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithDictionary:picDict]; | |
| 330 | + [self.pics addObject:dict]; | |
| 331 | + | |
| 332 | + if (keyArr.count == weakSelf.images.count) { | |
| 333 | + id imagesArrData = @{ @"images": self.pics.copy }; | |
| 334 | + [weakSelf.images removeAllObjects]; | |
| 335 | + // 帮助与反馈->产品建议App->h5图片urls | |
| 336 | + [self.bridge callHandler:wjjSubmitSuccess data:imagesArrData responseCallback:^(id responseData) { | |
| 337 | + NSLog(@"ObjC received response: %@", responseData); | |
| 338 | + }]; | |
| 339 | + } | |
| 340 | + } else if (info.broken) { | |
| 341 | + [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 342 | + [QMUITips showError:@"网络连接已断开" inView:self.view hideAfterDelay:1.5]; | |
| 343 | + return ; | |
| 344 | + } else { | |
| 345 | + [QMUITips hideAllToastInView:self.view animated:YES]; | |
| 346 | + [QMUITips showError:info.error.localizedDescription inView:self.view hideAfterDelay:1.5]; | |
| 347 | + return ; | |
| 348 | + } | |
| 349 | + } option:nil]; | |
| 350 | + } | |
| 351 | + } | |
| 352 | + | |
| 353 | +} | |
| 354 | + | |
| 355 | +// 图片转成base64字符串需要先取出所有空格和换行符 | |
| 356 | +- (NSString *)removeSpaceAndNewline:(NSString *)str{ | |
| 357 | + NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""]; | |
| 358 | + temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""]; | |
| 359 | + temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""]; | |
| 360 | + return temp; | |
| 361 | +} | |
| 362 | + | |
| 363 | +// 图片的BucketKey,BuketKey为文件路径 | |
| 364 | +- (NSString *)getImageBuketkeyFromServerWithExt{ | |
| 365 | + NSString *spid = [CNLiveBusinessTools getSpid]; | |
| 366 | + NSString *imgBucketKey = [NSString stringWithFormat:@"%@/img", spid]; | |
| 367 | + NSString *yearTime = [CNLiveTimeTools getyyMMdd]; | |
| 368 | + NSString *bucketKey = [NSString stringWithFormat:@"%@/%@",imgBucketKey,yearTime]; | |
| 369 | + return bucketKey; | |
| 370 | + | |
| 371 | +} | |
| 372 | + | |
| 373 | +- (NSData *)image_TransForm_Data:(UIImage *)image{ | |
| 374 | + NSData *imageData = UIImageJPEGRepresentation(image, 0.5); | |
| 375 | + //几乎是按0.5图片大小就降到原来的一半 | |
| 376 | + return imageData; | |
| 377 | +} | |
| 378 | + | |
| 379 | +//压缩图片质量 | |
| 380 | +-(UIImage *)reduceImage:(UIImage *)image percent:(float)percent{ | |
| 381 | + NSData *imageData = UIImageJPEGRepresentation(image, percent); | |
| 382 | + UIImage *newImage = [UIImage imageWithData:imageData]; | |
| 383 | + return newImage; | |
| 384 | +} | |
| 385 | +//压缩图片尺寸 | |
| 386 | +- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize{ | |
| 387 | + UIGraphicsBeginImageContext(newSize); | |
| 388 | + [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; | |
| 389 | + UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
| 390 | + UIGraphicsEndImageContext(); | |
| 391 | + return newImage; | |
| 392 | +} | |
| 394 | 393 | |
| 395 | 394 | @end | ... | ... |
Example/CNLiveBUserAgreement.xcodeproj/project.pbxproj
| ... | ... | @@ -207,8 +207,8 @@ |
| 207 | 207 | 6003F586195388D20070C39A /* Sources */, |
| 208 | 208 | 6003F587195388D20070C39A /* Frameworks */, |
| 209 | 209 | 6003F588195388D20070C39A /* Resources */, |
| 210 | - 1B064539224E0E1189FAF39C /* [CP] Embed Pods Frameworks */, | |
| 211 | - 3EC449E60B68AE0B45A3567E /* [CP] Copy Pods Resources */, | |
| 210 | + 570977C65A1DFAAA9C5638F0 /* [CP] Embed Pods Frameworks */, | |
| 211 | + D4F1D34CD77503C77B90F598 /* [CP] Copy Pods Resources */, | |
| 212 | 212 | ); |
| 213 | 213 | buildRules = ( |
| 214 | 214 | ); |
| ... | ... | @@ -299,7 +299,7 @@ |
| 299 | 299 | /* End PBXResourcesBuildPhase section */ |
| 300 | 300 | |
| 301 | 301 | /* Begin PBXShellScriptBuildPhase section */ |
| 302 | - 1B064539224E0E1189FAF39C /* [CP] Embed Pods Frameworks */ = { | |
| 302 | + 570977C65A1DFAAA9C5638F0 /* [CP] Embed Pods Frameworks */ = { | |
| 303 | 303 | isa = PBXShellScriptBuildPhase; |
| 304 | 304 | buildActionMask = 2147483647; |
| 305 | 305 | files = ( |
| ... | ... | @@ -308,11 +308,13 @@ |
| 308 | 308 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-frameworks.sh", |
| 309 | 309 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", |
| 310 | 310 | "${BUILT_PRODUCTS_DIR}/CNLiveAVCamera/CNLiveAVCamera.framework", |
| 311 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseClass/CNLiveBaseClass.framework", | |
| 311 | 312 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", |
| 312 | 313 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", |
| 313 | 314 | "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework", |
| 314 | 315 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", |
| 315 | 316 | "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", |
| 317 | + "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", | |
| 316 | 318 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 317 | 319 | "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework", |
| 318 | 320 | "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework", |
| ... | ... | @@ -327,17 +329,20 @@ |
| 327 | 329 | "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", |
| 328 | 330 | "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework", |
| 329 | 331 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", |
| 332 | + "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", | |
| 330 | 333 | "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", |
| 331 | 334 | ); |
| 332 | 335 | name = "[CP] Embed Pods Frameworks"; |
| 333 | 336 | outputPaths = ( |
| 334 | 337 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", |
| 335 | 338 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveAVCamera.framework", |
| 339 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseClass.framework", | |
| 336 | 340 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", |
| 337 | 341 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", |
| 338 | 342 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework", |
| 339 | 343 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", |
| 340 | 344 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", |
| 345 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", | |
| 341 | 346 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 342 | 347 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework", |
| 343 | 348 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework", |
| ... | ... | @@ -352,6 +357,7 @@ |
| 352 | 357 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", |
| 353 | 358 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework", |
| 354 | 359 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", |
| 360 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", | |
| 355 | 361 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", |
| 356 | 362 | ); |
| 357 | 363 | runOnlyForDeploymentPostprocessing = 0; |
| ... | ... | @@ -359,24 +365,6 @@ |
| 359 | 365 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-frameworks.sh\"\n"; |
| 360 | 366 | showEnvVarsInLog = 0; |
| 361 | 367 | }; |
| 362 | - 3EC449E60B68AE0B45A3567E /* [CP] Copy Pods Resources */ = { | |
| 363 | - isa = PBXShellScriptBuildPhase; | |
| 364 | - buildActionMask = 2147483647; | |
| 365 | - files = ( | |
| 366 | - ); | |
| 367 | - inputPaths = ( | |
| 368 | - "${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-resources.sh", | |
| 369 | - "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveBUserAgreement/CNLiveBUserAgreement.bundle", | |
| 370 | - ); | |
| 371 | - name = "[CP] Copy Pods Resources"; | |
| 372 | - outputPaths = ( | |
| 373 | - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveBUserAgreement.bundle", | |
| 374 | - ); | |
| 375 | - runOnlyForDeploymentPostprocessing = 0; | |
| 376 | - shellPath = /bin/sh; | |
| 377 | - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-resources.sh\"\n"; | |
| 378 | - showEnvVarsInLog = 0; | |
| 379 | - }; | |
| 380 | 368 | 605B89863D25EA4179988F8A /* [CP] Check Pods Manifest.lock */ = { |
| 381 | 369 | isa = PBXShellScriptBuildPhase; |
| 382 | 370 | buildActionMask = 2147483647; |
| ... | ... | @@ -421,6 +409,24 @@ |
| 421 | 409 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; |
| 422 | 410 | showEnvVarsInLog = 0; |
| 423 | 411 | }; |
| 412 | + D4F1D34CD77503C77B90F598 /* [CP] Copy Pods Resources */ = { | |
| 413 | + isa = PBXShellScriptBuildPhase; | |
| 414 | + buildActionMask = 2147483647; | |
| 415 | + files = ( | |
| 416 | + ); | |
| 417 | + inputPaths = ( | |
| 418 | + "${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-resources.sh", | |
| 419 | + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveBUserAgreement/CNLiveBUserAgreement.bundle", | |
| 420 | + ); | |
| 421 | + name = "[CP] Copy Pods Resources"; | |
| 422 | + outputPaths = ( | |
| 423 | + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveBUserAgreement.bundle", | |
| 424 | + ); | |
| 425 | + runOnlyForDeploymentPostprocessing = 0; | |
| 426 | + shellPath = /bin/sh; | |
| 427 | + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveBUserAgreement_Example/Pods-CNLiveBUserAgreement_Example-resources.sh\"\n"; | |
| 428 | + showEnvVarsInLog = 0; | |
| 429 | + }; | |
| 424 | 430 | /* End PBXShellScriptBuildPhase section */ |
| 425 | 431 | |
| 426 | 432 | /* Begin PBXSourcesBuildPhase section */ | ... | ... |