瀏覽代碼

部分优化

桂欢 2 年之前
父節點
當前提交
af04d855db

+ 2 - 2
SLAiELTS/SLAiELTS/Tool/NetWorking/SLHttpCenter.m

@@ -32,7 +32,7 @@ static SLHttpCenter *handle;
     url = [url hasPrefix:@"http"] ? url : [NSString stringWithFormat:@"%@%@",self.serverUrl,url];
     NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:parameter];
     NSString *userId = [SLGlobalInfo SharedInstance].loginInfo.user.userId;
-    if (userId.length) {
+    if (userId.length && ![dict objectForKey:@"userId"]) {
         [dict addEntriesFromDictionary:@{@"userId" : userId}];
     }
     [handle GET:url parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
@@ -56,7 +56,7 @@ static SLHttpCenter *handle;
     url = [url hasPrefix:@"http"] ? url : [NSString stringWithFormat:@"%@%@",self.serverUrl,url];
     NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:parameter];
     NSString *userId = [SLGlobalInfo SharedInstance].loginInfo.user.userId;
-    if (userId.length) {
+    if (userId.length && ![dict objectForKey:@"userId"]) {
         [dict addEntriesFromDictionary:@{@"userId" : userId}];
     }
     [handle POST:url parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

+ 15 - 2
SLAiELTS/SLAiELTS/Tool/SDPhotoBrowser/SDPhotoBrowser.m

@@ -23,6 +23,11 @@
 
 //  =============================================
 
+@interface SDPhotoBrowser()
+
+@property (nonatomic, strong) UIButton *operationLikeButton;
+
+@end
 @implementation SDPhotoBrowser 
 {
     UIScrollView *_scrollView;
@@ -31,7 +36,6 @@
     UIButton *_saveButton;
     UIActivityIndicatorView *_indicatorView;
     BOOL _willDisappear;
-    UIButton *_operationLikeButton;
     UIButton *_operationCommentButton;
     UILabel *_detailLabel;
 }
@@ -92,9 +96,18 @@
     _operationLikeButton.titleLabel.font = [UIFont systemFontOfSize:10];
     [_operationLikeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [_operationLikeButton setImage:[UIImage imageNamed:@"icon_heart"] forState:UIControlStateNormal];
+    [_operationLikeButton setImage:[UIImage imageNamed:@"icon_heart_sel"] forState:UIControlStateSelected];
+    WS(weakSelf);
     [_operationLikeButton handleEvent:UIControlEventTouchUpInside withBlock:^{
-        
+        weakSelf.operationLikeButton.selected = !weakSelf.operationLikeButton.selected;
+        weakSelf.cellModel.isLike = weakSelf.operationLikeButton.selected;
+        [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/LikeHe" parameter:@{@"friendId":weakSelf.cellModel.friendId} success:^(id responseObject) {
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"SLMomentsUpdate" object:nil];
+        } failure:^(SPRequestError *error) {
+            
+        }];
     }];
+    _operationLikeButton.selected = self.cellModel.isLike;
 
     _operationCommentButton = [UIButton buttonWithType:UIButtonTypeCustom];
     [_operationCommentButton setTitle:@"评论" forState:UIControlStateNormal];

+ 2 - 0
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/SLAddressBookVc.m

@@ -112,6 +112,8 @@
     self.tableView.sc_translucentForTableViewInNavigationBar = YES;
     self.tableView.sc_startSection = 1;
     self.tableView.backgroundColor = [UIColor clearColor];
+    //可以直接添加如下代码即可
+    self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
 }
 
 - (void)preserveBtnClick {

+ 1 - 2
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/SLAddressBookVc.xib

@@ -59,9 +59,8 @@
                         <constraint firstAttribute="height" constant="112" id="ZKL-QU-wwc"/>
                     </constraints>
                 </view>
-                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="zZg-tP-8TM">
+                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="zZg-tP-8TM">
                     <rect key="frame" x="0.0" y="241" width="390" height="569"/>
-                    <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     <connections>
                         <outlet property="dataSource" destination="-1" id="W0r-rK-VvZ"/>
                         <outlet property="delegate" destination="-1" id="Qns-8C-PT7"/>

+ 2 - 0
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/TimeLineController/SDTimeLineTableViewController.h

@@ -30,4 +30,6 @@
 
 @interface SDTimeLineTableViewController : SDBaseTableViewController
 
+@property (nonatomic, strong) SLUserModel *userModel;
+
 @end

+ 13 - 36
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/TimeLineController/SDTimeLineTableViewController.m

@@ -55,14 +55,11 @@ static CGFloat textFieldH = 56;
 
 @property (nonatomic, strong) SDTimeLineCellCommentItemModel *currentCommentItemModel;
 
-@property (nonatomic, assign) NSInteger currentPageIndex;
 @end
 
 @implementation SDTimeLineTableViewController
 
 {
-//    SDTimeLineRefreshFooter *_refreshFooter;
-//    SDTimeLineRefreshHeader *_refreshHeader;
     CGFloat _lastScrollViewOffsetY;
     CGFloat _totalKeybordHeight;
 }
@@ -70,19 +67,7 @@ static CGFloat textFieldH = 56;
 - (void)viewDidLoad
 {
     [super viewDidLoad];
-    
-    //LEETheme 分为两种模式 , 独立设置模式 JSON设置模式 , 朋友圈demo展示的是独立设置模式的使用 , 微信聊天demo 展示的是JSON模式的使用
-    
-    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"日间" style:UIBarButtonItemStyleDone target:self action:@selector(rightBarButtonItemAction:)];
-    
-    //为self.view 添加背景颜色设置
-    
-    self.view.lee_theme
-    .LeeAddBackgroundColor(DAY , [UIColor whiteColor])
-    .LeeAddBackgroundColor(NIGHT , [UIColor blackColor]);
-    
-    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
-    
+
     if (@available(iOS 11.0, *)) {
         self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
     } else {
@@ -90,20 +75,21 @@ static CGFloat textFieldH = 56;
     }
     self.edgesForExtendedLayout = UIRectEdgeTop;
     
-    
-    self.currentPageIndex = 1;
+    if (!self.userModel) {
+        self.userModel = [SLGlobalInfo SharedInstance].loginInfo.user;
+    }
     SDTimeLineTableHeaderView *headerView = [SDTimeLineTableHeaderView new];
-    headerView.frame = CGRectMake(0, 0, 0, 260);
+    headerView.frame = CGRectMake(0, 0, 0, 220 * KScaleW);
     self.tableView.tableHeaderView = headerView;
     
     //添加分隔线颜色设置
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-
     [self.tableView registerClass:[SDTimeLineCell class] forCellReuseIdentifier:kTimeLineTableViewCellId];
     
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
-    [self creatModelsWithCount:self.currentPageIndex];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(momentsUpdate:) name:@"SLMomentsUpdate" object:nil];
+    [self creatModelsWithCount:0];
     
 }
 
