SOPViewController.m 12.7 KB
Newer Older
admin's avatar
admin committed
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
//
//  SOPViewController.m
//  redstar
//
//  Created by admin on 15/12/25.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "SOPViewController.h"
#import "GroupTabBar.h"
#import "GroupItems.h"
#import "SOPTableView.h"
#import "HttpClient.h"

#define SELECTED_VIEW_CONTROLLER_TAG 39998

@interface SOPViewController () <GroupTabBarDelegate, SOPTableViewDelegate>
@property (nonatomic, strong) GroupTabBar *groupTabBar;

@property (nonatomic, strong) NSArray *titleArray;

@property (nonatomic, strong) NSArray *titleArray1;
@property (nonatomic, strong) NSArray *titleArray2;
@property (nonatomic, strong) NSArray *titleArray3;
@property (nonatomic, strong) NSArray *titleArray4;
@property (nonatomic, strong) NSArray *titleArray5;
@property (nonatomic, strong) NSArray *titleArray6;
@property (nonatomic, strong) NSArray *titleArray7;
@property (nonatomic, strong) NSArray *titleArray8;

@property (nonatomic, strong) NSString *detailTitle;

@property (nonatomic, strong) UIButton *resetBtn;
@property (nonatomic, strong) UIButton *queryBtn;


@end

