time 6 years ago
parent
commit
6119345d61

+ 14 - 0
UU_Ent/UU_Ent.xcodeproj/project.pbxproj

@@ -24,6 +24,7 @@
 		999F6516227E688600329012 /* UIView+selector.m in Sources */ = {isa = PBXBuildFile; fileRef = 999F6515227E688600329012 /* UIView+selector.m */; };
 		999F651A227E697D00329012 /* UILabel+vertical.m in Sources */ = {isa = PBXBuildFile; fileRef = 999F6519227E697D00329012 /* UILabel+vertical.m */; };
 		999F651E227E6A6000329012 /* NSString+regular.m in Sources */ = {isa = PBXBuildFile; fileRef = 999F651D227E6A6000329012 /* NSString+regular.m */; };
+		99B4252F22815E2900DAE304 /* YRAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 99B4252E22815E2900DAE304 /* YRAlertView.m */; };
 		99C16340227FD24E002ED79D /* YRWorkConModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C1633F227FD24E002ED79D /* YRWorkConModel.m */; };
 		99C16342227FDE64002ED79D /* work_route.json in Resources */ = {isa = PBXBuildFile; fileRef = 99C16341227FDE64002ED79D /* work_route.json */; };
 		99C16345228027C8002ED79D /* YRMsgHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C16344228027C8002ED79D /* YRMsgHeader.m */; };
@@ -173,6 +174,8 @@
 		999F6519227E697D00329012 /* UILabel+vertical.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UILabel+vertical.m"; sourceTree = "<group>"; };
 		999F651C227E6A6000329012 /* NSString+regular.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+regular.h"; sourceTree = "<group>"; };
 		999F651D227E6A6000329012 /* NSString+regular.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+regular.m"; sourceTree = "<group>"; };
+		99B4252D22815E2900DAE304 /* YRAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YRAlertView.h; sourceTree = "<group>"; };
+		99B4252E22815E2900DAE304 /* YRAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YRAlertView.m; sourceTree = "<group>"; };
 		99C1633E227FD24E002ED79D /* YRWorkConModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YRWorkConModel.h; sourceTree = "<group>"; };
 		99C1633F227FD24E002ED79D /* YRWorkConModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YRWorkConModel.m; sourceTree = "<group>"; };
 		99C16341227FDE64002ED79D /* work_route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = work_route.json; sourceTree = "<group>"; };
@@ -401,6 +404,15 @@
 			path = NSString;
 			sourceTree = "<group>";
 		};
+		99B4252C22815E0700DAE304 /* AlertView */ = {
+			isa = PBXGroup;
+			children = (
+				99B4252D22815E2900DAE304 /* YRAlertView.h */,
+				99B4252E22815E2900DAE304 /* YRAlertView.m */,
+			);
+			path = AlertView;
+			sourceTree = "<group>";
+		};
 		99C6FE3B22768B5B00C7070A = {
 			isa = PBXGroup;
 			children = (
@@ -561,6 +573,7 @@
 		99C6FE8D22768EC000C7070A /* Utils */ = {
 			isa = PBXGroup;
 			children = (
+				99B4252C22815E0700DAE304 /* AlertView */,
 				2710E65A22801D870002A4B0 /* UINavigation */,
 				2710E65922801D760002A4B0 /* UITextField */,
 				999F651B227E6A3E00329012 /* NSString */,
@@ -1327,6 +1340,7 @@
 				99C6FE96227690BE00C7070A /* YRBaseVC.m in Sources */,
 				2710E65522801B7E0002A4B0 /* YRRegisterVC.m in Sources */,
 				99C6FF172276D13500C7070A /* YRUserInfo.m in Sources */,
+				99B4252F22815E2900DAE304 /* YRAlertView.m in Sources */,
 				999F6510227E658E00329012 /* UIView+frame.m in Sources */,
 				99C6FEC32276959B00C7070A /* YRWorkVC.m in Sources */,
 				99F4A73D2277D1B8009AA6ED /* YRLoadImgCacheTool.m in Sources */,

+ 1 - 1
UU_Ent/UU_Ent/Modules/Base/YRBaseNav.m

@@ -18,6 +18,7 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     
+    [self setNavigationBar];
     
 }
 
@@ -25,7 +26,6 @@
     
     self.navigationBar.tintColor = [UIColor orangeColor];
     
-    
 }
 
 

+ 1 - 1
UU_Ent/UU_Ent/Modules/Login/Main/Controllers/YRLoginVC.m

@@ -245,7 +245,7 @@
     [self.scrollView addSubview:registerBtn];
     [registerBtn addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
     
-//    [self loginAction];
+    [self loginAction];
     
 }
 

+ 7 - 0
UU_Ent/UU_Ent/Modules/Main/Main/Controllers/YRMainVC.m

@@ -42,6 +42,13 @@
     [self setValue:tarBar forKey:@"tabBar"];
     
     self.tabBar.tintColor = HexColor(@"#1084D1");
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        
+        [tarBar showBadgeOnItemIndex:1];
+        [tarBar showBadgeOnItemIndex:2];
+        
+    });
 }
 
 