@@ -111,6 +97,7 @@ static CGFloat textFieldH = 56;
 {
     [super viewDidAppear:animated];
     [self setupTextField];
+    [self creatModelsWithCount:0];
 }
 
 - (void)viewWillDisappear:(BOOL)animated
@@ -129,6 +116,10 @@ static CGFloat textFieldH = 56;
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
+- (void)momentsUpdate:(NSNotificationCenter *)conter {
+    [self creatModelsWithCount:0];
+}
+
 - (void)setupTextField
 {
     self.moentsChatView = [[SLMoentsChatView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height, self.view.width_sd, textFieldH)];
@@ -181,19 +172,6 @@ static CGFloat textFieldH = 56;
     };
 }
 
-// 右栏目按钮点击事件
-
-- (void)rightBarButtonItemAction:(UIBarButtonItem *)sender{
-    
-    if ([[LEETheme currentThemeTag] isEqualToString:DAY]) {
-        
-        [LEETheme startTheme:NIGHT];
-        
-    } else {
-        [LEETheme startTheme:DAY];
-    }
-}
-
 - (void)creatModelsWithCount:(NSInteger)count
 {
     WEAKSELF;
@@ -202,6 +180,7 @@ static CGFloat textFieldH = 56;
         NSDictionary *parameter = @{@"PageIndex": @(pageNo),
                                     @"PageSize": @(SLPageSize),
                                     @"type" : @"0",
+                                    @"userId" : self.userModel.userId,
         };
         WS(weakSelf);
         [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/GetFriendList" parameter:parameter success:^(id responseObject) {
@@ -345,7 +324,6 @@ static CGFloat textFieldH = 56;
     } failure:^(SPRequestError *error) {
         
     }];