@implementation SOPViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
        self.navigationController.navigationBar.translucent = NO;
    }
    
    self.titleArray = [NSArray arrayWithObjects:@"质量管理",@"价格管理",@"现场服务",@"售后服务",@"环境管理",@"现场管理", @"400呼叫管理",@"单品管理",nil];

    
    self.titleArray1 = [NSArray arrayWithObjects:@"商品环保、质量检测管理规定",@"商品资质管理规定",@"三年质保管理规定",@"商品绿色展陈管理规定",@"  附件:绿色展陈操作手册", nil];
    self.titleArray2 = [NSArray arrayWithObjects:@"商品标价签管理规定",@"商品调价管理规定",@"商场全国大促活动执行管理规定",@"商户促销活动管理规定",@"“全场最低七折”管理规定", nil];
    self.titleArray3 = [NSArray arrayWithObjects:@"商场现场服务基本规定",@"便民服务管理规定",@"营业员管理规定",@"播音管理规定",@"商场实施管理者“顾客之声VOC”管理规定", @"30天无理由退货管理规定",@"15分钟退单管理规定",@"商场全员顾客服务规范管理规定",@"  附件:停车场安全员岗位车辆指挥标准手势手册",@"设计免费咨询管理规定",nil];
    self.titleArray4 = [NSArray arrayWithObjects:@"商场客诉处理管理规定",@"先行赔付管理规定",@"商品质量保证金管理规定",@"送货跟单回访管理规定", nil];
    self.titleArray5 = [NSArray arrayWithObjects:@"商场基础环境管理规定",@"口碑商场环境管理规定",@"  附件:室内地面维修养护规范",@"  附件:商户装修“五区管理法”规定",@"  附件:喷水池管理规范", @"商场停车场管理规定",@"商场洗手间管理规范",@"商场综合物料管理规定",nil];
    self.titleArray6 = [NSArray arrayWithObjects:@"楼层日常巡场管理规定",@"商户进/出货管理规定",@"商户进场管理规定",@"商户撤场管理规定",@"商户信用等级评定管理规定", nil];
    self.titleArray7 = [NSArray arrayWithObjects:@"呼叫中心商场虚拟座席远程管理规定", nil];
    self.titleArray8 = [NSArray arrayWithObjects:@"商品信息管理规定", nil];

    [self setupNav];
    
    [self setGroupBar];
    
    [self.resetBtn addTarget:self action:@selector(resetClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.queryBtn addTarget:self action:@selector(queryClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)resetClick:(UIButton *)sender
{
    
}

- (void)queryClick:(UIButton *)sender
{
    NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kGetAttachmentsURL];
    HttpClient *http = [[HttpClient alloc] initWithUrl:url];
    NSDictionary *parameters = @{@"type":@"sop",
admin's avatar
admin committed
82 83 84 85
//                                 @"category1":_titleArray[_groupTabBar.selectNumber],
//                                 @"category2":_detailTitle
                                 @"category1":@"11",
                                 @"category2":@"22"
admin's avatar
admin committed
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
                                 };
    [http getAttachmentsWithParameters:parameters completion:^(id response, NSError *error) {
        NSLog(@"7.1 口碑标注附件列表 = %@, error = %@", response, error);
    }];
}

- (void)setupNav
{
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
    [customLab setTextColor:[UIColor whiteColor]];
    [customLab setText:@"SOP分类查询"];
    customLab.font = [UIFont boldSystemFontOfSize:19];
    self.navigationItem.titleView = customLab;
    
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 30, 44);
    
    [backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = backItem;
}

- (void)setGroupBar
{
    self.groupTabBar = [[GroupTabBar alloc] initWithFrame:CGRectMake(0, 0, 120, kScreenHeight - 64 - 60)];
    _groupTabBar.delegate = self;
    [self.view addSubview:_groupTabBar];
    
    NSInteger selectedIndex = 0;
    NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
    
    SOPTableView *tableView1 = [[SOPTableView alloc] initWithTitleArray:_titleArray1];
    tableView1.sop_delegate = self;
    GroupItems *tableItem1 = [[GroupItems alloc] initWithTitle:_titleArray[0] view:tableView1];
    
    SOPTableView *tableView2 = [[SOPTableView alloc] initWithTitleArray:_titleArray2];
    tableView2.sop_delegate = self;
    GroupItems *tableItem2 = [[GroupItems alloc] initWithTitle:_titleArray[1] view:tableView2];
    
    SOPTableView *tableView3 = [[SOPTableView alloc] initWithTitleArray:_titleArray3];
    tableView3.sop_delegate = self;
    GroupItems *tableItem3 = [[GroupItems alloc] initWithTitle:_titleArray[2] view:tableView3];
    
    SOPTableView *tableView4 = [[SOPTableView alloc] initWithTitleArray:_titleArray4];
    tableView4.sop_delegate = self;
    GroupItems *tableItem4 = [[GroupItems alloc] initWithTitle:_titleArray[3] view:tableView4];
    
    SOPTableView *tableView5 = [[SOPTableView alloc] initWithTitleArray:_titleArray5];
    tableView5.sop_delegate = self;
    GroupItems *tableItem5 = [[GroupItems alloc] initWithTitle:_titleArray[4] view:tableView5];
    
    SOPTableView *tableView6 = [[SOPTableView alloc] initWithTitleArray:_titleArray6];
    tableView6.sop_delegate = self;
    GroupItems *tableItem6 = [[GroupItems alloc] initWithTitle:_titleArray[5] view:tableView6];
    
    SOPTableView *tableView7 = [[SOPTableView alloc] initWithTitleArray:_titleArray7];
    tableView7.sop_delegate = self;
    GroupItems *tableItem7 = [[GroupItems alloc] initWithTitle:_titleArray[6] view:tableView7];
    
    SOPTableView *tableView8 = [[SOPTableView alloc] initWithTitleArray:_titleArray8];
    tableView8.sop_delegate = self;
    GroupItems *tableItem8 = [[GroupItems alloc] initWithTitle:_titleArray[7] view:tableView8];
    
    [tableView1 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView2 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView3 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView4 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView5 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView6 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView7 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView8 selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    
    [self.view insertSubview:tableView1 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView2 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView3 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView4 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView5 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView6 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView7 belowSubview:_groupTabBar];
    [self.view insertSubview:tableView8 belowSubview:_groupTabBar];
    
    _groupTabBar.items = @[tableItem1, tableItem2, tableItem3, tableItem4, tableItem5, tableItem6, tableItem7, tableItem8];
    [_groupTabBar showIndex:0];


}

-(void)doBack:(id)sender
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}


#pragma mark - SOPTableViewDelegate
- (void)selectRowWithDetailTitle:(NSString *)detailTitle
{
    _detailTitle = detailTitle;
}

#pragma mark - GroupTabBarDelegate
- (void)switchView:(UIView *)view
{
    UIView *currentView = [self.view viewWithTag:SELECTED_VIEW_CONTROLLER_TAG];
    [currentView removeFromSuperview];
    currentView = nil;
    
    view.frame = CGRectMake(self.groupTabBar.frame.size.width,0,kScreenWidth - self.groupTabBar.frame.size.width, self.groupTabBar.size.height);
    
    view.tag = SELECTED_VIEW_CONTROLLER_TAG;
    
    [self.view insertSubview:view belowSubview:_groupTabBar];
    
}

#pragma mark - lazy loading
- (UIButton *)resetBtn
{
    if (!_resetBtn) {
        _resetBtn = [[UIButton alloc] init];
        _resetBtn.backgroundColor = [UIColor grayColor];
        _resetBtn.translatesAutoresizingMaskIntoConstraints = NO;
        [_resetBtn setTitle:@"重置" forState:UIControlStateNormal];
        _resetBtn.layer.cornerRadius = 4.0;
        [self.view addSubview:_resetBtn];
        
        NSLayoutConstraint *lineViewHeight = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:45];
        [self.view addConstraint:lineViewHeight];
        
        NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-10];
        [self.view addConstraint:lineViewRight];
        
        NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-7.5];
        [self.view addConstraint:lineViewBottom];
        
        NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.view addConstraint:lineViewLeft];
    }
    return _resetBtn;
}

- (UIButton *)queryBtn
{
    if (!_queryBtn) {
        _queryBtn = [[UIButton alloc] init];
        _queryBtn.backgroundColor = kNavigationBarColor;
        _queryBtn.translatesAutoresizingMaskIntoConstraints = NO;
        [_queryBtn setTitle:@"查看附件" forState:UIControlStateNormal];
        _queryBtn.layer.cornerRadius = 4.0;
        [self.view addSubview:_queryBtn];
        
        NSLayoutConstraint *lineViewHeight = [NSLayoutConstraint constraintWithItem:_queryBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:45];
        [self.view addConstraint:lineViewHeight];
        
        NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_queryBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.view addConstraint:lineViewRight];
        
        NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_queryBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-7.5];
        [self.view addConstraint:lineViewBottom];
        
        NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_queryBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:10];
        [self.view addConstraint:lineViewLeft];
    }
    return _queryBtn;
}


@end