CNLIVEViewController.m 9.49 KB
//
//  CNLIVEViewController.m
//  CNLiveCommunitModule
//
//  Created by woshiliushiyu on 01/30/2022.
//  Copyright (c) 2022 woshiliushiyu. All rights reserved.
//

#import "CNLIVEViewController.h"
#import "CNLiveCommuntActiviRecordViewController.h"
#import "CNLiveCommuntActiviRepairViewController.h"
#import "CNLiveCommuntInformViewController.h"
#import "CNLiveCommuntEvaluaViewController.h"
#import "CNLiveCommuntSignUpViewController.h"
#import "CNLiveCommuntyOrderViewController.h"
#import "CNLiveCommuntyHomeListViewController.h"
#import "CNLiveCommuntViewController.h"
#import <Masonry/Masonry.h>
#import "CNLiveCommuntyModule.h"
#import "CNLIVEAppDelegate.h"
#import <YYCategories/YYCategories.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXPagingView/JXPagerView.h>
#import <Masonry/Masonry.h>
#import <YYText/YYText.h>
#import "CNLiveCommuntViewModel.h"
#import "CNLiveCommuntSignUpView.h"
#import "CNLiveCommuntyResultListViewController.h"
#import <CNLiveEnvironment/CNLiveEnvironment.h>
#import <CNLiveUserManagement/CNUserInfoManager.h>
#import <CNLiveRequestBastKit/CNLiveNetworking.h>
@interface CNLIVEViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView * tableView;
@property (nonatomic, strong) NSMutableArray * dataArray;
@property (nonatomic, assign) BOOL isChange;
@end

@implementation CNLIVEViewController
-(NSMutableArray *)dataArray
{
    if (!_dataArray) {
        _dataArray = [[NSMutableArray alloc] initWithArray:@[
            @"有底部导航栏的界面",@"活动记录",@"报修记录",@"填写记录",@"活动评价",@"报名",@"订单详情-未接单",@"订单详情-已接单",@"145680",@"暂时点击无效",@"选择小区",@"主界面跳转"
        ]];
    }
    return _dataArray;
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
//    if (@available(iOS 11.0, *)) {
//        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
//    } else {
//        // Fallback on earlier versions
//        self.automaticallyAdjustsScrollViewInsets = NO;
//    }
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
    
    __block NSArray * array = @[@"123",@"123",@"123",@"123",@"123",@"123"];
    __block NSMutableString *picString = [[NSMutableString alloc] init];
    [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [picString appendString:obj];
        if (array.count != idx+1) [picString appendString:@","];
    }];
    NSLog(@"===>%@",picString);
    NSString * oldValue = @"1";
    oldValue = [NSString stringWithFormat:@"%.2f",[oldValue floatValue]/100];
    float unitPrice = [oldValue floatValue];
    NSString * p = [NSString stringWithFormat:@"合计: ¥%.2f",(8 * unitPrice)];
    NSLog(@"%@  =>%f ==>%@",oldValue,unitPrice,p);
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(UITableViewCell.class)];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(UITableViewCell.class)];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = [NSString stringWithFormat:@"%@==%ld",self.dataArray[indexPath.row],(long)indexPath.row];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40.0f;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        [[CNLiveCommuntyModule shareInstance] pushCommuntyHomeViewMethod];
    }
    if (indexPath.row == 1) {
        NSString * nbhdId =  (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"kCNLiveCommuntyNBhdIdIdentifier"];
        CNLiveCommuntActiviRecordViewController * recordVC = [[CNLiveCommuntActiviRecordViewController alloc] initWithNBhdId:nbhdId];
        [self.navigationController pushViewController:recordVC animated:YES];
//        [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"kCNLiveCommuntyNBhdIdIdentifier"];
//        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    if (indexPath.row == 2) {
        CNLiveCommuntActiviRepairViewController * repairView = [[CNLiveCommuntActiviRepairViewController alloc] init];
        [self.navigationController pushViewController:repairView animated:YES];
    }
    if (indexPath.row == 3) {
        NSString * nbhdId =  (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"kCNLiveCommuntyNBhdIdIdentifier"];
        CNLiveCommuntInformViewController * informView = [[CNLiveCommuntInformViewController alloc] initWithNBhdId:nbhdId];
        [self.navigationController pushViewController:informView animated:YES];
    }
    if (indexPath.row == 4) {
        CNLiveCommuntEvaluaViewController * evaluaView = [[CNLiveCommuntEvaluaViewController alloc] init];
        [self.navigationController pushViewController:evaluaView animated:YES];
    }
    if (indexPath.row == 5) {
        CNLiveCommuntSignUpViewController * signUpView = [[CNLiveCommuntSignUpViewController alloc] initWithStyle:UITableViewStyleGrouped ActivityId:@"52"];
        [self.navigationController pushViewController:signUpView animated:YES];
    }
    if (indexPath.row == 6) {
        NSString * cmnt_id = [[NSUserDefaults standardUserDefaults] objectForKey:@"cmnt_id"];
        if ([cmnt_id isNotBlank]) {
            CNLiveCommuntyOrderViewController * orderVC = [[CNLiveCommuntyOrderViewController alloc] initWithMaintenId:cmnt_id];
            [self.navigationController pushViewController:orderVC animated:YES];
        }

    }
    if (indexPath.row == 7) {
        CNLiveCommuntyResultListViewController * orderVC = [[CNLiveCommuntyResultListViewController alloc] initWithStyle:UITableViewStyleGrouped SignId:@"48" OrderId:@"" handworkId:@"52"];
        [self.navigationController pushViewController:orderVC animated:YES];
    }