-    
     if (!model.isLike) {
         SDTimeLineCellLikeItemModel *likeModel = [SDTimeLineCellLikeItemModel new];
         likeModel.userName = model.userName;
@@ -364,7 +342,6 @@ static CGFloat textFieldH = 56;
         model.isLike = NO;
     }
     model.likeItemsArray = [temp copy];
-    
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
     });

+ 2 - 0
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/TimeLineController/SLCreatMomentsVc.h

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface SLCreatMomentsVc : SLBaseViewController
 
+@property (nonatomic, assign) BOOL hasPhotoSel;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 4 - 0
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/TimeLineController/SLCreatMomentsVc.m

@@ -40,6 +40,10 @@
     backBarButtonItem.title = @"取消";
     self.navigationBar.leftBarButtonItem = backBarButtonItem;
     
+    if (!self.hasPhotoSel) {
+        self.photoHeightConst.constant = 0.f;
+    }
+    
     self.textView.placeholder = @"请输入...";
     self.textView.font = [UIFont systemFontOfSize:14];
     self.textView.textColor = SL333Color;

+ 9 - 0
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/TimeLineController/SLFriensInfoVc.m

@@ -8,6 +8,7 @@
 #import "SLFriensInfoVc.h"
 #import "SDTimeLineTableHeaderView.h"
 #import "SLMessageViewController.h"
+#import "SDTimeLineTableViewController.h"
 
 @interface SLFriensInfoVc ()
 @property (weak, nonatomic) IBOutlet UIImageView *fHeardImageView;
@@ -26,6 +27,14 @@
     [self.fHeardImageView sd_setImageWithURL:[NSURL URLWithString:userImg] placeholderImage:ImageName(@"icon_ellipse")];
     [self.userNameLabel setTitle:self.friendModel.name forState:UIControlStateNormal];
     self.navigationBar.separatorHeight = 0.0f;
+    WS(weakSelf);
+    [self.fpyqBgView addTapWithBlock:^{
+        SDTimeLineTableViewController *vc = [[SDTimeLineTableViewController alloc] init];
+        SLUserModel *userModel = [[SLUserModel alloc] init];
+        userModel.userId = weakSelf.friendModel.userId;
+        vc.userModel = userModel;
+        [weakSelf navPushViewController:vc animated:YES];
+    }];
 }
 
 - (IBAction)toMsgBtnClick:(id)sender {

+ 5 - 0
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/Views/Cell/SDTimeLineCell.m

@@ -90,6 +90,11 @@ NSString *const kSDTimeLineCellOperationButtonClickedNotification = @"SDTimeLine
     WS(weakSelf);
     [_nameLable addTapWithBlock:^{
         SLFriensInfoVc *vc = [[SLFriensInfoVc alloc] init];
+        SLFriendsModel *model = [[SLFriendsModel alloc] init];
+        model.userId = weakSelf.model.userName;
+        model.name = weakSelf.model.userName;
+        model.head = weakSelf.model.userImg;
+        vc.friendModel = model;
         [weakSelf.viewController.rdv_tabBarController.navigationController pushViewController:vc animated:YES];
     }];
     

+ 3 - 2
SLAiELTS/SLAiELTS/ViewControllers/TimeLine/Views/HeaderView/SDTimeLineTableHeaderView.m

@@ -103,7 +103,7 @@
     [self addSubview:moreInterestBtn];
     
     
-    _backgroundImageView.sd_layout.spaceToSuperView(UIEdgeInsetsMake(-60, 0, 40, 0));
+    _backgroundImageView.sd_layout.spaceToSuperView(UIEdgeInsetsMake(-54, 0, 40, 0));
     
     _iconView.sd_layout
     .widthIs(64)
@@ -129,7 +129,7 @@
     .widthIs(36)
     .heightIs(36)
     .rightSpaceToView(self, 12)
-    .topSpaceToView(self, 12);
+    .topSpaceToView(self, 0);
     
     moreInterestBtn.sd_layout
     .widthIs(26)
@@ -147,6 +147,7 @@
             case 2:
             {
                 SLCreatMomentsVc *vc = [SLCreatMomentsVc loadViewControllewWithNib];
+                vc.hasPhotoSel = index != 0;
                 [weakSelf.viewController.rdv_tabBarController.navigationController pushViewController:vc animated:YES];
             }
                 break;