diff --git a/ProductApp/ProductApp.xcodeproj/project.pbxproj b/ProductApp/ProductApp.xcodeproj/project.pbxproj index 74e85ab..b56d129 100644 --- a/ProductApp/ProductApp.xcodeproj/project.pbxproj +++ b/ProductApp/ProductApp.xcodeproj/project.pbxproj @@ -398,6 +398,8 @@ CAD092CB2CD48A2500853A26 /* MyDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD092CA2CD48A2500853A26 /* MyDocument.m */; }; CAD092CE2CD4A43300853A26 /* ZZDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD092CD2CD4A43300853A26 /* ZZDocument.m */; }; CAD092D12CD4AFE300853A26 /* PptOutlineModel.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD092D02CD4AFE300853A26 /* PptOutlineModel.m */; }; + CAD4AAE02CF81B88000E0B66 /* AIChatDrawLableView.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD4AADF2CF81B88000E0B66 /* AIChatDrawLableView.m */; }; + CAD4AAE32CF81BEF000E0B66 /* MarkDownLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD4AAE22CF81BEF000E0B66 /* MarkDownLabel.m */; }; CAE010B52CD9CF5B003E327F /* 逐字动效.pag in Resources */ = {isa = PBXBuildFile; fileRef = CAE010B42CD9CF5B003E327F /* 逐字动效.pag */; }; CAE010B72CD9D0E9003E327F /* 分数.pag in Resources */ = {isa = PBXBuildFile; fileRef = CAE010B62CD9D0E9003E327F /* 分数.pag */; }; CAF2BC7D2CCF7F7800028275 /* TextbookModel.m in Sources */ = {isa = PBXBuildFile; fileRef = CAF2BC7C2CCF7F7800028275 /* TextbookModel.m */; }; @@ -1313,6 +1315,10 @@ CAD092CD2CD4A43300853A26 /* ZZDocument.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZZDocument.m; sourceTree = ""; }; CAD092CF2CD4AFE300853A26 /* PptOutlineModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PptOutlineModel.h; sourceTree = ""; }; CAD092D02CD4AFE300853A26 /* PptOutlineModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PptOutlineModel.m; sourceTree = ""; }; + CAD4AADE2CF81B88000E0B66 /* AIChatDrawLableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIChatDrawLableView.h; sourceTree = ""; }; + CAD4AADF2CF81B88000E0B66 /* AIChatDrawLableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIChatDrawLableView.m; sourceTree = ""; }; + CAD4AAE12CF81BEF000E0B66 /* MarkDownLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarkDownLabel.h; sourceTree = ""; }; + CAD4AAE22CF81BEF000E0B66 /* MarkDownLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MarkDownLabel.m; sourceTree = ""; }; CAE010B42CD9CF5B003E327F /* 逐字动效.pag */ = {isa = PBXFileReference; lastKnownFileType = file; path = "逐字动效.pag"; sourceTree = ""; }; CAE010B62CD9D0E9003E327F /* 分数.pag */ = {isa = PBXFileReference; lastKnownFileType = file; path = "分数.pag"; sourceTree = ""; }; CAF2BC7B2CCF7F7800028275 /* TextbookModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextbookModel.h; sourceTree = ""; }; @@ -2904,6 +2910,10 @@ CAF76E622CBDFF8500825E5E /* AIChatYuYinView.m */, CAF76E642CBE01F100825E5E /* AIChatYuYinBackView.h */, CAF76E652CBE01F100825E5E /* AIChatYuYinBackView.m */, + CAD4AADE2CF81B88000E0B66 /* AIChatDrawLableView.h */, + CAD4AADF2CF81B88000E0B66 /* AIChatDrawLableView.m */, + CAD4AAE12CF81BEF000E0B66 /* MarkDownLabel.h */, + CAD4AAE22CF81BEF000E0B66 /* MarkDownLabel.m */, ); path = view; sourceTree = ""; @@ -5249,6 +5259,7 @@ CABA14712C9D0D4E002CB3B1 /* StartViewController.m in Sources */, CA2A38D32CEB0C4600156CD2 /* MosaiPath.m in Sources */, CABC08432CEF356B003FE507 /* BatchStatusByidModel.m in Sources */, + CAD4AAE02CF81B88000E0B66 /* AIChatDrawLableView.m in Sources */, CABA14892C9D2AE2002CB3B1 /* StartGNTiShiView.m in Sources */, CAF76E7A2CBE569500825E5E /* SearchInputHestoryView.m in Sources */, CA5D02E12CC0DD6B007B3BA5 /* M3u8Model.m in Sources */, @@ -5419,6 +5430,7 @@ CA0D08832CA5682D0086855E /* CamreViewController.m in Sources */, CAB9AAA22CEC808500B75BD6 /* PLPGDetailViewController.m in Sources */, CA0FD6932CA8EEF3009A4417 /* XieZuoFenXiangAlterNOTableViewCell.m in Sources */, + CAD4AAE32CF81BEF000E0B66 /* MarkDownLabel.m in Sources */, CA487D9B2CA40D3A00AE773B /* StartPayGoodsPayView.m in Sources */, CABD8C792CBF6AC4009A5E5E /* GongJuCreateResultViewController.m in Sources */, CA22D1CA2CD07D9100CA7E93 /* CorrectSaveModel.m in Sources */, diff --git a/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/UserInterfaceState.xcuserstate b/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/UserInterfaceState.xcuserstate index 2cdf669..fecca9d 100644 Binary files a/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/UserInterfaceState.xcuserstate and b/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 2149e2f..ea7abca 100644 --- a/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/ProductApp/ProductApp.xcworkspace/xcuserdata/gongzuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,54 +3,4 @@ uuid = "41EC793F-022E-49E6-A76A-A910FEF0483C" type = "0" version = "2.0"> - - - - - - - - - - - - - - diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/Contents.json b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/Contents.json new file mode 100644 index 0000000..1353206 --- /dev/null +++ b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "容器 18@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "容器 18@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@2x.png b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@2x.png new file mode 100644 index 0000000..ec5e037 Binary files /dev/null and b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@2x.png differ diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@3x.png b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@3x.png new file mode 100644 index 0000000..571dc2e Binary files /dev/null and b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_N.imageset/容器 18@3x.png differ diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/Contents.json b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/Contents.json new file mode 100644 index 0000000..1353206 --- /dev/null +++ b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "容器 18@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "容器 18@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@2x.png b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@2x.png new file mode 100644 index 0000000..3e17496 Binary files /dev/null and b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@2x.png differ diff --git a/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@3x.png b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@3x.png new file mode 100644 index 0000000..e65e75f Binary files /dev/null and b/ProductApp/ProductApp/Assets.xcassets/tabbar/jilu_Y.imageset/容器 18@3x.png differ diff --git a/ProductApp/ProductApp/BaseControl/TabBar/TabBarController.m b/ProductApp/ProductApp/BaseControl/TabBar/TabBarController.m index f765027..94d0e39 100644 --- a/ProductApp/ProductApp/BaseControl/TabBar/TabBarController.m +++ b/ProductApp/ProductApp/BaseControl/TabBar/TabBarController.m @@ -13,6 +13,7 @@ #import "AIChatViewController.h" #import "GongJuViewController.h" #import "WoDeViewController.h" +#import "ShouYeLiShiJiLuViewController.h" @interface TabBarController () @@ -38,44 +39,81 @@ normalImage:@"shouye_N" normalTitleColor:RGBCOLOR(216, 216, 216)]; [self.rootVcAry addObject:honeVC]; - - FanWenViewController *fanwenVC =[[FanWenViewController alloc] init]; - [self setTabBarItem:fanwenVC.tabBarItem - title:@"范文" - titleSize:12.0 - titleFontName:@"HeiTi SC" - selectedImage:@"fanwen_Y" - selectedTitleColor:RGBCOLOR(51, 51, 51) - normalImage:@"fanwen_N" - normalTitleColor:RGBCOLOR(216, 216, 216)]; - [self.rootVcAry addObject:fanwenVC]; - - AIChatViewController *aiVC =[[AIChatViewController alloc] init]; - [self setTabBarItem:aiVC.tabBarItem - title:@"" - titleSize:12.0 - titleFontName:@"HeiTi SC" - selectedImage:@"zhinenAI" - selectedTitleColor:RGBCOLOR(51, 51, 51) - normalImage:@"zhinenAI" - normalTitleColor:RGBCOLOR(216, 216, 216)]; - [self.rootVcAry addObject:aiVC]; - - - GongJuViewController *gongjuVC =[[GongJuViewController alloc] init]; - [self setTabBarItem:gongjuVC.tabBarItem - title:@"工具" - titleSize:12.0 - titleFontName:@"HeiTi SC" - selectedImage:@"gongju_Y" - selectedTitleColor:RGBCOLOR(51, 51, 51) - normalImage:@"gongju_N" - normalTitleColor:RGBCOLOR(216, 216, 216)]; - [self.rootVcAry addObject:gongjuVC]; + if([UserInfoModel shareModel].identityType.intValue == 3) + { + GongJuViewController *gongjuVC =[[GongJuViewController alloc] init]; + [self setTabBarItem:gongjuVC.tabBarItem + title:@"工具" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"gongju_Y" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"gongju_N" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:gongjuVC]; + + AIChatViewController *aiVC =[[AIChatViewController alloc] init]; + [self setTabBarItem:aiVC.tabBarItem + title:@"" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"zhinenAI" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"zhinenAI" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:aiVC]; + + ShouYeLiShiJiLuViewController *gjiluVC =[[ShouYeLiShiJiLuViewController alloc] init]; + [self setTabBarItem:gjiluVC.tabBarItem + title:@"记录" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"jilu_Y" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"jilu_N" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:gjiluVC]; + } + else + { + FanWenViewController *fanwenVC =[[FanWenViewController alloc] init]; + [self setTabBarItem:fanwenVC.tabBarItem + title:@"范文" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"fanwen_Y" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"fanwen_N" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:fanwenVC]; + + AIChatViewController *aiVC =[[AIChatViewController alloc] init]; + [self setTabBarItem:aiVC.tabBarItem + title:@"" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"zhinenAI" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"zhinenAI" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:aiVC]; + + + GongJuViewController *gongjuVC =[[GongJuViewController alloc] init]; + [self setTabBarItem:gongjuVC.tabBarItem + title:@"工具" + titleSize:12.0 + titleFontName:@"HeiTi SC" + selectedImage:@"gongju_Y" + selectedTitleColor:RGBCOLOR(51, 51, 51) + normalImage:@"gongju_N" + normalTitleColor:RGBCOLOR(216, 216, 216)]; + [self.rootVcAry addObject:gongjuVC]; + } WoDeViewController *wodeVC =[[WoDeViewController alloc] init]; [self setTabBarItem:wodeVC.tabBarItem - title:@"工具" + title:@"我的" titleSize:12.0 titleFontName:@"HeiTi SC" selectedImage:@"wode_Y" @@ -107,7 +145,22 @@ -(void)numberChangeNotifi:(NSNotification *)notifi { NSString *strobje = notifi.object; - [self setSelectedIndex:strobje.intValue]; + if([UserInfoModel shareModel].identityType.intValue == 3) + { + if(strobje.intValue==3) + { + [self setSelectedIndex:1]; + } + else + { + [self setSelectedIndex:strobje.intValue]; + } + } + else + { + [self setSelectedIndex:strobje.intValue]; + } + } #pragma mark - tabBar高度 diff --git a/ProductApp/ProductApp/BaseControl/UserInfo/UserInfoModel.m b/ProductApp/ProductApp/BaseControl/UserInfo/UserInfoModel.m index 407f724..e1922d4 100644 --- a/ProductApp/ProductApp/BaseControl/UserInfo/UserInfoModel.m +++ b/ProductApp/ProductApp/BaseControl/UserInfo/UserInfoModel.m @@ -311,9 +311,9 @@ static UserInfoModel *userinfo; ///权限校验 +(void)quanXianJiaoYan:(UIViewController *)vc scence:(NSString *)scence ispush:(BOOL)ispush back:(UserInfoModelQuanXianBack)backValue { - [LoadAlterView show]; +// [LoadAlterView show]; [PublicNetWorkManager requestUserAuthData:nil scene:scence Callback:^(BOOL state, UserAuthModel *responseObject, NSString * _Nullable describle) { - [LoadAlterView dismiss]; + if(state) { if(responseObject.data.auth.intValue == 1) @@ -323,6 +323,7 @@ static UserInfoModel *userinfo; } else {///跳转支付 + [LoadAlterView dismiss]; if(ispush) { StartPayViewController *vcpush = [StartPayViewController new]; @@ -335,6 +336,7 @@ static UserInfoModel *userinfo; } else { + [LoadAlterView dismiss]; [HXHud showMessage:responseObject.message afterDelayType:1]; backValue(NO); } diff --git a/ProductApp/ProductApp/Other/Tools.h b/ProductApp/ProductApp/Other/Tools.h index 895261f..f9d0cb9 100644 --- a/ProductApp/ProductApp/Other/Tools.h +++ b/ProductApp/ProductApp/Other/Tools.h @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN */ + (CGFloat)getLabelHeightWithText:(NSString *)text width:(CGFloat)width font: (CGFloat)font linHeight:(float)linHeight; + (CGFloat)getMacDonaldsLabelHeightWithText:(NSString *)text width:(CGFloat)width font: (CGFloat)font linHeight:(float)linHeight; - ++(float)getAttStringHeight:(NSMutableAttributedString *)attrString width:(float)width; /* * 根据高度度求宽度 text 计算的内容 height 计算的高度 font字体大小 * text 计算的内容 @@ -357,6 +357,10 @@ NS_ASSUME_NONNULL_BEGIN +(UIImage *)CreateStrcode:(NSString *)strcode size:(CGFloat)f_width; ///将小写数字转换为大写 + (NSString *)convertNumberToUppercase:(NSInteger)number ; + +///职业是否切换 教育和职场 ++(BOOL)zhiyeChange:(NSString *)value; + @end NS_ASSUME_NONNULL_END diff --git a/ProductApp/ProductApp/Other/Tools.m b/ProductApp/ProductApp/Other/Tools.m index 107ea07..7f06f4b 100644 --- a/ProductApp/ProductApp/Other/Tools.m +++ b/ProductApp/ProductApp/Other/Tools.m @@ -664,11 +664,54 @@ static dispatch_source_t _timer; MarkdownParser *parser = [[MarkdownParser alloc] init]; NSMutableAttributedString *attrString = [parser attributedStringFromMarkdown:text font:[UIFont systemFontOfSize:font] fontsize:font color:RGBCOLOR(51, 51, 51)]; [attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attrString.string.length)]; + [attrString addAttribute:NSUnderlineStyleAttributeName value:@(kCTUnderlineStyleNone) range:NSMakeRange(0, attrString.string.length)]; + + CFAttributedStringRef attributedStringRef = (__bridge CFAttributedStringRef)attrString; + CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attributedStringRef); + CFRange range = CFRangeMake(0, 0); + CFRange fitCFRange = CFRangeMake(0, 0); + CGSize newSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, range, NULL, CGSizeMake(width, CGFLOAT_MAX), &fitCFRange); + if (framesetter) { + CFRelease(framesetter); + } - CGSize msize = [attrString boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size; +// CGSize msize = [attrString boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size; - return msize.height+1; + return newSize.height+1; +} ++(float)getAttStringHeight:(NSMutableAttributedString *)attrString width:(float)width +{ + NSAttributedString *drawString = attrString; + if (drawString == nil) { + return 0; + } + CFAttributedStringRef attributedStringRef = (__bridge CFAttributedStringRef)drawString; + CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attributedStringRef); + CFRange range = CFRangeMake(0, 0); +// if (_numberOfLines > 0 && framesetter) { +// CGMutablePathRef path = CGPathCreateMutable(); +// CGPathAddRect(path, NULL, CGRectMake(0, 0, size.width, size.height)); +// CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL); +// CFArrayRef lines = CTFrameGetLines(frame); +// +// if (nil != lines && CFArrayGetCount(lines) > 0) { +// NSInteger lastVisibleLineIndex = MIN(_numberOfLines, CFArrayGetCount(lines)) - 1; +// CTLineRef lastVisibleLine = CFArrayGetValueAtIndex(lines, lastVisibleLineIndex); +// +// CFRange rangeToLayout = CTLineGetStringRange(lastVisibleLine); +// range = CFRangeMake(0, rangeToLayout.location + rangeToLayout.length); +// } +// CFRelease(frame); +// CFRelease(path); +// } + CFRange fitCFRange = CFRangeMake(0, 0); + CGSize newSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, range, NULL, CGSizeMake(width, CGFLOAT_MAX), &fitCFRange); + if (framesetter) { + CFRelease(framesetter); + } + + return newSize.height; } + (CGFloat)getWidthWithText:(NSString *)text height:(CGFloat)height font:(CGFloat)font{ @@ -2165,4 +2208,18 @@ static dispatch_source_t _timer; return uppercaseString; } + +///职业是否切换 教育和职场 ++(BOOL)zhiyeChange:(NSString *)value +{ + if(([UserInfoModel shareModel].identityType.intValue<3 && value.intValue<3) || [UserInfoModel shareModel].identityType.intValue == value.intValue) + { + return NO; + } + else + { + return YES; + } +} + @end diff --git a/ProductApp/ProductApp/Other/ViewLable.m b/ProductApp/ProductApp/Other/ViewLable.m index a2e1e1f..f5a0d13 100644 --- a/ProductApp/ProductApp/Other/ViewLable.m +++ b/ProductApp/ProductApp/Other/ViewLable.m @@ -65,7 +65,7 @@ [self.layoutManager addTextContainer:self.textContainer]; - PGJUILabel *lbname = [[PGJUILabel alloc] init]; + PGJUILabel *lbname = [[PGJUILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; [lbname setTextColor:RGBCOLOR(26, 26, 26)]; [lbname setTextAlignment:NSTextAlignmentLeft]; [lbname setFont:[UIFont systemFontOfSize:16]]; diff --git a/ProductApp/ProductApp/ProductMain/AIChart/AIChatViewController.m b/ProductApp/ProductApp/ProductMain/AIChart/AIChatViewController.m index 172bbb1..b4dfefc 100644 --- a/ProductApp/ProductApp/ProductMain/AIChart/AIChatViewController.m +++ b/ProductApp/ProductApp/ProductMain/AIChart/AIChatViewController.m @@ -133,7 +133,14 @@ { iscrollrow = arrtemp.count; } - [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:iscrollrow inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; + @try { + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:iscrollrow inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; + } @catch (NSException *exception) { + + } @finally { + + } + } } @@ -287,6 +294,9 @@ [cell setBackAudioValue:^(AIChatModel * _Nonnull model) { [self audioAction:model]; }]; + [cell setBackDrawValue:^(BOOL isDrawFinish) { + [self.tableView reloadData]; + }]; return cell; } @@ -308,10 +318,10 @@ return 200; } -// if(model.height>0) -// { -// return model.height; -// } + if(model.height>0) + { + return model.height; + } float fheight = 55; NSString *strtext = model.text; @@ -378,25 +388,42 @@ if(self.arrdata.count==0) { - AIChatModel *model = [AIChatModel new]; - model.messageType = 0; - model.text = @"你好,我是你的AI助手,有什么写作方面的问题都可以问我,你看需要我在哪些方面帮助你呢?"; - model.isAnimation = NO; - [self.arrdata addObject:model]; - - AIChatModel *model2 = [AIChatModel new]; - model2.messageType = 2; - model2.text = @""; - model2.arrfunction = responseObject.data.items; - model2.isAnimation = NO; - [self.arrdata addObject:model2]; - - ///需要存入数据库 - if(self.strtablename.length>0) + if([UserInfoModel shareModel].identityType.intValue==3) { - [FMDMySql insertChar:model andtablename:self.strtablename]; - [FMDMySql insertChar:model2 andtablename:self.strtablename]; + AIChatModel *model = [AIChatModel new]; + model.messageType = 0; + model.text = @"有什么能帮助您的,我可以联网查询!"; + model.isAnimation = NO; + [self.arrdata addObject:model]; + ///需要存入数据库 + if(self.strtablename.length>0) + { + [FMDMySql insertChar:model andtablename:self.strtablename]; + } } + else + { + AIChatModel *model = [AIChatModel new]; + model.messageType = 0; + model.text = @"你好,我是你的AI助手,有什么写作方面的问题都可以问我,你看需要我在哪些方面帮助你呢?"; + model.isAnimation = NO; + [self.arrdata addObject:model]; + + AIChatModel *model2 = [AIChatModel new]; + model2.messageType = 2; + model2.text = @""; + model2.arrfunction = responseObject.data.items; + model2.isAnimation = NO; + [self.arrdata addObject:model2]; + + ///需要存入数据库 + if(self.strtablename.length>0) + { + [FMDMySql insertChar:model andtablename:self.strtablename]; + [FMDMySql insertChar:model2 andtablename:self.strtablename]; + } + } + [self.tableView reloadData]; } } @@ -425,68 +452,69 @@ [UserInfoModel setAiChatIsDrawing:1]; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self getInfoValue:value]; }); } - +-(AIChatTextTableViewCell *)getDrawCell +{ + NSIndexPath *index = [NSIndexPath indexPathForRow:self.arrdata.count-1 inSection:0]; + AIChatTextTableViewCell *cellDraw = [self.tableView cellForRowAtIndexPath:index]; + if(cellDraw.hidden==YES||cellDraw==nil) + { + NSIndexPath *index = [NSIndexPath indexPathForRow:self.arrdata.count-1 inSection:0]; + [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + + cellDraw = [self getDrawCell]; + } + return cellDraw; +} -(void)getInfoValue:(NSString *)value { - dispatch_async(dispatch_get_main_queue(), ^{ - [LoadAlterView show]; - }); - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - __block float ftemp = ftemp = self.tableView.contentSize.height; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + __block float ftemp = self.tableView.contentSize.height; __block float ftheight = self.tableView.height; dispatch_async(dispatch_get_main_queue(), ^{ [LoadAlterView dismiss]; }); - __block NSIndexPath *index = [NSIndexPath indexPathForRow:self.arrdata.count-1 inSection:0]; - AIChatTextTableViewCell *cellDraw = [self.tableView cellForRowAtIndexPath:index]; - if(cellDraw.hidden==YES||cellDraw==nil) - { - [self scrollToBottom]; - sleep(1); - cellDraw = [self.tableView cellForRowAtIndexPath:index]; - } + +// if(DEBUG) +// { +// [UserInfoModel setAiChatIsDrawing:0]; +// return; +// } + + AIChatTextTableViewCell *cellDraw = [self getDrawCell]; + + [self.tableView beginUpdates]; + self.cellDraw = cellDraw; - [self.tableView setScrollEnabled:NO]; + [self.tableView setUserInteractionEnabled:NO]; [cellDraw setBackDrawValue:^(BOOL isDrawFinish) { if(isDrawFinish) { - [self.tableView setScrollEnabled:YES]; + [self.tableView setUserInteractionEnabled:YES]; AIChatModel *modeltemp = self.arrdata[self.arrdata.count-1]; float fheight = 55; if([Tools getWidthWithText:modeltemp.text height:20 font:14]>UISCREEN_WIDTH-80) { - fheight = [Tools getLabelHeightWithText:modeltemp.text width:UISCREEN_WIDTH-80 font:14 linHeight:5]+38; + fheight = [Tools getMacDonaldsLabelHeightWithText:modeltemp.text width:UISCREEN_WIDTH-80 font:14 linHeight:5]+38; } modeltemp.height = fheight; + modeltemp.isAnimation = NO; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView endUpdates]; +// [self.tableView reloadData]; if(self.isDragging==NO) { -// [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone]; -// [self scrollToBottom]; - NSIndexPath *index = [NSIndexPath indexPathForRow:self.arrdata.count-1 inSection:0]; [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:NO]; +// [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone]; - float fheightmac = 55; - if([Tools getMacDonaldsWidthWithText:modeltemp.text height:20 font:14]>UISCREEN_WIDTH-80) - { - fheightmac = [Tools getMacDonaldsLabelHeightWithText:modeltemp.text width:UISCREEN_WIDTH-80 font:14 linHeight:5]+38; - } - modeltemp.height = fheightmac; + self.cellDraw.model = modeltemp; - if(modeltemp.isAnimation) - { - modeltemp.isAnimation = NO; - self.cellDraw.model = modeltemp; - } +// [self scrollToBottom]; } }); [UserInfoModel setAiChatIsDrawing:0]; @@ -497,7 +525,8 @@ float fheight = modeltemp.height; self.cellDraw.height = fheight; - if(ftemp-ftheight>0 && self.isDragging==NO) + + if(ftemp-ftheight+fheight-60>0&& self.isDragging==NO) { [self.tableView setContentOffset:CGPointMake(0, ftemp-ftheight+fheight-60)]; } @@ -505,8 +534,6 @@ }]; - [self.tableView beginUpdates]; - NSInteger nowtime = [[NSDate date] timeIntervalSince1970]; if(self.chat_start_time.length==0) { diff --git a/ProductApp/ProductApp/ProductMain/AIChart/cell/AIChatTextTableViewCell.m b/ProductApp/ProductApp/ProductMain/AIChart/cell/AIChatTextTableViewCell.m index 9a0d59e..4143e3a 100644 --- a/ProductApp/ProductApp/ProductMain/AIChart/cell/AIChatTextTableViewCell.m +++ b/ProductApp/ProductApp/ProductMain/AIChart/cell/AIChatTextTableViewCell.m @@ -13,12 +13,13 @@ #import #import "AudioRecored.h" +#import "AIChatDrawLableView.h" @interface AIChatTextTableViewCell () /// @property (nonatomic , strong) AIChatArcView *viewinfoLeft; /// -@property (nonatomic , strong) ViewLable *lbvalueLeft ; +@property (nonatomic , strong) AIChatDrawLableView *lbvalueLeft ; /// @property (nonatomic , strong) AIChatFunctionView *functionView; @@ -84,7 +85,7 @@ [answerView setHidden:YES]; _answerView = answerView; - ViewLable *lbvalueLeft = [[ViewLable alloc] init]; + AIChatDrawLableView *lbvalueLeft = [[AIChatDrawLableView alloc] init]; [lbvalueLeft setTextColor:RGBCOLOR(51, 51, 51)]; [lbvalueLeft setTextFont:[UIFont systemFontOfSize:14]]; [viewinfoLeft addSubview:lbvalueLeft]; @@ -141,6 +142,9 @@ }]; _lbvalueright = lbvalueright; + [lbvalueright setUserInteractionEnabled:YES]; + UILongPressGestureRecognizer *tapright = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(rightTapAction:)]; + [lbvalueright addGestureRecognizer:tapright]; UIButton *btyuyin = [[UIButton alloc] init]; [btyuyin setImage:[UIImage imageNamed:@"ai_yuyincell"] forState:UIControlStateNormal]; @@ -185,7 +189,7 @@ [self.btyuyin setSelected:self.model.isaudioStart]; } - float f_width = [Tools getWidthWithText:strtext height:20 font:14]+41; + float f_width = [Tools getMacDonaldsWidthWithText:strtext height:20 font:14]+41; if(f_width>UISCREEN_WIDTH-40) { f_width = UISCREEN_WIDTH-40; @@ -317,7 +321,7 @@ }]; - ViewLable *lbwz = self.lbvalueLeft; + __block AIChatDrawLableView *lbwz = self.lbvalueLeft; if(self.model.isAnimation==YES && self.model.isDrwaEnd==NO) { [lbwz setBackHeight:^(float fheight, BOOL isend) { @@ -349,17 +353,41 @@ } else { - float fheight = 40; - if(f_width>UISCREEN_WIDTH-80) + if(self.model.height>0) { - fheight = [Tools getMacDonaldsLabelHeightWithText:model.text width:UISCREEN_WIDTH-80 font:14 linHeight:5]+20; - if(fheight<40) - { - fheight = 40; - } + [self.viewinfoLeft mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.offset(self.model.height-18); + }]; } - [self.viewinfoLeft mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.offset(fheight); + else + { + float fheight = 40; + if(f_width>UISCREEN_WIDTH-80) + { + fheight = [Tools getMacDonaldsLabelHeightWithText:model.text width:UISCREEN_WIDTH-80 font:14 linHeight:5]+20; + if(fheight<40) + { + fheight = 40; + } + } + [self.viewinfoLeft mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.offset(fheight); + }]; + } + __strong AIChatModel *modelself = self.model; + __weak typeof(self) weakSelf = self; + [self.lbvalueLeft setBackHeight:^(float fheighttemp, BOOL isend) { + if(isend) + { + if(fheighttemp+38>modelself.height) + { + modelself.height = fheighttemp+38; + if(weakSelf.backDrawValue) + { + weakSelf.backDrawValue(YES); + } + } + } }]; } @@ -400,6 +428,31 @@ // }); //} +-(void)rightTapAction:(UIGestureRecognizer *)gesture +{ + if(gesture.state==UIGestureRecognizerStateBegan) + { + if(self.model.isAnimation) + { + if(self.model.isDrwaEnd) + { + [self copyRightValue]; + } + } + else + { + [self copyRightValue]; + } + } +} + +-(void)copyRightValue +{ + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + pasteboard.string = self.lbvalueright.strValue; + [HXHud showMessage:@"复制成功" afterDelayType:0]; +} + -(void)leftTapAction:(UIGestureRecognizer *)gesture { if(gesture.state==UIGestureRecognizerStateBegan) diff --git a/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatBottomView.m b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatBottomView.m index 576b6eb..c7fea70 100644 --- a/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatBottomView.m +++ b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatBottomView.m @@ -286,6 +286,13 @@ { _arrdata = arrdata; [self.collect reloadData]; + if([UserInfoModel shareModel].identityType.intValue == 3) + { + [self.collect setHidden:YES]; + [self.collect mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.offset(0); + }]; + } } #pragma mark - UICollectionView - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section diff --git a/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.h b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.h new file mode 100644 index 0000000..2c7000b --- /dev/null +++ b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.h @@ -0,0 +1,36 @@ +// +// AIChatDrawLableView.h +// ProductApp +// +// Created by 工作 on 2024/11/28. +// + +#import +#import "SSEDrawModel.h" +NS_ASSUME_NONNULL_BEGIN +typedef void(^AIChatDrawLableViewBackHeight)(float fheight,BOOL isend); +@interface AIChatDrawLableView : UIView +/// +@property (nonatomic , strong) NSString *strValue; +/// +@property (nonatomic , strong) UIColor *textColor; +/// +@property (nonatomic , strong) UIFont *textFont; +///1个字需要多少s +@property (nonatomic , assign) float fspeed; +///是否关闭动画写入 +@property (nonatomic , assign) BOOL isCloseAnimation; +///是否写入完成 +@property (nonatomic , assign) BOOL isWriteEnd; + +///在尾部添加数据 +@property (nonatomic , strong) NSString *appendString; + +/// +@property (nonatomic , strong) ViewLableBackHeight backHeight; +/// +@property (nonatomic , strong) NSMutableAttributedString *attString; +-(void)endAction; +@end + +NS_ASSUME_NONNULL_END diff --git a/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.m b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.m new file mode 100644 index 0000000..e3b273e --- /dev/null +++ b/ProductApp/ProductApp/ProductMain/AIChart/view/AIChatDrawLableView.m @@ -0,0 +1,267 @@ +// +// AIChatDrawLableView.m +// ProductApp +// +// Created by 工作 on 2024/11/28. +// + +#import "AIChatDrawLableView.h" + +#import "MarkdownParser.h" +#import "MarkDownLabel.h" + +#import + +@interface AIChatDrawLableView () +/// +@property (nonatomic , strong) MarkDownLabel *lbname; +/// +@property (nonatomic , strong) UIImageView *imgvb; +/// +@property (nonatomic , strong) NSTimer *timer; +@property (nonatomic , assign) int inow; + +@property (strong, nonatomic) NSLayoutManager *layoutManager; +@property (strong, nonatomic) NSTextStorage *textStorage; +@property (strong, nonatomic) NSTextContainer *textContainer; + +/// +@property (nonatomic , strong) MarkdownParser *parser; + +/// +@property (nonatomic , strong) NSMutableParagraphStyle *style; + +@end + +@implementation AIChatDrawLableView + +-(NSMutableParagraphStyle *)style +{ + if(!_style) + { + NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; + style.lineSpacing = 5; + style.lineBreakMode = NSLineBreakByCharWrapping; + style.alignment = NSTextAlignmentLeft; + _style = style; + } + return _style; +} +-(MarkdownParser *)parser +{ + if(!_parser) + { + _parser = [[MarkdownParser alloc] init]; + } + return _parser; +} +-(id)initWithFrame:(CGRect)frame +{ + if(self = [super initWithFrame:frame]) + { + + self.textStorage = [NSTextStorage new]; + self.layoutManager = [NSLayoutManager new]; + + self.textContainer = [NSTextContainer new]; + + [self.textStorage addLayoutManager:self.layoutManager]; + + [self.layoutManager addTextContainer:self.textContainer]; + + + MarkDownLabel *lbname = [[MarkDownLabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; + [lbname setTextColor:RGBCOLOR(26, 26, 26)]; + [lbname setTextAlignment:NSTextAlignmentLeft]; + [lbname setFont:[UIFont systemFontOfSize:16]]; + [lbname setNumberOfLines:0]; + [self addSubview:lbname]; + [lbname mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.equalTo(self); + }]; + _lbname = lbname; +// [self mas_makeConstraints:^(MASConstraintMaker *make) { +// make.height.offset(18); +// }]; + + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.equalTo(lbname); + }]; + + UIImageView *imgvb = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18, 18)]; + [imgvb setImage:[UIImage imageNamed:@"yd_drawTextB"]]; + [self addSubview:imgvb]; + [imgvb setHidden:YES]; + _imgvb = imgvb; + } + return self; +} + +-(void)setTextColor:(UIColor *)textColor +{ + _textColor = textColor; + self.lbname.textColor = textColor; +} +-(void)setTextFont:(UIFont *)textFont +{ + _textFont = textFont; + self.lbname.font = textFont; +} +-(void)setFspeed:(float)fspeed +{ + _fspeed = fspeed; +} +-(void)setStrValue:(NSString *)strValue +{ + _strValue = strValue; + if(self.isCloseAnimation) + { + [self.imgvb setHidden:YES]; + + NSString *str = self.strValue; + + NSMutableAttributedString *attrString = [self.parser attributedStringFromMarkdown:str font:self.lbname.font fontsize:self.lbname.font.pointSize color:self.textColor]; + [attrString addAttribute:NSParagraphStyleAttributeName value:self.style range:NSMakeRange(0, attrString.string.length)]; + + [self.lbname setDisplayedAttributedString:attrString]; + + self.attString = (NSMutableAttributedString *)self.lbname.attributedText; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + float fheight = [Tools getAttStringHeight:self.attString width:UISCREEN_WIDTH-80]+1; + [self mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.offset(fheight); + }]; + if(self.backHeight) + { + self.backHeight(fheight,YES); + } + }); + } + else + { + [self showText]; + } +} + +-(void)setAppendString:(NSString *)appendString +{ + NSString *strtemp =@""; + if(self.strValue==nil) + { + strtemp = [[NSString alloc] initWithString:appendString]; + } + else + { + strtemp = [NSString stringWithFormat:@"%@%@",self.strValue,appendString]; + } + [self setStrValue:strtemp]; +} +-(void)showText +{ + if(self.timer==nil) + { + [self endAction]; +// [self.imgvb setHidden:NO]; + self.inow = 0; + NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:self.fspeed>0?self.fspeed:0.02 target:self selector:@selector(textSpeedAppend) userInfo:nil repeats:YES]; + _timer = timer; + [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; + [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode]; + } +} +-(void)textSpeedAppend +{ + if(self.inow>self.strValue.length && self.isWriteEnd==YES) + { + [self.timer invalidate]; + self.timer = nil; + [self.imgvb setHidden:YES]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if(self.backHeight) + { + self.backHeight(self.height,YES); + } + }); + return; + } + if(self.inow>self.strValue.length || self.strValue.length==0) + { + if(self.backHeight) + { + self.backHeight(-1,NO); + } + return; + } + NSString *str = [self.strValue substringToIndex:self.inow]; + + NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str]; + [attrString addAttribute:NSParagraphStyleAttributeName value:self.style range:NSMakeRange(0, str.length)]; + [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, str.length)]; + + self.lbname.attributedText = attrString; + self.inow++; + + float fheight = [Tools getLabelHeightWithText:self.lbname.text width:self.width font:self.lbname.font.pointSize linHeight:5]+1; + [self mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.offset(fheight); + }]; + if(self.backHeight) + { + self.backHeight(fheight,NO); + } + if(self.imgvb.hidden==NO) + { + CGPoint point = [self boundingRectForLastCharacterInLabel:self.lbname]; + if(point.x>0&&point.y>0) + { + self.imgvb.center = point; + } + } + + +} +- (CGPoint)boundingRectForLastCharacterInLabel:(UILabel *)label { + NSString *text = label.text; + + [self configWithLabel:label]; + CGRect rect = [self characterRectAtIndex:text.length-1]; + CGPoint lastPoint = CGPointMake(rect.origin.x+rect.size.width, rect.origin.y+rect.size.height/2.0); + return lastPoint; +} + +-(void)configWithLabel:(UILabel *)label +{ + self.textContainer.size = label.bounds.size; + self.textContainer.lineFragmentPadding = 0; + self.textContainer.maximumNumberOfLines = label.numberOfLines; + self.textContainer.lineBreakMode = label.lineBreakMode; + + NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:label.text]; + NSRange textRange = NSMakeRange(0, attributedText.length); + [attributedText addAttribute:NSFontAttributeName value:label.font range:textRange]; + + + [attributedText addAttribute:NSParagraphStyleAttributeName value:self.style range:textRange]; + [self.textStorage setAttributedString:attributedText]; +} +-(CGRect)characterRectAtIndex:(NSUInteger)charIndex +{ + if (charIndex >= self.textStorage.length) { + return CGRectZero; + } + NSRange characterRange = NSMakeRange(charIndex, 1); + NSRange glyphRange = [self.layoutManager glyphRangeForCharacterRange:characterRange actualCharacterRange:nil]; + return [self.layoutManager boundingRectForGlyphRange:glyphRange inTextContainer:self.textContainer]; +} + +-(void)endAction +{ + if(self.timer) + { + [self.timer invalidate]; + self.timer = nil; + } +} + +@end diff --git a/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.h b/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.h new file mode 100644 index 0000000..6a3ee4e --- /dev/null +++ b/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.h @@ -0,0 +1,16 @@ +// +// MarkDownLabel.h +// ProductApp +// +// Created by 工作 on 2024/11/28. +// + +#import "TTTAttributedLabel.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MarkDownLabel : TTTAttributedLabel +- (void)setDisplayedAttributedString:(id)text; +@end + +NS_ASSUME_NONNULL_END diff --git a/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.m b/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.m new file mode 100644 index 0000000..7bdc71e --- /dev/null +++ b/ProductApp/ProductApp/ProductMain/AIChart/view/MarkDownLabel.m @@ -0,0 +1,67 @@ +// +// MarkDownLabel.m +// ProductApp +// +// Created by 工作 on 2024/11/28. +// + +#import "MarkDownLabel.h" +#import "WkWebviewViewController.h" + +@implementation MarkDownLabel + +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if (self) { + [self commonConfig]; + } + return self; +} + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self commonConfig]; + } + return self; +} + +- (void)commonConfig { + self.delegate = self; + NSDictionary *linkAttributes = @{ + (id)kCTForegroundColorAttributeName:[UIColor blueColor], + NSUnderlineStyleAttributeName:@(kCTUnderlineStyleNone) + }; + self.linkAttributes = linkAttributes; + self.enabledTextCheckingTypes = 0; +} + +- (void)setDisplayedAttributedString:(id)text { + NSMutableArray *linksAndRange = [@[] mutableCopy]; + [self setText:[text string] afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) { + [text enumerateAttributesInRange:NSMakeRange(0, [text length]) + options:0 + usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop) { + if (attrs[NSLinkAttributeName]) { + [linksAndRange addObject:@[attrs[NSLinkAttributeName], [NSValue valueWithRange:range]]]; + } else { + [mutableAttributedString addAttributes:attrs range:range]; + } + }]; + return mutableAttributedString; + }]; + + for (NSArray *pair in linksAndRange) { + [self addLinkToURL:pair[0] withRange:[pair[1] rangeValue]]; + } +} + +- (void)attributedLabel:(TTTAttributedLabel *)label + didSelectLinkWithURL:(NSURL *)url +{ + WkWebviewViewController *vc = [[WkWebviewViewController alloc] init]; + vc.strurl = url.absoluteString; + [self.viewController.navigationController pushViewController:vc animated:YES]; +} + +@end diff --git a/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.h b/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.h index 9cc0f01..63ca416 100644 --- a/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.h +++ b/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.h @@ -186,6 +186,7 @@ NS_ASSUME_NONNULL_BEGIN */ + (void)requestToolsListData:(UIView *)view page:(int)page + size:(NSString *)size type_id:(NSString *)type_id tool_name:(NSString *)tool_name is_recommend:(NSString *)is_recommend diff --git a/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.m b/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.m index 6d92355..56c360d 100644 --- a/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.m +++ b/ProductApp/ProductApp/ProductMain/NetWorkManager/NetWorkManager.m @@ -463,6 +463,7 @@ */ + (void)requestToolsListData:(UIView *)view page:(int)page + size:(NSString *)size type_id:(NSString *)type_id tool_name:(NSString *)tool_name is_recommend:(NSString *)is_recommend @@ -470,7 +471,7 @@ { NSMutableDictionary *dicQuery = [NSMutableDictionary new]; [dicQuery setObject:[NSString stringWithFormat:@"%d",page] forKey:@"page"]; - [dicQuery setObject:@"10" forKey:@"size"]; + [dicQuery setObject:size forKey:@"size"]; [dicQuery setObject:[Tools isStringnil:type_id] forKey:@"type_id"]; // [dicQuery setObject:[Tools stringEncode:[Tools isStringnil:tool_name]] forKey:@"tool_name"]; [dicQuery setObject:[Tools isStringnil:is_recommend] forKey:@"is_recommend"]; diff --git a/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.h b/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.h index 589362d..2e7dc70 100644 --- a/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.h +++ b/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.h @@ -8,7 +8,7 @@ #import "BaseModel.h" NS_ASSUME_NONNULL_BEGIN -@class UserConfigModelData; +@class UserConfigModelData,UserConfigModelDataExtra; @interface UserConfigModel : BaseModel /// @property (nonatomic , strong) UserConfigModelData *data; @@ -26,9 +26,16 @@ NS_ASSUME_NONNULL_BEGIN ///用户名 @property (nonatomic , strong) NSString *name; + ///配置信息 @property (nonatomic , strong) NSDictionary *config; +/// +@property (nonatomic , strong) UserConfigModelDataExtra *extra; @end +@interface UserConfigModelDataExtra : NSObject +/// +@property (nonatomic , strong) NSString *identityType; +@end NS_ASSUME_NONNULL_END diff --git a/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.m b/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.m index dce0729..d50192e 100644 --- a/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.m +++ b/ProductApp/ProductApp/ProductMain/NetWorkManager/PublicModel/UserConfigModel.m @@ -13,6 +13,11 @@ } @end @implementation UserConfigModelData ++ (NSDictionary *)modelContainerPropertyGenericClass { + return @{@"extra" : [UserConfigModelDataExtra class]}; +} +@end +@implementation UserConfigModelDataExtra @end diff --git a/ProductApp/ProductApp/ProductMain/login/LoginViewController.m b/ProductApp/ProductApp/ProductMain/login/LoginViewController.m index b97ff9e..3509607 100644 --- a/ProductApp/ProductApp/ProductMain/login/LoginViewController.m +++ b/ProductApp/ProductApp/ProductMain/login/LoginViewController.m @@ -205,50 +205,19 @@ { [HXLoadingHUD showWithStatus:@"" maskType:0]; [PublicNetWorkManager requestUserLoginData:self.view login_type:@"onekey" phone:dic weixin:@{} apple:@{} device:@{} onekey:dic bind:[NSNumber numberWithBool:self.isbind] unbind:[NSNumber numberWithBool:NO] Callback:^(BOOL state, UserLoginModel *responseObject, NSString * _Nullable describle) { - [HXLoadingHUD dismiss]; if(state) { [UserInfoModel setLoingState:@"1"]; [UserInfoModel setToken:responseObject.data.token]; - [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"onekey" extra:[dic objectForKey:@"gyuid"]]; + + [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"onekey" extra:[Tools isStringnil:[dic objectForKey:@"gyuid"]]]; [UserInfoModel getUserData]; [self pushVC]; - [GeYanSdk closeAuthVC:NO completion:^{ - - AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; - if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) - { - NSArray *arr = self.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) - { - [self.navigationController popToViewController:vc animated:YES]; - return; - } - } - [self.navigationController popToRootViewControllerAnimated:YES]; - [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"onekey" extra:[Tools isStringnil:[dic objectForKey:@"gyuid"]]]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; - } - else - { - NSArray *arr = self.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[StartPayViewController class]]) - { - [self.navigationController popViewControllerAnimated:YES]; - return; - } - } - [appde.window setRootViewController:[TabBarController new]]; - } - }]; } else { + [HXLoadingHUD dismiss]; [HXHud showMessage:responseObject.message afterDelayType:1]; [UserInfoModel shijianShangBao:0 key:@"client.login.err" value:@"onekey" extra:responseObject.message]; } @@ -259,6 +228,7 @@ { NSString *stridfa = [[NSUserDefaults standardUserDefaults] objectForKey:UserIDFA]; [PublicNetWorkManager requestUserConfigData:self.view idfa:stridfa Callback:^(BOOL state, UserConfigModel *responseObject, NSString * _Nullable describle) { + [HXLoadingHUD dismiss]; if(state) { [UserInfoModel setToken:responseObject.data.token]; @@ -268,6 +238,10 @@ [UserInfoModel setConfig:responseObject.data.config]; [UserInfoModel shareModel].isloadconfig=YES; + BOOL ischange = [Tools zhiyeChange:responseObject.data.extra.identityType]; + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; + ///判断是否需要更新tabbar + [self yemiantiaozhuan:ischange]; } else { @@ -275,8 +249,62 @@ } }]; } +///职业是否切换 教育和职场 +-(BOOL)zhiyeChange:(NSString *)value +{ + if(([UserInfoModel shareModel].identityType.intValue<3 && value.intValue<3) || [UserInfoModel shareModel].identityType.intValue == value.intValue) + { + return NO; + } + else + { + return YES; + } +} - +-(void)yemiantiaozhuan:(BOOL)ischange +{ + [GeYanSdk closeAuthVC:NO completion:^{ + + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) + { + NSArray *arr = self.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) + { + [self.navigationController popToViewController:vc animated:YES]; + return; + } + } + + if(ischange) + { + [appde.window setRootViewController:[TabBarController new]]; + } + else + { + [self.navigationController popToRootViewControllerAnimated:YES]; + } + + [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; + } + else + { + NSArray *arr = self.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[StartPayViewController class]]) + { + [self.navigationController popViewControllerAnimated:YES]; + return; + } + } + [appde.window setRootViewController:[TabBarController new]]; + } + }]; +} //MARK: - Model - (GyAuthViewModel *)customModel { diff --git a/ProductApp/ProductApp/ProductMain/login/view/LoginAppleView.m b/ProductApp/ProductApp/ProductMain/login/view/LoginAppleView.m index c5a3c16..8ec2be2 100644 --- a/ProductApp/ProductApp/ProductMain/login/view/LoginAppleView.m +++ b/ProductApp/ProductApp/ProductMain/login/view/LoginAppleView.m @@ -333,7 +333,7 @@ -(void)loginPushApple:(NSDictionary *)dic login_type:(NSString *)login_type { [PublicNetWorkManager requestUserLoginData:self login_type:login_type phone:@{} weixin:@{} apple:dic device:@{} onekey:@{} bind:[NSNumber numberWithBool:self.isbind] unbind:[NSNumber numberWithBool:NO] Callback:^(BOOL state, UserLoginModel *responseObject, NSString * _Nullable describle) { - [HXLoadingHUD dismiss]; + if(state) { [UserInfoModel setLoingState:@"1"]; @@ -341,40 +341,10 @@ [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"apple" extra:@""]; [UserInfoModel getUserData]; [self pushVC]; - - AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; - - if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) - { - [self.viewController.navigationController popToViewController:vc animated:YES]; - return; - } - } - [self.viewController.navigationController popToRootViewControllerAnimated:YES]; - } - else - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[StartPayViewController class]]) - { - [self.viewController.navigationController popViewControllerAnimated:YES]; - return; - } - } - [appde.window setRootViewController:[TabBarController new]]; - } - [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"apple" extra:@""]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; } else { + [HXLoadingHUD dismiss]; [HXHud showMessage:responseObject.message afterDelayType:1]; [UserInfoModel shijianShangBao:0 key:@"client.login.err" value:@"apple" extra:responseObject.message]; } @@ -384,6 +354,7 @@ { NSString *stridfa = [[NSUserDefaults standardUserDefaults] objectForKey:UserIDFA]; [PublicNetWorkManager requestUserConfigData:self idfa:stridfa Callback:^(BOOL state, UserConfigModel *responseObject, NSString * _Nullable describle) { + [HXLoadingHUD dismiss]; if(state) { [UserInfoModel setToken:responseObject.data.token]; @@ -393,6 +364,10 @@ [UserInfoModel setConfig:responseObject.data.config]; [UserInfoModel shareModel].isloadconfig=YES; + BOOL ischange = [Tools zhiyeChange:responseObject.data.extra.identityType]; + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; + ///判断是否需要更新tabbar + [self yemiantiaozhuan:ischange]; } else { @@ -400,7 +375,45 @@ } }]; } - +-(void)yemiantiaozhuan:(BOOL)ischange +{ + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + + if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) + { + [self.viewController.navigationController popToViewController:vc animated:YES]; + return; + } + } + if(ischange) + { + [appde.window setRootViewController:[TabBarController new]]; + } + else + { + [self.viewController.navigationController popToRootViewControllerAnimated:YES]; + } + } + else + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[StartPayViewController class]]) + { + [self.viewController.navigationController popViewControllerAnimated:YES]; + return; + } + } + [appde.window setRootViewController:[TabBarController new]]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; +} #pragma mark - ASAuthorizationController - (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization { if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) { diff --git a/ProductApp/ProductApp/ProductMain/login/view/LoginView.m b/ProductApp/ProductApp/ProductMain/login/view/LoginView.m index c5d489a..8953a13 100644 --- a/ProductApp/ProductApp/ProductMain/login/view/LoginView.m +++ b/ProductApp/ProductApp/ProductMain/login/view/LoginView.m @@ -550,7 +550,6 @@ [HXLoadingHUD showWithStatus:@"" maskType:0]; [PublicNetWorkManager requestUserLoginData:self login_type:@"phone" phone:dic weixin:@{} apple:@{} device:@{} onekey:@{} bind:[NSNumber numberWithBool:self.isbind] unbind:[NSNumber numberWithBool:NO] Callback:^(BOOL state, UserLoginModel *responseObject, NSString * _Nullable describle) { - [HXLoadingHUD dismiss]; if(state) { @@ -570,39 +569,11 @@ [UserInfoModel getUserData]; [self pushVC]; - AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; - if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) - { - [self.viewController.navigationController popToViewController:vc animated:YES]; - return; - } - } - [self.viewController.navigationController popToRootViewControllerAnimated:YES]; - } - else - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[StartPayViewController class]]) - { - [self.viewController.navigationController popViewControllerAnimated:YES]; - return; - } - } - [appde.window setRootViewController:[TabBarController new]]; - } - [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"code" extra:self.fieldPhone.text]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; } else { + [HXLoadingHUD dismiss]; [UserInfoModel shijianShangBao:0 key:@"client.login.err" value:@"phone" extra:responseObject.message]; [HXHud showMessage:responseObject.message afterDelayType:1]; } @@ -612,6 +583,7 @@ { NSString *stridfa = [[NSUserDefaults standardUserDefaults] objectForKey:UserIDFA]; [PublicNetWorkManager requestUserConfigData:self idfa:stridfa Callback:^(BOOL state, UserConfigModel *responseObject, NSString * _Nullable describle) { + [HXLoadingHUD dismiss]; if(state) { [UserInfoModel setToken:responseObject.data.token]; @@ -621,6 +593,11 @@ [UserInfoModel setConfig:responseObject.data.config]; [UserInfoModel shareModel].isloadconfig=YES; + BOOL ischange = [Tools zhiyeChange:responseObject.data.extra.identityType]; + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; + ///判断是否需要更新tabbar + [self yemiantiaozhuan:ischange]; + } else { @@ -628,7 +605,45 @@ } }]; } - +-(void)yemiantiaozhuan:(BOOL)ischange +{ + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + + if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) + { + [self.viewController.navigationController popToViewController:vc animated:YES]; + return; + } + } + if(ischange) + { + [appde.window setRootViewController:[TabBarController new]]; + } + else + { + [self.viewController.navigationController popToRootViewControllerAnimated:YES]; + } + } + else + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[StartPayViewController class]]) + { + [self.viewController.navigationController popViewControllerAnimated:YES]; + return; + } + } + [appde.window setRootViewController:[TabBarController new]]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; +} -(void)otherAction:(UIButton *)sender { [self otherSelectAction:sender.tag]; diff --git a/ProductApp/ProductApp/ProductMain/login/view/LoginWXView.m b/ProductApp/ProductApp/ProductMain/login/view/LoginWXView.m index 72a5d72..8a0aef9 100644 --- a/ProductApp/ProductApp/ProductMain/login/view/LoginWXView.m +++ b/ProductApp/ProductApp/ProductMain/login/view/LoginWXView.m @@ -340,7 +340,7 @@ [HXLoadingHUD showWithStatus:@"" maskType:0]; [PublicNetWorkManager requestUserLoginData:self login_type:@"weixin" phone:@{} weixin:dic apple:@{} device:@{} onekey:@{} bind:[NSNumber numberWithBool:self.isbind] unbind:[NSNumber numberWithBool:NO] Callback:^(BOOL state, UserLoginModel *responseObject, NSString * _Nullable describle) { - [HXLoadingHUD dismiss]; + if(state) { @@ -349,41 +349,10 @@ [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"weixin" extra:@""]; [UserInfoModel getUserData]; [self pushVC]; - AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; - - if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) - { - [self.viewController.navigationController popToViewController:vc animated:YES]; - return; - } - } - [self.viewController.navigationController popToRootViewControllerAnimated:YES]; - } - else - { - NSArray *arr = self.viewController.navigationController.viewControllers; - for(UIViewController *vc in arr) - { - if([vc isKindOfClass:[StartPayViewController class]]) - { - [self.viewController.navigationController popViewControllerAnimated:YES]; - return; - } - } - - [appde.window setRootViewController:[TabBarController new]]; - } - - [UserInfoModel shijianShangBao:0 key:@"client.login.success" value:@"weixin" extra:[Tools isStringnil:resp.code]]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; } else { + [HXLoadingHUD dismiss]; [HXHud showMessage:responseObject.message afterDelayType:1]; [UserInfoModel shijianShangBao:0 key:@"client.login.err" value:@"weixin" extra:responseObject.message]; } @@ -401,6 +370,7 @@ { NSString *stridfa = [[NSUserDefaults standardUserDefaults] objectForKey:UserIDFA]; [PublicNetWorkManager requestUserConfigData:self idfa:stridfa Callback:^(BOOL state, UserConfigModel *responseObject, NSString * _Nullable describle) { + [HXLoadingHUD dismiss]; if(state) { [UserInfoModel setToken:responseObject.data.token]; @@ -409,6 +379,10 @@ [UserInfoModel setName:responseObject.data.name]; [UserInfoModel setConfig:responseObject.data.config]; [UserInfoModel shareModel].isloadconfig=YES; + BOOL ischange = [Tools zhiyeChange:responseObject.data.extra.identityType]; + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; + ///判断是否需要更新tabbar + [self yemiantiaozhuan:ischange]; } else @@ -417,5 +391,46 @@ } }]; } +-(void)yemiantiaozhuan:(BOOL)ischange +{ + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + + if([appde.window.rootViewController isKindOfClass:[TabBarController class]]) + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[ZhangHaoBangDingViewController class]]) + { + [self.viewController.navigationController popToViewController:vc animated:YES]; + return; + } + } + if(ischange) + { + [appde.window setRootViewController:[TabBarController new]]; + } + else + { + [self.viewController.navigationController popToRootViewControllerAnimated:YES]; + } + } + else + { + NSArray *arr = self.viewController.navigationController.viewControllers; + for(UIViewController *vc in arr) + { + if([vc isKindOfClass:[StartPayViewController class]]) + { + [self.viewController.navigationController popViewControllerAnimated:YES]; + return; + } + } + + [appde.window setRootViewController:[TabBarController new]]; + } + + [[NSNotificationCenter defaultCenter] postNotificationName:@"updataUserState" object:nil]; +} @end diff --git a/ProductApp/ProductApp/ProductMain/工具/GongJuListViewController.m b/ProductApp/ProductApp/ProductMain/工具/GongJuListViewController.m index d81be7d..220f330 100644 --- a/ProductApp/ProductApp/ProductMain/工具/GongJuListViewController.m +++ b/ProductApp/ProductApp/ProductMain/工具/GongJuListViewController.m @@ -59,7 +59,7 @@ -(void)getdata { [LoadAlterView show]; - [NetWorkManager requestToolsListData:self.view page:self.ipage type_id:self.model.ID tool_name:self.model.type_name is_recommend:[Tools isStringnil:self.model.ID].length==0?@"0":@"" Callback:^(BOOL state, ToolsListModel *responseObject, NSString * _Nullable describle) { + [NetWorkManager requestToolsListData:self.view page:self.ipage size:@"10" type_id:self.model.ID tool_name:self.model.type_name is_recommend:[Tools isStringnil:self.model.ID].length==0?@"0":@"" Callback:^(BOOL state, ToolsListModel *responseObject, NSString * _Nullable describle) { [LoadAlterView dismiss]; [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; diff --git a/ProductApp/ProductApp/ProductMain/工具/GongJuViewController.m b/ProductApp/ProductApp/ProductMain/工具/GongJuViewController.m index 175ca6e..d839c85 100644 --- a/ProductApp/ProductApp/ProductMain/工具/GongJuViewController.m +++ b/ProductApp/ProductApp/ProductMain/工具/GongJuViewController.m @@ -84,8 +84,20 @@ NSMutableArray *arrurls = [NSMutableArray new]; for(NSDictionary *dic in arrbanner) { - [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + if([UserInfoModel shareModel].identityType.intValue == 3) + { + if(![[dic objectForKey:@"page"] isEqualToString:@"composition"] && ![[dic objectForKey:@"page"] isEqualToString:@"classroom_write"]) + { + [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + } + } + else + { + [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + } } + + cleScrollView.imageURLStringsGroup = arrurls; [self drawUI]; @@ -264,7 +276,23 @@ { NSArray *arrbanner = [[UserInfoModel shareModel].config objectForKey:@"client.home.banner.urls"]; - NSDictionary *dic = arrbanner[index]; + NSMutableArray *arrurls = [NSMutableArray new]; + for(NSDictionary *dic in arrbanner) + { + if([UserInfoModel shareModel].identityType.intValue == 3) + { + if(![[dic objectForKey:@"page"] isEqualToString:@"composition"] && ![[dic objectForKey:@"page"] isEqualToString:@"classroom_write"]) + { + [arrurls addObject:dic]; + } + } + else + { + [arrurls addObject:dic]; + } + } + + NSDictionary *dic = arrurls[index]; NSString *strpage = [Tools isStringnil:[dic objectForKey:@"page"]]; if([strpage isEqualToString:@"recharge"]) { diff --git a/ProductApp/ProductApp/ProductMain/引导/StartNJViewController.m b/ProductApp/ProductApp/ProductMain/引导/StartNJViewController.m index ef06ad6..bc5b1ba 100644 --- a/ProductApp/ProductApp/ProductMain/引导/StartNJViewController.m +++ b/ProductApp/ProductApp/ProductMain/引导/StartNJViewController.m @@ -228,6 +228,13 @@ [dicpush setObject:[NSNumber numberWithInt:(int)self.type] forKey:@"identityType"]; [PublicNetWorkManager requestUserPutData:self.view body:dicpush Callback:^(BOOL state, id _Nullable responseObject, NSString * _Nullable describle) { + ///初始化收藏工具 +// [self pushCollectInit]; + }]; +} +-(void)pushCollectInit +{ + [NetWorkManager requestToolsFavInitData:self.view Callback:^(BOOL state, id _Nullable responseObject, NSString * _Nullable describle) { }]; } diff --git a/ProductApp/ProductApp/ProductMain/引导/StartViewController.m b/ProductApp/ProductApp/ProductMain/引导/StartViewController.m index cec6d52..9b915fe 100644 --- a/ProductApp/ProductApp/ProductMain/引导/StartViewController.m +++ b/ProductApp/ProductApp/ProductMain/引导/StartViewController.m @@ -216,7 +216,7 @@ [self.view setUserInteractionEnabled:YES]; [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:YingDaoYe]; ///初始化收藏工具 - [self pushCollectInit]; +// [self pushCollectInit]; [UserInfoModel shijianShangBao:0 key:@"client.guide.domain.check" value:@"职业选择" extra:[NSString stringWithFormat:@"%@,%@",[self getTingLiuShiJian],lb.text]]; @@ -262,7 +262,8 @@ [dicpush setObject:[NSNumber numberWithInt:3] forKey:@"identityType"]; [PublicNetWorkManager requestUserPutData:self.view body:dicpush Callback:^(BOOL state, id _Nullable responseObject, NSString * _Nullable describle) { - + ///初始化收藏工具 +// [self pushCollectInit]; }]; } } @@ -377,7 +378,7 @@ [UserInfoModel setConfig:responseObject.data.config]; [UserInfoModel shareModel].isloadconfig = YES; - + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; [self pushVC]; } else diff --git a/ProductApp/ProductApp/ProductMain/我的/系统设置/账户管理/ZhangHuGuanLiViewController.m b/ProductApp/ProductApp/ProductMain/我的/系统设置/账户管理/ZhangHuGuanLiViewController.m index 51756ce..0945d68 100644 --- a/ProductApp/ProductApp/ProductMain/我的/系统设置/账户管理/ZhangHuGuanLiViewController.m +++ b/ProductApp/ProductApp/ProductMain/我的/系统设置/账户管理/ZhangHuGuanLiViewController.m @@ -213,7 +213,19 @@ [UserInfoModel shareModel].isloadconfig = YES; - [self.navigationController popToRootViewControllerAnimated:YES]; + BOOL ischange = [Tools zhiyeChange:responseObject.data.extra.identityType]; + + [UserInfoModel setIdentityType:responseObject.data.extra.identityType]; + ///判断是否需要更新tabbar + if(ischange) + { + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + [appde.window setRootViewController:[TabBarController new]]; + } + else + { + [self.navigationController popToRootViewControllerAnimated:YES]; + } } else { diff --git a/ProductApp/ProductApp/ProductMain/首页/ShouYeViewController.m b/ProductApp/ProductApp/ProductMain/首页/ShouYeViewController.m index 3971b03..30eefa7 100644 --- a/ProductApp/ProductApp/ProductMain/首页/ShouYeViewController.m +++ b/ProductApp/ProductApp/ProductMain/首页/ShouYeViewController.m @@ -48,10 +48,10 @@ [self.tableView reloadData]; } [self updateBtShow]; - if(self.arrTools.count==0 || [[[NSUserDefaults standardUserDefaults] objectForKey:HomeToosRef] intValue] == 1) - { - [self getTools]; - } +// if(self.arrTools.count==0 || [[[NSUserDefaults standardUserDefaults] objectForKey:HomeToosRef] intValue] == 1) +// { +// [self getTools]; +// } if([UserInfoModel shareModel].isupdataJiaoyu) { [UserInfoModel shareModel].isupdataJiaoyu = NO; @@ -88,7 +88,7 @@ }]; [self getUserData]; - + [self getTools]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ NSDictionary *dic = [[UserInfoModel shareModel].config objectForKey:@"client.version.upgrade"]; [self showUpDataAltre:dic]; @@ -471,17 +471,12 @@ ///常用工具 -(void)getTools { - [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:HomeToosRef]; - [NetWorkManager requestToolsFavData:self.view page:1 size:@"100" Callback:^(BOOL state, ToolsListModel *responseObject, NSString * _Nullable describle) { + [NetWorkManager requestToolsListData:self.view page:1 size:@"8" type_id:@"" tool_name:@"" is_recommend:@"0" Callback:^(BOOL state, ToolsListModel *responseObject, NSString * _Nullable describle) { [self.tableView.mj_header endRefreshing]; if(state) { self.arrTools = responseObject.data.items; [self.tableView reloadData]; - if(responseObject.data.items.count==0) - { - [self pushCollectInit]; - } } }]; } diff --git a/ProductApp/ProductApp/ProductMain/首页/cell/ShouYeBannerTableViewCell.m b/ProductApp/ProductApp/ProductMain/首页/cell/ShouYeBannerTableViewCell.m index 4a6d1db..d02daba 100644 --- a/ProductApp/ProductApp/ProductMain/首页/cell/ShouYeBannerTableViewCell.m +++ b/ProductApp/ProductApp/ProductMain/首页/cell/ShouYeBannerTableViewCell.m @@ -52,7 +52,17 @@ NSMutableArray *arrurls = [NSMutableArray new]; for(NSDictionary *dic in arrbanner) { - [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + if([UserInfoModel shareModel].identityType.intValue == 3) + { + if(![[dic objectForKey:@"page"] isEqualToString:@"composition"] && ![[dic objectForKey:@"page"] isEqualToString:@"classroom_write"]) + { + [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + } + } + else + { + [arrurls addObject:[Tools isStringnil:[dic objectForKey:@"image"]]]; + } } cleScrollView.imageURLStringsGroup = arrurls; @@ -75,7 +85,24 @@ { NSArray *arrbanner = [[UserInfoModel shareModel].config objectForKey:@"client.home.banner.urls"]; - NSDictionary *dic = arrbanner[index]; + NSMutableArray *arrurls = [NSMutableArray new]; + for(NSDictionary *dic in arrbanner) + { + if([UserInfoModel shareModel].identityType.intValue == 3) + { + if(![[dic objectForKey:@"page"] isEqualToString:@"composition"] && ![[dic objectForKey:@"page"] isEqualToString:@"classroom_write"]) + { + [arrurls addObject:dic]; + } + } + else + { + [arrurls addObject:dic]; + } + } + + + NSDictionary *dic = arrurls[index]; NSString *strpage = [Tools isStringnil:[dic objectForKey:@"page"]]; if([strpage isEqualToString:@"recharge"]) { diff --git a/ProductApp/ProductApp/ProductMain/首页/切换身份/ShouYeLingYuViewController.m b/ProductApp/ProductApp/ProductMain/首页/切换身份/ShouYeLingYuViewController.m index c1c27dd..469548b 100644 --- a/ProductApp/ProductApp/ProductMain/首页/切换身份/ShouYeLingYuViewController.m +++ b/ProductApp/ProductApp/ProductMain/首页/切换身份/ShouYeLingYuViewController.m @@ -9,6 +9,8 @@ #import "ShouYeShenFenViewController.h" #import "NetWorkManager.h" #import "PublicNetWorkManager.h" +#import "AppDelegate.h" +#import "GongJuViewController.h" @interface ShouYeLingYuViewController () /// @@ -196,10 +198,44 @@ { [UserInfoModel shareModel].user_stage = modelson; [UserInfoModel shareModel].isAllLevel = [NSString stringWithFormat:@"%@",[NSNumber numberWithBool:NO]]; + + BOOL ischange = [Tools zhiyeChange:@"3"]; [UserInfoModel setIdentityType:@"3"]; [UserInfoModel shareModel].isupdataJiaoyu = YES; - - [self.navigationController popToRootViewControllerAnimated:YES]; + ///判断是否需要更新tabbar + if(ischange) + { + NSArray *arrtemp = self.navigationController.viewControllers; + + BOOL isgongju = NO; + for(UIViewController *vc in arrtemp) + { + if([vc isKindOfClass:[GongJuViewController class]]) + { + isgongju = YES; + break; + } + } + + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + TabBarController *tabbar = [TabBarController new]; + [appde.window setRootViewController:tabbar]; + if(isgongju) + { + if([UserInfoModel shareModel].identityType.intValue == 3) + { + [tabbar setSelectedIndex:1]; + } + else + { + [tabbar setSelectedIndex:3]; + } + } + } + else + { + [self.navigationController popToRootViewControllerAnimated:YES]; + } } else { diff --git a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.h b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.h index b10f43c..76cbcc1 100644 --- a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.h +++ b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ShouYeShenFenNianJiView : UIView ///0学生 1家长 2老师 @property (nonatomic , assign) NSInteger type; - +@property (nonatomic , assign) BOOL isslect; /// @property (nonatomic , strong) NSArray *arrdata; diff --git a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.m b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.m index 880a778..eb55acc 100644 --- a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.m +++ b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenNianJiView.m @@ -221,6 +221,11 @@ } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + if(self.isslect==NO) + { + [HXHud showMessage:@"请选择身份" afterDelayType:0]; + return; + } RoleTreeModelData *modelsuper = self.arrdata[indexPath.section]; RoleTreeModelData *model = modelsuper.node[indexPath.row]; diff --git a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenView.m b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenView.m index aa743a6..354ade0 100644 --- a/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenView.m +++ b/ProductApp/ProductApp/ProductMain/首页/切换身份/view/ShouYeShenFenView.m @@ -12,6 +12,8 @@ #import "PublicNetWorkManager.h" #import "RoleTreeModel.h" +#import "AppDelegate.h" +#import "GongJuViewController.h" @interface ShouYeShenFenView () /// @@ -213,8 +215,44 @@ [UserInfoModel shareModel].isupdataJiaoyu=YES; [UserInfoModel shareModel].user_stage = modelson; [UserInfoModel shareModel].isAllLevel = [NSString stringWithFormat:@"%@",[NSNumber numberWithBool:isall]]; + + BOOL ischange = [Tools zhiyeChange:[NSString stringWithFormat:@"%d",type]]; + [UserInfoModel setIdentityType:[NSString stringWithFormat:@"%d",type]]; - [self.viewController.navigationController popToRootViewControllerAnimated:YES]; + ///判断是否需要更新tabbar + if(ischange) + { + NSArray *arrtemp = self.viewController.navigationController.viewControllers; + + BOOL isgongju = NO; + for(UIViewController *vc in arrtemp) + { + if([vc isKindOfClass:[GongJuViewController class]]) + { + isgongju = YES; + break; + } + } + + AppDelegate *appde = (AppDelegate *)[UIApplication sharedApplication].delegate; + TabBarController *tabbar = [TabBarController new]; + [appde.window setRootViewController:tabbar]; + if(isgongju) + { + if([UserInfoModel shareModel].identityType.intValue == 3) + { + [tabbar setSelectedIndex:1]; + } + else + { + [tabbar setSelectedIndex:3]; + } + } + } + else + { + [self.viewController.navigationController popToRootViewControllerAnimated:YES]; + } } else { @@ -262,6 +300,9 @@ model.select = YES; self.viewnj.type = indexPath.row; [self.collect reloadData]; + + self.viewnj.isslect = YES; + } @end diff --git a/ProductApp/ProductApp/ProductMain/首页/历史记录/ShouYeLiShiJiLuViewController.m b/ProductApp/ProductApp/ProductMain/首页/历史记录/ShouYeLiShiJiLuViewController.m index 856822b..5a82919 100644 --- a/ProductApp/ProductApp/ProductMain/首页/历史记录/ShouYeLiShiJiLuViewController.m +++ b/ProductApp/ProductApp/ProductMain/首页/历史记录/ShouYeLiShiJiLuViewController.m @@ -22,14 +22,14 @@ } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self.navigationController setNavigationBarHidden:YES animated:animated]; +} +- (void)viewDidLoad { + [super viewDidLoad]; + [self.navigationController setNavigationBarHidden:YES animated:NO]; [self showNaviGationView:YES]; [self.navigationView setTitle:@"历史记录" titleColor:RGBCOLOR(60, 60, 60)]; [self.navigationView setBackgroundColor:[UIColor whiteColor]]; -} -- (void)viewDidLoad { - [super viewDidLoad]; [self.view setBackgroundColor:RGBCOLOR(242, 242, 242)]; ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init]; @@ -43,7 +43,12 @@ style.scrollLineWidth = 20; style.scrollLineColor = [UIColor whiteColor]; style.autoAdjustTitlesWidth = YES; - ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, NavHeight, UISCREEN_WIDTH, UISCREEN_HEIGHT - NavHeight) segmentStyle:style titles:@[@"写作",@"批改",@"拍题",@"PPT"] parentViewController:self delegate:self]; + float ftemp = 0; + if([UserInfoModel shareModel].identityType.intValue==3) + { + ftemp = TabHeight; + } + ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, NavHeight, UISCREEN_WIDTH, UISCREEN_HEIGHT - NavHeight-ftemp) segmentStyle:style titles:@[@"写作",@"批改",@"拍题",@"PPT"] parentViewController:self delegate:self]; [self.view addSubview:scrollPageView]; scrollPageView.segmentView.backgroundColor = [UIColor whiteColor]; [scrollPageView reloadWithNewTitles:@[@"写作",@"批改",@"拍题",@"PPT"]];