CNLiveCommuntyOrderViewController.m 25.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
//
//  CNLiveCommuntyOrderViewController.m
//  CNLiveCommunitModule
//
//  Created by open on 2022/2/8.
//

#import "CNLiveCommuntyOrderViewController.h"

@interface CNLiveCommuntyOrderViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
@property (nonatomic, strong) CNLiveCommuntyActivityMaintainsCreateModel * createMdoel;
@property (nonatomic, assign) CNLiveCommuntyOrderShowType showType;
@property (nonatomic, assign) BOOL isShowTopAndBottem;
@property (nonatomic, strong) UIView * bottemView;
@property (nonatomic, strong) UIButton * payButton;
@property (nonatomic, copy) NSString *maintenId;
@property (nonatomic, assign) BOOL isChat;
@end

@implementation CNLiveCommuntyOrderViewController

- (instancetype)initWithShowType:(CNLiveCommuntyOrderShowType)showType CreateModel:(nonnull CNLiveCommuntyActivityMaintainsCreateModel *)createModel
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        _createMdoel = createModel;
        _showType = showType;
    }
    return self;
}

- (instancetype)initWithShowType:(CNLiveCommuntyOrderShowType)showType MaintenId:(NSString *)maintenId
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        _maintenId = maintenId;
        _showType = showType;
    }
    return self;
}
- (instancetype)initWithMaintenId:(NSString *)maintenId
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        _isChat = YES;
        _maintenId = maintenId;
    }
    return self;
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) {
        NSMutableArray * tempArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
        for (UIViewController * vc in self.navigationController.viewControllers) {
            if ([vc isKindOfClass:CNLiveCommuntInformViewController.class]) {
                [tempArray removeObject:vc];
                break;
            }
        }
        self.navigationController.viewControllers = tempArray;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColorHex(#F9F9F9);
    self.title = @"订单详情";
    
    [self reloadDataWithDataSource];
}
-(void)reloadDataWithDataSource
{
    if ([self.maintenId isNotBlank]) {
        __weak typeof(self) weakSelf = self;
        [CNLiveCommuntViewModel requestWithCommuntyMaintenDetailForMaintenId:self.maintenId isChat:self.isChat CompleterBlock:^(CNLiveCommuntyActivityMaintainsCreateModel * _Nonnull createModel) {
            if (createModel) {
                weakSelf.createMdoel = createModel;
                if (weakSelf.isChat) weakSelf.showType = weakSelf.createMdoel.showType;
                if ([createModel.status isEqualToString:@"0"] && weakSelf.isChat) weakSelf.showType = CNLiveCommuntyOrderShowTypeChatYetOrder;
                [weakSelf setupWithBottemView];
                [weakSelf setupWithNaviView];
                [weakSelf.tableView reloadData];
            }
        }];
    }else{
        self.createMdoel.imgs = [self.createMdoel.img componentsSeparatedByString:@","].mutableCopy;
        [self.createMdoel.imgs removeObject:@""];
    }
}
-(void)setupWithNaviView
{
    if (([self.createMdoel.status isEqualToString:@"0"] && [self.createMdoel.userId isEqualToString:[CNUserInfoManager manager].userInfoModel.uid]) || ([self.createMdoel.status isEqualToString:@"1"] && [self.createMdoel.repairId isEqualToString:[CNUserInfoManager manager].userInfoModel.uid])) {
        NSString * name = @"取消订单";
        UIColor * titleColor = UIColorHex(#F5A623);
        UIButton * submiteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        submiteBtn.frame = CGRectMake(0, 0, 50, 14);
        [submiteBtn setTitle:name forState:UIControlStateNormal];
        [submiteBtn setTitleColor:titleColor forState:UIControlStateNormal];
        submiteBtn.backgroundColor = [UIColor whiteColor];
        submiteBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [submiteBtn addTarget:self action:@selector(rightBarButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:submiteBtn];
    }else{
        self.navigationItem.rightBarButtonItem = nil;
    }
}
-(void)setupWithBottemView
{
    if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder
        || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) {
        __weak typeof(self) weakSelf = self;
        if (!self.bottemView) {
            self.bottemView = [[UIView alloc] init];
            self.bottemView.backgroundColor = [UIColor whiteColor];
            self.bottemView.hidden = self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder;
            [self.view addSubview:self.bottemView];
            [self.bottemView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.mas_equalTo(weakSelf.view);
                make.height.mas_equalTo(50+kVerticalBottomSafeHeight);
            }];
        }
        
        NSString * payString = @"";
        if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder) payString = @"立即接单";
        if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) payString = @"取消接单";
        
        if (!self.payButton) {
            self.payButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [self.payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [self.payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
            self.payButton.backgroundColor = UIColorHex(#CD0302);
            self.payButton.layer.masksToBounds = YES;
            self.payButton.layer.cornerRadius = 18;
            self.payButton.hidden = self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder;
            self.payButton.titleLabel.font = [UIFont systemFontOfSize:16];
            self.payButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
            [self.payButton addTarget:self action:@selector(payResultAction:) forControlEvents:UIControlEventTouchUpInside];
            [self.bottemView addSubview:self.payButton];
            [self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(weakSelf.bottemView.mas_top).offset(7);
                make.right.mas_equalTo(weakSelf.bottemView.mas_right).offset(-10);
                make.left.mas_equalTo(weakSelf.bottemView.mas_left).offset(10);
                make.height.mas_equalTo(36);
            }];
        }
        if ([self.createMdoel.status isEqualToString:@"1"] && [self.createMdoel.repairId isNotBlank] && ![self.createMdoel.repairId isEqualToString:[CNUserInfoManager manager].userInfoModel.uid]) {
            payString = @"已接单";
            self.payButton.backgroundColor = UIColorHex(#D7D7D7);
            self.payButton.userInteractionEnabled = NO;
        }else{
            self.payButton.userInteractionEnabled = YES;
        }
        [self.payButton setTitle:payString forState:UIControlStateNormal];
        [self.payButton setTitle:payString forState:UIControlStateHighlighted];
        self.bottemView.hidden = ![payString isNotBlank];
        self.payButton.hidden = ![payString isNotBlank];
        
        
        if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder && [self.createMdoel.totalFee isNotBlank] && [self.createMdoel.totalFee integerValue] > 0) {
            self.payButton.hidden = self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder;
            self.bottemView.hidden = self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder;
            [self.bottemView removeAllSubviews];
        }
    }else{
        if (self.bottemView && self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) {
            self.payButton.hidden = self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder;
            self.bottemView.hidden = self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder;
            [self.bottemView removeAllSubviews];
        }
    }
}

-(void)rightBarButtonAction:(UIButton *)button
{
    MJWeakSelf
    if ([button.titleLabel.text isEqualToString:@"咨询电话"]) {
        UIAlertController * alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
        [alert addAction:[UIAlertAction actionWithTitle:self.createMdoel.phone style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSMutableString* str = [[NSMutableString alloc] initWithFormat:@"tel:%@",self.createMdoel.phone];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:NULL];
        }]];
        [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:NULL]];
        [[self displayViewController] presentViewController:alert animated:YES completion:nil];
    }
    if ([button.titleLabel.text isEqualToString:@"取消订单"]) {
        [CNLiveCommuntSignUpView showAlertViewWithMessage:@"确定取消订单后,此订单将失效" CompleterBlock:^{
            [CNLiveCommuntViewModel requestWithCommuntyCancleOrderMentOrderId:weakSelf.createMdoel.idStr CompleterBlock:^{
//                weakSelf.showType = CNLiveCommuntyOrderShowTypeListFailureOrder;
//                [weakSelf setupWithBottemView];
//                [weakSelf setupWithNaviView];
//                [weakSelf.tableView reloadData];
                [weakSelf reloadDataWithDataSource];
            }];
        }];
    }
}
-(void)payResultAction:(UIButton *)button
{
    MJWeakSelf
    if ([button.titleLabel.text isEqualToString:@"立即接单"]) {
        [QMUITips showLoadingInView:self.view];
        [CNLiveCommuntViewModel requestWithCommuntyGrabOrderMentOrderId:self.createMdoel.idStr type:YES CompleterBlock:^{
            [CNLiveCommuntSignUpView showHaveTipSuccessViewCompleterBlock:^{
                weakSelf.showType = CNLiveCommuntyOrderShowTypeChatReadyOrder;
                [button setTitle:@"取消接单" forState:UIControlStateNormal];
                [button setTitle:@"取消接单" forState:UIControlStateHighlighted];
//                [weakSelf setupWithBottemView];
//                [weakSelf setupWithNaviView];
//                [weakSelf.tableView reloadData];
                [weakSelf reloadDataWithDataSource];
            }];
        }];
    }
    if ([button.titleLabel.text isEqualToString:@"取消接单"]) {
        [CNLiveCommuntSignUpView showAlertViewWithMessage:@"确定取消接单后,此订单将重新转至群" CompleterBlock:^{
            [CNLiveCommuntViewModel requestWithCommuntyGrabOrderMentOrderId:weakSelf.createMdoel.idStr type:NO CompleterBlock:^{
                weakSelf.showType = CNLiveCommuntyOrderShowTypeChatYetOrder;
                [button setTitle:@"立即接单" forState:UIControlStateNormal];
                [button setTitle:@"立即接单" forState:UIControlStateHighlighted];
//                [weakSelf setupWithBottemView];
//                [weakSelf setupWithNaviView];
//                [weakSelf.tableView reloadData];
                [weakSelf reloadDataWithDataSource];
            }];
        }];
    }
}
- (void)initTableView
{
    [super initTableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.backgroundColor = UIColorHex(#f9f9f9);
    self.tableView.frame = CGRectMake(0, kNavigationBarHeight, kScreenWidth, kScreenHeight - kNavigationBarHeight);
    if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) {
        self.tableView.contentInset = UIEdgeInsetsMake(kNavigationBarHeight + 10, 0, 60 + kVerticalBottomSafeHeight, 0);
    }else{
        self.tableView.contentInset = UIEdgeInsetsMake(kNavigationBarHeight + 10, 0, 0, 0);
    }
}
-(void)layoutTableView
{
    [super layoutTableView];

}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:kCNLiveHiddenModalViewWithQrNotification object:nil];
}
#pragma mark =
#pragma mark - DZNEmptyDataSetSource Methods
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    return [[NSAttributedString alloc] initWithString:@"暂无订单详情" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}];
}
-(UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    return [CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_content_empty"];
}
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
{
    return [[NSAttributedString alloc] initWithString:@"重试" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(#CD0302)}];
}
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button
{
    [self reloadDataWithDataSource];
}
- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIColor whiteColor];
}

- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView
{
    return YES;
}

- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView
{
    return YES;
}

- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
    return NO;
}
#pragma mark =
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.createMdoel) {
        if (self.showType == CNLiveCommuntyOrderShowTypeListYetOrder) return 2;
        if (self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder) return 2;
        if (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder) return 3;
        if (self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) return 2;
        if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder) return 1;
        if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) return [self.createMdoel.repairId isNotBlank] && ![self.createMdoel.repairId isEqualToString:[CNUserInfoManager manager].userInfoModel.uid]?1:2;
        if (self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) return 1;
    }
    return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.createMdoel) {
        if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
            || self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) {
            if (section == 0) return self.createMdoel.infoArray.count;
        }
        if (self.showType == CNLiveCommuntyOrderShowTypeListYetOrder
            || self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder
            || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) {
            if (section == 0) return self.createMdoel.infoArray.count;
            if (section == 1) return self.createMdoel.processArray.count;
        }
        if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) {
            if (section == 0) return self.createMdoel.infoArray.count;
            if (section == 1) return 1;
        }
        if (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder) {
            if (section == 0) return self.createMdoel.infoArray.count;
            if (section == 1) return 1;
            if (section == 2) return self.createMdoel.processArray.count;
        }
    }
    return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) {
        return [CNLiveCommuntSignUpOrderViewCell setTableView:tableView Dict:self.createMdoel.infoArray[indexPath.row]];
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeListYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder
        || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) {
        if (indexPath.section == 0) return [CNLiveCommuntSignUpOrderViewCell setTableView:tableView Dict:self.createMdoel.infoArray[indexPath.row]];
        if (indexPath.section == 1) return [CNLiveCommuntSignUpDetailViewCell setTableView:tableView isTop:indexPath.row == 0 isBottom:indexPath.row == (self.createMdoel.processArray.count - 1) Dict:self.createMdoel.processArray[indexPath.row]];
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) {
        __weak typeof(self) weakSelf = self;
        if (indexPath.section == 0) return [CNLiveCommuntSignUpOrderViewCell setTableView:tableView Dict:self.createMdoel.infoArray[indexPath.row]];
        if (indexPath.section == 1) return [CNLiveCommuntSignUpAmountViewCell setTableView:tableView CreateModel:self.createMdoel ReloadBlock:^{
            [weakSelf reloadDataWithDataSource];
        }];
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder) {
        if (indexPath.section == 0) return [CNLiveCommuntSignUpOrderViewCell setTableView:tableView Dict:self.createMdoel.infoArray[indexPath.row]];
        if (indexPath.section == 1) return [CNLiveCommuntSignUpContactViewCell setTableView:tableView CreateModel:self.createMdoel];
        if (indexPath.section == 2) return [CNLiveCommuntSignUpDetailViewCell setTableView:tableView isTop:indexPath.row == 0 isBottom:indexPath.row == (self.createMdoel.processArray.count - 1) Dict:self.createMdoel.processArray[indexPath.row]];
    }
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.showType == CNLiveCommuntyOrderShowTypeChatYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeChatCompletOrder) {
        NSDictionary * subDict = self.createMdoel.infoArray[indexPath.row];
        CGFloat height = [[subDict stringValueForKey:@"value" default:@""] calculateSizeWithUIWidth:kScreenWidth - 125 font:[UIFont systemFontOfSize:15.0]].height;
        return height > 30 ? height : 30;
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeListYetOrder
        || self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder
        || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) {
        if (indexPath.section == 0) {
            NSDictionary * subDict = self.createMdoel.infoArray[indexPath.row];
            CGFloat height = [[subDict stringValueForKey:@"value" default:@""] calculateSizeWithUIWidth:kScreenWidth - 125 font:[UIFont systemFontOfSize:15.0]].height;
            return height > 30 ? height : 30;
        }
        if (indexPath.section == 1) return 70;
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeChatReadyOrder) {
        if (indexPath.section == 0) {
            NSDictionary * subDict = self.createMdoel.infoArray[indexPath.row];
            CGFloat height = [[subDict stringValueForKey:@"value" default:@""] calculateSizeWithUIWidth:kScreenWidth - 125 font:[UIFont systemFontOfSize:15.0]].height;
            return height > 30 ? height : 30;
        }
        if (indexPath.section == 1) return 130;
    }
    if (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder) {
        if (indexPath.section == 0) {
            NSDictionary * subDict = self.createMdoel.infoArray[indexPath.row];
            CGFloat height = [[subDict stringValueForKey:@"value" default:@""] calculateSizeWithUIWidth:kScreenWidth - 125 font:[UIFont systemFontOfSize:15.0]].height;
            return height > 30 ? height : 30;
        }
        if (indexPath.section == 1) return 60;
        if (indexPath.section == 2) return 70;
    }
    return 0.001f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return section == 0 || ((self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder || self.showType == CNLiveCommuntyOrderShowTypeListYetOrder || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) && section == 1) || (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder && section == 2) ? 50 : 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0 || ((self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder || self.showType == CNLiveCommuntyOrderShowTypeListYetOrder || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) && section == 1) || (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder && section == 2)) {
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 50)];
        view.backgroundColor = [UIColor clearColor];
        
        UIView * radiusView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, kScreenWidth - 20, 40)];
        radiusView.backgroundColor = [UIColor whiteColor];
        radiusView.layer.shadowColor = [UIColor blackColor].CGColor;
        radiusView.layer.shadowOffset = CGSizeMake(0, 0);
        radiusView.layer.shadowOpacity = 0.3;
        radiusView.layer.shadowRadius = 8;
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH - 20, 40) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.path = maskPath.CGPath;
        radiusView.layer.mask = maskLayer;
        [view insertSubview:radiusView belowSubview:view];
        
        UILabel * nameLabel = [[UILabel alloc] init];
        nameLabel.textColor = UIColorHex(#333333);
        nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        nameLabel.numberOfLines = 1;
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.font = [UIFont boldSystemFontOfSize:14];
        nameLabel.text = section == 0 ? [NSString stringWithFormat:@"订单编号:%@",self.createMdoel.idStr]:@"进度详情";
        [view addSubview:nameLabel];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(view);
            make.left.mas_equalTo(view.mas_left).offset(20);
        }];
        return view;
    }else{
        return nil;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    CGFloat height = section == 0 && self.createMdoel.imgs.count > 0 ? (kScreenWidth - 60)/3 + 20 : 10;
    return section == 0 || ((self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder || self.showType == CNLiveCommuntyOrderShowTypeListYetOrder || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) && section == 1) || (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder && section == 2) ? height : 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    CGFloat height = section == 0 && self.createMdoel.imgs.count > 0 ? (kScreenWidth - 60)/3 + 20 : 10;
    if (section == 0 || ((self.showType == CNLiveCommuntyOrderShowTypeListReadyOrder || self.showType == CNLiveCommuntyOrderShowTypeListYetOrder || self.showType == CNLiveCommuntyOrderShowTypeListFailureOrder) && section == 1) || (self.showType == CNLiveCommuntyOrderShowTypeListCompletOrder && section == 2)) {
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, height)];
        view.backgroundColor = [UIColor clearColor];

        UIView * radiusView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, kScreenWidth - 20, height)];
        radiusView.backgroundColor = [UIColor whiteColor];
        radiusView.layer.shadowColor = [UIColor blackColor].CGColor;
        radiusView.layer.shadowOffset = CGSizeMake(0, 0);
        radiusView.layer.shadowOpacity = 0.3;
        radiusView.layer.shadowRadius = 10;
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH - 20, height) byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.path = maskPath.CGPath;
        radiusView.layer.mask = maskLayer;
        [view insertSubview:radiusView belowSubview:view];
        
        if (section == 0 && self.createMdoel.imgs.count > 0) {
            CGFloat itemW = (kScreenWidth - 60)/3;
            __block NSMutableArray * tempArray = [[NSMutableArray alloc] init];
            for (int i = 0; i < self.createMdoel.imgs.count; i++) {
                UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20 + (i * (itemW + 10)), 10, itemW, itemW)];
                imageView.backgroundColor = UIColorHex(#f9f9f9);
                imageView.tag = 1000 + i;
                imageView.layer.cornerRadius = 7;
                imageView.layer.masksToBounds = YES;
                imageView.contentMode = UIViewContentModeScaleAspectFill;
                [imageView setUserInteractionEnabled:YES];
                [imageView sd_setImageWithURL:[NSURL URLWithString:self.createMdoel.imgs[i]] placeholderImage:[UIImage imageWithColor:UIColorHex(#f9f9f9)]];
                __weak typeof(self) weakSelf = self;
                [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(UITapGestureRecognizer *  _Nonnull sender) {
                    UIImageView * imageView = (UIImageView *)sender.view;
                    [CNLivePhotoBrowser photoBrowserForDefultWithSourceViews:tempArray MediaURLArray:weakSelf.createMdoel.imgs CurrentIndex:imageView.tag - 1000 ShowType:CNLivePhotoBrowserShowTypeImage Sheet:nil CompleterBlock:NULL];
                }]];
                [view addSubview:imageView];
                [tempArray addObject:imageView];
            }
        }
        return view;
    }else{
        return nil;
    }
}
@end