CNLiveCommuntSignUpView.m 47.4 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
//
//  CNLiveCommuntSignUpView.m
//  CNLiveCommunitModule
//
//  Created by open on 2022/2/7.
//

#import "CNLiveCommuntSignUpView.h"

@implementation CNLiveCommuntSignUpView

/// 显示接单成功弹框
+(void)showHaveTipSuccessViewCompleterBlock:(void(^)(void))completerBlock
{
    UIView * tipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    tipView.backgroundColor = [UIColor whiteColor];
    tipView.layer.masksToBounds = YES;
    tipView.layer.cornerRadius = 10;
    
    QMUIButton * successBtn = [[QMUIButton alloc] initWithFrame:tipView.bounds];
    [successBtn setTitle:@"接单成功!" forState:UIControlStateNormal];
    [successBtn setTitle:@"接单成功!" forState:UIControlStateHighlighted];
    [successBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_result_success"] forState:UIControlStateNormal];
    successBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    successBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    [successBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    successBtn.imagePosition =  QMUIButtonImagePositionTop;
    successBtn.spacingBetweenImageAndTitle = 10;
    [tipView addSubview:successBtn];
    
    QMUIModalPresentationViewController *modalViewController = [[QMUIModalPresentationViewController alloc] init];
    modalViewController.animationStyle = QMUIModalPresentationAnimationStyleFade;
    modalViewController.contentView = tipView;
    [modalViewController showWithAnimated:YES completion:nil];
    
    __weak typeof(modalViewController) weakModalViewController = modalViewController;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [weakModalViewController hideWithAnimated:YES completion:^(BOOL finished) {
            if (completerBlock) completerBlock();
        }];
    });
}

/// 显示双选项弹框
/// @param completerBlock 确认回调
+(void)showAlertViewWithMessage:(NSString *)message CompleterBlock:(void(^)(void))completerBlock
{
    QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:NULL];
    QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"确定" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
        if (completerBlock) completerBlock();
    }];
    // 弹窗
    QMUIAlertController *alertController = [[QMUIAlertController alloc] initWithTitle:@"提示" message:message preferredStyle:QMUIAlertControllerStyleAlert];
    NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
    titleAttributs[NSForegroundColorAttributeName] = [UIColor blackColor];
    alertController.alertTitleAttributes = titleAttributs;
    
    action1.buttonAttributes = titleAttributs;
    
    NSMutableDictionary *sureTitleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
    sureTitleAttributs[NSForegroundColorAttributeName] = UIColorMake(0, 194, 0);
    action2.buttonAttributes = sureTitleAttributs;
    alertController.alertHeaderBackgroundColor = [UIColor whiteColor];
    alertController.alertSeparatorColor = [UIColor grayColor];
    alertController.alertTitleMessageSpacing = 7;
    alertController.alertButtonBackgroundColor = [UIColor whiteColor];
    
    [alertController addAction:action1];
    [alertController addAction:action2];
    [alertController showWithAnimated:YES];
}

/// 显示收款弹框
/// @param price 价格
+(QMUIModalPresentationViewController *)showQrTipSuccessViewWithPrice:(NSString *)price PayUrl:(NSString *)payUrl CompleterBlock:(void(^)(void))completerBlock
{
    UIView * tipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 60, 300)];
    tipView.backgroundColor = [UIColor whiteColor];
    tipView.layer.masksToBounds = YES;
    tipView.layer.cornerRadius = 10;
    
    UILabel * priceLabel = [[UILabel alloc] init];
    priceLabel.textColor = [UIColor blackColor];
    priceLabel.font = [UIFont systemFontOfSize:17];
    priceLabel.font = [UIFont boldSystemFontOfSize:17];
    priceLabel.textAlignment = NSTextAlignmentCenter;
    priceLabel.text = [NSString stringWithFormat:@"收款金额: %@元",price];
    [tipView addSubview:priceLabel];
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(tipView);
        make.top.mas_equalTo(tipView).offset(20);
    }];
    
    UIButton * closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [closeButton setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_content_close"] forState:UIControlStateNormal];
    [closeButton setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_content_close"] forState:UIControlStateHighlighted];
    [closeButton setBackgroundColor:[UIColor whiteColor]];
    [tipView addSubview:closeButton];
    [closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(tipView).offset(-10);
        make.top.mas_equalTo(tipView).offset(10);
        make.size.mas_equalTo(30);
    }];
    
    
    UIImageView * qrView = [[UIImageView alloc] init];
    qrView.contentMode = UIViewContentModeScaleAspectFill;
    qrView.backgroundColor = [UIColor whiteColor];
    qrView.image = [CNLiveCommuntSignUpView communty_generateWithDefaultQRCodeData:payUrl imageViewWidth:kScreenWidth - 60];
    [tipView addSubview:qrView];
    [qrView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(tipView);
        make.top.mas_equalTo(priceLabel.mas_bottom).offset(15);
        make.size.mas_equalTo(230);
    }];
    
    QMUIModalPresentationViewController *modalViewController = [[QMUIModalPresentationViewController alloc] init];
    modalViewController.animationStyle = QMUIModalPresentationAnimationStyleFade;
    modalViewController.contentView = tipView;
    modalViewController.modal = YES;
    [modalViewController showWithAnimated:YES completion:nil];
    
    __weak typeof(modalViewController) weakModalViewController = modalViewController;
    [closeButton addBlockForControlEvents:UIControlEventTouchUpInside block:^(id  _Nonnull sender) {
        [weakModalViewController hideWithAnimated:YES completion:^(BOOL finished) {
            if (finished && completerBlock) completerBlock();
        }];
    }];
    
    return modalViewController;

}