+ 1 - 1
UU_Ent/UU_Ent/Modules/Main/Main/Views/YRTabBar.m

@@ -57,7 +57,7 @@
                         label.textAlignment = NSTextAlignmentCenter;
                         
                         [viewOne addSubview:label];
-                        label.text = @"33";
+                        
                         [label mas_makeConstraints:^(MASConstraintMaker *make) {
                             
                             make.top.equalTo(viewOne).offset(-6);

+ 70 - 4
UU_Ent/UU_Ent/Modules/Message/Main/Controllers/YRMsgVC.m

@@ -54,10 +54,14 @@
     
 }
 
+#pragma mark - 网络请求
 
+/**
+ 获取配置信息
+ */
 -(void)getDataFromServer{
     
-    
+    //获取配置信息
     [GRPCCall useInsecureConnectionsForHost:kHostAddress];
     
     MessageService *client = [[MessageService alloc]initWithHost:kHostAddress];
@@ -65,16 +69,15 @@
     GetMessageConfigRequest *request = [GetMessageConfigRequest message];
     
     GRPCProtoCall *call = [client RPCTogetConfigWithRequest:request handler:^(GetMessageConfigResponse * _Nullable response, NSError * _Nullable error) {
-        [self.tableView.mj_header endRefreshing];
+        
         if (!error) {//请求成功
             
             NSDictionary *dict = response.mj_keyValues;
             
             self.dataArr = [YRMsgMainModel mj_objectArrayWithKeyValuesArray:dict[@"configArray"]];
             
-            [self calculteRemindCount];
+            [self getUnreadMessage];
             
-            [self.tableView reloadData];
             
         }else{//请求失败
             
@@ -88,9 +91,72 @@
     
     [call start];
     
+    
 }
 
 
+/**
+ 获取未读消息条数
+ */
+-(void)getUnreadMessage{
+    
+   
+    [GRPCCall useInsecureConnectionsForHost:kHostAddress];
+    
+    MessageService *client = [[MessageService alloc]initWithHost:kHostAddress];
+    
+    GetUnreadMessageCountRequest *request = [GetUnreadMessageCountRequest message];
+    
+    GRPCProtoCall *call =  [client RPCTogetUnreadCountWithRequest:request handler:^(GetUnreadMessageCountResponse * _Nullable response, NSError * _Nullable error) {
+      [self.tableView.mj_header endRefreshing];
+      for (YRMsgMainModel *model in self.dataArr) {
+          
+          for (UnreadMessageCount *msgUn in response.unreadArray) {
+              
+              if ([model.code isEqualToString:msgUn.code]) {
+                  
+                  model.remindCount = msgUn.count+arc4random_uniform(20);
+                  
+              }
+              
+          }
+          
+      }
+      
+      [self calculteRemindCount];
+      
+      [self.tableView reloadData];
+      
+    }];
+    
+    call.requestHeaders[@"authentication"] = [YRUserInfo shareManager].token;
+    
+    [call start];
+    
+}
+
+-(void)setMessageReadRequest:(YRMsgMainModel *)model{
+    
+    [GRPCCall useInsecureConnectionsForHost:kHostAddress];
+    
+    MessageService *client = [[MessageService alloc]initWithHost:kHostAddress];
+    
+    SetMessageReadRequest *request = [SetMessageReadRequest message];
+    
+   GRPCProtoCall *call = [client RPCTosetReadWithRequest:request handler:^(SetMessageReadResponse * _Nullable response, NSError * _Nullable error) {
+        
+       NSDictionary *dict = response.mj_keyValues;
+       
+       DLog(@"%@",dict);
+       
+    }];
+    
+    call.requestHeaders[@"authentication"] = [YRUserInfo shareManager].token;
+    
+    [call start];
+    
+    
+}
 
 #pragma mark - delegate && dataSource
 

+ 7 - 2
UU_Ent/UU_Ent/Modules/Message/Main/Models/YRMsgMainModel.m

@@ -16,7 +16,7 @@
 -(void)setCode:(NSString *)code{
     
     _code = code;
-    
+   
     NSString *path = [[NSBundle mainBundle]pathForResource:@"msg_route" ofType:@"json"];
     
     NSData *data = [[NSData alloc]initWithContentsOfFile:path];
@@ -36,7 +36,12 @@
             }
             
         }
-    
+    //如果本地未配置,尝试直接跳转该页面
+    if (!self.desVC) {
+        
+        self.desVC = self.iosWidget;
+        
+    }
     
 }
 

+ 1 - 0
UU_Ent/UU_Ent/Modules/Message/Main/Views/YRMsgMainCell.m

@@ -38,6 +38,7 @@
 
 -(void)setUpUI{
     
+    
     [self.contentView addSubview:self.iconView];
     [self.iconView addSubview:self.remindLabel];
     [self.contentView addSubview:self.titleLabel];

+ 6 - 1
UU_Ent/UU_Ent/Modules/Mine/Main/Controllers/YRMineVC.m

@@ -7,7 +7,7 @@
 //
 
 #import "YRMineVC.h"
-
+#import "YRTabBar.h"
 @interface YRMineVC ()
 
 @end
@@ -18,6 +18,11 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     self.title = @"我";
+    
+    YRTabBar *tarbar = (YRTabBar *)self.tabBarController.tabBar;
+    
+    [tarbar hideBadgeOnItemIndex:2];
+    
 }
 
 

+ 5 - 0
UU_Ent/UU_Ent/Modules/Work/Main/Controllers/YRWorkVC.m

@@ -8,6 +8,7 @@
 
 #import "YRWorkVC.h"
 #import "YRWebVC.h"
+#import "YRTabBar.h"
 #import <UU_Ent/App.pbrpc.h>
 #import "YRWorkTabCell.h"
 @interface YRWorkVC ()<UITableViewDelegate,UITableViewDataSource>
@@ -313,6 +314,10 @@
         
     }
     
+    YRTabBar *tarbar = (YRTabBar *)self.tabBarController.tabBar;
+    
+    [tarbar hideBadgeOnItemIndex:1];
+    
 }
 
 #pragma mark -scrollDelegate

