Commit c3c59baa authored by AvatarC's avatar AvatarC

Merge branch 'develop' of https://git.oschina.net/gomoretech/RedstarIOS into develop_avatar

parents 4c4dd48e 04e044ce
......@@ -38,7 +38,6 @@
84800D1E1C1FB67300E8B673 /* SelectAreaTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84800D1D1C1FB67300E8B673 /* SelectAreaTableCell.m */; };
84800D211C1FB69400E8B673 /* SelectProvinceTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84800D201C1FB69400E8B673 /* SelectProvinceTableCell.m */; };
84800D241C1FB6A000E8B673 /* SelectStoreTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84800D231C1FB6A000E8B673 /* SelectStoreTableCell.m */; };
84800D2F1C1FF71200E8B673 /* RankListTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84800D2E1C1FF71200E8B673 /* RankListTableHeaderView.m */; };
8480BEA21C14326100E2F18F /* MoreScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8480BEA11C14326100E2F18F /* MoreScreenView.m */; };
8480BEA61C14378C00E2F18F /* ScopeTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8480BEA51C14378C00E2F18F /* ScopeTableView.m */; };
8480BEA91C143A0800E2F18F /* GroupTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8480BEA81C143A0800E2F18F /* GroupTableView.m */; };
......@@ -76,6 +75,7 @@
849B2F711C0CA22F005D809F /* AnnoContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 849B2F701C0CA22F005D809F /* AnnoContentTableViewCell.m */; };
849B2F741C0CA60E005D809F /* AnnounceDetailFootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 849B2F731C0CA60E005D809F /* AnnounceDetailFootView.m */; };
849B2F771C0CABE6005D809F /* AnnounceDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 849B2F761C0CABE6005D809F /* AnnounceDetailModel.m */; };
84A2270E1C229409002766DC /* RankPickView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84A2270D1C229409002766DC /* RankPickView.m */; };
84A673881C0B50B4000F828E /* OnLineCompleteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84A673871C0B50B4000F828E /* OnLineCompleteViewController.m */; };
84A6738E1C0BE2D0000F828E /* OnLineCompleteCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84A6738D1C0BE2D0000F828E /* OnLineCompleteCell.m */; };
84A673911C0C2681000F828E /* FunctionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84A673901C0C2681000F828E /* FunctionViewController.m */; };
......@@ -127,6 +127,9 @@
84D8636F1C1148EC00E4F4CC /* InspectAddCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D8636B1C1148EC00E4F4CC /* InspectAddCell.m */; };
84D863701C1148EC00E4F4CC /* InspectPicAddCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D8636D1C1148EC00E4F4CC /* InspectPicAddCell.m */; };
84D863731C11923F00E4F4CC /* AddQuestionTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D863721C11923F00E4F4CC /* AddQuestionTableCell.m */; };
84D98D131C210F3300C7C96F /* RankScreenTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D98D121C210F3300C7C96F /* RankScreenTableViewCell.m */; };
84D98D161C21371D00C7C96F /* SelectStoreHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D98D151C21371D00C7C96F /* SelectStoreHeadView.m */; };
84D98D191C21507500C7C96F /* CheckBoxButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D98D181C21507500C7C96F /* CheckBoxButton.m */; };
84DB9BC41BDCD4B600822CC4 /* CustomDropMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84DB9BC31BDCD4B600822CC4 /* CustomDropMenuView.m */; };
84DB9BC71BDCD67200822CC4 /* UIView+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 84DB9BC61BDCD67200822CC4 /* UIView+Extension.m */; };
84E0ABCD1BFB082E001C8F45 /* TaskDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E0ABCC1BFB082E001C8F45 /* TaskDetailModel.m */; };
......@@ -231,8 +234,6 @@
84800D201C1FB69400E8B673 /* SelectProvinceTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectProvinceTableCell.m; sourceTree = "<group>"; };
84800D221C1FB6A000E8B673 /* SelectStoreTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectStoreTableCell.h; sourceTree = "<group>"; };
84800D231C1FB6A000E8B673 /* SelectStoreTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectStoreTableCell.m; sourceTree = "<group>"; };
84800D2D1C1FF71200E8B673 /* RankListTableHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankListTableHeaderView.h; sourceTree = "<group>"; };
84800D2E1C1FF71200E8B673 /* RankListTableHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankListTableHeaderView.m; sourceTree = "<group>"; };
8480BEA01C14326100E2F18F /* MoreScreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoreScreenView.h; sourceTree = "<group>"; };
8480BEA11C14326100E2F18F /* MoreScreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoreScreenView.m; sourceTree = "<group>"; };
8480BEA41C14378C00E2F18F /* ScopeTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopeTableView.h; sourceTree = "<group>"; };
......@@ -309,6 +310,8 @@
849B2F731C0CA60E005D809F /* AnnounceDetailFootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnnounceDetailFootView.m; sourceTree = "<group>"; };
849B2F751C0CABE6005D809F /* AnnounceDetailModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnnounceDetailModel.h; sourceTree = "<group>"; };
849B2F761C0CABE6005D809F /* AnnounceDetailModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnnounceDetailModel.m; sourceTree = "<group>"; };
84A2270C1C229409002766DC /* RankPickView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankPickView.h; sourceTree = "<group>"; };
84A2270D1C229409002766DC /* RankPickView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankPickView.m; sourceTree = "<group>"; };
84A673861C0B50B4000F828E /* OnLineCompleteViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnLineCompleteViewController.h; sourceTree = "<group>"; };
84A673871C0B50B4000F828E /* OnLineCompleteViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OnLineCompleteViewController.m; sourceTree = "<group>"; };
84A6738C1C0BE2D0000F828E /* OnLineCompleteCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnLineCompleteCell.h; sourceTree = "<group>"; };
......@@ -410,6 +413,12 @@
84D8636D1C1148EC00E4F4CC /* InspectPicAddCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InspectPicAddCell.m; sourceTree = "<group>"; };
84D863711C11923F00E4F4CC /* AddQuestionTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddQuestionTableCell.h; sourceTree = "<group>"; };
84D863721C11923F00E4F4CC /* AddQuestionTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddQuestionTableCell.m; sourceTree = "<group>"; };
84D98D111C210F3300C7C96F /* RankScreenTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankScreenTableViewCell.h; sourceTree = "<group>"; };
84D98D121C210F3300C7C96F /* RankScreenTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankScreenTableViewCell.m; sourceTree = "<group>"; };
84D98D141C21371D00C7C96F /* SelectStoreHeadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectStoreHeadView.h; sourceTree = "<group>"; };
84D98D151C21371D00C7C96F /* SelectStoreHeadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectStoreHeadView.m; sourceTree = "<group>"; };
84D98D171C21507500C7C96F /* CheckBoxButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckBoxButton.h; sourceTree = "<group>"; };
84D98D181C21507500C7C96F /* CheckBoxButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheckBoxButton.m; sourceTree = "<group>"; };
84DB9BC21BDCD4B600822CC4 /* CustomDropMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomDropMenuView.h; sourceTree = "<group>"; };
84DB9BC31BDCD4B600822CC4 /* CustomDropMenuView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomDropMenuView.m; sourceTree = "<group>"; };
84DB9BC51BDCD67200822CC4 /* UIView+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Extension.h"; sourceTree = "<group>"; };
......@@ -705,8 +714,8 @@
children = (
846206B31C06AF700015C456 /* RankListHeaderView.h */,
846206B41C06AF700015C456 /* RankListHeaderView.m */,
84800D2D1C1FF71200E8B673 /* RankListTableHeaderView.h */,
84800D2E1C1FF71200E8B673 /* RankListTableHeaderView.m */,
84A2270C1C229409002766DC /* RankPickView.h */,
84A2270D1C229409002766DC /* RankPickView.m */,
);
path = View;
sourceTree = "<group>";
......@@ -751,6 +760,8 @@
84800D201C1FB69400E8B673 /* SelectProvinceTableCell.m */,
84800D221C1FB6A000E8B673 /* SelectStoreTableCell.h */,
84800D231C1FB6A000E8B673 /* SelectStoreTableCell.m */,
84D98D171C21507500C7C96F /* CheckBoxButton.h */,
84D98D181C21507500C7C96F /* CheckBoxButton.m */,
);
path = Cell;
sourceTree = "<group>";
......@@ -771,6 +782,8 @@
846ABE061C1EE3970020C331 /* View */ = {
isa = PBXGroup;
children = (
84D98D141C21371D00C7C96F /* SelectStoreHeadView.h */,
84D98D151C21371D00C7C96F /* SelectStoreHeadView.m */,
);
path = View;
sourceTree = "<group>";
......@@ -1010,6 +1023,8 @@
84846E991BE07CDF0010550A /* RankingListCell.m */,
846206B91C06AFF50015C456 /* RankCommentCell.h */,
846206BA1C06AFF50015C456 /* RankCommentCell.m */,
84D98D111C210F3300C7C96F /* RankScreenTableViewCell.h */,
84D98D121C210F3300C7C96F /* RankScreenTableViewCell.m */,
);
path = Cell;
sourceTree = "<group>";
......@@ -2201,6 +2216,7 @@
846ABE0C1C1EE3970020C331 /* StoreModel.m in Sources */,
84F57C501BEC7AA300DDEEB1 /* AddQuestionFooterView.m in Sources */,
84CF0F1E1BE9B40400C855CE /* InspectDetailFooterView.m in Sources */,
84D98D161C21371D00C7C96F /* SelectStoreHeadView.m in Sources */,
84F30DA41BFC19F200CBAD13 /* RankListModel.m in Sources */,
84CC34EF1C09AEC0002F10E2 /* LookOnLineDetailViewController.m in Sources */,
8487D8091BF20FAD00E63E90 /* TaxisView.m in Sources */,
......@@ -2213,6 +2229,7 @@
848A201D1C180C1900422FAB /* OnLineCompleteDetailCell.m in Sources */,
84F57C461BEC388A00DDEEB1 /* CommentView.m in Sources */,
84ED5DD81BF2E64300A1BB6D /* ScreenView.m in Sources */,
84D98D191C21507500C7C96F /* CheckBoxButton.m in Sources */,
8474C5831BE751A2007DCF19 /* CommonFunc.m in Sources */,
84AD4F491BF4BC0600BFB37C /* RankDetailTableCell.m in Sources */,
848699B31BDF810900859DFE /* InspectTaskViewController.m in Sources */,
......@@ -2244,7 +2261,6 @@
84AD4F3D1BF4894D00BFB37C /* RankDetailView.m in Sources */,
84C972961C1ABE08003A3276 /* PicScreenView.m in Sources */,
8473E38B1C1BCFC400960257 /* InspectTitleTableViewCell.m in Sources */,
84800D2F1C1FF71200E8B673 /* RankListTableHeaderView.m in Sources */,
84ECCF1B1C0210F000EA4960 /* CommentModel.m in Sources */,
846ABDF51C1E5E780020C331 /* PictureListModel.m in Sources */,
84E0ABCD1BFB082E001C8F45 /* TaskDetailModel.m in Sources */,
......@@ -2277,6 +2293,7 @@
84CC34E21C09583D002F10E2 /* LookOnLineTableViewCell.m in Sources */,
8480BEB21C143A4100E2F18F /* StateTableView.m in Sources */,
849B2F711C0CA22F005D809F /* AnnoContentTableViewCell.m in Sources */,
84A2270E1C229409002766DC /* RankPickView.m in Sources */,
84D3E6021C04DA85001FF1DD /* InspectUpLoadFootView.m in Sources */,
84A673881C0B50B4000F828E /* OnLineCompleteViewController.m in Sources */,
8474C5991BE78BBC007DCF19 /* QuestionDetailCell.m in Sources */,
......@@ -2292,6 +2309,7 @@
84A673C11C0C7AEB000F828E /* AnnounceViewController.m in Sources */,
842547FC1BF03977006C79C5 /* QuestionModel.m in Sources */,
84E420441BE84A2300689976 /* QuestionCommentCell.m in Sources */,
84D98D131C210F3300C7C96F /* RankScreenTableViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "no_select_box@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "no_select_box@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "select_box@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "select_box@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "选中@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "选中@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "形状-49@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "形状-49@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "x@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "x@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -130,6 +130,7 @@
#define kResultTitleBackColor [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:244 / 255.0 alpha:1.0]
#define kSelectStoreColor [UIColor colorWithRed:111 / 255.0 green:120 / 255.0 blue:216 / 255.0 alpha:1.0]
#define kCommentViewHeight 300
#define kCommentWithStarViewHeight 325
......
......@@ -31,7 +31,6 @@
// 口碑排名列表
#define kRankingListURL @"redstar-server/rest/praise/ranking"
// 提交评论
#define kAddCommentURL @"redstar-server/rest/comment/submit"
......@@ -105,4 +104,12 @@
// 口碑取消点赞
#define kPicturePraiseCancelLikeURL @"redstar-server/rest/legendpraise/cancel_like/"
/**
* 口碑排名(新)
*/
// 获取口碑列表
#define kQueryShortPraiseURL @"redstar-server/rest/praise/query_short?userUuid="
#endif /* Url_h */
......@@ -21,4 +21,15 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -21,4 +21,15 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -7,10 +7,14 @@
//
#import <UIKit/UIKit.h>
#import "ZanButton.h"
@interface OnLineTableViewCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *selectLabel;
@property (nonatomic, strong) UIButton *storeBtn;
@property (nonatomic, strong) UIButton *averageBtn;
@end
......@@ -28,7 +28,6 @@
- (void)setup
{
self.titleLabel.textColor = kOnLineCellTitleColor;
self.selectLabel.textColor = kOnLineCellDetailColor;
}
......@@ -56,6 +55,9 @@
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:titleBottom];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
[self.contentView addConstraint:titleHeight];
}
return _titleLabel;
......@@ -66,6 +68,7 @@
{
if (!_selectLabel) {
_selectLabel = [[UILabel alloc] init];
_selectLabel.textColor = kOnLineCellDetailColor;
_selectLabel.textAlignment = NSTextAlignmentRight;
_selectLabel.translatesAutoresizingMaskIntoConstraints = NO;
_selectLabel.font = [UIFont systemFontOfSize:15.0];
......@@ -80,9 +83,9 @@
[self.contentView addConstraint:selectRight];
// 右边
NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
[self.contentView addConstraint:selectWidth];
// NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
// [self.contentView addConstraint:selectWidth];
//
// 高度
NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:selectBottom];
......@@ -90,4 +93,78 @@
return _selectLabel;
}
- (UIButton *)storeBtn
{
if (!_storeBtn) {
_storeBtn = [[UIButton alloc] init];
_storeBtn.tag = 323228;
[_storeBtn setTitleColor:kOnLineCellTitleColor forState:UIControlStateNormal];
_storeBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_storeBtn setTitle:@"商场得分" forState:UIControlStateNormal];
_storeBtn.selected = YES;
[_storeBtn setImage:[UIImage imageNamed:@"select_box"] forState:UIControlStateNormal];
[_storeBtn setImage:[UIImage imageNamed:@"no_select_box"] forState:UIControlStateSelected];
_storeBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
_storeBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_storeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_storeBtn.imageView.contentMode = UIViewContentModeRight;
_storeBtn.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_storeBtn];
// 顶端
NSLayoutConstraint *selectTop = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:selectTop];
// 左边
NSLayoutConstraint *selectRight = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-122];
[self.contentView addConstraint:selectRight];
// 右边
NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:80];
[self.contentView addConstraint:selectWidth];
// 高度
NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:selectBottom];
}
return _storeBtn;
}
- (UIButton *)averageBtn
{
if (!_averageBtn) {
_averageBtn = [[UIButton alloc] init];
_averageBtn.tag = 323229;
[_averageBtn setTitleColor:kOnLineCellTitleColor forState:UIControlStateNormal];
_averageBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_averageBtn setTitle:@"区域平均分" forState:UIControlStateNormal];
[_averageBtn setImage:[UIImage imageNamed:@"select_box"] forState:UIControlStateNormal];
[_averageBtn setImage:[UIImage imageNamed:@"no_select_box"] forState:UIControlStateSelected];
_averageBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
_averageBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_averageBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_averageBtn.imageView.contentMode = UIViewContentModeRight;
_averageBtn.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_averageBtn];
// 顶端
NSLayoutConstraint *selectTop = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:selectTop];
// 左边
NSLayoutConstraint *selectRight = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-18];
[self.contentView addConstraint:selectRight];
// 右边
NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:95];
[self.contentView addConstraint:selectWidth];
// 高度
NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:selectBottom];
}
return _averageBtn;
}
@end
//
// CheckBoxButton.h
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CheckBoxButton : UIButton
@end
//
// CheckBoxButton.m
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "CheckBoxButton.h"
@implementation CheckBoxButton
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
CGFloat w = self.frame.size.width;
CGFloat h = self.frame.size.height;
return CGRectMake(32, 0, w - 22, h);
}
- (CGRect)imageRectForContentRect:(CGRect)contentRect;
{
CGFloat h = self.frame.size.height;
return CGRectMake(0, (h - 22) / 2, 22, 22);
}
@end
......@@ -7,10 +7,11 @@
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "AreaModel.h"
@interface SelectAreaTableCell : UITableViewCell
@property (nonatomic, strong) UIImageView *checkBoxImageView;
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) AreaModel *areaModel;
@end
......@@ -10,8 +10,66 @@
@implementation SelectAreaTableCell
- (void)awakeFromNib {
// Initialization code
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
// [_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:titleLeft];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:34];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (UIImageView *)iconImageView
{
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_iconImageView];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:23];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:13];
[self.contentView addConstraint:titleWidth];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:8];
[self.contentView addConstraint:titleBottom];
}
return _iconImageView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
......
......@@ -7,7 +7,12 @@
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "ProvinceModel.h"
@interface SelectProvinceTableCell : UITableViewCell
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) ProvinceModel *provinceModel;
@end
......@@ -10,8 +10,70 @@
@implementation SelectProvinceTableCell
- (void)awakeFromNib {
// Initialization code
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[_checkBoxButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:50];
[self.contentView addConstraint:titleLeft];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (void)click:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
}
- (UIImageView *)iconImageView
{
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_iconImageView];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:23];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:11];
[self.contentView addConstraint:titleWidth];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7.5];
[self.contentView addConstraint:titleBottom];
}
return _iconImageView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
......@@ -19,5 +81,4 @@
// Configure the view for the selected state
}
@end
......@@ -7,7 +7,13 @@
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "StoreModel.h"
@interface SelectStoreTableCell : UITableViewCell
//@property (nonatomic, strong) UIButton *storeButton1;
//@property (nonatomic, strong) UIButton *storeButton2;
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) StoreModel *storeModel;
@end
......@@ -9,10 +9,104 @@
#import "SelectStoreTableCell.h"
@implementation SelectStoreTableCell
//- (UIButton *)storeButton1
//{
// if (!_storeButton1) {
// _storeButton1 = [[UIButton alloc] init];
// _storeButton1.translatesAutoresizingMaskIntoConstraints = NO;
// _storeButton1.backgroundColor = [UIColor lightGrayColor];
// [self.contentView addSubview:_storeButton1];
//
// // 顶端
// NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleTop];
//
// // 右边
// NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-5];
// [self.contentView addConstraint:titleRight];
//
// // 左边
// NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
// [self.contentView addConstraint:titleLeft];
//
// // 高度
// NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
// [self.contentView addConstraint:titleHeight];
//
// // 高度
// NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
// [self.contentView addConstraint:titleBottom];
// }
// return _storeButton1;
//}
//
//- (UIButton *)storeButton2
//{
// if (!_storeButton2) {
// _storeButton2 = [[UIButton alloc] init];
// _storeButton2.translatesAutoresizingMaskIntoConstraints = NO;
// _storeButton2.backgroundColor = [UIColor lightGrayColor];
// [self.contentView addSubview:_storeButton2];
//
// // 顶端
// NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleTop];
//
// // 右边
// NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
// [self.contentView addConstraint:titleRight];
//
// // 左边
// NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleLeft];
//
// // 高度
// NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
// [self.contentView addConstraint:titleHeight];
// }
// return _storeButton2;
//}
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[_checkBoxButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:80];
[self.contentView addConstraint:titleLeft];
- (void)awakeFromNib {
// Initialization code
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (void)click:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
......
......@@ -12,6 +12,8 @@
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray *provinceArray;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name children:(NSArray *)children;
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children;
......
......@@ -23,4 +23,16 @@
{
return [[self alloc] initWithName:name children:children];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -11,6 +11,7 @@
@interface ProvinceModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray *storeArray;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name children:(NSArray *)children;
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children;
......
......@@ -23,5 +23,15 @@
{
return [[self alloc] initWithName:name children:children];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -10,6 +10,7 @@
@interface StoreModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name;
+ (id)dataObjectWithName:(NSString *)name;
......
......@@ -22,4 +22,16 @@
{
return [[self alloc] initWithName:name];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
//
// SelectStoreHeadView.h
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SelectStoreHeadView : UIView
@property (nonatomic, strong) UITextField *searchTextFiled; // 搜索框
@end
//
// SelectStoreHeadView.m
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "SelectStoreHeadView.h"
@implementation SelectStoreHeadView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.searchTextFiled.placeholder = @"请输入问题关键字";
self.layer.borderColor = kSeparateLineCGColor;
self.layer.borderWidth = 0.5;
}
return self;
}
#pragma mark - Lazy Loading
- (UITextField *)searchTextFiled
{
if (!_searchTextFiled) {
_searchTextFiled = [[UITextField alloc] init];
_searchTextFiled.font = [UIFont systemFontOfSize:14.0];
_searchTextFiled.backgroundColor = [UIColor whiteColor];
_searchTextFiled.translatesAutoresizingMaskIntoConstraints = NO;
_searchTextFiled.layer.cornerRadius = 4.0;
_searchTextFiled.layer.borderWidth = 1.0;
_searchTextFiled.layer.borderColor = kPasswordBorderColor;
UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search_icon"]];
imageV.width += 20;
imageV.contentMode = UIViewContentModeCenter;
_searchTextFiled.leftView = imageV;
_searchTextFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *imageR = [[UIButton alloc] init];
imageR.frame = CGRectMake(0, 0, 28, 28);
[imageR setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
[imageR addTarget:self action:@selector(searchClick:) forControlEvents:UIControlEventTouchUpInside];
imageR.contentMode = UIViewContentModeCenter;
imageR.width += 10;
_searchTextFiled.rightView = imageR;
_searchTextFiled.rightViewMode = UITextFieldViewModeAlways;
[self addSubview:_searchTextFiled];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_searchTextFiled attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_searchTextFiled attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_searchTextFiled attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_searchTextFiled attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self addConstraint:titleBottom];
}
return _searchTextFiled;
}
- (void)searchClick:(UIButton *)sender
{
self.searchTextFiled.text = @"";
}
@end
......@@ -8,14 +8,27 @@
#import "SelectStoreViewController.h"
#import <RATreeView.h>
#import "SelectAreaTableCell.h"
#define kSelectAreaTableCell @"selectAreaTableCell"
#import "SelectProvinceTableCell.h"
#define kSelectProvinceTableCell @"selectProvinceTableCell"
#import "SelectStoreTableCell.h"
#define kSelectStoreTableCell @"selectStoreTableCell"
#import "AreaModel.h"
#import "ProvinceModel.h"
#import "StoreModel.h"
#import "SelectStoreHeadView.h"
#import "CheckBoxButton.h"
@interface SelectStoreViewController () <RATreeViewDelegate, RATreeViewDataSource>
@property (nonatomic, strong) RATreeView *treeView;
@property (nonatomic, strong) NSMutableArray *allAreaData;
@property (nonatomic, strong) SelectStoreHeadView *headerView;
@end
@implementation SelectStoreViewController
......@@ -89,16 +102,37 @@
AreaModel *jinghu = [AreaModel dataObjectWithName:@"京沪西南"
children:[NSArray arrayWithObjects:computer1, computer2, computer3, nil]];
self.allAreaData = [NSMutableArray arrayWithObjects:huadong ,huabei, jinghu, nil];
self.allAreaData = [NSMutableArray arrayWithObjects:huadong ,huabei, jinghu,nil];
}
- (void)areaClick:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
SelectAreaTableCell *cell = (SelectAreaTableCell *)sender.superview.superview;
NSArray *provinceArray = cell.areaModel.provinceArray;
if (sender.selected) {
for (ProvinceModel *proVin in provinceArray) {
proVin.isChoose = YES;
}
[sender setTitleColor:kLightBlack forState:UIControlStateNormal];
} else {
for (ProvinceModel *proVin in provinceArray) {
proVin.isChoose = NO;
}
[sender setTitleColor:kSelectStoreColor forState:UIControlStateNormal];
}
[_treeView reloadRows];
}
#pragma mark - RAtreeView Delegate/DataSource
- (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item
{
NSInteger level = [treeView levelForCellForItem:item];
NSLog(@"11level = %ld", level);
if (level == -1) {
return [self.allAreaData count];
} else if (level == 0) {
......@@ -116,7 +150,6 @@
- (id)treeView:(RATreeView *)treeView child:(NSInteger)index ofItem:(id)item
{
NSInteger level = [treeView levelForCellForItem:item];
NSLog(@"22level = %ld", level);
if (level == -1) {
return [self.allAreaData objectAtIndex:index];
} else if (level == 0) {
......@@ -133,56 +166,41 @@ NSLog(@"22level = %ld", level);
- (UITableViewCell *)treeView:(RATreeView *)treeView cellForItem:(id)item
{
NSInteger level = [self.treeView levelForCellForItem:item];
NSLog(@"33level = %ld", level);
if (level == 0) {
AreaModel *data = item;
NSInteger numberOfChildren = [data.provinceArray count];
NSString *detailText = [NSString localizedStringWithFormat:@"Number of children %@ level = %ld", [@(numberOfChildren) stringValue], level];
UITableViewCell *cell = [self.treeView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
cell.contentView.backgroundColor = [UIColor brownColor];
cell.textLabel.text = data.name;
cell.detailTextLabel.text = detailText;
SelectAreaTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectAreaTableCell];
cell.areaModel = data;
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
[cell.checkBoxButton addTarget:self action:@selector(areaClick:) forControlEvents:UIControlEventTouchUpInside];
cell.iconImageView.image = [UIImage imageNamed:@"arrow_down"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else if (level == 1) {
ProvinceModel *data = item;
NSInteger numberOfChildren = [data.storeArray count];
NSString *detailText = [NSString localizedStringWithFormat:@"Number of children %@ level = %ld", [@(numberOfChildren) stringValue], level];
UITableViewCell *cell = [self.treeView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
cell.contentView.backgroundColor = [UIColor yellowColor];
SelectProvinceTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectProvinceTableCell];
cell.provinceModel = data;
if (data.isChoose) {
cell.checkBoxButton.selected = YES;
} else {
cell.checkBoxButton.selected = NO;
}
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
cell.textLabel.text = data.name;
cell.detailTextLabel.text = detailText;
cell.iconImageView.image = [UIImage imageNamed:@"grey-trilateral_down"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
StoreModel *data = item;
NSInteger numberOfChildren = 0;
NSString *detailText = [NSString localizedStringWithFormat:@"Number of children %@ level = %ld", [@(numberOfChildren) stringValue], level];
UITableViewCell *cell = [self.treeView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
cell.contentView.backgroundColor = [UIColor orangeColor];
cell.textLabel.text = data.name;
cell.detailTextLabel.text = detailText;
SelectStoreTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectStoreTableCell];
cell.storeModel = data;
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
}
- (CGFloat)treeView:(RATreeView *)treeView heightForRowForItem:(id)item
{
return 44;
}
- (BOOL)treeView:(RATreeView *)treeView canEditRowForItem:(id)item
{
......@@ -196,11 +214,25 @@ NSLog(@"22level = %ld", level);
if (!_treeView) {
_treeView = [[RATreeView alloc] initWithFrame:self.view.bounds];
_treeView.treeFooterView = [UIView new];
_treeView.rowHeight = UITableViewAutomaticDimension;
_treeView.estimatedRowHeight = 150.0;
_treeView.treeHeaderView = self.headerView;
[_treeView registerClass:[SelectAreaTableCell class] forCellReuseIdentifier:kSelectAreaTableCell];
[_treeView registerClass:[SelectProvinceTableCell class] forCellReuseIdentifier:kSelectProvinceTableCell];
[_treeView registerClass:[SelectStoreTableCell class] forCellReuseIdentifier:kSelectStoreTableCell];
[self.view addSubview:_treeView];
}
return _treeView;
}
- (SelectStoreHeadView *)headerView
{
if (!_headerView) {
_headerView = [[SelectStoreHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 50)];
}
return _headerView;
}
/*
#pragma mark - Navigation
......
......@@ -13,4 +13,16 @@
if([key isEqualToString:@"description"])
self.descriptionText = value;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -9,5 +9,15 @@
#import "PictureDetailModel.h"
@implementation PictureDetailModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -9,5 +9,15 @@
#import "PictureListModel.h"
@implementation PictureListModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -9,5 +9,15 @@
#import "CommentModel.h"
@implementation CommentModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -9,5 +9,15 @@
#import "QuestionDetailModel.h"
@implementation QuestionDetailModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -51,6 +51,6 @@
@property (nonatomic, strong) NSString *principal_code;
@property (nonatomic, strong) NSString *store_code;
@property (nonatomic, strong) NSString *store_uuid;
@property (nonatomic, strong) NSString *store_name;
//@property (nonatomic, strong) NSString *store_name;
@end
......@@ -7,7 +7,19 @@
//
#import "QuestionModel.h"
#include <objc/runtime.h>
@implementation QuestionModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
@interface SearchToolBar : UIView <UITextFieldDelegate>
@interface SearchToolBar : UIView
@property (nonatomic, strong) UITextField *searchTextFiled; // 搜索框
@property (nonatomic, strong) UIButton *queryButton; // 快速查询按钮
......
......@@ -45,7 +45,6 @@
{
if (!_searchTextFiled) {
_searchTextFiled = [[UITextField alloc] init];
_searchTextFiled.delegate = self;
_searchTextFiled.font = [UIFont systemFontOfSize:14.0];
_searchTextFiled.backgroundColor = [UIColor whiteColor];
_searchTextFiled.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -109,12 +108,6 @@
return _queryButton;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if ([textField resignFirstResponder]) {
return YES;
}
return NO;
}
@end
......@@ -27,7 +27,7 @@
#define kQuestionListCell @"questionListTableViewCell"
#define kThumbTag 745645
@interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, TaxisViewDelegate, ScopeTableViewDelegate, GroupTableViewDelegate, CategoryTableViewDelegate, StateTableViewDelegate, TimeTableViewDelegate>
@interface QuestionViewController () <UITextFieldDelegate,UITableViewDelegate, UITableViewDataSource, TaxisViewDelegate, ScopeTableViewDelegate, GroupTableViewDelegate, CategoryTableViewDelegate, StateTableViewDelegate, TimeTableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *allQuestionArray;
......@@ -54,7 +54,7 @@
@property (nonatomic, assign) NSInteger stateRow;
@property (nonatomic, assign) NSInteger timeRow;
@property (nonatomic, strong) NSLayoutConstraint *searchBottom;
@end
@implementation QuestionViewController
......@@ -404,7 +404,21 @@
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"content CONTAINS %@ || title CONTAINS %@", self.searchBar.searchTextFiled.text, self.searchBar.searchTextFiled.text];
NSArray *arrayPre=[_allQuestionArray filteredArrayUsingPredicate:predicate];
_allQuestionArray = [NSMutableArray arrayWithArray:arrayPre];
if (_allQuestionArray.count == 0) {
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
self.noDataView.backgroundColor = [UIColor whiteColor];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
}
self.searchBar.backgroundColor = kSectionBackGroundColor;
[self.tableView reloadData];
}
}
// 重置按钮
......@@ -774,7 +788,7 @@
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];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-50];
[self.view addConstraint:tableBottom];
}
return _tableView;
......@@ -784,6 +798,7 @@
{
if (!_searchBar) {
_searchBar = [[SearchToolBar alloc] init];
_searchBar.searchTextFiled.delegate = self;
_searchBar.translatesAutoresizingMaskIntoConstraints = NO;
[_searchBar.queryButton addTarget:self action:@selector(searchBarClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:_searchBar aboveSubview:_tableView];
......@@ -799,8 +814,8 @@
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_searchBar attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_searchBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
self.searchBottom = [NSLayoutConstraint constraintWithItem:_searchBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:self.searchBottom];
}
return _searchBar;
}
......@@ -829,12 +844,37 @@
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (![self.searchBar.searchTextFiled isExclusiveTouch]) {
[self.searchBar.searchTextFiled resignFirstResponder];
}
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if ([self.searchBar.searchTextFiled resignFirstResponder]) {
return YES;
}
return NO;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
self.searchBottom.constant = -256;
[UIView animateWithDuration:0.23 animations:^{
[self.searchBar layoutIfNeeded];
}];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
self.searchBottom.constant = 0;
[UIView animateWithDuration:0.23 animations:^{
[self.searchBar layoutIfNeeded];
}];
}
/*
#pragma mark - Navigation
......
......@@ -66,7 +66,7 @@
image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
self.alreadyView.image = image;
NSLog(@"taskList = %@", taskList.state);
if ([taskList.state isEqualToString:@"initial"]) {
if ([taskList.state isEqualToString:@"submitted"]) {
NSString *str = [NSString stringWithFormat:@"巡检进度:未处理"];
NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
[strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
......@@ -104,8 +104,8 @@
[strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
[strAttr addAttributes:@{NSForegroundColorAttributeName:kNavigationBarColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(5,str.length - 5)];
[self.progressLabel setAttributedText:strAttr];
self.alreadyLabel.textColor = kProgressDealWithColor;
self.allLabel.textColor = kProgressDealWithColor;
self.alreadyLabel.textColor = kNavigationBarColor;
self.allLabel.textColor = kNavigationBarColor;
} else if ([taskList.state isEqualToString:@"expired"]){
NSString *str = [NSString stringWithFormat:@"巡检进度:已过期"];
NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
......@@ -114,16 +114,7 @@
[self.progressLabel setAttributedText:strAttr];
self.alreadyLabel.textColor = kProgressOverDueColor;
self.allLabel.textColor = kProgressOverDueColor;
} else if ([taskList.state isEqualToString:@"submitted"]) {
NSString *str = [NSString stringWithFormat:@"巡检进度:已提交"];
NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
[strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
[strAttr addAttributes:@{NSForegroundColorAttributeName:kProgressDealWithColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(5,str.length - 5)];
[self.progressLabel setAttributedText:strAttr];
self.alreadyLabel.textColor = kProgressDealWithColor;
self.allLabel.textColor = kProgressDealWithColor;
} else {
}
}
......
......@@ -9,5 +9,15 @@
#import "TaskListModel.h"
@implementation TaskListModel
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -212,7 +212,6 @@
{
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
NSLog(@"urlllll = %@", url);
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
......@@ -220,7 +219,6 @@
@"pageNumber":@(0),
@"pageSize":@(10)
};
NSLog(@"parametersssssss = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -440,7 +438,7 @@
} else if (_selectRow == 1) {
_screenView.textView.text = @"";
[parameters setObject:@"initial" forKey:@"state"];
[parameters setObject:@"submitted" forKey:@"state"];
} else if (_selectRow == 2) {
_screenView.textView.text = @"";
[parameters setObject:@"processing" forKey:@"state"];
......
......@@ -85,7 +85,7 @@
}
if ([taskDetail.state isEqualToString:@"initial"]) {
if ([taskDetail.state isEqualToString:@"submitted"]) {
if (taskDetail.reportCount == 0 || taskDetail.questionCount == 0) {
self.progressLabel.text = @"0%";
} else {
......
......@@ -21,4 +21,16 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -22,4 +22,16 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
//
// RankScreenTableViewCell.h
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RankScreenTableViewCell : UITableViewCell
@property (nonatomic, strong) UILabel *queryLabel;
@property (nonatomic, strong) UIButton *screenButton;
@end
//
// RankScreenTableViewCell.m
// redstar
//
// Created by admin on 15/12/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankScreenTableViewCell.h"
@implementation RankScreenTableViewCell
- (UILabel *)queryLabel
{
if (!_queryLabel) {
_queryLabel = [[UILabel alloc] init];
_queryLabel.translatesAutoresizingMaskIntoConstraints = NO;
_queryLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:_queryLabel];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_queryLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_queryLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_queryLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.screenButton attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_queryLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:55];
[self.contentView addConstraint:contentHeight];
NSLayoutConstraint *contentBottom = [NSLayoutConstraint constraintWithItem:_queryLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:contentBottom];
}
return _queryLabel;
}
- (UIButton *)screenButton
{
if (!_screenButton) {
_screenButton = [[UIButton alloc] init];
_screenButton.translatesAutoresizingMaskIntoConstraints = NO;
_screenButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
[_screenButton setTitle:@"确定" forState:UIControlStateNormal];
[_screenButton setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
_screenButton.layer.borderWidth = 1.0;
_screenButton.layer.borderColor = kNavigationBarCGColor;
_screenButton.layer.cornerRadius = 4.0;
[self.contentView addSubview:_screenButton];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_screenButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
[self.contentView addConstraint:contentTop];
NSLayoutConstraint *contentWidth = [NSLayoutConstraint constraintWithItem:_screenButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:120];
[self.contentView addConstraint:contentWidth];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_screenButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_screenButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
[self.contentView addConstraint:contentHeight];
}
return _screenButton;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
......@@ -21,4 +21,15 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -28,4 +28,6 @@
+ (instancetype)rankListModelWithDict:(NSDictionary *)dict;
- (instancetype)initWithDict:(NSDictionary *)dict;
@property (nonatomic, assign) int index;
@end
......@@ -21,5 +21,15 @@
}
return self;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
......@@ -21,5 +21,5 @@
@property (nonatomic, strong) UIButton *pushButton;
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section;
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section index:(int)index;
@end
......@@ -27,19 +27,19 @@
@end
@implementation RankListHeaderView
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section
+ (instancetype)headViewWithTableView:(UITableView *)tableView section:(NSInteger)section index:(int)index
{
static NSString *headIdentifier = @"header";
RankListHeaderView *headView = (RankListHeaderView *)[tableView dequeueReusableCellWithIdentifier:headIdentifier];
if (headView == nil) {
headView = [[RankListHeaderView alloc] initWithReuseIdentifier:headIdentifier section:(NSInteger)section];
headView = [[RankListHeaderView alloc] initWithReuseIdentifier:headIdentifier section:(NSInteger)section index:index];
}
return headView;
}
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier section:(NSInteger)section
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier section:(NSInteger)section index:(int)index
{
if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
......@@ -71,9 +71,8 @@
[self addSubview:scoreLabel];
_scoreLabel = scoreLabel;
if (section < 3) {
UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", (int)section + 1]]];
if (index < 3) {
UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", index]]];
[self addSubview:gradeImageView];
_gradeImageView = gradeImageView;
......@@ -83,7 +82,7 @@
gradeLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:gradeLabel];
NSString *rankStr = [NSString stringWithFormat:@"第 %d 名", (int)section + 1];
NSString *rankStr = [NSString stringWithFormat:@"第 %d 名", index];
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)];
......@@ -150,7 +149,7 @@
{
[super layoutSubviews];
_bgView.frame = self.bounds;
_bgButton.frame = CGRectMake(30, 0, 0.3 * kScreenWidth, self.bounds.size.height);
_bgButton.frame = CGRectMake(30, 0, 0.35 * 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.25 * kScreenWidth, 50);
if (_section < 3) {
......
//
// RankListTableHeaderView.h
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RankListTableHeaderView : UIView
@property (nonatomic, strong) UILabel *praiseLabel;
@property (nonatomic, strong) UILabel *limitsLabel;
@property (nonatomic, strong) UILabel *statisticsLabel;
@end
//
// RankListTableHeaderView.m
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankListTableHeaderView.h"
@implementation RankListTableHeaderView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// RankPickView.h
// redstar
//
// Created by admin on 15/12/17.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RankPickView : UIView
@property (nonatomic, strong) UIPickerView *pickerView;
@property (nonatomic, strong) UIButton *okButton;
@end
//
// RankPickView.m
// redstar
//
// Created by admin on 15/12/17.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RankPickView.h"
@implementation RankPickView
- (instancetype)init
{
self = [super init];
if (self) {
[self setup];
}
return self;
}
- (void)setup{
self.pickerView = [[UIPickerView alloc] init];
_pickerView.frame = CGRectMake(0, 30, kScreenWidth, 120);
[self addSubview:_pickerView];
self.okButton = [[UIButton alloc] init];
_okButton.frame = CGRectMake(kScreenWidth - 60, 0, 60, 30);
[_okButton setTitle:@"完成" forState:UIControlStateNormal];
[_okButton setTitleColor:kLightBlack forState:UIControlStateNormal];
_okButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
[self addSubview:_okButton];
}
@end
......@@ -9,12 +9,7 @@
#import <UIKit/UIKit.h>
#import "DateButton.h"
@interface RankingListViewController : UIViewController
@property (nonatomic, strong) UILabel *pointLabel1; // 月度排名
@property (nonatomic, strong) UILabel *pointLabel2; // 参与商场数量
@property (nonatomic, strong) DateButton *dateButton; // 年月日
@property (nonatomic, strong) UILabel *shoppingCountLabel; // 商场数
@property (nonatomic, strong) UIView *lineView; // 分割线
@interface RankingListViewController : UIViewController
@end
......@@ -17,16 +17,25 @@
#import "RankListHeaderView.h"
#import "RankCommentCell.h"
#import "RankScreenTableViewCell.h"
#import <MBProgressHUD.h>
#import "OnLineTableViewCell.h"
#import "HomeTitleTableCell.h"
#import "SelectStoreViewController.h"
#import "RankPickView.h"
#define konlineCell @"onlinesTableViewCell"
#define kRankingCell @"RankingTableViewCell"
#define kHomeTitleCellInde @"homeTitleCellInde"
#define kRankScreenTableViewCell @"rankingScreenCell"
#define kShopNameBtnTag 15000
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate>
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate, UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *headView;
@property (nonatomic, strong) UIView *lineView1;
@property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NoDataView *noDataView;
......@@ -36,7 +45,15 @@
@property (nonatomic, strong) UILabel *gradeLabel;
@property (nonatomic, strong) NSArray *rankData;
@property (nonatomic, strong) NSArray *allTitleArray;
@property (nonatomic, strong) UIButton *selectButton;
@property (nonatomic, strong) RankPickView *pickerView;
@property (nonatomic, strong) UIView *backGroundView;
@property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, assign) NSInteger pickRow;
@end
@implementation RankingListViewController
......@@ -45,6 +62,13 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.allTitleArray = [NSArray arrayWithObjects:@"口碑巡检", @"选择范围", @"统计方式" ,nil];
self.titleArray = [NSMutableArray array];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.view.backgroundColor = [UIColor whiteColor];
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
......@@ -68,10 +92,9 @@
self.edgesForExtendedLayout = UIRectEdgeNone;
}
_pickRow = 0;
[self addTableViews];
[self requestShortPraise];
[self requestRankingList];
self.shoppingLabel.text = @"商场名称";
......@@ -98,19 +121,17 @@
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"beginDateFrom":@"",
@"endDateTo":@"",
@"queryOrders":@[],
@"pageNumber":@(0),
@"pageSize":@(10)
NSDictionary *parameters = @{@"praiseUuid":@"5a7417015147f8eb0151482b2359005b",
@"statisMode":@(0),
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
__block RankingListViewController *weakSelf = self;
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
if ([(NSArray *)response[@"data"] count] == 0) {
return;
}
NSArray *dataArray = response[@"data"];
NSMutableArray *tgArray = [NSMutableArray array];
......@@ -119,8 +140,15 @@
[tgArray addObject:rankList];
}
_rankData = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray];
for (int i = 0 ; i < _rankData.count; i++) {
RankListModel *rank = _rankData[i];
if (i == 0) {
rank.index = i + 1;
} else {
RankListModel *prevRank = _rankData[i-1];
rank.index = rank.score == prevRank.score ? prevRank.index: i + 1;
}
}
if (_rankData.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES];
......@@ -129,17 +157,73 @@
self.tableView.delegate = self;
self.tableView.dataSource = self;
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)];
_shoppingCountLabel.attributedText = shopAttr;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}];
}
- (void)requestShortPraise
{
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSString *url = [NSString stringWithFormat:@"%@%@%@", kRedStarURL, kQueryShortPraiseURL, user_uuid];
NSLog(@"url = %@",url);
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
[httpCilent queryShortPraiseWithCompletion:^(id response, NSError *error) {
NSLog(@"查询所有列表 response = %@ error= %@", response, error);
NSArray *dataArray = response[@"data"];
for (NSDictionary *dict in dataArray) {
[_titleArray addObject:dict];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView reloadData];
}
}];
}
- (void)requestPartPraise
{
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
NSInteger statisMode = _selectButton.tag - 323228;
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *dict = _titleArray[_pickRow];
NSDictionary *parameters = @{@"praiseUuid":dict[@"uuid"],
@"statisMode":@(statisMode),
};
NSLog(@"parrrrrters = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"分区域 口碑排名response = %@", response);
NSArray *dataArray = response[@"data"];
NSMutableArray *tgArray = [NSMutableArray array];
for (NSDictionary *ListDict in dataArray) {
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[tgArray addObject:rankList];
}
_rankData = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray];
for (int i = 0 ; i < _rankData.count; i++) {
RankListModel *rank = _rankData[i];
if (i == 0) {
rank.index = i + 1;
} else {
RankListModel *prevRank = _rankData[i-1];
rank.index = rank.score == prevRank.score ? prevRank.index: i + 1;
}
}
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
......@@ -153,19 +237,46 @@
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)addTableViews
- (void)changeDateClick:(DateButton *)sender
{
self.pointLabel1.text = @"月度排名";
self.lineView.backgroundColor = kSeparateLineColor;
self.pointLabel2.text = @"参与商家数量";
self.lineView1.backgroundColor = kSeparateLineColor;
self.shoppingCountLabel.textAlignment = NSTextAlignmentCenter;
[self.dateButton addTarget:self action:@selector(changeDateClick:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)changeDateClick:(DateButton *)sender
- (void)statisticsClick:(UIButton *)sender
{
NSLog(@"sender.tag = %ld, _sele.tag = %ld", sender.tag, _selectButton.tag);
if (sender.tag == _selectButton.tag) {
return;
} else {
_selectButton.selected = NO;
sender.selected = YES;
_selectButton = (UIButton *)sender;
}
}
- (void)closeBackGroundView
{
CGRect fromFrame = CGRectMake(0, kScreenHeight, kScreenWidth, 200);
[UIView animateWithDuration:0.3 animations:^{
_backGroundView.alpha = .0f;
_pickerView.frame = fromFrame;
} completion:^(BOOL finished) {
[_backGroundView removeFromSuperview];
[_pickerView removeFromSuperview];
}];
}
- (void)okClick:(UIButton *)sender
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
OnLineTableViewCell *cell = (OnLineTableViewCell *)[_tableView cellForRowAtIndexPath:indexPath];
_pickRow = [_pickerView.pickerView selectedRowInComponent:0];
NSDictionary *dict = _titleArray[_pickRow];
cell.selectLabel.text = [NSString stringWithFormat:@"%@", dict[@"name"]];
[self closeBackGroundView];
}
......@@ -173,18 +284,74 @@
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _rankData.count;
return _rankData.count + 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
RankListModel *rankList = _rankData[section];
if (section == 0) {
return 5;
} else {
RankListModel *rankList = _rankData[section - 1];
NSInteger count = rankList.isOpened ? rankList.comments.count: 0;
return count;
}
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
if (indexPath.row < 3) {
OnLineTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:konlineCell];
if (!cell) {
cell = [[OnLineTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:konlineCell];
}
cell.titleLabel.text = _allTitleArray[indexPath.row];
if (indexPath.row < 2) {
if (indexPath.row == 0) {
if (_titleArray.count == 0) {
cell.selectLabel.text = @"";
} else {
NSDictionary *dict = _titleArray[_pickRow];
cell.selectLabel.text = [NSString stringWithFormat:@"%@", dict[@"name"]];
}
} else {
cell.selectLabel.text = @"全部";
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else {
[cell.storeBtn addTarget:self action:@selector(statisticsClick:) forControlEvents:UIControlEventTouchUpInside];
_selectButton = cell.storeBtn;
[cell.averageBtn addTarget:self action:@selector(statisticsClick:) forControlEvents:UIControlEventTouchUpInside];
}
return cell;
} else if (indexPath.row == 3){
RankScreenTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kRankScreenTableViewCell];
if (!cell) {
cell = [[RankScreenTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kRankScreenTableViewCell];
}
NSString *queryStr = [NSString stringWithFormat:@"查询结果共计 %ld 家", (unsigned long)_rankData.count];
NSMutableAttributedString *queryAttr = [[NSMutableAttributedString alloc] initWithString:queryStr];
[queryAttr addAttributes:@{NSForegroundColorAttributeName:kLightGray,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,7)];
[queryAttr addAttributes:@{NSForegroundColorAttributeName:kNavigationBarColor,NSFontAttributeName:[UIFont systemFontOfSize:20.0f]} range:NSMakeRange(7,queryStr.length - 9)];
[queryAttr addAttributes:@{NSForegroundColorAttributeName:kLightGray,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(queryStr.length - 1,1)];
[cell.queryLabel setAttributedText:queryAttr];
[cell.screenButton addTarget:self action:@selector(requestPartPraise) forControlEvents:UIControlEventTouchUpInside];
return cell;
} else {
HomeTitleTableCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeTitleCellInde];
if (!cell) {
cell = [[HomeTitleTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeTitleCellInde];
}
cell.contentView.backgroundColor = kSectionBackGroundColor;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
} else {
RankCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:kRankingCell];
if (!cell) {
cell = [[RankCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kRankingCell];
......@@ -193,13 +360,48 @@
RankCommentModel *commentModel = rankListModel.comments[indexPath.row];
cell.rankComment = commentModel;
return cell;
}
}
// cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RankListModel *rankList = _rankData[indexPath.section];
if (indexPath.section == 0) {
if (indexPath.row == 0) {
if (!_backGroundView) {
_backGroundView = [[UIView alloc] initWithFrame:self.view.bounds];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeBackGroundView)];
[_backGroundView addGestureRecognizer:tapGR];
}
if (!_pickerView) {
_pickerView = [[RankPickView alloc] init];
_pickerView.backgroundColor = [UIColor whiteColor];
_pickerView.pickerView.delegate = self;
_pickerView.pickerView.dataSource = self;
}
_backGroundView.alpha = 0;
_backGroundView.backgroundColor = [UIColor blackColor];
[self.view insertSubview:_backGroundView aboveSubview:_tableView];
[self.view insertSubview:_pickerView aboveSubview:_backGroundView];
_pickerView.frame = CGRectMake(0, kScreenHeight, kScreenWidth, 200);
[_pickerView.okButton addTarget:self action:@selector(okClick:) forControlEvents:UIControlEventTouchUpInside];
[UIView animateWithDuration:0.3 animations:^{
_backGroundView.alpha = 0.6;
_pickerView.frame = CGRectMake(0, kScreenHeight - 200, kScreenWidth, 200);
}];
} else if (indexPath.row == 1) {
SelectStoreViewController *select = [[SelectStoreViewController alloc] init];
[self.navigationController pushViewController:select animated:YES];
} else {
return;
}
} else {
RankListModel *rankList = _rankData[indexPath.section - 1];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.section;
rankDetailVC.uuid = rankList.uuid;
......@@ -207,6 +409,7 @@
rankDetailVC.storeAddress = rankList.storeAddress;
rankDetailVC.storePictures = rankList.storePictures;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
}
// cell的高度
......@@ -214,7 +417,11 @@
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return CGFLOAT_MIN;
} else {
return 50;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
......@@ -225,21 +432,25 @@
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
RankListHeaderView *headView = [RankListHeaderView headViewWithTableView:tableView section:section];
if (section == 0) {
return nil;
} else {
RankListModel *rankList = _rankData[section - 1];
RankListHeaderView *headView = [RankListHeaderView headViewWithTableView:tableView section:section - 1 index:rankList.index];
headView.delegate = self;
[headView.pushButton addTarget:self action:@selector(pushclick:) forControlEvents:UIControlEventTouchUpInside];
headView.rankListModel = _rankData[section];
headView.rankListModel = rankList;
return headView;
}
}
- (void)pushclick:(UIButton *)sender
{
NSInteger section = sender.tag - kPushTag;
RankListModel *rankList = _rankData[section];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = section;
rankDetailVC.indexRow = section - 1;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
......@@ -248,259 +459,25 @@
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
#pragma mark - lazy loading
- (UILabel *)pointLabel1
#pragma mark - PickViewDelegate/DataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if (!_pointLabel1) {
_pointLabel1 = [[UILabel alloc] init];
_pointLabel1.translatesAutoresizingMaskIntoConstraints = NO;
_pointLabel1.textColor = kRankHeadTitleTextColor;
_pointLabel1.font = [UIFont systemFontOfSize:15.0];
_pointLabel1.textAlignment = NSTextAlignmentCenter;
[self.headView addSubview:_pointLabel1];
NSLayoutConstraint *point1Top = [NSLayoutConstraint constraintWithItem:_pointLabel1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:7];
[self.headView addConstraint:point1Top];
NSLayoutConstraint *point1Right = [NSLayoutConstraint constraintWithItem:_pointLabel1 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:15];
[self.headView addConstraint:point1Right];
NSLayoutConstraint *point1Left = [NSLayoutConstraint constraintWithItem:_pointLabel1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.headView addConstraint:point1Left];
NSLayoutConstraint *point1Height = [NSLayoutConstraint constraintWithItem:_pointLabel1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.headView addConstraint:point1Height];
}
return _pointLabel1;
return 1;
}
- (UIView *)lineView
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (!_lineView) {
_lineView = [[UIView alloc] init];
_lineView.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_lineView];
NSLayoutConstraint *point1Top = [NSLayoutConstraint constraintWithItem:_lineView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
[self.headView addConstraint:point1Top];
NSLayoutConstraint *point1Left = [NSLayoutConstraint constraintWithItem:_lineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.pointLabel1 attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.headView addConstraint:point1Left];
NSLayoutConstraint *point1Height = [NSLayoutConstraint constraintWithItem:_lineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
[self.headView addConstraint:point1Height];
NSLayoutConstraint *point1Width = [NSLayoutConstraint constraintWithItem:_lineView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0.5];
[self.headView addConstraint:point1Width];
}
return _lineView;
}
- (UILabel *)pointLabel2
{
if (!_pointLabel2) {
_pointLabel2 = [[UILabel alloc] init];
_pointLabel2.translatesAutoresizingMaskIntoConstraints = NO;
_pointLabel2.textColor = kRankHeadTitleTextColor;
_pointLabel2.font = [UIFont systemFontOfSize:15.0];
_pointLabel2.textAlignment = NSTextAlignmentCenter;
[self.headView addSubview:_pointLabel2];
NSLayoutConstraint *point1Top = [NSLayoutConstraint constraintWithItem:_pointLabel2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeTop multiplier:1.0 constant:7];
[self.headView addConstraint:point1Top];
NSLayoutConstraint *point1Right = [NSLayoutConstraint constraintWithItem:_pointLabel2 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-(kScreenWidth / 2 - 15 - 90) / 2];
[self.headView addConstraint:point1Right];
NSLayoutConstraint *point1Height = [NSLayoutConstraint constraintWithItem:_pointLabel2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.headView addConstraint:point1Height];
}
return _pointLabel2;
return _titleArray.count;
}
- (DateButton *)dateButton
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (!_dateButton) {
_dateButton = [[DateButton alloc] init];
_dateButton.translatesAutoresizingMaskIntoConstraints = NO;
NSString *dateStr = [NSString stringWithFormat:@"2015 年 08 月"];
NSMutableAttributedString *dateAttr = [[NSMutableAttributedString alloc] initWithString:dateStr];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:kDateButtonTextColor,NSFontAttributeName:[UIFont systemFontOfSize:21.0f]} range:NSMakeRange(0,5)];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(5,1)];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:kDateButtonTextColor,NSFontAttributeName:[UIFont systemFontOfSize:21.0f]} range:NSMakeRange(6,4)];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(10,1)];
[_dateButton setAttributedTitle:dateAttr forState:UIControlStateNormal];
[self.headView addSubview:_dateButton];
NSLayoutConstraint *dateTop = [NSLayoutConstraint constraintWithItem:_dateButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.pointLabel1 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.headView addConstraint:dateTop];
NSLayoutConstraint *dateLeft = [NSLayoutConstraint constraintWithItem:_dateButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.pointLabel1 attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-70];
[self.headView addConstraint:dateLeft];
NSLayoutConstraint *dateWidth = [NSLayoutConstraint constraintWithItem:_dateButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:150];
[self.headView addConstraint:dateWidth];
NSLayoutConstraint *dateHeight = [NSLayoutConstraint constraintWithItem:_dateButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[_dateButton addConstraint:dateHeight];
}
return _dateButton;
NSDictionary *dict = _titleArray[row];
return [NSString stringWithFormat:@"%@", dict[@"name"]];
}
- (UILabel *)shoppingCountLabel
{
if (!_shoppingCountLabel) {
_shoppingCountLabel = [[UILabel alloc] init];
_shoppingCountLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_shoppingCountLabel];
NSLayoutConstraint *shoppingCountTop = [NSLayoutConstraint constraintWithItem:_shoppingCountLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.pointLabel2 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.headView addConstraint:shoppingCountTop];
NSLayoutConstraint *shoppingCountRight = [NSLayoutConstraint constraintWithItem:_shoppingCountLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.headView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-(kScreenWidth / 2 - 60) / 2];
[self.headView addConstraint:shoppingCountRight];
NSLayoutConstraint *shoppingCountHeight = [NSLayoutConstraint constraintWithItem:_shoppingCountLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[_shoppingCountLabel addConstraint:shoppingCountHeight];
}
return _shoppingCountLabel;
}
- (UIView *)lineView1
{
if (!_lineView1) {
_lineView1 = [[UIView alloc] init];
_lineView1.translatesAutoresizingMaskIntoConstraints = NO;
[self.headView addSubview:_lineView1];
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];
[self.headView addConstraint:lineLeft];
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:1];
[_lineView1 addConstraint:lineHeight];
}
return _lineView1;
}
- (UIView *)headView
{
if (!_headView) {
_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;
}
#pragma mark - lazy loading
- (UITableView *)tableView
{
......@@ -512,7 +489,11 @@
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100.0;
[_tableView registerClass:[RankCommentCell class] forCellReuseIdentifier:kRankingCell];
_tableView.tableHeaderView = self.headView;
[_tableView registerClass:[OnLineTableViewCell class] forCellReuseIdentifier:konlineCell];
[_tableView registerClass:[RankScreenTableViewCell class] forCellReuseIdentifier:kRankScreenTableViewCell];
[_tableView registerClass:[HomeTitleTableCell class] forCellReuseIdentifier:kHomeTitleCellInde];
_tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, CGFLOAT_MIN)];
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
......@@ -556,14 +537,6 @@
{
[_tableView reloadData];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -23,6 +23,7 @@
// 商场
UILabel *shoppingLabel = [[UILabel alloc] init];
shoppingLabel.text = @"商场名称";
shoppingLabel.backgroundColor = [UIColor clearColor];
shoppingLabel.textAlignment = NSTextAlignmentCenter;
shoppingLabel.textColor = kRankHeadTitleTextColor;
shoppingLabel.font = [UIFont systemFontOfSize:17.0];
......@@ -32,6 +33,8 @@
// 总分
UILabel *scoreLabel = [[UILabel alloc] init];
scoreLabel.text = @"总分";
scoreLabel.backgroundColor = [UIColor clearColor];
scoreLabel.textAlignment = NSTextAlignmentCenter;
scoreLabel.textColor = kRankHeadTitleTextColor;
scoreLabel.font = [UIFont systemFontOfSize:17.0];
......@@ -41,6 +44,7 @@
// 排名
UILabel *gradeLabel = [[UILabel alloc] init];
gradeLabel.text = @"排名";
gradeLabel.backgroundColor = [UIColor clearColor];
gradeLabel.textAlignment = NSTextAlignmentCenter;
gradeLabel.textColor = kRankHeadTitleTextColor;
gradeLabel.font = [UIFont systemFontOfSize:17.0];
......@@ -48,7 +52,7 @@
[self.contentView addSubview:gradeLabel];
//
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
......@@ -64,7 +68,7 @@
[self.contentView addConstraint:shoppingWidth];
//
NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[self.contentView addConstraint:scoreTop];
NSLayoutConstraint *scoreRight = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
......@@ -77,7 +81,7 @@
[self.contentView addConstraint:scoreBottom];
//
NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[self.contentView addConstraint:gradeTop];
NSLayoutConstraint *gradeRight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
......
......@@ -226,6 +226,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
__block HomeViewController *weakSelf = self;
[httpCilent1 getRankingListWithParameters:parameters1 completion:^(id response, NSError *error) {
NSLog(@"刷新!! = 口碑排名response = %@", response);
if ([(NSArray *)response[@"data"] count] == 0) {
return;
}
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
......@@ -298,6 +301,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response);
NSLog(@"error = %@", error);
if ([(NSArray *)response[@"data"] count] == 0) {
return;
}
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
......@@ -311,6 +317,8 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
......
......@@ -113,5 +113,10 @@ typedef void (^completionBlock) (id response, NSError *error);
// 口碑取消点赞
- (void)cancelLikePicturePraiseWithCompletion:(completionBlock)completion;
/**
* 口碑排名(新)
*/
// 获取口碑列表
- (void)queryShortPraiseWithCompletion:(completionBlock)completion;
@end
......@@ -397,4 +397,14 @@
}];
}
// 获取口碑列表
- (void)queryShortPraiseWithCompletion:(completionBlock)completion
{
[self getParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
@end
......@@ -14,6 +14,7 @@
#import "Constant.h"
#import "Url.h"
#include <objc/runtime.h>
#endif /* redstar_pch */
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