+ (UIImage *)communty_generateWithDefaultQRCodeData:(NSString *)data imageViewWidth:(CGFloat)imageViewWidth {

    CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
    [filter setDefaults];
    NSString *info = data;
    NSData *infoData = [info dataUsingEncoding:NSUTF8StringEncoding];
    [filter setValue:infoData forKeyPath:@"inputMessage"];
    CIImage *outputImage = [filter outputImage];
    
    return [CNLiveCommuntSignUpView communty_createNonInterpolatedUIImageFormCIImage:outputImage withSize:imageViewWidth];
}

/** 根据CIImage生成指定大小的UIImage */
+ (UIImage *)communty_createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size {
    CGRect extent = CGRectIntegral(image.extent);
    CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
    
    // 1.创建bitmap;
    size_t width = CGRectGetWidth(extent) * scale;
    size_t height = CGRectGetHeight(extent) * scale;
    CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
    CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
    CIContext *context = [CIContext contextWithOptions:nil];
    CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
    CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
    CGContextScaleCTM(bitmapRef, scale, scale);
    CGContextDrawImage(bitmapRef, extent, bitmapImage);
    
    // 2.保存bitmap到图片
    CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
    CGContextRelease(bitmapRef);
    CGImageRelease(bitmapImage);
    return [UIImage imageWithCGImage:scaledImage];
}

@end

@implementation CNLiveCommuntSignUpUserViewCell