+ 7 - 0
UU_Ent/UU_Ent/Modules/Work/Main/Models/YRWorkConModel.m

@@ -47,6 +47,13 @@
             }
             
         }
+     
+        //如果本地未配置,尝试直接跳转该页面
+        if (!model.desVC) {
+            
+            model.desVC = model.iosWidget;
+            
+        }
         
     }
 

+ 27 - 0
UU_Ent/UU_Ent/Utils/AlertView/YRAlertView.h

@@ -0,0 +1,27 @@
+//
+//  YRAlertView.h
+//  UU_Ent
+//
+//  Created by liujl on 2019/5/7.
+//  Copyright © 2019 UAS. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface YRAlertView : UIWindow
+
+/*
+ title:标题 (默认UU互联)
+ content:内容
+ sureTitle:右边按钮
+ cancelTitle:左边按钮 (为nil时,只显示sureTitle 置中)
+ */
++(void)showWithTitle:(NSString *)title content:(NSString *)content sureTitle:(NSString *)sureTitle cancelTitle:(NSString *)cancelTitle click:(void(^)(NSInteger index))clicked;
+//一元捐
++(void)yyj_showWithTitle:(NSString *)title content:(NSString *)content sureTitle:(NSString *)sureTitle cancelTitle:(NSString *)cancelTitle click:(void(^)(NSInteger index))clicked;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 203 - 0
UU_Ent/UU_Ent/Utils/AlertView/YRAlertView.m

