Commit ea559b8a authored by admin's avatar admin

评论数据目前为写死测试数据修改

parent b996770e
......@@ -17,6 +17,9 @@
841D24FB1BEB75CA0005CC9F /* QuestionDetailFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 841D24FA1BEB75CA0005CC9F /* QuestionDetailFooterView.m */; };
842547FC1BF03977006C79C5 /* QuestionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 842547FB1BF03977006C79C5 /* QuestionModel.m */; };
8442BA5C1BDB8FDB005E5657 /* MineTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8442BA5B1BDB8FDB005E5657 /* MineTableHeaderView.m */; };
846206B51C06AF700015C456 /* RankListHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 846206B41C06AF700015C456 /* RankListHeaderView.m */; };
846206B81C06AFCA0015C456 /* RankCommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 846206B71C06AFCA0015C456 /* RankCommentModel.m */; };
846206BB1C06AFF50015C456 /* RankCommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 846206BA1C06AFF50015C456 /* RankCommentCell.m */; };
8462C6EC1BF5F3BE00344DDD /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8462C6EB1BF5F3BE00344DDD /* MenuButton.m */; };
84720BC11C0377D300314099 /* CommentWithStarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84720BC01C0377D300314099 /* CommentWithStarView.m */; };
8474A01C1BE368D700315F30 /* HomeCellItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 8474A01B1BE368D700315F30 /* HomeCellItem.m */; };
......@@ -135,6 +138,12 @@
842547FB1BF03977006C79C5 /* QuestionModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuestionModel.m; sourceTree = "<group>"; };
8442BA5A1BDB8FDB005E5657 /* MineTableHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MineTableHeaderView.h; sourceTree = "<group>"; };
8442BA5B1BDB8FDB005E5657 /* MineTableHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MineTableHeaderView.m; sourceTree = "<group>"; };
846206B31C06AF700015C456 /* RankListHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankListHeaderView.h; sourceTree = "<group>"; };
846206B41C06AF700015C456 /* RankListHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankListHeaderView.m; sourceTree = "<group>"; };
846206B61C06AFCA0015C456 /* RankCommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankCommentModel.h; sourceTree = "<group>"; };
846206B71C06AFCA0015C456 /* RankCommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankCommentModel.m; sourceTree = "<group>"; };
846206B91C06AFF50015C456 /* RankCommentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankCommentCell.h; sourceTree = "<group>"; };
846206BA1C06AFF50015C456 /* RankCommentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankCommentCell.m; sourceTree = "<group>"; };
8462C6EA1BF5F3BE00344DDD /* MenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuButton.h; sourceTree = "<group>"; };
8462C6EB1BF5F3BE00344DDD /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuButton.m; sourceTree = "<group>"; };
84720BBF1C0377D300314099 /* CommentWithStarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentWithStarView.h; sourceTree = "<group>"; };
......@@ -532,6 +541,15 @@
path = WordOfMouth;
sourceTree = "<group>";
};
846206B21C06AF700015C456 /* View */ = {
isa = PBXGroup;
children = (
846206B31C06AF700015C456 /* RankListHeaderView.h */,
846206B41C06AF700015C456 /* RankListHeaderView.m */,
);
path = View;
sourceTree = "<group>";
};
8474C5801BE751A2007DCF19 /* CommonFunc */ = {
isa = PBXGroup;
children = (
......@@ -721,6 +739,7 @@
848699AD1BDF810900859DFE /* RankingList */ = {
isa = PBXGroup;
children = (
846206B21C06AF700015C456 /* View */,
84F30DA11BFC19DF00CBAD13 /* Model */,
848699AE1BDF810900859DFE /* Cell */,
848699AF1BDF810900859DFE /* ViewController */,
......@@ -735,6 +754,8 @@
84846E961BE069BC0010550A /* DateButton.m */,
84846E981BE07CDF0010550A /* RankingListCell.h */,
84846E991BE07CDF0010550A /* RankingListCell.m */,
846206B91C06AFF50015C456 /* RankCommentCell.h */,
846206BA1C06AFF50015C456 /* RankCommentCell.m */,
);
path = Cell;
sourceTree = "<group>";
......@@ -1207,6 +1228,8 @@
84F30DA11BFC19DF00CBAD13 /* Model */ = {
isa = PBXGroup;
children = (
846206B61C06AFCA0015C456 /* RankCommentModel.h */,
846206B71C06AFCA0015C456 /* RankCommentModel.m */,
84F30DA21BFC19F200CBAD13 /* RankListModel.h */,
84F30DA31BFC19F200CBAD13 /* RankListModel.m */,
);
......@@ -1547,11 +1570,13 @@
84AD4F261BF4356A00BFB37C /* TaskModel.m in Sources */,
841D24FB1BEB75CA0005CC9F /* QuestionDetailFooterView.m in Sources */,
84CF0FA21BE9EDA900C855CE /* TakePhotoView.m in Sources */,
846206BB1C06AFF50015C456 /* RankCommentCell.m in Sources */,
841D24F81BEB473C0005CC9F /* CheckPicViewController.m in Sources */,
84D80EB61BF714BE00A10EA4 /* GroupTabBar.m in Sources */,
8487D7721BF19A9C00E63E90 /* SearchToolBar.m in Sources */,
84970E361BD8E09D00C1728A /* LoginViewController.m in Sources */,
84720BC11C0377D300314099 /* CommentWithStarView.m in Sources */,
846206B81C06AFCA0015C456 /* RankCommentModel.m in Sources */,
84FD8A0A1BDA01D1006E442A /* MineViewController.m in Sources */,
848699B21BDF810900859DFE /* InspectListViewController.m in Sources */,
84846E971BE069BC0010550A /* DateButton.m in Sources */,
......@@ -1559,6 +1584,7 @@
84E363D21BFAC5200061547E /* TaskListModel.m in Sources */,
84C9574E1BDB344900083584 /* UIView+Frame.m in Sources */,
848699B01BDF810900859DFE /* InspectListCell.m in Sources */,
846206B51C06AF700015C456 /* RankListHeaderView.m in Sources */,
84AD4F3A1BF4844600BFB37C /* RankDetailHeaderView.m in Sources */,
8490C4D41BF9DEF0006B6569 /* PictureViewController.m in Sources */,
8474C5951BE78AE1007DCF19 /* QuestionDetailViewController.m in Sources */,
......
......@@ -29,9 +29,7 @@
// 口碑排名列表
#define kRankingListURL @"redstar-server/rest/praise/ranking"
// 提交问题
// http://.../redstar-server/rest/question/submit?time={time}&operId={operId}&operName={operName}
#define kAddQuestionURL @""
// 提交评论
//#define kAddCommentURL @"redstar-server/rest/comment/submit?time=2015-06-25+13:59:26&operId=admin&operName=admin"
......@@ -46,4 +44,7 @@
// 上传新问题
#define kUpLoadQuestionURL @"redstar-server/rest/question/submit"
// 上报巡检结果
#define kUpLoadInspectResult @"redstar-server/rest/praise/report/"
#endif /* Url_h */
......@@ -34,4 +34,5 @@
@property (nonatomic, copy) NSArray *stores;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *version;
@property (nonatomic, copy) NSString *storePath;
@end
......@@ -36,6 +36,7 @@
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *version;
@property (nonatomic, copy) NSString *storePath;
+ (instancetype)taskDetailModelWithDict:(NSDictionary *)dict;
......
//
// RankCommentCell.h
// redstar
//
// Created by admin on 15/11/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "RankCommentModel.h"
@interface RankCommentCell : UITableViewCell
@property (nonatomic, strong) UILabel *peopleLabel;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *commentLabel;
@property (nonatomic, strong) RankCommentModel *rankComment;
@end
//
// RankCommentCell.m
// redstar
//
// Created by admin on 15/11/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankCommentCell.h"
@interface RankCommentCell ()
@end
@implementation RankCommentCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
- (void)setRankComment:(RankCommentModel *)rankComment
{
_rankComment = rankComment;
self.peopleLabel.text = [NSString stringWithFormat:@"%@", rankComment.commentor_name];
self.dateLabel.text = [NSString stringWithFormat:@"%@", rankComment.commentTime];
self.commentLabel.text = [NSString stringWithFormat:@"评论:%@", rankComment.comment];
}
- (UILabel *)peopleLabel
{
if (!_peopleLabel) {
_peopleLabel = [[UILabel alloc] init];
_peopleLabel.font = [UIFont systemFontOfSize:15.0];
_peopleLabel.textColor = kRankHeadTitleTextColor;
_peopleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_peopleLabel];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-20];
[self.contentView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:30];
[self.contentView addConstraint:shoppingWidth];
NSLayoutConstraint *shoppingHeight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:shoppingHeight];
}
return _peopleLabel;
}
- (UILabel *)dateLabel
{
if (!_dateLabel) {
_dateLabel = [[UILabel alloc] init];
_dateLabel.font = [UIFont systemFontOfSize:15.0];
_dateLabel.textColor = kRankHeadTitleTextColor;
_dateLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_dateLabel];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-20];
[self.contentView addConstraint:shoppingWidth];
NSLayoutConstraint *shoppingHeight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:shoppingHeight];
}
return _dateLabel;
}
- (UILabel *)commentLabel
{
if (!_commentLabel) {
_commentLabel = [[UILabel alloc] init];
_commentLabel.font = [UIFont systemFontOfSize:15.0];
_commentLabel.textColor = kRankHeadTitleTextColor;
_commentLabel.numberOfLines = 0;
_commentLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_commentLabel];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_commentLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.peopleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_commentLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:_commentLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:30];
[self.contentView addConstraint:shoppingWidth];
NSLayoutConstraint *shoppingHeight = [NSLayoutConstraint constraintWithItem:_commentLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
[self.contentView addConstraint:shoppingHeight];
}
return _commentLabel;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
......@@ -35,7 +35,7 @@
{
_rankList = rankList;
[self.shopNameButton setTitle:[NSString stringWithFormat:@"%@", rankList.store_name] forState:UIControlStateNormal];
self.scoreLabel.text = [NSString stringWithFormat:@"%.0f", rankList.score];
self.scoreLabel.text = [NSString stringWithFormat:@"%@", rankList.score];
}
......
//
// RankCommentModel.h
// redstar
//
// Created by admin on 15/11/25.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface RankCommentModel : NSObject
@property (nonatomic,copy) NSString *uuid;
@property (nonatomic,copy) NSString *commentor_uuid;
@property (nonatomic,copy) NSString *commentor_code;
@property (nonatomic,copy) NSString *commentor_name;
@property (nonatomic,copy) NSString *comment;
@property (nonatomic,copy) NSString *commentTime;
+ (instancetype)rankCommentModelWithDict:(NSDictionary *)dict;
- (instancetype)initWithDict:(NSDictionary *)dict;
@end
//
// RankCommentModel.m
// redstar
//
// Created by admin on 15/11/25.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankCommentModel.h"
@implementation RankCommentModel
+ (instancetype)rankCommentModelWithDict:(NSDictionary *)dict
{
return [[self alloc] initWithDict:dict];
}
- (instancetype)initWithDict:(NSDictionary *)dict
{
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dict];
}
return self;
}
@end
......@@ -14,11 +14,15 @@
@property (nonatomic,copy) NSString *store_uuid;
@property (nonatomic,copy) NSString *store_code;
@property (nonatomic,copy) NSString *store_name;
@property (nonatomic, assign) double score;
@property (nonatomic,copy) NSString * score;
@property (nonatomic,copy) NSString *reported;
@property (nonatomic,copy) NSString *commentId;
@property (nonatomic,copy) NSString *ranking;
@property (nonatomic,copy) NSString *storePath;
@property (nonatomic,copy) NSString *storeAddress;
@property (nonatomic,strong) NSArray *storePictures;
@property (nonatomic, assign, getter = isOpened) BOOL opened;
@property (nonatomic,strong) NSArray *comments;
......
//
// RankListHeaderView.h
// redstar
//
// Created by admin on 15/11/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@class RankListModel;
@protocol RankListHeaderDelegate <NSObject>
@optional
- (void)clickHeadView;
@end
@interface RankListHeaderView : UITableViewHeaderFooterView
@property (nonatomic, strong) RankListModel *rankListModel;
@property (nonatomic, weak) id<RankListHeaderDelegate> delegate;
@property (nonatomic, strong) UIButton *pushButton;
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section;
@end
//
// RankListHeaderView.m
// redstar
//
// Created by admin on 15/11/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankListHeaderView.h"
#import "RankListModel.h"
#define kPushTag 2354924
@interface RankListHeaderView ()
{
UIView *_bgView;
UIImageView *_arrowImageView;
UIButton *_bgButton;
UIButton *_otherButton;
UILabel *_scoreLabel;
NSInteger _section;
UILabel *_gradeLabel;
UIImageView *_gradeImageView;
}
@end
@implementation RankListHeaderView
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section
{
static NSString *headIdentifier = @"header";
RankListHeaderView *headView = (RankListHeaderView *)[tableView dequeueReusableCellWithIdentifier:headIdentifier];
if (headView == nil) {
headView = [[RankListHeaderView alloc] initWithReuseIdentifier:headIdentifier section:(NSInteger)section];
}
return headView;
}
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier section:(NSInteger)section
{
if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor whiteColor];
[self addSubview:bgView];
_bgView = bgView;
UIButton *bgButton = [UIButton buttonWithType:UIButtonTypeCustom];
bgButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
bgButton.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
bgButton.titleEdgeInsets = UIEdgeInsetsMake(0, 45, 0, 0);
[bgButton setTitleColor:kLightBlack forState:UIControlStateNormal];
bgButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
[bgButton addTarget:self action:@selector(headBtnClick) forControlEvents:UIControlEventTouchUpInside];
bgButton.backgroundColor = [UIColor whiteColor];
[self addSubview:bgButton];
_bgButton = bgButton;
UIImageView *arrowIMView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"grey-trilateral_right"]];
[self addSubview:arrowIMView];
_arrowImageView = arrowIMView;
UILabel *scoreLabel = [[UILabel alloc] init];
scoreLabel.textAlignment = NSTextAlignmentCenter;
scoreLabel.textColor = kNavigationBarColor;
scoreLabel.font = [UIFont systemFontOfSize:17.0];
[self addSubview:scoreLabel];
_scoreLabel = scoreLabel;
if (section < 3) {
UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%ld", section + 1]]];
[self addSubview:gradeImageView];
_gradeImageView = gradeImageView;
} else {
UILabel *gradeLabel = [[UILabel alloc] init];
gradeLabel.textAlignment = NSTextAlignmentCenter;
gradeLabel.textColor = kLightBlack;
gradeLabel.font = [UIFont systemFontOfSize:16.0];
[self addSubview:gradeLabel];
gradeLabel.text = [NSString stringWithFormat:@"第%ld名", section + 1];
_gradeLabel = gradeLabel;
}
_section = section;
UIButton *pushButton = [UIButton buttonWithType:UIButtonTypeCustom];
pushButton.tag = kPushTag + section;
[_bgView addSubview:pushButton];
_pushButton = pushButton;
}
return self;
}
- (void)headBtnClick
{
_rankListModel.opened = !_rankListModel.isOpened;
if ([_delegate respondsToSelector:@selector(clickHeadView)]) {
[_delegate clickHeadView];
}
}
- (void)setRankListModel:(RankListModel *)rankListModel
{
_rankListModel = rankListModel;
[_bgButton setTitle:rankListModel.store_name forState:UIControlStateNormal];
_scoreLabel.text = [NSString stringWithFormat:@"%@ 分",rankListModel.score];
}
- (void)didMoveToSuperview
{
if (_rankListModel.isOpened) {
[UIView animateWithDuration:0.2 animations:^{
_arrowImageView.transform = CGAffineTransformIdentity;
_arrowImageView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}];
} else {
[UIView animateWithDuration:0.2 animations:^{
_arrowImageView.transform = CGAffineTransformIdentity;
_arrowImageView.transform = CGAffineTransformMakeRotation(0);
}];
}
}
- (void)layoutSubviews
{
[super layoutSubviews];
_bgView.frame = self.bounds;
_bgButton.frame = CGRectMake(30, 0, 0.3 * kScreenWidth, self.bounds.size.height);
_arrowImageView.frame = CGRectMake(20, (self.frame.size.height - 11) / 2, 9, 10);
_scoreLabel.frame = CGRectMake(0.4 * kScreenWidth, 0, 0.3 * kScreenWidth, 50);
if (_section < 3) {
_gradeImageView.frame = CGRectMake(0.8 * kScreenWidth, 9, 36, 33);
} else {
_gradeLabel.frame = CGRectMake(0.7 * kScreenWidth, 0, 0.3 * kScreenWidth, 50);
}
_pushButton.frame = CGRectMake(30 + 0.3 * kScreenWidth, 0, 0.7 * kScreenWidth - 30, self.bounds.size.height);;
}
@end
......@@ -13,20 +13,31 @@
#import "HttpClient.h"
#import "RankListModel.h"
#import "NoDataView.h"
#import "RankCommentModel.h"
#import "RankListHeaderView.h"
#import "RankCommentCell.h"
#import <MBProgressHUD.h>
#define kRankingCell @"RankingTableViewCell"
#define kShopNameBtnTag 15000
#define kPushTag 2354924
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate>
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *headView;
@property (nonatomic, strong) UIView *lineView1;
@property (nonatomic, strong) NSMutableDictionary *selectedIndexes;
@property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NoDataView *noDataView;
@property (nonatomic, strong) UILabel *shoppingLabel;
@property (nonatomic, strong) UILabel *scoreLabel;
@property (nonatomic, strong) UILabel *gradeLabel;
@property (nonatomic, strong) NSArray *rankData;
@end
@implementation RankingListViewController
......@@ -58,12 +69,14 @@
// 初始化容器
self.selectedIndexes = [[NSMutableDictionary alloc] init];
[self addTableViews];
[self requestRankingList];
self.shoppingLabel.text = @"商场名称";
self.scoreLabel.text = @"总分";
self.gradeLabel.text = @"排名";
}
- (void)didReceiveMemoryWarning {
......@@ -97,11 +110,17 @@
NSLog(@"口碑排名response = %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tgArray = [NSMutableArray array];
for (NSDictionary *ListDict in dataArray) {
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[weakSelf.allRankListArray addObject:rankList];
[tgArray addObject:rankList];
}
if (_allRankListArray.count == 0) {
_rankData = tgArray;
if (_rankData.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES];
......@@ -109,7 +128,7 @@
self.tableView.delegate = self;
self.tableView.dataSource = self;
NSString *shopCount = [NSString stringWithFormat:@"%lu 家", (unsigned long)_allRankListArray.count];
NSString *shopCount = [NSString stringWithFormat:@"%lu 家", (unsigned long)_rankData.count];
NSMutableAttributedString *shopAttr = [[NSMutableAttributedString alloc] initWithString:shopCount];
[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)];
......@@ -140,201 +159,51 @@
}
- (BOOL)cellIsSelected:(NSIndexPath *)indexPath {
// Return whether the cell at the specified index path is selected or not
NSNumber *selectedIndex = [_selectedIndexes objectForKey:indexPath];
return selectedIndex == nil ? FALSE : [selectedIndex boolValue];
}
- (void)loadMoreInfo:(UIButton *)sender
{
NSInteger key = sender.tag - kShopNameBtnTag;
RankListModel *rankList = _allRankListArray[key];
NSArray *infoArray = rankList.comments;
RankingListCell * cell = (RankingListCell *)[[sender superview] superview];
cell.isDrop = !cell.isDrop;
NSIndexPath * path = [self.tableView indexPathForCell:cell];
[_tableView deselectRowAtIndexPath:path animated:TRUE];
BOOL isSelected = ![self cellIsSelected:path];
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[_selectedIndexes setObject:selectedIndex forKey:path];
if (cell.isDrop) {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}];
cell.someoneLabel = [[UILabel alloc] init];
cell.someoneLabel.text = @"集团领导某总";
cell.someoneLabel.font = [UIFont systemFontOfSize:15.0];
cell.someoneLabel.textAlignment = NSTextAlignmentCenter;
cell.someoneLabel.textColor = kRankHeadTitleTextColor;
cell.someoneLabel.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:cell.someoneLabel];
cell.dateLabel = [[UILabel alloc] init];
cell.dateLabel.text = @"2015-09-25 12:12:09";
cell.dateLabel.font = [UIFont systemFontOfSize:15.0];
cell.dateLabel.textAlignment = NSTextAlignmentCenter;
cell.dateLabel.textColor = kRankHeadTitleTextColor;
cell.dateLabel.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:cell.dateLabel];
cell.remarkLabel = [[UILabel alloc] init];
cell.remarkLabel.translatesAutoresizingMaskIntoConstraints = NO;
cell.remarkLabel.text = @"评语:该店进步非常大,值得大家一起学习!";
cell.remarkLabel.font = [UIFont systemFontOfSize:15.0];
cell.remarkLabel.textColor = kRankHeadTitleTextColor;
[cell.contentView addSubview:cell.remarkLabel];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:someoneTop];
NSLayoutConstraint *someoneCenterX = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:5];
[cell.contentView addConstraint:someoneCenterX];
NSLayoutConstraint *someoneWidth = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:100];
[cell.contentView addConstraint:someoneWidth];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:someoneHeight];
//
NSLayoutConstraint *dateTop = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:dateTop];
NSLayoutConstraint *dateLeft = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:10];
[cell.contentView addConstraint:dateLeft];
NSLayoutConstraint *dateRight = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[cell.contentView addConstraint:dateRight];
NSLayoutConstraint *dateHeight = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:dateHeight];
//
NSLayoutConstraint *remarkTop = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:remarkTop];
NSLayoutConstraint *remarkLeft = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:3];
[cell.contentView addConstraint:remarkLeft];
NSLayoutConstraint *remarkRight = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[cell.contentView addConstraint:remarkRight];
NSLayoutConstraint *remarkHeight = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:remarkHeight];
if (!infoArray.count == 0) {
NSDictionary *infoDict = infoArray[0];
cell.someoneLabel.text = [NSString stringWithFormat:@"%@", infoDict[@"commentor"]];
cell.dateLabel.text = [NSString stringWithFormat:@"%@", infoDict[@"commentTime"]];
cell.remarkLabel.text = [NSString stringWithFormat:@"评语:%@", infoDict[@"comment"]];
}
} else {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(0);
}];
if (cell.someoneLabel) {
[cell.someoneLabel removeFromSuperview];
cell.someoneLabel = nil;
}
if (cell.dateLabel) {
[cell.dateLabel removeFromSuperview];
cell.dateLabel = nil;
}
if (cell.remarkLabel) {
[cell.remarkLabel removeFromSuperview];
cell.remarkLabel = nil;
}
}
#pragma mark - UITableView DataSource/Delegate
[_tableView beginUpdates];
[_tableView endUpdates];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _rankData.count;
}
#pragma mark - UITableView DataSource/Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _allRankListArray.count;
RankListModel *rankList = _rankData[section];
NSInteger count = rankList.isOpened ? rankList.comments.count: 0;
return count;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
RankingListCell *cell=[tableView dequeueReusableCellWithIdentifier:kRankingCell];
RankCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:kRankingCell];
if (!cell) {
cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kRankingCell];
cell = [[RankCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kRankingCell];
}
// 前三个店名次显示图片
if (indexPath.row < 3) {
cell.scoreState = ScoreStateHigh;
NSString *imageName = [NSString stringWithFormat:@"medal_0%ld", (long)(indexPath.row + 1)];
cell.gradeImageView.image = [UIImage imageNamed:imageName];
} else {
cell.scoreState = ScoreStateLow;
NSString *rankStr = [NSString stringWithFormat:@"第 %ld 名", (long)(indexPath.row + 1)];
NSMutableAttributedString *rankAttr = [[NSMutableAttributedString alloc] initWithString:rankStr];
[rankAttr addAttributes:@{NSForegroundColorAttributeName:kRankHeadTitleTextColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,1)];
[rankAttr addAttributes:@{NSForegroundColorAttributeName:kGradeNumberTextColor} range:NSMakeRange(1,rankStr.length - 2)];
[rankAttr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldMT" size:18.0] range:NSMakeRange(1,rankStr.length - 2)];
[rankAttr addAttributes:@{NSForegroundColorAttributeName:kRankHeadTitleTextColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(rankStr.length - 1,1)];
[cell.gradeLabel setAttributedText:rankAttr];
}
RankListModel *rankList = _allRankListArray[indexPath.row];
[cell.shopNameButton setTitle:rankList.store_name forState:UIControlStateNormal];
cell.scoreLabel.text = [NSString stringWithFormat:@"%.0f", rankList.score];
cell.shopNameButton.tag = (kShopNameBtnTag + indexPath.row);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// 添加点击事件
[cell.shopNameButton addTarget:self action:@selector(loadMoreInfo:) forControlEvents:UIControlEventTouchUpInside];
RankListModel *rankListModel = _rankData[indexPath.section];
RankCommentModel *commentModel = rankListModel.comments[indexPath.row];
cell.rankComment = commentModel;
return cell;
}
// cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RankListModel *rankList = _allRankListArray[indexPath.row];
RankListModel *rankList = _rankData[indexPath.section];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.row;
rankDetailVC.indexRow = indexPath.section;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
// cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if([self cellIsSelected:indexPath]) {
return 108;
}
return 50;
}
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
......@@ -345,77 +214,24 @@
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// 创建sectionView
UIView *sectionView = [[UIView alloc] init];
sectionView.backgroundColor = kSectionBackGroundColor;
// 商场
UILabel *shoppingLabel = [[UILabel alloc] init];
shoppingLabel.text = @"商场名称";
shoppingLabel.textAlignment = NSTextAlignmentCenter;
shoppingLabel.textColor = kRankHeadTitleTextColor;
shoppingLabel.font = [UIFont systemFontOfSize:17.0];
shoppingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[sectionView addSubview:shoppingLabel];
// 总分
UILabel *scoreLabel = [[UILabel alloc] init];
scoreLabel.text = @"总分";
scoreLabel.textAlignment = NSTextAlignmentCenter;
scoreLabel.textColor = kRankHeadTitleTextColor;
scoreLabel.font = [UIFont systemFontOfSize:17.0];
scoreLabel.translatesAutoresizingMaskIntoConstraints = NO;
[sectionView addSubview:scoreLabel];
// 排名
UILabel *gradeLabel = [[UILabel alloc] init];
gradeLabel.text = @"排名";
gradeLabel.textAlignment = NSTextAlignmentCenter;
gradeLabel.textColor = kRankHeadTitleTextColor;
gradeLabel.font = [UIFont systemFontOfSize:17.0];
gradeLabel.translatesAutoresizingMaskIntoConstraints = NO;
[sectionView addSubview:gradeLabel];
//
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[sectionView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:shoppingLeft];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingBottom = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:shoppingBottom];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeWidth multiplier:1.2 constant:0];
[sectionView addConstraint:shoppingWidth];
//
NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[sectionView addConstraint:scoreTop];
NSLayoutConstraint *scoreRight = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:scoreRight];
NSLayoutConstraint *scoreWidth = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[sectionView addConstraint:scoreWidth];
NSLayoutConstraint *scoreBottom = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:scoreBottom];
//
NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[sectionView addConstraint:gradeTop];
RankListHeaderView *headView = [RankListHeaderView headViewWithTableView:tableView section:section];
headView.delegate = self;
[headView.pushButton addTarget:self action:@selector(pushclick:) forControlEvents:UIControlEventTouchUpInside];
headView.rankListModel = _rankData[section];
return headView;
}
NSLayoutConstraint *gradeRight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[sectionView addConstraint:gradeRight];
- (void)pushclick:(UIButton *)sender
{
NSInteger section = sender.tag - kPushTag;
NSLayoutConstraint *gradeBottom = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:gradeBottom];
RankListModel *rankList = _rankData[section];
return sectionView;
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = section;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
......@@ -546,31 +362,6 @@
return _shoppingCountLabel;
}
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
[_tableView registerClass:[RankingListCell class] forCellReuseIdentifier:kRankingCell];
_tableView.tableHeaderView = self.headView;
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
- (UIView *)lineView1
{
......@@ -579,7 +370,7 @@
_lineView1.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_lineView1];
NSLayoutConstraint *lineBottom = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
NSLayoutConstraint *lineBottom = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:75];
[self.headView addConstraint:lineBottom];
NSLayoutConstraint *lineLeft = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
......@@ -588,7 +379,7 @@
NSLayoutConstraint *lineRight = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.headView addConstraint:lineRight];
NSLayoutConstraint *lineHeight = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:2];
NSLayoutConstraint *lineHeight = [NSLayoutConstraint constraintWithItem:_lineView1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:1];
[_lineView1 addConstraint:lineHeight];
}
return _lineView1;
......@@ -597,12 +388,133 @@
- (UIView *)headView
{
if (!_headView) {
_headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 76)];
_headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 116)];
_headView.backgroundColor = [UIColor whiteColor];
}
return _headView;
}
- (UILabel *)shoppingLabel
{
if (!_shoppingLabel) {
// 商场
_shoppingLabel = [[UILabel alloc] init];
_shoppingLabel.textAlignment = NSTextAlignmentCenter;
_shoppingLabel.textColor = kRankHeadTitleTextColor;
_shoppingLabel.backgroundColor = kSectionBackGroundColor;
_shoppingLabel.font = [UIFont systemFontOfSize:17.0];
_shoppingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_shoppingLabel];
//
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:76];
[self.headView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:_shoppingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.headView addConstraint:shoppingLeft];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_shoppingLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.headView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingBottom = [NSLayoutConstraint constraintWithItem:_shoppingLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.headView addConstraint:shoppingBottom];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:_shoppingLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.scoreLabel attribute:NSLayoutAttributeWidth multiplier:1.2 constant:0];
[self.headView addConstraint:shoppingWidth];
}
return _shoppingLabel;
}
- (UILabel *)scoreLabel
{
if (!_scoreLabel) {
_scoreLabel = [[UILabel alloc] init];
_scoreLabel.textAlignment = NSTextAlignmentCenter;
_scoreLabel.textColor = kRankHeadTitleTextColor;
_scoreLabel.backgroundColor = kSectionBackGroundColor;
_scoreLabel.font = [UIFont systemFontOfSize:17.0];
_scoreLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_scoreLabel];
//
NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:_scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:76];
[self.headView addConstraint:scoreTop];
NSLayoutConstraint *scoreRight = [NSLayoutConstraint constraintWithItem:_scoreLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.gradeLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.headView addConstraint:scoreRight];
NSLayoutConstraint *scoreWidth = [NSLayoutConstraint constraintWithItem:_scoreLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.gradeLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[self.headView addConstraint:scoreWidth];
NSLayoutConstraint *scoreBottom = [NSLayoutConstraint constraintWithItem:_scoreLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.headView addConstraint:scoreBottom];
}
return _scoreLabel;
}
- (UILabel *)gradeLabel
{
if (!_gradeLabel) {
_gradeLabel = [[UILabel alloc] init];
_gradeLabel.textAlignment = NSTextAlignmentCenter;
_gradeLabel.textColor = kRankHeadTitleTextColor;
_gradeLabel.font = [UIFont systemFontOfSize:17.0];
_gradeLabel.translatesAutoresizingMaskIntoConstraints = NO;
_gradeLabel.backgroundColor = kSectionBackGroundColor;
[self.headView addSubview:_gradeLabel];
//
NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:_gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:76];
[self.headView addConstraint:gradeTop];
NSLayoutConstraint *gradeRight = [NSLayoutConstraint constraintWithItem:_gradeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.headView addConstraint:gradeRight];
NSLayoutConstraint *gradeBottom = [NSLayoutConstraint constraintWithItem:_gradeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.headView addConstraint:gradeBottom];
}
return _gradeLabel;
}
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100.0;
[_tableView registerClass:[RankCommentCell class] forCellReuseIdentifier:kRankingCell];
_tableView.tableHeaderView = self.headView;
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
- (NoDataView *)noDataView
{
......@@ -626,7 +538,10 @@
return _noDataView;
}
- (void)clickHeadView
{
[_tableView reloadData];
}
/*
#pragma mark - Navigation
......
......@@ -120,6 +120,8 @@
*/
- (void)loginButtonClick:(UIButton *)sender
{
self.rootTBC = [[RootTabBarController alloc] init];
[self presentViewController:_rootTBC animated:YES completion:nil];
if (self.loginView.usernameTextFiled.text.length == 0 || self.loginView.passwordTextFiled.text.length == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"账号、密码不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
......
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