+(CNLiveCommuntSignUpUserViewCell *)setTableView:(UITableView *)tableView selectArray:(NSArray *)selectArray isAddUser:(BOOL)isAddUser UserDict:(nonnull NSDictionary *)userDict
{
    CNLiveCommuntSignUpUserViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpViewCell"];
    if (!cell) {
        cell = [[CNLiveCommuntSignUpUserViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpViewCell"];
    }
    cell.selectArray = selectArray;
    cell.userDict = userDict;
    cell.isAddUser = isAddUser;
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.nameLabel];
        [self.mainView addSubview:self.lineLabel];
        [self.mainView addSubview:self.sexAgeLabel];
        [self.mainView addSubview:self.phoneLabel];
        [self.mainView addSubview:self.delectBtn];
        [self.mainView addSubview:self.editButton];
        [self.mainView addSubview:self.bottemLineLabel];
    }
    return self;
}
-(void)setSelectArray:(NSArray *)selectArray
{
    _selectArray = selectArray;
}
-(void)setUserDict:(NSDictionary *)userDict
{
    _userDict = userDict;
    _nameLabel.text = [userDict stringValueForKey:@"name" default:@""];
    _sexAgeLabel.text = [NSString stringWithFormat:@"%@  %@岁",[[userDict stringValueForKey:@"gender" default:@""] isEqualToString:@"0"]?@"女":@"男",[userDict stringValueForKey:@"age" default:@""]];
    _phoneLabel.text = [NSString stringWithFormat:@"联系电话:%@",[userDict stringValueForKey:@"mobile" default:@""]];
    BOOL isHave = NO;
    for (NSDictionary * userSubDict in self.selectArray) {
        if ([userDict isEqual:userSubDict]) isHave = YES;
    }
    if (isHave) self.delectBtn.selected = YES;
}
-(void)setIsAddUser:(BOOL)isAddUser
{
    _isAddUser = isAddUser;
    self.editButton.hidden = !isAddUser;
    if (isAddUser) {
        [self.delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_add_user_nomal"] forState:UIControlStateNormal];
        [self.delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_add_user_nomal"] forState:UIControlStateHighlighted];
        [self.delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_add_user_select"] forState:UIControlStateSelected];
    }else{
        [self.delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_list_delect_user"] forState:UIControlStateNormal];
        [self.delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_list_delect_user"] forState:UIControlStateHighlighted];
    }
}
-(void)selectUserAction:(UIButton *)button
{
    button.selected = !button.selected;
    if (!self.isAddUser) {
        if ([self.delegate respondsToSelector:@selector(setCommuntPushAddWithDelectUserViewController:)]) {
            [self.delegate setCommuntPushAddWithDelectUserViewController:self.userDict];
        }
    }else{
        if ([self.delegate respondsToSelector:@selector(setCommuntSelectAddWithEditUserViewController:isSelect:)]) {
            [self.delegate setCommuntSelectAddWithEditUserViewController:self.userDict isSelect:button.selected];
        }
    }
}
-(void)editUserAction:(UIButton *)button
{
    if ([self.delegate respondsToSelector:@selector(setCommuntPushAddWithEditUserViewController:)]) {
        [self.delegate setCommuntPushAddWithEditUserViewController:self.userDict];
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView).offset(10);
        make.right.mas_equalTo(weakSelf.contentView).offset(-10);
        make.top.bottom.mas_equalTo(weakSelf.contentView);
    }];
    [self.delectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mainView);
        make.left.mas_equalTo(weakSelf.mainView).offset(10);
        make.size.mas_equalTo(20);
    }];
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.delectBtn.mas_right).offset(10);
        make.top.mas_equalTo(weakSelf.nameLabel.mas_bottom).offset(5);
    }];
    [self.editButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mainView);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
        make.size.mas_equalTo(20);
    }];
    [self.sexAgeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.nameLabel);
        make.right.mas_equalTo(weakSelf.editButton.mas_left).offset(-5);
    }];
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.nameLabel);
        make.right.mas_equalTo(weakSelf.sexAgeLabel.mas_left).offset(-5);
        make.height.mas_equalTo(10);
        make.width.mas_equalTo(0.5);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mainView).offset(5);
        make.left.mas_equalTo(weakSelf.delectBtn.mas_right).offset(10);
        make.right.mas_equalTo(weakSelf.lineLabel.mas_left).offset(-5);
    }];
    [self.bottemLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(5);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-5);
        make.bottom.mas_equalTo(weakSelf.mainView.mas_bottom).offset(-1);
        make.height.mas_equalTo(1);
    }];
}
#pragma mark =
-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
    }
    return _mainView;
}
-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = UIColorHex(#333333);
        _nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _nameLabel.numberOfLines = 1;
        _nameLabel.font = [UIFont systemFontOfSize:15];
        _nameLabel.font = [UIFont boldSystemFontOfSize:15];
    }
    return _nameLabel;
}
-(UILabel *)lineLabel
{
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc] init];
        _lineLabel.backgroundColor = UIColorHex(#C8C8C8);
        _lineLabel.hidden = NO;
    }
    return _lineLabel;
}
-(UILabel *)bottemLineLabel
{
    if (!_bottemLineLabel) {
        _bottemLineLabel = [[UILabel alloc] init];
        _bottemLineLabel.backgroundColor = UIColorHex(#F1F2F6);
    }
    return _bottemLineLabel;
}
-(UILabel *)sexAgeLabel
{
    if (!_sexAgeLabel) {
        _sexAgeLabel = [[UILabel alloc] init];
        _sexAgeLabel.textColor = UIColorHex(#8A8A8A);
        _sexAgeLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _sexAgeLabel.numberOfLines = 1;
        _sexAgeLabel.font = [UIFont systemFontOfSize:11];
        _sexAgeLabel.font = [UIFont boldSystemFontOfSize:11];
    }
    return _sexAgeLabel;
}
-(UILabel *)phoneLabel
{
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] init];
        _phoneLabel.textColor = UIColorHex(#8A8A8A);
        _phoneLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _phoneLabel.numberOfLines = 1;
        _phoneLabel.font = [UIFont systemFontOfSize:13];
        _phoneLabel.font = [UIFont boldSystemFontOfSize:13];
    }
    return _phoneLabel;
}
-(UIButton *)delectBtn
{
    if (!_delectBtn) {
        _delectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _delectBtn.backgroundColor = [UIColor whiteColor];
        [_delectBtn addTarget:self action:@selector(selectUserAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _delectBtn;
}
-(UIButton *)editButton
{
    if (!_editButton) {
        _editButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_editButton setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_list_edit_user"] forState:UIControlStateNormal];
        _editButton.backgroundColor = [UIColor whiteColor];
        [_editButton addTarget:self action:@selector(editUserAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _editButton;
}
@end


@implementation CNLiveCommuntSignUpTextViewCell

+(CNLiveCommuntSignUpTextViewCell *)setTableView:(UITableView *)tableView Desc:(nonnull NSString *)desc ReloadWebViewBlock:(nonnull void (^)(CGFloat))reloadWebViewBlock
{
    CNLiveCommuntSignUpTextViewCell * textCell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpTextViewCell"];
    if (!textCell) {
        textCell = [[CNLiveCommuntSignUpTextViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpTextViewCell"];
    }
    textCell.reloadWebViewBlock = reloadWebViewBlock;
    textCell.desc = desc;
    return textCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.webView];
    }
    return self;
}
-(void)setDesc:(NSString *)desc
{
    [self.webView loadHTMLString:[NSString stringWithFormat:[self loadDocumentHTML],desc] baseURL:nil];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(weakSelf.contentView).offset(10);
        make.bottom.right.mas_equalTo(weakSelf.contentView).offset(-10);
    }];
    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.top.mas_equalTo(weakSelf.mainView).offset(10);
//        make.right.bottom.mas_equalTo(weakSelf.mainView).offset(-10);
        make.edges.mas_equalTo(weakSelf.mainView);
    }];
}
-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
        _mainView.layer.masksToBounds = YES;
        _mainView.layer.cornerRadius = 8;
    }
    return _mainView;
}
-(WKWebView *)webView
{
    if (!_webView) {
        WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc] init];
        configuration.preferences.javaScriptEnabled = NO;//打开js交互
        _webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
        _webView.backgroundColor = [UIColor whiteColor];
        _webView.allowsBackForwardNavigationGestures = NO;//打开网页间的 滑动返回
        _webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
        if (@available(iOS 9.0, *)) _webView.allowsLinkPreview = NO;
        _webView.scrollView.bounces = NO;
    }
    return _webView;
}

