From 2c3c6ad17de64d026b55efb92a80851b9eca85ee Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Fri, 17 May 2024 16:57:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=BC=93=E5=AD=98=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi/Modules/YMMine/Presenter/XPMinePresent.m | 2 +- .../Modules/YMMine/View/Guild/Api/Api+Guild.h | 5 +- .../Modules/YMMine/View/Guild/Api/Api+Guild.m | 7 ++- .../View/IncomeRecord/XPIncomeRecordVC.h | 7 +-- .../YMMine/View/XPMineViewController.m | 3 +- .../View/AnimationView/XPRoomAnimationView.m | 8 +-- .../View/MoreView/Model/XPRoomMoreItemModel.h | 6 +- .../MoreView/Presenter/XPMoreMenuPresenter.m | 18 +++--- .../View/XPRoomMoreMenuViewController.m | 36 +++++------ .../View/View/XPTreasureFairyStoreView.m | 2 +- .../View/XPTreasureFairyTrialsContentView.m | 2 +- .../YMTabbar/View/TabbarViewController.m | 61 +++++++++---------- YuMi/Modules/YMWeb/XPWebViewController.m | 20 ++++-- YuMi/Tools/File/UploadFile.h | 2 + YuMi/Tools/File/UploadFile.m | 46 ++++++++++++++ 15 files changed, 141 insertions(+), 84 deletions(-) diff --git a/YuMi/Modules/YMMine/Presenter/XPMinePresent.m b/YuMi/Modules/YMMine/Presenter/XPMinePresent.m index 2bef27e8..4d805aef 100644 --- a/YuMi/Modules/YMMine/Presenter/XPMinePresent.m +++ b/YuMi/Modules/YMMine/Presenter/XPMinePresent.m @@ -67,7 +67,7 @@ [[self getView]onGetClanDetailInfofail]; return; } - [Api getClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [Api getNewClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { ClanDetailInfoModel * clanDetailInfo = [ClanDetailInfoModel modelWithDictionary:data.data]; [[self getView] onGetClanDetailInfoSuccess:clanDetailInfo]; }fail:^(NSInteger code, NSString * _Nullable msg) { diff --git a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.h b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.h index e4021244..2eb0e401 100644 --- a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.h +++ b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.h @@ -14,7 +14,10 @@ NS_ASSUME_NONNULL_BEGIN @interface Api (Guild) - +/// 获取家族详情 +/// @param completion 完成 +/// @param uid 族长的uid ++ (void)getNewClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid; /// 获取家族详情 /// @param completion 完成 /// @param uid 族长的uid diff --git a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m index c167b3c2..d4a89ea1 100644 --- a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m +++ b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m @@ -15,7 +15,12 @@ + (void)getClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid { [self makeRequest:@"clan/getUserHallAndClan" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil]; } - +/// 获取家族详情 +/// @param completion 完成 +/// @param uid 族长的uid ++ (void)getNewClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid { + [self makeRequest:@"user/getUserClanInfo" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil]; +} /// 获取公会中房间列表 /// @param completion 完成 /// @param clanId 公会的id diff --git a/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.h b/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.h index 1e9d2815..e59aeac0 100644 --- a/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.h +++ b/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.h @@ -6,15 +6,12 @@ // #import "MvpViewController.h" -#import "ClanDetailInfoModel.h" #import "UserInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface XPIncomeRecordVC : MvpViewController -///家族信息 -@property (nonatomic,strong) ClanDetailInfoModel *clanInfo; -///个人信息 -@property (nonatomic,strong) UserInfoModel *userInfo; + + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMine/View/XPMineViewController.m b/YuMi/Modules/YMMine/View/XPMineViewController.m index 06be7e44..05bd79f5 100644 --- a/YuMi/Modules/YMMine/View/XPMineViewController.m +++ b/YuMi/Modules/YMMine/View/XPMineViewController.m @@ -454,8 +454,7 @@ UIKIT_EXTERN NSString *kRequestRicket; -(void)pushEarningsRecordVC{ XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new]; - incomeRecordVC.clanInfo = self.clanInfo; - incomeRecordVC.userInfo = self.userInfo; + [self.navigationController pushViewController:incomeRecordVC animated:YES]; } diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index 955d2517..2aac0501 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -2099,7 +2099,7 @@ }; - [self.parser parseWithURL:[NSURL URLWithString:vggUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { + [self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { if (videoItem != nil) { self.giftEffectView.hidden = NO; @@ -2181,7 +2181,7 @@ [self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self]; return; } - [self.vapParser parseWithURL:vapUrl completionBlock:^(NSString * _Nullable videoUrl) { + [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { if (videoUrl.length) { self.vapGiftEffectView.hidden = NO; @@ -2248,7 +2248,7 @@ }; - [self.parser parseWithURL:vggUrl completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { + [self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { if (videoItem != nil) { self.luckyGiftEffectView.hidden = NO; if (self.luckyGiftEffectView.superview == nil) { @@ -2303,7 +2303,7 @@ [self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self]; return; } - [self.vapParser parseWithURL:vapUrl completionBlock:^(NSString * _Nullable videoUrl) { + [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { if (videoUrl.length) { self.luckyVapGiftEffectView.hidden = NO; if (self.luckyVapGiftEffectView.superview == nil) { diff --git a/YuMi/Modules/YMRoom/View/MoreView/Model/XPRoomMoreItemModel.h b/YuMi/Modules/YMRoom/View/MoreView/Model/XPRoomMoreItemModel.h index 17f208c1..91d2357f 100644 --- a/YuMi/Modules/YMRoom/View/MoreView/Model/XPRoomMoreItemModel.h +++ b/YuMi/Modules/YMRoom/View/MoreView/Model/XPRoomMoreItemModel.h @@ -19,9 +19,9 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) { // ///公屏开启 // RoomMoreMenuType_Message_Screen_Open = 4, // ///我的礼物特效关闭 -// RoomMoreMenuType_Gift_Effect_Close = 5, -// ///我的礼物特效开启 -// RoomMoreMenuType_Gift_Effect_Open = 6, + RoomMoreMenuType_Gift_Effect_Close = 5, + ///我的礼物特效开启 + RoomMoreMenuType_Gift_Effect_Open = 6, ///房间设置 RoomMoreMenuType_Room_Setting = 7, ///邀请粉丝 diff --git a/YuMi/Modules/YMRoom/View/MoreView/Presenter/XPMoreMenuPresenter.m b/YuMi/Modules/YMRoom/View/MoreView/Presenter/XPMoreMenuPresenter.m index 846560b0..84d6a751 100644 --- a/YuMi/Modules/YMRoom/View/MoreView/Presenter/XPMoreMenuPresenter.m +++ b/YuMi/Modules/YMRoom/View/MoreView/Presenter/XPMoreMenuPresenter.m @@ -38,11 +38,11 @@ // giftValue.type = roomInfo.showGiftValue ? RoomMoreMenuType_Gift_Value_Close : RoomMoreMenuType_Gift_Value_Open; // giftValue.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; -// XPRoomMoreItemModel * giftEffect = [[XPRoomMoreItemModel alloc] init]; -// giftEffect.title = roomInfo.hasAnimationEffect ? YMLocalizedString(@"XPMoreMenuPresenter28") : YMLocalizedString(@"XPMoreMenuPresenter5"); -// giftEffect.imageName = @"room_more_menu_gift_effect"; -// giftEffect.type = roomInfo.hasAnimationEffect ? RoomMoreMenuType_Gift_Effect_Close : RoomMoreMenuType_Gift_Effect_Open; -// giftEffect.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; + XPRoomMoreItemModel * giftEffect = [[XPRoomMoreItemModel alloc] init]; + giftEffect.title = roomInfo.hasAnimationEffect ? YMLocalizedString(@"XPMoreMenuPresenter28") : YMLocalizedString(@"XPMoreMenuPresenter5"); + giftEffect.imageName = @"room_more_menu_gift_effect"; + giftEffect.type = roomInfo.hasAnimationEffect ? RoomMoreMenuType_Gift_Effect_Close : RoomMoreMenuType_Gift_Effect_Open; + giftEffect.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; XPRoomMoreItemModel * wishGift = [[XPRoomMoreItemModel alloc] init]; wishGift.title = YMLocalizedString(@"XPMoreMenuPresenter6"); @@ -179,15 +179,17 @@ // if (isCreator && roomInfo.type != RoomType_Anchor && roomInfo.isPermitRoom != PermitRoomType_Licnese && roomInfo.isPermitRoom != PermitRoomType_YoungerStar) { // [array addObject:releaseRadio]; // } - + [array addObject:giftEffect]; [array addObject:roomSetting]; [array addObject:clearScreen]; - + } else { [array addObject:trumpet]; - + [array addObject:giftEffect]; } + }else{ + [array addObject:giftEffect]; } diff --git a/YuMi/Modules/YMRoom/View/MoreView/View/XPRoomMoreMenuViewController.m b/YuMi/Modules/YMRoom/View/MoreView/View/XPRoomMoreMenuViewController.m index f0abb3cb..a1586c4d 100644 --- a/YuMi/Modules/YMRoom/View/MoreView/View/XPRoomMoreMenuViewController.m +++ b/YuMi/Modules/YMRoom/View/MoreView/View/XPRoomMoreMenuViewController.m @@ -277,24 +277,24 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey; // [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeScreen"}]; // [self.presenter updateRoomMessageScreenState:YES roomId:roomId]; // break; -// case RoomMoreMenuType_Gift_Effect_Open: -// { -// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"openGiftEffect"}]; -// [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController4")]; -// NSDictionary * dic = @{@"hasAnimationEffect": @(1)}; -// [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic]; -// [self dismissViewControllerAnimated:YES completion:nil]; -// } -// break; -// case RoomMoreMenuType_Gift_Effect_Close: -// { -// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeGiftEffect"}]; -// [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController5")]; -// NSDictionary * dic = @{@"hasAnimationEffect": @(0)}; -// [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic]; -// [self dismissViewControllerAnimated:YES completion:nil]; -// } -// break; + case RoomMoreMenuType_Gift_Effect_Open: + { + [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"openGiftEffect"}]; + [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController4")]; + NSDictionary * dic = @{@"hasAnimationEffect": @(1)}; + [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic]; + [self dismissViewControllerAnimated:YES completion:nil]; + } + break; + case RoomMoreMenuType_Gift_Effect_Close: + { + [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeGiftEffect"}]; + [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController5")]; + NSDictionary * dic = @{@"hasAnimationEffect": @(0)}; + [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic]; + [self dismissViewControllerAnimated:YES completion:nil]; + } + break; case RoomMoreMenuType_Invite_Fans: { [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"inviteFans"}]; diff --git a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m index 50aa0c2f..792cef9a 100644 --- a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m +++ b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m @@ -488,7 +488,7 @@ [view playHWDMP4:fullPath repeatCount:1 delegate:self]; }else{ - [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { + [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { if (videoUrl.length) { [view setMute:YES]; [view playHWDMP4:videoUrl repeatCount:1 delegate:self]; diff --git a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m index d8aee920..d7d35d3b 100644 --- a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m +++ b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m @@ -293,7 +293,7 @@ [self.trialsView playHWDMP4:fullPath repeatCount:1 delegate:self]; }else{ - [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { + [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { if (videoUrl.length) { [self.trialsView setMute:YES]; [self.trialsView playHWDMP4:videoUrl repeatCount:1 delegate:self]; diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 5da69883..9af17201 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -124,7 +124,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @property(nonatomic,assign) BOOL isReloadTicket; ///房间外的飘屏 @property(nonatomic,strong) PIFullScreenBannerAnimation *roomAnimation; - +///缓存礼物的次数,超过了就不缓存了 +@property(nonatomic,assign) int downloadGiftCount; @end @@ -349,17 +350,16 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; case AFNetworkReachabilityStatusReachableViaWiFi: { if(self.isFirstReachability == NO){ - [self dealWithDefaultSvga]; + [self dealWithGiftList]; [Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if(code == 200){ self.isFirstReachability = YES; - NSArray *list = data.data; - NSSet *setList = [[NSSet alloc]initWithArray:list];///去重,防止有重复的 - for (NSString *url in setList) { - NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; - [self cacheGiftDynamicEffectList:encodingUrl]; - } + NSMutableArray *giftList = [[NSMutableArray alloc]initWithArray:data.data ?: @[]]; + NSArray *elfList = @[@"https://image.hfighting.com/fenjie2.mp4",@"https://image.hfighting.com/treasure_fairy_ten.mp4",@"https://image.hfighting.com/hecheng3.mp4",@"https://image.hfighting.com/treasure_fairy_one.mp4"]; + [giftList addObjectsFromArray:elfList]; + NSSet *setList = [[NSSet alloc]initWithArray:giftList];///去重,防止有重复的 + [self cacheGiftDynamicEffectList:setList]; } }]; } @@ -374,32 +374,27 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } --(void)dealWithDefaultSvga{ - - ///夺宝精灵动效 - NSArray *elfList = @[@"https://image.hfighting.com/fenjie2.mp4",@"https://image.hfighting.com/treasure_fairy_ten.mp4",@"https://image.hfighting.com/hecheng3.mp4",@"https://image.hfighting.com/treasure_fairy_one.mp4"]; - for (NSString *url in elfList) { - NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; - [self cacheGiftDynamicEffectList:encodingUrl]; - } -} -///缓存新的礼物动效数据 --(void)cacheGiftDynamicEffectList:(NSString *)url{ - NSString *fileName = [[url componentsSeparatedByString:@"/"] lastObject]; - NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; - NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; - if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { - return; - } - NSFileManager *fileMgr = [[NSFileManager alloc] init]; - [fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; - [UploadFile downloadAudioWithFileName:fileName musicUrl:url mainFileName:@"GiftDynamicEffectList" completion:^(BOOL isSuccess, NSString *editAudioPath) { - if(isSuccess){ - - - }else{ - +///缓存新的礼物动效数据 +-(void)cacheGiftDynamicEffectList:(NSSet *)list{ + [UploadFile downloadGiftDynamicEffectWithList:list completion:^(BOOL isSuccess, NSMutableArray * _Nonnull failList) { + if(isSuccess == NO){ + if(self.downloadGiftCount > 3 || failList.count == 0){ + return; + } + [self downloadGiftDynamicEffectWithList:failList]; + } + }]; +} +-(void)downloadGiftDynamicEffectWithList:( NSMutableArray * )requestList{ + NSSet *setList = [[NSSet alloc]initWithArray:requestList]; + [UploadFile downloadGiftDynamicEffectWithList:setList completion:^(BOOL isSuccess, NSMutableArray * _Nonnull failList) { + if(isSuccess == NO){ + if(self.downloadGiftCount > 3 || failList.count == 0){ + return; + } + self.downloadGiftCount++; + [self downloadGiftDynamicEffectWithList:failList]; } }]; } diff --git a/YuMi/Modules/YMWeb/XPWebViewController.m b/YuMi/Modules/YMWeb/XPWebViewController.m index 00110608..890e3e81 100644 --- a/YuMi/Modules/YMWeb/XPWebViewController.m +++ b/YuMi/Modules/YMWeb/XPWebViewController.m @@ -30,6 +30,7 @@ #import "XPIAPRechargeViewController.h" #import "SessionViewController.h" #import "XPMonentTopicContainerViewController.h" +#import "XPIncomeRecordVC.h" #import "PIWebViewSavePhotoView.h" @@ -111,6 +112,8 @@ NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId"; NSString * const kJSOpenChatPage = @"geToChatPage"; NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; NSString * const kJSSavePictureShare = @"savePictureShare"; +NSString * const kJSGoToExchangeGold = @"goToExchangeGold"; + @implementation XPWebViewController @@ -281,7 +284,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare"; if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) { BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL]; if (canOpen) { - [[UIApplication sharedApplication] openURL:request.URL]; + [[UIApplication sharedApplication] openURL:request.URL options:@{} completionHandler:^(BOOL success) { + + }]; } decisionHandler(WKNavigationActionPolicyCancel); return; @@ -347,20 +352,17 @@ NSString * const kJSSavePictureShare = @"savePictureShare"; } else if ([message.name isEqualToString:kJSOpenPurse]) { }else if([message.name isEqualToString:kJSChargePayPage]){ - NSString *money = [NSString stringWithFormat:@"%@",message.body] ; +// NSString *money = [NSString stringWithFormat:@"%@",message.body] ; }else if([message.name isEqualToString:kJSChargePayClickPage]){ if(message.body != nil && self.model.diamonds != nil){ - NSString *type = [NSString stringWithFormat:@"%@",message.body]; +// NSString *type = [NSString stringWithFormat:@"%@",message.body]; } }else if ([message.name isEqualToString:kJSOpenChargePage]) { if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){ [self.delegate payHandler]; return; } - - - [TTPopup dismiss]; if(self.isPush){ XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; @@ -499,6 +501,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare"; self.savePhotoDic = bodyDic; [self showShareSavePhote]; } + }else if([message.name isEqualToString:kJSGoToExchangeGold]){ + XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new]; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:incomeRecordVC animated:YES]; } } }]; @@ -849,6 +854,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare"; [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat]; ///分享及保存 [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare]; + ///兑换金币 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGoToExchangeGold]; + } return _pi_userContentController; diff --git a/YuMi/Tools/File/UploadFile.h b/YuMi/Tools/File/UploadFile.h index 51e4ae01..1a81c815 100644 --- a/YuMi/Tools/File/UploadFile.h +++ b/YuMi/Tools/File/UploadFile.h @@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN ///下载资料 -(void)downloadAnimationFileName:(NSString *)fileName localPath:(NSString *)localPath completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion; +///下载礼物特效 ++(void)downloadGiftDynamicEffectWithList:(NSSet *)list completion:(void (^) (BOOL isSuccess, NSMutableArray *editAudioPath))completion; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Tools/File/UploadFile.m b/YuMi/Tools/File/UploadFile.m index 1c909f79..6677387b 100644 --- a/YuMi/Tools/File/UploadFile.m +++ b/YuMi/Tools/File/UploadFile.m @@ -275,4 +275,50 @@ static UploadFile* manager; }]; [download resume]; } + ++(void)downloadGiftDynamicEffectWithList:(NSSet *)list completion:(void (^) (BOOL isSuccess, NSMutableArray *editAudioPath))completion{ + AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; + manager.operationQueue.maxConcurrentOperationCount = 20; // 控制并发数量 + dispatch_group_t requestGroup = dispatch_group_create(); + NSMutableArray *failList = [NSMutableArray array]; + + for (NSString *giftUrl in list) { + NSString *encodingUrl = [giftUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; + NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { + continue; + } + NSFileManager *fileMgr = [[NSFileManager alloc] init]; + [fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; + dispatch_group_enter(requestGroup); + NSURL *url = [NSURL URLWithString:[encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]; + NSURLRequest *request = [NSURLRequest requestWithURL :url]; + NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { + } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { + return [NSURL fileURLWithPath:fullPath]; + } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { + dispatch_group_leave(requestGroup); + if (!error) { + NSLog(@"下载完成"); + } else { + NSLog(@"下载失败"); + [failList addObject:encodingUrl]; + } + }]; + [download resume]; + } + dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{ + if(failList.count > 0){ + completion(NO,failList); + NSLog(@"下载有失败"); + }else{ + NSLog(@"下载全部完成"); + completion(NO,nil); + } + }); + +} + @end