#import "OrderCheckLogisticsPathViewController.h"
#import "ConstantHeader.h"
#import <Masonry/Masonry.h>
#import "MBProgressHUD+QSJ.h"
#import "AlertUtil.h"
#import "MJRefresh.h"
#import "UIColor+RCColor.h"
#import "UIImageView+WebCache.h"
#import "OrderLogisticsFirstPathCell.h"
#import "OrderLogisticsPathCell.h"
@interface OrderCheckLogisticsPathViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView *myTableView;
@property(nonatomic,strong) UILabel *wuLiuState ,*wuLiuCom ,*wuLiuNum ,*wuLiuTel;
@property(nonatomic,strong) UIImageView *wuLiuImgv;
@end
@implementation OrderCheckLogisticsPathViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"查看物流";
//绘画添加tableview
self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_SIZE_WIDTH, SCREEN_SIZE_WIDTH) style:UITableViewStyleGrouped];
self.myTableView.delegate = self;
self.myTableView.dataSource = self;
self.myTableView.rowHeight = UITableViewAutomaticDimension;
self.myTableView.estimatedRowHeight = 55;
self.myTableView.showsVerticalScrollIndicator = NO;
self.myTableView.showsHorizontalScrollIndicator = NO;
self.myTableView.backgroundColor = NORMAL_BKG_GREY;
[self.view addSubview:self.myTableView];
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
make.left.mas_equalTo(self.view);
make.right.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view);
}];
[self.myTableView registerClass:[OrderLogisticsFirstPathCell class] forCellReuseIdentifier:@"OrderLogisticsFirstPathCell"];
[self.myTableView registerClass:[OrderLogisticsPathCell class] forCellReuseIdentifier:@"OrderLogisticsPathCell"];
self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//头视图
//1.原理初始化一个view(headerView) 临时加到Self.view上或者其他固定地方
//实际上是 headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 155);
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
headerView.backgroundColor = NORMAL_BKG_GREY;
[self.view addSubview:headerView];
//2.绘图
//上
UIView *shangView = [[UIView alloc]init];
shangView.backgroundColor = [UIColor whiteColor];
[headerView addSubview:shangView];
[shangView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(headerView.mas_top);
make.left.right.mas_equalTo(headerView);
make.height.mas_equalTo(105);
}];
self.wuLiuImgv = [[UIImageView alloc]init];
[shangView addSubview:self.wuLiuImgv];
[self.wuLiuImgv mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(shangView.mas_top).mas_offset(TEXT_LINE_DISTANCE);
make.left.mas_equalTo(shangView.mas_left).mas_equalTo(TEXT_LINE_DISTANCE);
make.size.mas_equalTo(CGSizeMake(90, 90));
}];
[self.wuLiuImgv sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"placeholder_img"]];
//物流状态
UILabel *wlState = [[UILabel alloc]init];
[shangView addSubview:wlState];
wlState.textColor = TEXT_DARK_GREY;
wlState.font = NORMAL_FONT;
wlState.text = @"物流状态:";
[wlState mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.wuLiuImgv.mas_top);
make.left.mas_equalTo(self.wuLiuImgv.mas_right).mas_offset(TEXT_EDGE_DISTANCE);
}];
self.wuLiuState = [[UILabel alloc]init];
[shangView addSubview:self.wuLiuState];
self.wuLiuState.textColor = [UIColor colorWithHexString:@"#fd7191" alpha:1.0];
self.wuLiuState.font = NORMAL_FONT;
self.wuLiuState.text = @"运输中";
[self.wuLiuState mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlState.mas_top);
make.left.mas_equalTo(wlState.mas_right).mas_offset(TEXT_LINE_DISTANCE);
}];
//什么快递
UILabel *wlCom = [[UILabel alloc]init];
[shangView addSubview:wlCom];
wlCom.textColor = TEXT_LIGHT_GREY;
wlCom.font = MIDDLE_SECOND_FONT;
wlCom.text = @"承运来源:";
[wlCom mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlState.mas_bottom).mas_offset(TEXT_LINE_DISTANCE);
make.left.mas_equalTo(self.wuLiuImgv.mas_right).mas_offset(TEXT_EDGE_DISTANCE);
}];
self.wuLiuCom = [[UILabel alloc]init];
[shangView addSubview:self.wuLiuCom];
self.wuLiuCom.textColor = TEXT_LIGHT_GREY;
self.wuLiuCom.font = MIDDLE_SECOND_FONT;
self.wuLiuCom.text = @"韵达快递";
[self.wuLiuCom mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlCom.mas_top);
make.left.mas_equalTo(wlCom.mas_right).mas_offset(TEXT_LINE_DISTANCE);
}];
//订单编号
UILabel *wlNum = [[UILabel alloc]init];
[shangView addSubview:wlNum];
wlNum.textColor = TEXT_LIGHT_GREY;
wlNum.font = MIDDLE_SECOND_FONT;
wlNum.text = @"订单编号:";
[wlNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlCom.mas_bottom).mas_offset(TEXT_LINE_DISTANCE);
make.left.mas_equalTo(self.wuLiuImgv.mas_right).mas_offset(TEXT_EDGE_DISTANCE);
}];
self.wuLiuNum= [[UILabel alloc]init];
[shangView addSubview:self.wuLiuNum];
self.wuLiuNum.textColor = TEXT_LIGHT_GREY;
self.wuLiuNum.font = MIDDLE_SECOND_FONT;
self.wuLiuNum.text = @"204956123454343";
[self.wuLiuNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlNum.mas_top);
make.left.mas_equalTo(wlNum.mas_right).mas_offset(TEXT_LINE_DISTANCE);
}];
//官方电话
UILabel *wlTel = [[UILabel alloc]init];
[shangView addSubview:wlTel];
wlTel.textColor = TEXT_LIGHT_GREY;
wlTel.font = MIDDLE_SECOND_FONT;
wlTel.text = @"官方电话:";
[wlTel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlNum.mas_bottom).mas_offset(TEXT_LINE_DISTANCE);
make.left.mas_equalTo(self.wuLiuImgv.mas_right).mas_offset(TEXT_EDGE_DISTANCE);
}];
self.wuLiuTel= [[UILabel alloc]init];
[shangView addSubview:self.wuLiuTel];
self.wuLiuTel.textColor = [UIColor colorWithHexString:@"#2b98de" alpha:1.0];
self.wuLiuTel.font = MIDDLE_SECOND_FONT;
self.wuLiuTel.text = @"204956";
[self.wuLiuTel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(wlTel.mas_top);
make.left.mas_equalTo(wlTel.mas_right).mas_offset(TEXT_LINE_DISTANCE);
}];
[shangView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(headerView.mas_top);
make.left.right.mas_equalTo(headerView);
make.bottom.mas_equalTo(self.wuLiuImgv.mas_bottom).mas_offset(TEXT_LINE_DISTANCE);
}];
//线
UIView *lineOne = [[UIView alloc]init];
[headerView addSubview:lineOne];
lineOne.backgroundColor = LINE_CELL_COLOR;
[lineOne mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(shangView.mas_bottom);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(0.5);
}];
//缝隙
UIView *fengVeiw = [[UIView alloc]init];
[headerView addSubview:fengVeiw];
fengVeiw.backgroundColor = NORMAL_BKG_GREY;
[fengVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(shangView.mas_bottom);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(5);
}];
//线
UIView *lineTwo = [[UIView alloc]init];
[headerView addSubview:lineTwo];
lineTwo.backgroundColor = LINE_CELL_COLOR;
[lineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(fengVeiw.mas_bottom);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(0.5);
}];
//下面标题菜鸟果果
UIView *xiaBkgView = [[UIView alloc]init];
[headerView addSubview:xiaBkgView];
xiaBkgView.backgroundColor = [UIColor whiteColor];
[xiaBkgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(lineTwo.mas_bottom);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(43);
}];
UIImageView *tIconImgv = [[UIImageView alloc]init];
[xiaBkgView addSubview:tIconImgv];
tIconImgv.layer.cornerRadius = 10;
tIconImgv.layer.masksToBounds = YES;
[tIconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(xiaBkgView);
make.left.mas_equalTo(TEXT_EDGE_DISTANCE);
make.size.mas_equalTo(CGSizeMake(20, 20));
}];
[tIconImgv sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"chatListCellHead"]];
//菜鸟果果文本
UILabel *cnTextL = [[UILabel alloc]init];
[xiaBkgView addSubview:cnTextL];
cnTextL.font = MIDDLE_SECOND_FONT;
NSString *cntext = @"本数据由菜鸟裹裹提供";
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:cntext];
[string addAttributes:@{NSForegroundColorAttributeName:TEXT_DARK_GREY} range:NSMakeRange(0, 4)];
[string addAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#2b98de" alpha:1.0]} range:NSMakeRange(4, 4)];
[string addAttributes:@{NSForegroundColorAttributeName:TEXT_DARK_GREY} range:NSMakeRange(8, 2)];
cnTextL.attributedText = string;
[cnTextL mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(xiaBkgView);
make.left.mas_equalTo(tIconImgv.mas_right).mas_offset(TEXT_LINE_DISTANCE);
}];
//线
UIView *lineThree = [[UIView alloc]init];
[headerView addSubview:lineThree];
lineThree.backgroundColor = LINE_CELL_COLOR;
[lineThree mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(xiaBkgView.mas_bottom);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(0.5);
}];
//3.masonry得到headerview尺寸
[headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.myTableView.mas_top);
make.left.right.mas_equalTo(self.myTableView);
make.bottom.mas_equalTo(lineThree);
}];
[headerView layoutSubviews];
//4.适配得到相应高
CGFloat height = [headerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
CGRect frame = headerView.frame;
frame.size.height = height;
headerView.frame = frame;
//5.得到表头
self.myTableView.tableHeaderView = headerView;
}
#pragma makr----tableview Delegate DataSource----
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 4;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Buyer seller
switch (indexPath.row) {
case 0:
{
OrderLogisticsFirstPathCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderLogisticsFirstPathCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
case 1:
{
OrderLogisticsPathCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderLogisticsPathCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
case 2:
{
OrderLogisticsPathCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderLogisticsPathCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
case 3:
{
OrderLogisticsPathCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderLogisticsPathCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
default:
{
OrderLogisticsPathCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderLogisticsPathCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.00001;
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.tabBarController.tabBar.hidden = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}