-(UILabel *)cententLabel
{
    if (!_cententLabel) {
        _cententLabel = [[UILabel alloc] init];
        _cententLabel.textColor = UIColorHex(#333333);
        _cententLabel.backgroundColor = [UIColor whiteColor];
        _cententLabel.lineBreakMode = NSLineBreakByCharWrapping;
        _cententLabel.numberOfLines = 0;
        _cententLabel.layer.masksToBounds = YES;
        _cententLabel.layer.cornerRadius = 12;
        _cententLabel.font = [UIFont systemFontOfSize:15];
        _cententLabel.font = [UIFont boldSystemFontOfSize:15];
        _cententLabel.text = @"1. 现场签到 2. 工作人员介绍本次活动内容 3. 老师讲解衍纸制作流程并现场制作 4. 合影留念";
    }
    return _cententLabel;
}
-(NSString *)loadDocumentHTML
{
    return @"<!DOCTYPE html>\n"
    "<html> \n"
    "<head> \n"
    "<meta charset=\"utf-8\" name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"> \n"
    "<style type=\"text/css\"> \n"
    "body {font-weight: normal;line-height: 0 auto-pos;text-align: left;} \n"
    "</style> \n"
    "</head> \n"
    "<body> \n"
    "%@"
    "</body> \n"
    "</html> \n";
}
@end

@implementation CNLiveCommuntSignUpOrderViewCell

+(CNLiveCommuntSignUpOrderViewCell *)setTableView:(UITableView *)tableView Dict:(NSDictionary *)dict
{
    CNLiveCommuntSignUpOrderViewCell * textCell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpOrderView"];
    if (!textCell) {
        textCell = [[CNLiveCommuntSignUpOrderViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpTextViewCell"];
    }
    textCell.paramDict = dict;
    return textCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.nameLabel];
        [self.mainView addSubview:self.cententLabel];
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(10);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-10);
        make.bottom.top.mas_equalTo(weakSelf.contentView);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(10);
        make.width.mas_equalTo(65);
        make.height.mas_equalTo(30);
        make.top.mas_equalTo(weakSelf.mainView.mas_top);
    }];
    [self.cententLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.nameLabel.mas_right);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
        make.top.bottom.mas_equalTo(weakSelf.mainView);
    }];
}
-(void)setParamDict:(NSDictionary *)paramDict
{
    _paramDict = paramDict;
    _nameLabel.text = [paramDict stringValueForKey:@"key" default:@""];
    _cententLabel.text = [paramDict stringValueForKey:@"value" default:@""];
}
-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
    }
    return _mainView;
}
-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = UIColorHex(#999999);
        _nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _nameLabel.numberOfLines = 1;
        _nameLabel.backgroundColor = UIColorHex(#F9F9F9);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.font = [UIFont boldSystemFontOfSize:14];

    }
    return _nameLabel;
}
-(UILabel *)cententLabel
{
    if (!_cententLabel) {
        _cententLabel = [[UILabel alloc] init];
        _cententLabel.textColor = UIColorHex(#333333);
        _cententLabel.backgroundColor = UIColorHex(#F9F9F9);
        _cententLabel.lineBreakMode = NSLineBreakByCharWrapping;
        _cententLabel.numberOfLines = 0;
        _cententLabel.font = [UIFont systemFontOfSize:15];
        _cententLabel.font = [UIFont boldSystemFontOfSize:15];

    }
    return _cententLabel;
}
@end


@implementation CNLiveCommuntSignUpAmountViewCell

+(CNLiveCommuntSignUpAmountViewCell *)setTableView:(UITableView *)tableView CreateModel:(CNLiveCommuntyActivityMaintainsCreateModel *)createModel ReloadBlock:(nonnull void (^)(void))reloadBlock
{
    CNLiveCommuntSignUpAmountViewCell * textCell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpAmountViewCell"];
    if (!textCell) {
        textCell = [[CNLiveCommuntSignUpAmountViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpAmountViewCell"];
    }
    textCell.reloadBlock = reloadBlock;
    textCell.createModel = createModel;
    return textCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.amoutField];
        [self.mainView addSubview:self.qrButton];
        [self.mainView addSubview:self.payButton];
        
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenModalViewNotification:) name:kCNLiveHiddenModalViewWithQrNotification object:nil];
    }
    return self;
}
-(void)hiddenModalViewNotification:(NSNotification *)note
{
    __weak typeof(self) weakSelf = self;
    [self.modalView hideWithAnimated:YES completion:^(BOOL finished) {
        if (finished && weakSelf.reloadBlock) weakSelf.reloadBlock();
    }];
}
-(void)setCreateModel:(CNLiveCommuntyActivityMaintainsCreateModel *)createModel
{
    _createModel = createModel;
    if ([createModel.totalFee isNotBlank]
        && [createModel.totalFee integerValue] > 0) {
        NSString * p = [NSString stringWithFormat:@"%.2f",([createModel.totalFee integerValue]/100.0)];
        self.amoutField.text = p;
        self.amoutField.enabled = NO;
        self.amoutField.textColor = UIColorHex(#c8c8c8);
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(10);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-10);
        make.bottom.mas_equalTo(weakSelf.contentView).offset(-10);
        make.top.mas_equalTo(weakSelf.contentView).offset(10);
    }];
    [self.amoutField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mainView.mas_top).offset(10);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(10);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
        make.height.mas_equalTo(40);
    }];
    [self.qrButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.amoutField.mas_bottom).offset(10);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(10);
        make.width.mas_equalTo((kScreenWidth - 50)/2);
        make.height.mas_equalTo(40);
    }];
    [self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.amoutField.mas_bottom).offset(10);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
        make.width.mas_equalTo((kScreenWidth - 50)/2);
        make.height.mas_equalTo(40);
    }];
}
-(void)qrCreateAction
{
    if ([self.amoutField.text floatValue] == 0 || ([self.amoutField.text floatValue] < 0.01 && ![self.amoutField.text isEqualToString:@"0.01"])) {
        [QMUITips showError:@"数字输入错误" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    if (![self isPurerFloat:self.amoutField.text]) {
        [QMUITips showError:@"数字输入错误" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    self.amoutField.text = [NSString stringWithFormat:@"%.2f",[self.amoutField.text floatValue]];
    if ([self.amoutField.text floatValue] >= 999999.99) {
        if (![self.amoutField.text isEqualToString:@"1000000.0"]
            && ![self.amoutField.text isEqualToString:@"1000000"]
            && ![self.amoutField.text isEqualToString:@"1000000.00"]) {
            [QMUITips showWithText:@"最高限额1000000元" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
            self.amoutField.text = @"1000000.00";
            return;
        }
    }
    if (![CNLiveNetworking isNetworking]) {
        [QMUITips showError:@"似乎与互联网断开连接" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    __weak typeof(self) weakSelf = self;
    if ([self.createModel.totalFee isNotBlank]
        && [self.createModel.totalFee integerValue] > 0) {
        NSString * p = [NSString stringWithFormat:@"%.0f",[weakSelf.amoutField.text doubleValue]*100];
        [CNLiveCommuntViewModel requestWithCommuntyTotalFeeOrderMentOrderId:self.createModel.idStr totalFee:p CompleterBlock:^(NSString * _Nonnull payUrl) {
            NSString * p = [NSString stringWithFormat:@"%.2f",[self.amoutField.text doubleValue]];
            weakSelf.modalView = [CNLiveCommuntSignUpView showQrTipSuccessViewWithPrice:p PayUrl:payUrl CompleterBlock:^{
                NSLog(@"移除监听通知");
                [[NSNotificationCenter defaultCenter] removeObserver:weakSelf name:@"kIMAMSG_ScanPaySuccessNotification" object:nil];
            }];
            [[NSNotificationCenter defaultCenter] addObserver:weakSelf selector:@selector(hiddenModalViewNotification:) name:@"kIMAMSG_ScanPaySuccessNotification" object:nil];
            if (weakSelf.reloadBlock) weakSelf.reloadBlock();
        }];
    }else{
        [CNLiveCommuntSignUpView showAlertViewWithMessage:@"请仔细核对金额,确认后将不可修改" CompleterBlock:^{
            NSString * p = [NSString stringWithFormat:@"%.0f",[weakSelf.amoutField.text doubleValue]*100];
            weakSelf.amoutField.enabled = NO;
            weakSelf.amoutField.textColor = UIColorHex(#c8c8c8);
            [CNLiveCommuntViewModel requestWithCommuntyTotalFeeOrderMentOrderId:weakSelf.createModel.idStr totalFee:p CompleterBlock:^(NSString * _Nonnull payUrl) {
                NSString * p = [NSString stringWithFormat:@"%.2f",[self.amoutField.text doubleValue]];
                weakSelf.modalView = [CNLiveCommuntSignUpView showQrTipSuccessViewWithPrice:p PayUrl:payUrl CompleterBlock:^{
                    NSLog(@"移除监听通知");
                    [[NSNotificationCenter defaultCenter] removeObserver:weakSelf name:@"kIMAMSG_ScanPaySuccessNotification" object:nil];
                }];
                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenModalViewNotification:) name:@"kIMAMSG_ScanPaySuccessNotification" object:nil];
                if (weakSelf.reloadBlock) weakSelf.reloadBlock();
            }];
        }];
    }
}
-(void)payCreateAction
{
    if ([self.amoutField.text floatValue] == 0 || ([self.amoutField.text floatValue] < 0.01 && ![self.amoutField.text isEqualToString:@"0.01"])) {
        [QMUITips showError:@"数字输入错误" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    if (![self isPurerFloat:self.amoutField.text]) {
        [QMUITips showError:@"数字输入错误" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    self.amoutField.text = [NSString stringWithFormat:@"%.2f",[self.amoutField.text floatValue]];
    if ([self.amoutField.text floatValue] >= 999999.99) {
        if (![self.amoutField.text isEqualToString:@"1000000.0"]
            && ![self.amoutField.text isEqualToString:@"1000000"]
            && ![self.amoutField.text isEqualToString:@"1000000.00"]) {
            [QMUITips showWithText:@"最高限额1000000元" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
            return;
        }
    }
    if (![CNLiveNetworking isNetworking]) {
        [QMUITips showError:@"似乎与互联网断开连接" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        return;
    }
    __weak typeof(self) weakSelf = self;
    [CNLiveCommuntSignUpView showAlertViewWithMessage:@"请仔细核对金额,确认后将不可修改" CompleterBlock:^{
        NSString * p = [NSString stringWithFormat:@"%.0f",[weakSelf.amoutField.text doubleValue]*100];
        weakSelf.amoutField.enabled = NO;
        weakSelf.amoutField.textColor = UIColorHex(#c8c8c8);
        [CNLiveCommuntViewModel requestWithCommuntyTotalFeeOrderMentOrderId:weakSelf.createModel.idStr totalFee:p CompleterBlock:^(NSString * _Nonnull payUrl) {
            [CNLiveCommuntViewModel requestWithCommuntyMaintenPayMentOrderId:weakSelf.createModel.idStr CompleterBlock:weakSelf.reloadBlock];
        }];
    }];
}
#pragma mark =
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (![self checkDecimal:[textField.text stringByAppendingString:string]]) {
        if (textField.text.length > 0
            && ([string isEqualToString:@"."])
            && ![textField.text containsString:@"."]) {
            return YES;
        }
        return [string isEqualToString:@""] ? YES : NO;
    }
    return YES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    if ([textField.text isNotBlank] && textField.text.length > 10) {
        [QMUITips showWithText:@"最高限额1000000.00元" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
        //如果是表情的话 这里容易截断显示
        textField.text = @"1000000.00";
    }
    return YES;
}
/// 判断是否是两位小数
- (BOOL)checkDecimal:(NSString *)str
{
    NSString *regex = @"^[0-9]+(\\.[0-9]{1,2})?$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [pred evaluateWithObject:str];
}
- (BOOL)isPureFloat:(NSString *)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    float val;
    return [scan scanFloat:&val] && [scan isAtEnd];
}
- (BOOL)isPurerFloat:(NSString*)string{
    
    if ([self isPureFloat:string]) {
        float f = [string floatValue];
        if (f >= 0) {
            return YES;
        }else{
            return NO;
        }
    }
    return NO;
}
#pragma mark =
-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
        _mainView.layer.masksToBounds = YES;
        _mainView.layer.cornerRadius = 8;
    }
    return _mainView;
}
-(UITextField *)amoutField
{
    if (!_amoutField) {
        _amoutField = [[UITextField alloc] init];
        _amoutField.backgroundColor = UIColorHex(#F9F9F9);
        _amoutField.font = [UIFont systemFontOfSize:14.0f];
        _amoutField.textColor = UIColorHex(#333333);
        _amoutField.clearButtonMode = UITextFieldViewModeWhileEditing;
        _amoutField.keyboardType = UIKeyboardTypeDefault;
        _amoutField.textAlignment = NSTextAlignmentLeft;
        _amoutField.keyboardType = UIKeyboardTypeDecimalPad;
        _amoutField.minimumFontSize = 8;
        _amoutField.placeholder = @"请输入金额";
        _amoutField.returnKeyType = UIReturnKeyDone;
        _amoutField.layer.masksToBounds = YES;
        _amoutField.layer.cornerRadius = 5;
        _amoutField.delegate = self;
    }
    return _amoutField;
}
-(UIButton *)qrButton
{
    if (!_qrButton) {
        _qrButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_qrButton setTitle:@"生成二维码" forState:UIControlStateNormal];
        [_qrButton setTitleColor:UIColorHex(#FD862E) forState:UIControlStateNormal];
        _qrButton.titleLabel.font = [UIFont systemFontOfSize:13];
        _qrButton.titleLabel.font = [UIFont boldSystemFontOfSize:13];
        _qrButton.layer.cornerRadius = 5;
        _qrButton.layer.masksToBounds = YES;
//        _qrButton.enabled = NO;
        [_qrButton setBackgroundImage:[UIImage imageWithColor:UIColorHex(#FEF2EA)] forState:UIControlStateNormal];
        [_qrButton addTarget:self action:@selector(qrCreateAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _qrButton;
}
-(UIButton *)payButton
{
    if (!_payButton) {
        _payButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_payButton setTitle:@"已线下支付" forState:UIControlStateNormal];
        [_payButton setTitleColor:UIColorHex(#0091FF) forState:UIControlStateNormal];
        _payButton.titleLabel.font = [UIFont systemFontOfSize:13];
        _payButton.titleLabel.font = [UIFont boldSystemFontOfSize:13];
        _payButton.layer.cornerRadius = 5;
        _payButton.layer.masksToBounds = YES;
//        _payButton.enabled = NO;
        [_payButton setBackgroundImage:[UIImage imageWithColor:UIColorHex(#E5F4FF)] forState:UIControlStateNormal];
        [_payButton addTarget:self action:@selector(payCreateAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _payButton;
}
@end

@implementation CNLiveCommuntSignUpContactViewCell

+(CNLiveCommuntSignUpContactViewCell *)setTableView:(UITableView *)tableView CreateModel:(CNLiveCommuntyActivityMaintainsCreateModel *)createModel
{
    CNLiveCommuntSignUpContactViewCell * textCell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpContactViewCell"];
    if (!textCell) {
        textCell = [[CNLiveCommuntSignUpContactViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpContactViewCell"];
    }
    textCell.createModel = createModel;
    return textCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.nameLabel];
        [self.mainView addSubview:self.phoneButton];
    }
    return self;
}
-(void)setCreateModel:(CNLiveCommuntyActivityMaintainsCreateModel *)createModel
{
    _createModel = createModel;
    _nameLabel.text = [createModel.name isNotBlank]?[NSString stringWithFormat:@"维修人:%@",createModel.name]:@"";
    if ([createModel.mobile isNotBlank]) {
        [_phoneButton setTitle:createModel.mobile forState:UIControlStateNormal];
        [_phoneButton setTitle:createModel.mobile forState:UIControlStateHighlighted];
        [_phoneButton setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_order_phone"] forState:UIControlStateNormal];
        [_phoneButton setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_order_phone"] forState:UIControlStateHighlighted];
    }
}
-(void)phoneAction
{
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    [alert addAction:[UIAlertAction actionWithTitle:self.createModel.mobile style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSMutableString* str = [[NSMutableString alloc] initWithFormat:@"tel:%@",self.createModel.mobile];
        [[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];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(10);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-10);
        make.bottom.mas_equalTo(weakSelf.contentView);
//        make.bottom.mas_equalTo(weakSelf.contentView).offset(-10);
        make.top.mas_equalTo(weakSelf.contentView).offset(10);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mainView);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(10);
    }];
    [self.phoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mainView);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
    }];
}
-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
        _mainView.layer.masksToBounds = YES;
        _mainView.layer.cornerRadius = 8;
    }
    return _mainView;
}
-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = UIColorHex(#333333);
        _nameLabel.numberOfLines = 1;
        _nameLabel.backgroundColor = [UIColor whiteColor];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _nameLabel;
}
-(QMUIButton *)phoneButton
{
    if (!_phoneButton) {
        _phoneButton = [[QMUIButton alloc] init];
        [_phoneButton setTitleColor:UIColorHex(#0091FF) forState:UIControlStateNormal];
        _phoneButton.titleLabel.font = [UIFont systemFontOfSize:12];
        _phoneButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
        _phoneButton.imagePosition = QMUIButtonImagePositionLeft;
        _phoneButton.spacingBetweenImageAndTitle = 3;
        [_phoneButton addTarget:self action:@selector(phoneAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _phoneButton;
}
@end

@implementation CNLiveCommuntSignUpDetailViewCell

+(CNLiveCommuntSignUpDetailViewCell *)setTableView:(UITableView *)tableView isTop:(BOOL)isTop isBottom:(BOOL)isbottom Dict:(NSDictionary *)dict
{
    CNLiveCommuntSignUpDetailViewCell * textCell = [tableView dequeueReusableCellWithIdentifier:@"CNLiveCommuntSignUpDetailViewCell"];
    if (!textCell) {
        textCell = [[CNLiveCommuntSignUpDetailViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CNLiveCommuntSignUpDetailViewCell"];
    }
    textCell.dict = dict;
    textCell.isTop = isTop;
    textCell.isBottom = isbottom;
    
    return textCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.mainView];
        [self.mainView addSubview:self.nameLabel];
        [self.mainView addSubview:self.timeLabel];
        
        [self.mainView addSubview:self.lineLabel];
        [self.mainView addSubview:self.topLabel];
        [self.mainView addSubview:self.bottemLabel];
        
        [self.mainView addSubview:self.statusView];
    }
    return self;
}
-(void)setDict:(NSDictionary *)dict
{
    _dict = dict;
    _nameLabel.text = [dict stringValueForKey:@"key" default:@""];
    _timeLabel.text = [dict stringValueForKey:@"value" default:@""];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(10);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-10);
        make.top.bottom.mas_equalTo(weakSelf.contentView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mainView.mas_top).offset(10);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(30);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.nameLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(30);
    }];
    
    [self.topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mainView.mas_top);
        make.bottom.mas_equalTo(weakSelf.statusView.mas_top).offset(2);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(16);
        make.width.mas_equalTo(1);
    }];
    [self.bottemLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.statusView.mas_bottom);
        make.bottom.mas_equalTo(weakSelf.mainView.mas_bottom);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(16);
        make.width.mas_equalTo(1);
    }];
    
    [self.statusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.nameLabel);
        make.centerX.mas_equalTo(weakSelf.topLabel);
    }];
    
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(weakSelf.mainView.mas_bottom).offset(-0.5);
        make.left.mas_equalTo(weakSelf.mainView.mas_left).offset(30);
        make.right.mas_equalTo(weakSelf.mainView.mas_right).offset(-10);
        make.height.mas_equalTo(0.5);
    }];
    
    self.topLabel.hidden = self.isTop;
    self.bottemLabel.hidden = self.isBottom;
    self.lineLabel.hidden = self.isBottom;
    
    if (self.isTop) {
        self.statusView.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_order_status"];
        self.nameLabel.textColor = UIColorHex(#CD0302);
    }else{
        self.statusView.image = [UIImage imageWithColor:UIColorHex(#D2D2D2) size:CGSizeMake(10, 10)];
        self.nameLabel.textColor = UIColorHex(#999999);
    }
}

-(UIView *)mainView
{
    if (!_mainView) {
        _mainView = [[UIView alloc] init];
        _mainView.backgroundColor = [UIColor whiteColor];
    }
    return _mainView;
}
-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = UIColorHex(#CD0302);
        _nameLabel.numberOfLines = 1;
        _nameLabel.backgroundColor = [UIColor whiteColor];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = [UIFont systemFontOfSize:15];
        _nameLabel.font = [UIFont boldSystemFontOfSize:15];
    }
    return _nameLabel;
}
-(UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = UIColorHex(#B4B4B4);
        _timeLabel.numberOfLines = 1;
        _timeLabel.backgroundColor = [UIColor whiteColor];
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.font = [UIFont systemFontOfSize:12];
    }
    return _timeLabel;
}
-(UIImageView *)statusView
{
    if (!_statusView) {
        _statusView = [[UIImageView alloc] init];
        _statusView.contentMode = UIViewContentModeScaleAspectFill;
        _statusView.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_order_status"];
        _statusView.backgroundColor = [UIColor clearColor];
        _statusView.layer.masksToBounds = YES;
        _statusView.layer.cornerRadius = 5;
    }
    return _statusView;
}
-(UILabel *)lineLabel
{
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc] init];
        _lineLabel.backgroundColor = UIColorHex(#E4E4E4);
    }
    return _lineLabel;
}
-(UILabel *)topLabel
{
    if (!_topLabel) {
        _topLabel = [[UILabel alloc] init];
        _topLabel.backgroundColor = UIColorHex(#E4E4E4);
    }
    return _topLabel;
}
-(UILabel *)bottemLabel
{
    if (!_bottemLabel) {
        _bottemLabel = [[UILabel alloc] init];
        _bottemLabel.backgroundColor = UIColorHex(#E4E4E4);
    }
    return _bottemLabel;
}
@end