Commit 6b9855fb authored by admin's avatar admin

完成点赞接口 完成评论接口 完成无数据页的显示

parent 7c37e110
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
84F57C4C1BEC785E00DDEEB1 /* AddQuestionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C4B1BEC785E00DDEEB1 /* AddQuestionViewController.m */; }; 84F57C4C1BEC785E00DDEEB1 /* AddQuestionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C4B1BEC785E00DDEEB1 /* AddQuestionViewController.m */; };
84F57C501BEC7AA300DDEEB1 /* AddQuestionFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C4F1BEC7AA300DDEEB1 /* AddQuestionFooterView.m */; }; 84F57C501BEC7AA300DDEEB1 /* AddQuestionFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C4F1BEC7AA300DDEEB1 /* AddQuestionFooterView.m */; };
84F57C9C1BECA73800DDEEB1 /* StarBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C9B1BECA73800DDEEB1 /* StarBar.m */; }; 84F57C9C1BECA73800DDEEB1 /* StarBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C9B1BECA73800DDEEB1 /* StarBar.m */; };
84FAC7611BFF2C6E00FD094D /* NoDataView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FAC7601BFF2C6E00FD094D /* NoDataView.m */; };
84FD89F21BD9FC71006E442A /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD89F11BD9FC71006E442A /* HomeViewController.m */; }; 84FD89F21BD9FC71006E442A /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD89F11BD9FC71006E442A /* HomeViewController.m */; };
84FD8A071BDA01C4006E442A /* ChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD8A061BDA01C4006E442A /* ChartViewController.m */; }; 84FD8A071BDA01C4006E442A /* ChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD8A061BDA01C4006E442A /* ChartViewController.m */; };
84FD8A0A1BDA01D1006E442A /* MineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD8A091BDA01D1006E442A /* MineViewController.m */; }; 84FD8A0A1BDA01D1006E442A /* MineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FD8A091BDA01D1006E442A /* MineViewController.m */; };
...@@ -264,6 +265,8 @@ ...@@ -264,6 +265,8 @@
84F57C4F1BEC7AA300DDEEB1 /* AddQuestionFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddQuestionFooterView.m; sourceTree = "<group>"; }; 84F57C4F1BEC7AA300DDEEB1 /* AddQuestionFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddQuestionFooterView.m; sourceTree = "<group>"; };
84F57C9A1BECA73800DDEEB1 /* StarBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StarBar.h; sourceTree = "<group>"; }; 84F57C9A1BECA73800DDEEB1 /* StarBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StarBar.h; sourceTree = "<group>"; };
84F57C9B1BECA73800DDEEB1 /* StarBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StarBar.m; sourceTree = "<group>"; }; 84F57C9B1BECA73800DDEEB1 /* StarBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StarBar.m; sourceTree = "<group>"; };
84FAC75F1BFF2C6E00FD094D /* NoDataView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoDataView.h; sourceTree = "<group>"; };
84FAC7601BFF2C6E00FD094D /* NoDataView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoDataView.m; sourceTree = "<group>"; };
84FD89F01BD9FC71006E442A /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; }; 84FD89F01BD9FC71006E442A /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; };
84FD89F11BD9FC71006E442A /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; }; 84FD89F11BD9FC71006E442A /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
84FD8A051BDA01C4006E442A /* ChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartViewController.h; sourceTree = "<group>"; }; 84FD8A051BDA01C4006E442A /* ChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartViewController.h; sourceTree = "<group>"; };
...@@ -397,6 +400,7 @@ ...@@ -397,6 +400,7 @@
8426A4A01BDF0CD600E5FDF5 /* Function */ = { 8426A4A01BDF0CD600E5FDF5 /* Function */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
84FAC75E1BFF2C5B00FD094D /* NoData */,
8426A4A11BDF0CD600E5FDF5 /* Case */, 8426A4A11BDF0CD600E5FDF5 /* Case */,
8426A4A41BDF0CD600E5FDF5 /* OnLine */, 8426A4A41BDF0CD600E5FDF5 /* OnLine */,
8426A4A71BDF0CD600E5FDF5 /* Picture */, 8426A4A71BDF0CD600E5FDF5 /* Picture */,
...@@ -1218,6 +1222,15 @@ ...@@ -1218,6 +1222,15 @@
path = StarBar; path = StarBar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
84FAC75E1BFF2C5B00FD094D /* NoData */ = {
isa = PBXGroup;
children = (
84FAC75F1BFF2C6E00FD094D /* NoDataView.h */,
84FAC7601BFF2C6E00FD094D /* NoDataView.m */,
);
path = NoData;
sourceTree = "<group>";
};
84FD89ED1BD9FC5B006E442A /* Home */ = { 84FD89ED1BD9FC5B006E442A /* Home */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1515,6 +1528,7 @@ ...@@ -1515,6 +1528,7 @@
8487D80C1BF218F900E63E90 /* MenuView.m in Sources */, 8487D80C1BF218F900E63E90 /* MenuView.m in Sources */,
8474C5921BE78A85007DCF19 /* QuestionViewController.m in Sources */, 8474C5921BE78A85007DCF19 /* QuestionViewController.m in Sources */,
84AD4F291BF4360E00BFB37C /* TaskGroup.m in Sources */, 84AD4F291BF4360E00BFB37C /* TaskGroup.m in Sources */,
84FAC7611BFF2C6E00FD094D /* NoDataView.m in Sources */,
84AD4F2F1BF4370E00BFB37C /* InspectHeaderView.m in Sources */, 84AD4F2F1BF4370E00BFB37C /* InspectHeaderView.m in Sources */,
8408261E1BE5D22A0022B795 /* OnLineTableViewCell.m in Sources */, 8408261E1BE5D22A0022B795 /* OnLineTableViewCell.m in Sources */,
8408261A1BE5CEDD0022B795 /* OnLineViewController.m in Sources */, 8408261A1BE5CEDD0022B795 /* OnLineViewController.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "iconfont-duigou2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "iconfont-duigou2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "commend_after@2x.png", "filename" : "已评论@2x.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "commend_after@3x.png", "filename" : "已评论@3x.png",
"scale" : "3x" "scale" : "3x"
} }
], ],
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "comment_after@2x.png", "filename" : "已赞@2x.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "comment_after@3x.png", "filename" : "已赞@3x.png",
"scale" : "3x" "scale" : "3x"
} }
], ],
......
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
#define kAddQuestionURL @"" #define kAddQuestionURL @""
// 提交评论 // 提交评论
#define kAddCommentURL @"redstar-server/rest/comment" //#define kAddCommentURL @"redstar-server/rest/comment/submit?time=2015-06-25+13:59:26&operId=admin&operName=admin"
#define kAddCommentURL @"redstar-server/rest/comment/submit"
// 点赞
#define kAddLikeURL @"redstar-server/rest/question/like/"
// 取消点赞
#define kCancelLikeURL @"redstar-server/rest/question/cancel_like/"
#endif /* Url_h */ #endif /* Url_h */
//
// NoDataView.h
// redstar
//
// Created by admin on 15/11/20.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NoDataView : UIView
@end
//
// NoDataView.m
// redstar
//
// Created by admin on 15/11/20.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "NoDataView.h"
#define kImageWidth 91
#define kImageHeight 91
@implementation NoDataView
- (instancetype)init
{
self = [super init];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
UIImageView *imageView = [[UIImageView alloc] init];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
imageView.image = [UIImage imageNamed:@"空白页_icon"];
[self addSubview:imageView];
NSLayoutConstraint *imageViewTop = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:-30];
[self addConstraint:imageViewTop];
NSLayoutConstraint *imageViewLeft = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:(kScreenWidth - kImageWidth) / 2];
[self addConstraint:imageViewLeft];
NSLayoutConstraint *imageViewHeight = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:kImageHeight];
[self addConstraint:imageViewHeight];
NSLayoutConstraint *imageViewWidth = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:kImageWidth];
[self addConstraint:imageViewWidth];
UILabel *label = [[UILabel alloc] init];
label.text = @"很抱歉,暂无数据!";
label.translatesAutoresizingMaskIntoConstraints = NO;
label.font = [UIFont boldSystemFontOfSize:30.0];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor colorWithRed:189/255.0 green:224/255.0 blue:246/255.0 alpha:1.0];
[self addSubview:label];
NSLayoutConstraint *labelTop = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:imageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10];
[self addConstraint:labelTop];
NSLayoutConstraint *labelLeft = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:labelLeft];
NSLayoutConstraint *labelRight = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:labelRight];
NSLayoutConstraint *labelHeight = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
[self addConstraint:labelHeight];
}
@end
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
} }
// 点赞数 // 点赞数
[self.thumbBtn setTitle:@"300" forState:UIControlStateNormal]; [self.thumbBtn setTitle:[NSString stringWithFormat:@"%d",question.likeCount] forState:UIControlStateNormal];
// 分类 // 分类
NSString *sortText = [NSString stringWithFormat:@"分类:%@", question.categoryName]; NSString *sortText = [NSString stringWithFormat:@"分类:%@", question.categoryName];
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
_thumbBtn = [[ZanButton alloc] init]; _thumbBtn = [[ZanButton alloc] init];
[_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal]; [_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal];
_thumbBtn.translatesAutoresizingMaskIntoConstraints = NO; _thumbBtn.translatesAutoresizingMaskIntoConstraints = NO;
_thumbBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15.0]; _thumbBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
[_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal]; [_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
[self.contentView addSubview:_thumbBtn]; [self.contentView addSubview:_thumbBtn];
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
@interface QuestionDetailViewController : UIViewController @interface QuestionDetailViewController : UIViewController
@property (nonatomic,strong) QuestionModel *question; @property (nonatomic,strong) QuestionModel *question;
@property (nonatomic, assign) NSInteger row;
@end @end
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "CommentView.h" #import "CommentView.h"
#import "HttpClient.h" #import "HttpClient.h"
#import <MBProgressHUD.h>
#define kQuestionDetailCell @"QuestionDetailCell" // 问题详情 #define kQuestionDetailCell @"QuestionDetailCell" // 问题详情
#define kQuestionCommentCell @"QuestionCommentCell" // 评论 #define kQuestionCommentCell @"QuestionCommentCell" // 评论
...@@ -45,6 +46,8 @@ ...@@ -45,6 +46,8 @@
self.test2Array = [NSArray arrayWithObjects:@"李XX 集团XX总", @"王XX 某大区经理", nil]; self.test2Array = [NSArray arrayWithObjects:@"李XX 集团XX总", @"王XX 某大区经理", nil];
self.test3Array = [NSArray arrayWithObjects:@"2015-09-10 10:21:43", @"2015-10-27 11:21:43", nil]; self.test3Array = [NSArray arrayWithObjects:@"2015-09-10 10:21:43", @"2015-10-27 11:21:43", nil];
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
...@@ -83,6 +86,7 @@ ...@@ -83,6 +86,7 @@
- (void)doBack:(UIBarButtonItem *)sender - (void)doBack:(UIBarButtonItem *)sender
{ {
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} }
- (void)addComment:(UIButton *)sender - (void)addComment:(UIButton *)sender
...@@ -121,16 +125,41 @@ ...@@ -121,16 +125,41 @@
{ {
NSNumber *count = [NSNumber numberWithInteger:_commentView.starBar.starNumber]; NSNumber *count = [NSNumber numberWithInteger:_commentView.starBar.starNumber];
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kAddCommentURL]; NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:date];
NSDate *localeDate = [date dateByAddingTimeInterval:interval];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *operId = dict[@"user_code"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddCommentURL , dateString , operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"url = %@", url); NSLog(@"url = %@", url);
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"entityType":@"question", NSDictionary *parameters = @{@"entityType":@"question",
@"entityUuid":_question.uuid, @"entityUuid":_question.uuid,
@"star":count, @"star":count,
@"comment":_commentView.contentTextView.text}; @"comment":_commentView.contentTextView.text};
NSLog(@"parameters = %@", parameters); NSLog(@"parameters = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpClient submitCommentWithParameters:parameters completion:^(id response, NSError *error) { [httpClient submitCommentWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"respo = %@, error = %@", response , error); NSLog(@"respo = %@, error = %@", response , error);
if ([response[@"message"] isEqualToString:@"ok"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"添加评论成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"添加评论失败" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}]; }];
[self closeBackGroundView]; [self closeBackGroundView];
...@@ -148,6 +177,41 @@ ...@@ -148,6 +177,41 @@
}]; }];
} }
- (void)addZan:(ZanButton *)sender
{
sender.selected = !sender.selected;
NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:date];
NSDate *localeDate = [date dateByAddingTimeInterval:interval];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *operId = dict[@"user_code"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, _question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount + 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
}
#pragma mark - UITableView Delegate/DataSource #pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
...@@ -174,6 +238,7 @@ ...@@ -174,6 +238,7 @@
cell = [[QuestionDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDetailCell]; cell = [[QuestionDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDetailCell];
} }
cell.question = self.question; cell.question = self.question;
[cell.thumbBtn addTarget:self action:@selector(addZan:) forControlEvents:UIControlEventTouchUpInside];
return cell; return cell;
} else if (indexPath.section == 1) { } else if (indexPath.section == 1) {
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
- (void)setup - (void)setup
{ {
self.titleLabel.textColor = kQuestionCellTitleColor; self.titleLabel.textColor = kQuestionCellTitleColor;
self.hotLabel.font = [UIFont boldSystemFontOfSize:12.0];
self.thumbBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
} }
- (void)setQuestion:(QuestionModel *)question - (void)setQuestion:(QuestionModel *)question
...@@ -38,6 +37,15 @@ ...@@ -38,6 +37,15 @@
self.stateLabel.text = [NSString stringWithFormat:@"%@", question.categoryName]; self.stateLabel.text = [NSString stringWithFormat:@"%@", question.categoryName];
// 提报时间 // 提报时间
self.dateLabel.text = [NSString stringWithFormat:@"提报时间:%@", question.submitTime]; self.dateLabel.text = [NSString stringWithFormat:@"提报时间:%@", question.submitTime];
// 点赞数
[self.thumbBtn setTitle:[NSString stringWithFormat:@"%d", question.likeCount] forState:UIControlStateNormal];
if (question.hotspot) {
self.hotLabel.hidden = NO;
} else {
self.hotLabel.hidden = YES;
}
} }
#pragma mark - lazy laoding #pragma mark - lazy laoding
...@@ -72,6 +80,7 @@ ...@@ -72,6 +80,7 @@
{ {
if (!_hotLabel) { if (!_hotLabel) {
_hotLabel = [[UILabel alloc] init]; _hotLabel = [[UILabel alloc] init];
_hotLabel.font = [UIFont boldSystemFontOfSize:12.0];
_hotLabel.translatesAutoresizingMaskIntoConstraints = NO; _hotLabel.translatesAutoresizingMaskIntoConstraints = NO;
_hotLabel.backgroundColor = kHotBackGroundColor; _hotLabel.backgroundColor = kHotBackGroundColor;
_hotLabel.textColor = [UIColor whiteColor]; _hotLabel.textColor = [UIColor whiteColor];
...@@ -190,8 +199,8 @@ ...@@ -190,8 +199,8 @@
if (!_thumbBtn) { if (!_thumbBtn) {
_thumbBtn = [[ZanButton alloc] init]; _thumbBtn = [[ZanButton alloc] init];
_thumbBtn.translatesAutoresizingMaskIntoConstraints = NO; _thumbBtn.translatesAutoresizingMaskIntoConstraints = NO;
_thumbBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
[_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal]; [_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
[_thumbBtn setTitle:@"220" forState:UIControlStateNormal];
[_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal]; [_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal];
[self.contentView addSubview:_thumbBtn]; [self.contentView addSubview:_thumbBtn];
......
...@@ -37,6 +37,6 @@ ...@@ -37,6 +37,6 @@
@property (nonatomic, strong) NSString *submitTime;// @property (nonatomic, strong) NSString *submitTime;//
@property (nonatomic, strong) NSString *type;//问题处理分类 @property (nonatomic, strong) NSString *type;//问题处理分类
@property (nonatomic, strong) NSString *version;// @property (nonatomic, strong) NSString *version;//
@property (nonatomic, strong) NSString *hotspot; // 热点问题 @property (nonatomic, assign) BOOL hotspot; // 热点问题
@property (nonatomic, strong) NSString *likeCount; // @property (nonatomic, assign) int likeCount; // 点赞数
@end @end
...@@ -19,9 +19,12 @@ ...@@ -19,9 +19,12 @@
#import "MenuView.h" #import "MenuView.h"
#import "CustomDropMenuView.h" #import "CustomDropMenuView.h"
#define kQuestionListCell @"questionListTableViewCell" #import "NoDataView.h"
#import <MBProgressHUD.h>
@interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, ScreenTableDelegate> #define kQuestionListCell @"questionListTableViewCell"
#define kThumbTag 745645
@interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, ScreenTableDelegate, TaxisViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *allQuestionArray; @property (nonatomic, strong) NSMutableArray *allQuestionArray;
...@@ -33,6 +36,9 @@ ...@@ -33,6 +36,9 @@
@property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) MenuButton *selctedButton; @property (nonatomic, strong) MenuButton *selctedButton;
@property (nonatomic, strong) UIButton *selectBtn;
@property (nonatomic, strong) NoDataView *noDataView;
@end @end
...@@ -61,10 +67,9 @@ ...@@ -61,10 +67,9 @@
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
self.tabBarController.tabBar.hidden = YES;
[self.menuView.taxiButton addTarget:self action:@selector(dropCilck:) forControlEvents:UIControlEventTouchUpInside]; [self.menuView.taxiButton addTarget:self action:@selector(dropCilck:) forControlEvents:UIControlEventTouchUpInside];
[self.menuView.screenButton addTarget:self action:@selector(dropCilck:) forControlEvents:UIControlEventTouchUpInside]; [self.menuView.screenButton addTarget:self action:@selector(dropCilck:) forControlEvents:UIControlEventTouchUpInside];
self.tabBarController.tabBar.hidden = YES;
} }
...@@ -94,14 +99,16 @@ ...@@ -94,14 +99,16 @@
NSDictionary *parameters = @{@"user":@"5a74170150b940ae0150b940f8450083", NSDictionary *parameters = @{@"user":@"5a74170150b940ae0150b940f8450083",
@"scope":@"all", @"scope":@"all",
@"category":@"", @"category":@"",
@"type":@"" , @"type":@""
@"state":@"resolved" //,@"state":@"resolved"
}; };
// 发起请求 // 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
// //
__block QuestionViewController *weakSelf = self; __block QuestionViewController *weakSelf = self;
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
// 请求问题列表 // 请求问题列表
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) { [httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
NSDictionary *dataDict = (NSDictionary *)response[@"data"]; NSDictionary *dataDict = (NSDictionary *)response[@"data"];
...@@ -112,13 +119,21 @@ ...@@ -112,13 +119,21 @@
[question setValuesForKeysWithDictionary:questionDict]; [question setValuesForKeysWithDictionary:questionDict];
[weakSelf.allQuestionArray addObject:question]; [weakSelf.allQuestionArray addObject:question];
} }
if (_allQuestionArray.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} else {
[weakSelf setupTableView]; [weakSelf setupTableView];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}]; }];
} }
- (void)setupTableView - (void)setupTableView
{ {
[self.tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kQuestionListCell]; [self.tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kQuestionListCell];
self.searchBar.backgroundColor = kSectionBackGroundColor; self.searchBar.backgroundColor = kSectionBackGroundColor;
} }
...@@ -152,6 +167,43 @@ ...@@ -152,6 +167,43 @@
[self.navigationController dismissViewControllerAnimated:YES completion:nil]; [self.navigationController dismissViewControllerAnimated:YES completion:nil];
} }
- (void)addZan:(ZanButton *)sender
{
sender.selected = !sender.selected;
NSInteger row = sender.tag - kThumbTag;
QuestionModel *question = _allQuestionArray[row];
NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:date];
NSDate *localeDate = [date dateByAddingTimeInterval:interval];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *operId = dict[@"user_code"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount + 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
}
- (void)addClick:(UIButton *)sender - (void)addClick:(UIButton *)sender
{ {
...@@ -235,6 +287,7 @@ ...@@ -235,6 +287,7 @@
_taxisView.backgroundColor = [UIColor whiteColor]; _taxisView.backgroundColor = [UIColor whiteColor];
} }
_taxisView.delegate = self;
[self.view addSubview:_bgView]; [self.view addSubview:_bgView];
[self.view insertSubview:_taxisView aboveSubview:_bgView]; [self.view insertSubview:_taxisView aboveSubview:_bgView];
...@@ -312,18 +365,20 @@ ...@@ -312,18 +365,20 @@
} }
- (void)searchBarClick:(UIButton *)sender - (void)searchBarClick:(UIButton *)sender
{ {
NSLog(@"%@", self.searchBar.searchTextFiled.text); NSLog(@"%@", self.searchBar.searchTextFiled.text);
} }
#pragma mark - TaxisDelegate
- (void)timeChange:(UIButton *)sender
{
[self closeRedView];
}
#pragma mark - ScreenTableDelegate #pragma mark - ScreenTableDelegate
- (void)click - (void)tableViewDidSelectRow:(NSInteger)row
{ {
NSLog(@"点一下"); NSLog(@"点一下");
[self closeGreenView]; [self closeGreenView];
...@@ -342,7 +397,8 @@ ...@@ -342,7 +397,8 @@
cell = [[QuestionListTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionListCell]; cell = [[QuestionListTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionListCell];
} }
cell.question = _allQuestionArray[indexPath.row]; cell.question = _allQuestionArray[indexPath.row];
// cell.stateLabel.text = @"服务 - 15分钟退单"; [cell.thumbBtn addTarget:self action:@selector(addZan:) forControlEvents:UIControlEventTouchUpInside];
cell.thumbBtn.tag = kThumbTag + indexPath.row;
return cell; return cell;
} }
...@@ -352,6 +408,7 @@ ...@@ -352,6 +408,7 @@
{ {
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init]; QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
questionDetailVC.question = (QuestionModel *)_allQuestionArray[indexPath.row]; questionDetailVC.question = (QuestionModel *)_allQuestionArray[indexPath.row];
questionDetailVC.row = indexPath.row;
[self.navigationController pushViewController:questionDetailVC animated:YES]; [self.navigationController pushViewController:questionDetailVC animated:YES];
} }
...@@ -407,6 +464,7 @@ ...@@ -407,6 +464,7 @@
_tableView.dataSource = self; _tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO; _tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO; _tableView.showsHorizontalScrollIndicator = NO;
_tableView.tableFooterView = [[UIView alloc] init];
[self.view addSubview:_tableView]; [self.view addSubview:_tableView];
[self.view insertSubview:_tableView atIndex:0]; [self.view insertSubview:_tableView atIndex:0];
...@@ -449,6 +507,27 @@ ...@@ -449,6 +507,27 @@
return _searchBar; return _searchBar;
} }
- (NoDataView *)noDataView
{
if (!_noDataView) {
_noDataView = [[NoDataView alloc] init];
_noDataView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_noDataView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _noDataView;
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
@property (nonatomic, copy) NSString *lastModify_time; @property (nonatomic, copy) NSString *lastModify_time;
@property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) int questionCount; @property (nonatomic, assign) int questionCount;
@property (nonatomic, copy) NSArray *questions;
@property (nonatomic, copy) NSString *ranking; @property (nonatomic, copy) NSString *ranking;
@property (nonatomic, assign) int reportCount; @property (nonatomic, assign) int reportCount;
@property (nonatomic, copy) NSString *reportTime; @property (nonatomic, copy) NSString *reportTime;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
@property (nonatomic, copy) NSString *remark; @property (nonatomic, copy) NSString *remark;
@property (nonatomic, copy) NSString *reportTime; @property (nonatomic, copy) NSString *reportTime;
@property (nonatomic, strong) NSDictionary *reportor; @property (nonatomic, strong) NSDictionary *reportor;
@property (nonatomic, copy) NSString *score;
@property (nonatomic, assign) int state; @property (nonatomic, assign) int state;
@property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *uuid; @property (nonatomic, copy) NSString *uuid;
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#import "HttpClient.h" #import "HttpClient.h"
#import "RankListModel.h" #import "RankListModel.h"
#import "NoDataView.h"
#import <MBProgressHUD.h>
#define kRankingCell @"RankingTableViewCell" #define kRankingCell @"RankingTableViewCell"
#define kShopNameBtnTag 15000 #define kShopNameBtnTag 15000
...@@ -23,7 +26,7 @@ ...@@ -23,7 +26,7 @@
@property (nonatomic, strong) NSMutableDictionary *selectedIndexes; @property (nonatomic, strong) NSMutableDictionary *selectedIndexes;
@property (nonatomic, strong) NSMutableArray *allRankListArray; @property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NoDataView *noDataView;
@end @end
@implementation RankingListViewController @implementation RankingListViewController
...@@ -88,16 +91,21 @@ ...@@ -88,16 +91,21 @@
@"pageNumber":@(1), @"pageNumber":@(1),
@"pageSize":@(10) @"pageSize":@(10)
}; };
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
__block RankingListViewController *weakSelf = self;
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response); NSLog(@"口碑排名response = %@", response);
NSDictionary *dataDict = response[@"data"]; NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"]; NSArray *dataArray = dataDict[@"records"];
for (NSDictionary *ListDict in dataArray) { for (NSDictionary *ListDict in dataArray) {
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict]; RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[self.allRankListArray addObject:rankList]; [weakSelf.allRankListArray addObject:rankList];
} }
if (_allRankListArray.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} else {
self.tableView.delegate = self; self.tableView.delegate = self;
self.tableView.dataSource = self; self.tableView.dataSource = self;
...@@ -106,6 +114,9 @@ ...@@ -106,6 +114,9 @@
[shopAttr addAttributes:@{NSForegroundColorAttributeName:kShopCountTextColor,NSFontAttributeName:[UIFont systemFontOfSize:21.0f]} range:NSMakeRange(0,shopCount.length - 2)]; [shopAttr addAttributes:@{NSForegroundColorAttributeName:kShopCountTextColor,NSFontAttributeName:[UIFont systemFontOfSize:21.0f]} range:NSMakeRange(0,shopCount.length - 2)];
[shopAttr addAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(shopCount.length - 2,2)]; [shopAttr addAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(shopCount.length - 2,2)];
_shoppingCountLabel.attributedText = shopAttr; _shoppingCountLabel.attributedText = shopAttr;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}]; }];
} }
...@@ -587,6 +598,31 @@ ...@@ -587,6 +598,31 @@
} }
return _headView; return _headView;
} }
- (NoDataView *)noDataView
{
if (!_noDataView) {
_noDataView = [[NoDataView alloc] init];
_noDataView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_noDataView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _noDataView;
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -160,7 +160,27 @@ ...@@ -160,7 +160,27 @@
- (void)moreButtonClick:(UIButton *)sender - (void)moreButtonClick:(UIButton *)sender
{ {
NSLog(@"查看全部公告···"); UIButton *button = (UIButton *)sender;
UINavigationController *nav;
if (button.tag - 332892 == 0) {
PictureViewController *pictureVC = [[PictureViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:pictureVC];
} else if (button.tag - 332892 == 1) {
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
} else if (button.tag - 332892 == 2) {
QuestionViewController *questionVC = [[QuestionViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:questionVC];
} else {
InspectListViewController *inspectListVC = [[InspectListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:inspectListVC];
}
[nav.navigationBar setBarTintColor:kNavigationBarColor];
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
[self presentViewController:nav animated:YES completion:nil];
} }
- (void)itemClick:(HomeCellItem *)sender - (void)itemClick:(HomeCellItem *)sender
...@@ -519,6 +539,7 @@ ...@@ -519,6 +539,7 @@
// 查看更多按钮 // 查看更多按钮
UIButton *moreButton = [[UIButton alloc] init]; UIButton *moreButton = [[UIButton alloc] init];
moreButton.tag = 332892 + section;
moreButton.translatesAutoresizingMaskIntoConstraints = NO; moreButton.translatesAutoresizingMaskIntoConstraints = NO;
[moreButton setTitle:@"更多" forState:UIControlStateNormal]; [moreButton setTitle:@"更多" forState:UIControlStateNormal];
[moreButton setTitleColor:kMoreButtonTextColor forState:UIControlStateNormal]; [moreButton setTitleColor:kMoreButtonTextColor forState:UIControlStateNormal];
......
...@@ -37,4 +37,10 @@ typedef void (^completionBlock) (id response, NSError *error); ...@@ -37,4 +37,10 @@ typedef void (^completionBlock) (id response, NSError *error);
// 提交评论 // 提交评论
- (void)submitCommentWithParameters:(id)parameters completion:(completionBlock)completion; - (void)submitCommentWithParameters:(id)parameters completion:(completionBlock)completion;
// 提交评论
- (void)likeCountWithParameters:(id)parameters completion:(completionBlock)completion;
// 取消点赞
- (void)cancelLikeCountWithParameters:(id)parameters completion:(completionBlock)completion;
@end @end
...@@ -147,7 +147,27 @@ ...@@ -147,7 +147,27 @@
- (void)submitCommentWithParameters:(id)parameters completion:(completionBlock)completion - (void)submitCommentWithParameters:(id)parameters completion:(completionBlock)completion
{ {
[self getParameters:parameters completion:^(id response, NSError *error) { [self postParameters:parameters completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
// 点赞
- (void)likeCountWithParameters:(id)parameters completion:(completionBlock)completion
{
[self postParameters:parameters completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
// 取消点赞
- (void)cancelLikeCountWithParameters:(id)parameters completion:(completionBlock)completion
{
[self postParameters:parameters completion:^(id response, NSError *error) {
if (completion) { if (completion) {
completion (response, error); completion (response, error);
} }
......
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
_taxiButton.tag = 4001; _taxiButton.tag = 4001;
_taxiButton.translatesAutoresizingMaskIntoConstraints = NO; _taxiButton.translatesAutoresizingMaskIntoConstraints = NO;
[_taxiButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; [_taxiButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
[_taxiButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
[_taxiButton setImage:[UIImage imageNamed:@"sort_icon_after"] forState:UIControlStateSelected];
_taxiButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; _taxiButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
[_taxiButton setTitle:@"排序" forState:UIControlStateNormal]; [_taxiButton setTitle:@"排序" forState:UIControlStateNormal];
[self addSubview:_taxiButton]; [self addSubview:_taxiButton];
...@@ -77,6 +80,8 @@ ...@@ -77,6 +80,8 @@
_screenButton.translatesAutoresizingMaskIntoConstraints = NO; _screenButton.translatesAutoresizingMaskIntoConstraints = NO;
_screenButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; _screenButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
[_screenButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; [_screenButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
[_screenButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
[_screenButton setImage:[UIImage imageNamed:@"filter_after"] forState:UIControlStateSelected];
[_screenButton setTitle:@"筛选" forState:UIControlStateNormal]; [_screenButton setTitle:@"筛选" forState:UIControlStateNormal];
[self addSubview:_screenButton]; [self addSubview:_screenButton];
......
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
self.tableView = [[UITableView alloc] init]; self.tableView = [[UITableView alloc] init];
_tableView.delegate = self; _tableView.delegate = self;
_tableView.dataSource = self; _tableView.dataSource = self;
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[_tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
GroupItems *tableItem = [[GroupItems alloc] initWithTitle:@"状态等于" view:_tableView]; GroupItems *tableItem = [[GroupItems alloc] initWithTitle:@"状态等于" view:_tableView];
...@@ -110,14 +113,21 @@ ...@@ -110,14 +113,21 @@
if (!cell) { if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kScreenTabelViewCell]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kScreenTabelViewCell];
} }
cell.textLabel.text = _testArray[indexPath.row]; cell.textLabel.text = _testArray[indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0]; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-duigou2"]];
imageView.frame = CGRectMake(kScreenWidth - self.groupTabBar.frame.size.width - 30, 15, 19, 14);
[cell.contentView addSubview:imageView];
return cell; return cell;
} }
// cell的点击事件 // cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_delegate) { if (_delegate) {
[_delegate tableViewDidSelectRow:indexPath.row]; [_delegate tableViewDidSelectRow:indexPath.row];
} }
......
...@@ -8,12 +8,18 @@ ...@@ -8,12 +8,18 @@
#import "TaxisView.h" #import "TaxisView.h"
@interface TaxisView ()
@property (nonatomic, strong) NSMutableArray *buttons;
@end
@implementation TaxisView @implementation TaxisView
- (instancetype)init - (instancetype)init
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self.buttons = [NSMutableArray array];
[self setup]; [self setup];
} }
return self; return self;
...@@ -23,6 +29,7 @@ ...@@ -23,6 +29,7 @@
{ {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.buttons = [NSMutableArray array];
[self setup]; [self setup];
} }
return self; return self;
...@@ -30,131 +37,62 @@ ...@@ -30,131 +37,62 @@
- (void)setup - (void)setup
{ {
[self.defaultBtn setTitle:@"默认排序" forState:UIControlStateNormal];
[self.sequenceBtn setTitle:@"时间顺序排序" forState:UIControlStateNormal];
[self.changeoverBtn setTitle:@"时间逆序排序" forState:UIControlStateNormal];
}
#pragma mark - Lazy loading
- (UIButton *)defaultBtn
{
if (!_defaultBtn) {
_defaultBtn = [[UIButton alloc] init];
_defaultBtn.layer.borderWidth = 0.5;
_defaultBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
_defaultBtn.layer.borderColor = kSeparateLineCGColor;
_defaultBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_defaultBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
_defaultBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
_defaultBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
[_defaultBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
_defaultBtn.tag = kTAxisBtnTag + 1;
[self addSubview:_defaultBtn];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:titleRight];
// 右边
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_defaultBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.sequenceBtn attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0];
[self addConstraint:titleHeight];
}
return _defaultBtn;
} }
- (UIButton *)sequenceBtn - (void)layoutSubviews
{ {
if (!_sequenceBtn) { CGFloat buttonW = kScreenWidth;
_sequenceBtn = [[UIButton alloc] init]; CGFloat buttonH = self.frame.size.height / 3;
_sequenceBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0); NSArray *titleArray = @[@"默认排序",@"时间顺序排序",@"时间逆序排序"];
_sequenceBtn.translatesAutoresizingMaskIntoConstraints = NO;
_sequenceBtn.layer.borderColor = kSeparateLineCGColor;
_sequenceBtn.layer.borderWidth = 0.5; for (int i = 0; i < 3; i++) {
[_sequenceBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; UIButton *button = [[UIButton alloc] init];
_sequenceBtn.titleLabel.font = [UIFont systemFontOfSize:14.0]; button.titleLabel.font = [UIFont systemFontOfSize:15.0];
_sequenceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ; button.tag = kTAxisBtnTag + i + 1;
_sequenceBtn.imageEdgeInsets = UIEdgeInsetsMake(0, kScreenWidth - 30, 0, 0); [button setTitleColor:kLightBlack forState:UIControlStateNormal];
_sequenceBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0); [button setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
_sequenceBtn.imageView.contentMode = UIViewContentModeRight; button.frame = CGRectMake(0, i * buttonH, buttonW, buttonH);
_sequenceBtn.titleLabel.contentMode = UIViewContentModeLeft; [button setTitle:titleArray[i] forState:UIControlStateNormal];
[_sequenceBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; button.layer.borderWidth = 0.5;
_sequenceBtn.tag = kTAxisBtnTag + 2; button.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
button.layer.borderColor = kSeparateLineCGColor;
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
[self addSubview:_sequenceBtn]; button.titleLabel.font = [UIFont systemFontOfSize:14.0];
[button setImage:[UIImage imageNamed:@"iconfont-duigou2"] forState:UIControlStateNormal];
// 顶端 [button setImage:[UIImage imageNamed:@"iconfont-duigou"] forState:UIControlStateSelected];
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_defaultBtn attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; button.imageEdgeInsets = UIEdgeInsetsMake(0, kScreenWidth - 30, 0, 0);
[self addConstraint:titleTop]; button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
button.imageView.contentMode = UIViewContentModeRight;
// 左边 button.titleLabel.contentMode = UIViewContentModeLeft;
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; [button addTarget:self action:@selector(touchDownForButton:) forControlEvents:UIControlEventTouchDown];
[self addConstraint:titleLeft]; button.adjustsImageWhenHighlighted = NO;
[self addSubview:button];
// 右边 [self.buttons addObject:button];
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:titleRight];
// 右边
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_sequenceBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.changeoverBtn attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0];
[self addConstraint:titleHeight];
} }
return _sequenceBtn; UIButton *tempBtn = [_buttons objectAtIndex:0];
tempBtn.selected = YES;
} }
- (UIButton *)changeoverBtn
{ - (void)touchDownForButton:(UIButton *)button{
if (!_changeoverBtn) { for (UIButton * b in self.buttons) {
_changeoverBtn = [[UIButton alloc] init]; b.selected = NO;
_changeoverBtn.layer.borderColor = kSeparateLineCGColor;
_changeoverBtn.layer.borderWidth = 0.5;
_changeoverBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
_changeoverBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
_changeoverBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_changeoverBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
_changeoverBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
_changeoverBtn.imageEdgeInsets = UIEdgeInsetsMake(0, kScreenWidth - 30, 0, 0);
_changeoverBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
[_changeoverBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
_changeoverBtn.tag = kTAxisBtnTag + 3;
[self addSubview:_changeoverBtn];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_sequenceBtn attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:titleRight];
// 右边
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_changeoverBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:titleBottom];
} }
return _changeoverBtn;
}
- (void)click:(UIButton *)sender button.selected = YES;
{
if (_delegate) { if (_delegate) {
[_delegate timeChange:sender]; [_delegate timeChange:button];
} }
} }
@end @end
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface ZanButton : UIButton @interface ZanButton : UIButton
@property (nonatomic, assign) BOOL isZan;
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment