Commit a284f37b07b56b4213b524592c77e774d4d1b338
1 parent
c51bb0ab
no message
Showing
3 changed files
with
77 additions
and
4 deletions
CNLiveUserAgreementManager.podspec
| @@ -39,6 +39,7 @@ TODO: Add long description of the pod here. | @@ -39,6 +39,7 @@ TODO: Add long description of the pod here. | ||
| 39 | s.public_header_files = 'CNLiveUserAgreementManager/Classes/**/*.h' | 39 | s.public_header_files = 'CNLiveUserAgreementManager/Classes/**/*.h' |
| 40 | # s.frameworks = 'UIKit', 'MapKit' | 40 | # s.frameworks = 'UIKit', 'MapKit' |
| 41 | s.dependency 'QMUIKit' | 41 | s.dependency 'QMUIKit' |
| 42 | + s.dependency 'Qiniu' | ||
| 42 | s.dependency 'WebViewJavascriptBridge' | 43 | s.dependency 'WebViewJavascriptBridge' |
| 43 | s.dependency 'CNLiveRequestBastKit' | 44 | s.dependency 'CNLiveRequestBastKit' |
| 44 | s.dependency 'CNLiveEnvironment' | 45 | s.dependency 'CNLiveEnvironment' |
CNLiveUserAgreementManager/Classes/CNLiveAgreementWebController.m
| @@ -9,6 +9,8 @@ | @@ -9,6 +9,8 @@ | ||
| 9 | #import "CNLiveAgreementWebController.h" | 9 | #import "CNLiveAgreementWebController.h" |
| 10 | // 交接库 | 10 | // 交接库 |
| 11 | #import "WKWebViewJavascriptBridge.h" | 11 | #import "WKWebViewJavascriptBridge.h" |
| 12 | +// 七牛 | ||
| 13 | +#import "QiniuSDK.h" | ||
| 12 | #import <WebKit/WebKit.h> | 14 | #import <WebKit/WebKit.h> |
| 13 | // 环境库 | 15 | // 环境库 |
| 14 | #import "CNLiveEnvironment.h" | 16 | #import "CNLiveEnvironment.h" |
| @@ -82,8 +84,6 @@ | @@ -82,8 +84,6 @@ | ||
| 82 | [self interaction]; | 84 | [self interaction]; |
| 83 | [self loadUrl]; | 85 | [self loadUrl]; |
| 84 | 86 | ||
| 85 | - [self getImageToken]; | ||
| 86 | - | ||
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | - (void)dealloc { | 89 | - (void)dealloc { |
| @@ -465,17 +465,85 @@ | @@ -465,17 +465,85 @@ | ||
| 465 | if ([responseObject isKindOfClass:[NSDictionary class]]) { | 465 | if ([responseObject isKindOfClass:[NSDictionary class]]) { |
| 466 | NSDictionary *dic = (NSDictionary *)responseObject; | 466 | NSDictionary *dic = (NSDictionary *)responseObject; |
| 467 | if (!error && dic[@"token"] && ![dic[@"token"] isEqualToString:@""]) { | 467 | if (!error && dic[@"token"] && ![dic[@"token"] isEqualToString:@""]) { |
| 468 | -// [self QNStartUploadWithtoken:dic[@"token"]]; | 468 | + [self cn_QNStartUploadImageWithToken:dic[@"token"]]; |
| 469 | return; | 469 | return; |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | } | 472 | } |
| 473 | [QMUITips hideAllToastInView:strongSelf.view animated:YES]; | 473 | [QMUITips hideAllToastInView:strongSelf.view animated:YES]; |
| 474 | - [QMUITips showError:error.localizedDescription inView:strongSelf.view hideAfterDelay:1.5]; | 474 | + [QMUITips showError:@"提交失败" inView:strongSelf.view hideAfterDelay:1.5]; |
| 475 | 475 | ||
| 476 | + }]; | ||
| 477 | + | ||
| 478 | +} | ||
| 479 | + | ||
| 480 | +// 图片开始上传 | ||
| 481 | +- (void)cn_QNStartUploadImageWithToken:(NSString *)token { | ||
| 482 | + __weak typeof(self) weakSelf = self; | ||
| 483 | + // 图片视频压缩(LXG) | ||
| 484 | + [_photos enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 485 | + if (!weakSelf.photos[idx]) { | ||
| 486 | + [QMUITips hideAllToastInView:weakSelf.view animated:YES]; | ||
| 487 | + [QMUITips showError:@"提交失败" inView:weakSelf.view hideAfterDelay:1.5]; | ||
| 488 | + return; | ||
| 489 | + } | ||
| 490 | +// NSData *zipData = [UIImage zipNSDataWithImage:weakSelf.photos[idx]];//非原图压缩 | ||
| 491 | +// if (zipData.length > kFriendsCircle_limit_photo) {//压缩后大于20M | ||
| 492 | +// [QMUITips hideAllToastInView:weakSelf.view animated:YES]; | ||
| 493 | +// [QMUITips showError:@"图片过大" inView:weakSelf.view hideAfterDelay:1.5]; | ||
| 494 | +// return; | ||
| 495 | +// } | ||
| 496 | +// else{ | ||
| 497 | +// weakSelf.photos[idx] = [UIImage imageWithData:zipData]; | ||
| 498 | +// } | ||
| 476 | 499 | ||
| 477 | }]; | 500 | }]; |
| 478 | 501 | ||
| 502 | + NSMutableDictionary *picDict = [NSMutableDictionary dictionaryWithCapacity:_photos.count]; | ||
| 503 | + NSMutableArray *keyArr = [NSMutableArray arrayWithCapacity:_photos.count]; | ||
| 504 | +// self.picArr = [NSMutableArray arrayWithCapacity:_photos.count]; | ||
| 505 | + for (int i = 0; i < _photos.count; i++) { | ||
| 506 | + @autoreleasepool { | ||
| 507 | + UIImage *image = _photos[i]; | ||
| 508 | + __block NSData *imageData1 = UIImageJPEGRepresentation(image, 1); | ||
| 509 | +// NSString *timeTampStr = [CNLiveTimeTools get13tsRandTimeStr]; | ||
| 510 | +// NSString *qiniuFileName = [NSString stringWithFormat:@"%@/%@.jpg",[self getImageBuketkeyFromServerWithExt], timeTampStr]; | ||
| 511 | + QNUploadManager *uploadManager = [QNUploadManager sharedInstanceWithConfiguration:nil]; | ||
| 512 | + [uploadManager putData:imageData1 key:@"qiniuFileName" token:token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { | ||
| 513 | + __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 514 | + if(!strongSelf) return ; | ||
| 515 | + if (info.ok) { | ||
| 516 | + NSString *imageUrl = [NSString stringWithFormat:@"%@%@",API_PhotoUrl,key]; | ||
| 517 | + [picDict setObject:imageUrl ? imageUrl: @"" forKey:@"imageUrl"]; | ||
| 518 | + [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.width] forKey:@"imageWidth"]; | ||
| 519 | + [picDict setObject:[NSString stringWithFormat:@"%.0f",image.size.height] forKey:@"imageHeight"]; | ||
| 520 | + [keyArr addObject:key]; | ||
| 521 | + NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithDictionary:picDict]; | ||
| 522 | +// [self.picArr addObject:dict]; | ||
| 523 | + | ||
| 524 | + if (keyArr.count == strongSelf.photos.count) { | ||
| 525 | +// id data = @{ @"images": strongSelf.picArr.copy }; | ||
| 526 | +// [strongSelf.photos removeAllObjects]; | ||
| 527 | +// // 帮助与反馈->产品建议App->h5图片urls | ||
| 528 | +// [strongSelf.bridge callHandler:@"wjjSubmitSuccess" data:data responseCallback:^(id responseData) { | ||
| 529 | +// NSLog(@"ObjC received response: %@", responseData); | ||
| 530 | +// }]; | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + } else if (info.broken) { | ||
| 534 | + [QMUITips hideAllToastInView:strongSelf.view animated:YES]; | ||
| 535 | + [QMUITips showError:@"网络连接失败" inView:strongSelf.view hideAfterDelay:1.5]; | ||
| 536 | + return ; | ||
| 537 | + } else { | ||
| 538 | + [QMUITips hideAllToastInView:strongSelf.view animated:YES]; | ||
| 539 | + [QMUITips showError:info.error.localizedDescription inView:strongSelf.view hideAfterDelay:1.5]; | ||
| 540 | + return ; | ||
| 541 | + } | ||
| 542 | + | ||
| 543 | + } option:nil]; | ||
| 544 | + } | ||
| 545 | + } | ||
| 546 | + | ||
| 479 | } | 547 | } |
| 480 | 548 | ||
| 481 | //获取当前时间戳 | 549 | //获取当前时间戳 |
Example/CNLiveUserAgreementManager.xcodeproj/project.pbxproj
| @@ -310,7 +310,9 @@ | @@ -310,7 +310,9 @@ | ||
| 310 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | 310 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 311 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | 311 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 312 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", | 312 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", |
| 313 | + "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", | ||
| 313 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", | 314 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 315 | + "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", | ||
| 314 | "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", | 316 | "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", |
| 315 | ); | 317 | ); |
| 316 | name = "[CP] Embed Pods Frameworks"; | 318 | name = "[CP] Embed Pods Frameworks"; |
| @@ -321,7 +323,9 @@ | @@ -321,7 +323,9 @@ | ||
| 321 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | 323 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 322 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | 324 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 323 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", | 325 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", |
| 326 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", | ||
| 324 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", | 327 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 328 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", | ||
| 325 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", | 329 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", |
| 326 | ); | 330 | ); |
| 327 | runOnlyForDeploymentPostprocessing = 0; | 331 | runOnlyForDeploymentPostprocessing = 0; |