//    if (indexPath.row == 8) {
//        CNLiveCommuntyOrderViewController * orderVC = [[CNLiveCommuntyOrderViewController alloc] initWithShowType:CNLiveCommuntyOrderShowTypeChatCompletOrder MaintenId:@"cmnt2022021166936098185"];
//        [self.navigationController pushViewController:orderVC animated:YES];
//    }
    if (indexPath.row == 8) {
        [CNUserInfoManager manager].userInfoModel.uid = self.isChange ? @"11973842" : @"145680";
        [self.dataArray replaceObjectAtIndex:8 withObject:self.isChange ? @"11973842" : @"145680"];
        self.isChange = !self.isChange;
        NSMutableDictionary * mDict = [[NSMutableDictionary alloc] init];
        [mDict setValue:[CNUserInfoManager manager].userInfoModel.uid forKey:@"loginSid"];
        [mDict setValue:@"com.cnlive.CNLiveNetAdd.debug" forKey:@"platform_id"];
        [mDict setValue:[[[[UIDevice currentDevice] identifierForVendor] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""] forKey:@"uuid"];
        [mDict setValue:@"i" forKey:@"plat"];
        [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"];
        [mDict setObject:AppId forKey:@"appId"];
        [mDict setObject:[CNUserInfoManager manager].userInfoModel.uid forKey:@"sid"];
        [CNLiveNetworking setupDefaultParam:mDict];
        [CNLiveNetworking setupShowResult:NO];
        [CNLiveNetworking setupSignKey:APPKey];
        [CNLiveNetworking setAllowRequestDefaultArgument:YES];
        [CNLiveNetworking setResponseSerializerType:CNLiveResponseSerializerJSON];
        [self.tableView reloadData];
//        CNLiveCommuntyOrderViewController * orderVC = [[CNLiveCommuntyOrderViewController alloc] initWithShowType:CNLiveCommuntyOrderShowTypeHave MaintenId:@"cmnt2022021166936098185"];
//        [self.navigationController pushViewController:orderVC animated:YES];
    }
    if (indexPath.row == 10) {
        CNLiveCommuntyHomeListViewController * listVC = [[CNLiveCommuntyHomeListViewController alloc] init];
        [self.navigationController pushViewController:listVC animated:YES];
    }
    if (indexPath.row == 11) {
        [[CNLiveCommuntyModule shareInstance] pushCommuntyHomeViewMethod];
    }
}

-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.tableFooterView =[[UIView alloc] init];
        _tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
        [_tableView registerClass:UITableViewCell.class forCellReuseIdentifier:NSStringFromClass(UITableViewCell.class)];
    }
    return _tableView;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end