@@ -0,0 +1,203 @@
+//
+//  YRAlertView.m
+//  UU_Ent
+//
+//  Created by liujl on 2019/5/7.
+//  Copyright © 2019 UAS. All rights reserved.
+//
+
+#import "YRAlertView.h"
+
+static YRAlertView *alert = nil;
+
+@interface YRAlertView()
+
+@property(copy,nonatomic)void(^clicked)(NSInteger index);
+
+@end
+
+@implementation YRAlertView
+
++(void)showWithTitle:(NSString *)title content:(NSString *)content sureTitle:(NSString *)sureTitle cancelTitle:(NSString *)cancelTitle click:(void(^)(NSInteger index))clicked{
+    
+    if (!alert) {
+        
+        alert = [[YRAlertView alloc]initWithFrame:[UIScreen mainScreen].bounds];
+        
+        alert.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
+        
+        [alert makeKeyAndVisible];
+        
+        alert.clicked = clicked;
+        
+        UIView *centView = [[UIView alloc]init];
+        
+        centView.layer.cornerRadius = 8;
+        centView.layer.masksToBounds = YES;
+        centView.backgroundColor = [UIColor whiteColor];
+        [alert addSubview:centView];
+        
+        [centView mas_makeConstraints:^(MASConstraintMaker *make) {
+            
+            make.center.equalTo(alert);
+            make.width.mas_equalTo(268);
+            make.height.mas_equalTo(150);
+            
+        }];
+        
+        UILabel *titleL = [UILabel new];
+        titleL.font = FONT_SIZE(16);
+        titleL.textColor = HexColor(@"#333333");
+        titleL.textAlignment = NSTextAlignmentCenter;
+        [centView addSubview:titleL];
+        if (!title) {
+            
+            title = @"UU互联";
+            
+        }
+        titleL.text = title;
+        [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
+            
+            make.top.equalTo(centView).offset(11);
+            make.left.right.equalTo(centView);
+            make.height.mas_equalTo(21);
+            
+        }];
+        
+        UILabel *contentL = [UILabel new];
+        contentL.textAlignment = NSTextAlignmentLeft;
+        contentL.font = FONT_SIZE(15);
+        contentL.textColor = HexColor(@"#666666");
+        contentL.text = content;
+        contentL.numberOfLines = 0;
+        [centView addSubview:contentL];
+        contentL.lineBreakMode = NSLineBreakByCharWrapping;
+        
+        CGSize contentSize = [content boundingRectWithSize:CGSizeMake(268 - 52, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : FONT_SIZE(15)} context:NULL].size;;
+        
+        [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.top.equalTo(centView).offset(51);
+            make.left.equalTo(centView).offset(26);
+            make.right.equalTo(centView).offset(-26);
+            if (contentSize.height > 40) {
+                make.height.mas_equalTo(contentSize.height);
+            }else{
+                make.height.mas_equalTo(40);
+            }
+        }];
+        
+        if (contentSize.height > 40) {
+            [centView mas_updateConstraints:^(MASConstraintMaker *make) {
+                make.center.equalTo(alert);
+                make.width.mas_equalTo(268);
+                make.height.mas_equalTo(150+contentSize.height-40);
+            }];
+        }
+        
+        UIButton *cancel = [UIButton new];
+        cancel.titleLabel.font = FONT_SIZE(15);
+        cancel.tag = 1;
+        cancel.layer.borderWidth = 1;
+        cancel.layer.borderColor = HexColor(@"33a2ee").CGColor;
+        [cancel setTitle:cancelTitle forState:UIControlStateNormal];
+        [cancel setTitle:cancelTitle forState:UIControlStateHighlighted];
+        [cancel setTitleColor:HexColor(@"#1084D1") forState:UIControlStateNormal];
+        [cancel setTitleColor:HexColor(@"#065C97") forState:UIControlStateHighlighted];
+        [cancel setBackgroundColor:[UIColor whiteColor] forState:UIControlStateNormal];
+        [cancel setBackgroundColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
+        cancel.layer.cornerRadius = 5;
+        cancel.layer.masksToBounds = YES;
+        [cancel addTarget:alert action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
+        
+        
+        UIButton *sure = [UIButton new];
+        sure.titleLabel.font = FONT_SIZE(15);
+        sure.tag = 2;
+        sure.layer.borderWidth = 1;
+        sure.layer.borderColor = HexColor(@"33A2EE").CGColor;
+        [sure setTitle:sureTitle forState:UIControlStateNormal];
+        [sure setTitle:sureTitle forState:UIControlStateHighlighted];
+        [sure setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+        [sure setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
+        [sure setBackgroundColor:HexColor(@"33A2EE") forState:UIControlStateNormal];
+        [sure setBackgroundColor:HexColor(@"#2D84C0") forState:UIControlStateHighlighted];
+        sure.layer.cornerRadius = 5;
+        sure.layer.masksToBounds = YES;
+        [centView addSubview:sure];
+        [sure addTarget:alert action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
+        
+        if (cancelTitle) {
+            [centView addSubview:cancel];
+            [cancel mas_makeConstraints:^(MASConstraintMaker *make) {
+                
+                make.left.equalTo(centView).offset(26);
+                make.top.equalTo(contentL.mas_bottom).offset(10);
+                make.width.mas_equalTo(94);
+                make.height.mas_equalTo(35);
+                
+            }];
+            [sure mas_makeConstraints:^(MASConstraintMaker *make) {
+                
+                make.right.equalTo(centView).offset(-26);
+                make.top.equalTo(contentL.mas_bottom).offset(10);
+                make.width.mas_equalTo(94);
+                make.height.mas_equalTo(35);
+                
+            }];
+        }else{
+            
+            
+            [sure mas_makeConstraints:^(MASConstraintMaker *make) {
+                
+                make.centerX.equalTo(centView);
+                make.top.equalTo(contentL.mas_bottom).offset(10);
+                make.width.mas_equalTo(110);
+                make.height.mas_equalTo(35);
+                
+            }];
+        }
+        
+        CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
+        anima.fromValue = [NSNumber numberWithFloat:0.9f];
+        anima.toValue = [NSNumber numberWithFloat:1.0f];
+        anima.duration = 0.1f;
+        anima.repeatCount = 1;
+        [centView.layer addAnimation:anima forKey:@"scaleAnimation"];
+        
+    }else{
+        
+        [alert makeKeyAndVisible];
+        
+        
+    }
+    
+}
+
+
++(void)yyj_showWithTitle:(NSString *)title content:(NSString *)content sureTitle:(NSString *)sureTitle cancelTitle:(NSString *)cancelTitle click:(void(^)(NSInteger index))clicked{
+    
+    
+}
+
+-(void)buttonClicked:(UIButton *)btn{
+    
+    
+    if (self.clicked) {
+        
+        self.clicked(btn.tag);
+        
+    }
+    
+    
+    [self resignKeyWindow];
+    
+    alert = nil;
+    
+}
+
+-(void)dealloc{
+    
+    
+}
+
+@end