123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // ClassDetailVC.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/12/13.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "ClassDetailVC.h"
- #import "LocServiceVC.h"
- @interface ClassDetailVC ()
- @end
- @implementation ClassDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"理论教室详情";
- [self setSegmentControllWithTitles:@[@"基本信息"] isBttomBar:NO];
-
- [Tools permissionValidationWithID:@"1246" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- if (isCan) {
- [self createBottomBarWithtoolTitles:@[@"重置教室位置"]];
- }
- }];
- }
- -(void)setData{
- self.headImgStr = self.dataSource[@"EI_PHOTO_PATH"];
- _keysArr = @[
- @[@"所属机构",@"JXMC"],
- @[@"教室名称",@"TR_NAME"],
- @[@"最大人数(个)",@"TR_STUNUM"],
- @[@"教室地址",@"TR_ADDRESS"],
- @[@"开课时间",@"TR_STARTTIME"],
- @[@"下课时间",@"TR_ENDTIME"],
- @[@"教室类型",@"TR_TYPE"],
- @[@"教室面积(m2)",@"TR_AREA"]
- ];
-
- [super setData];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- //这里返回的cell是第一个tableview的。下面对于key的判定isequal和contains的区别在于 一个是独有,一个是共有
-
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
- }
-
-
- NSString * key = _keysArr[indexPath.row][1];
- cell.textLabel.text = _keysArr[indexPath.row][0];
- if ([key isEqualToString:@"TR_TYPE"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
- switch ([status integerValue]) {
- case 1:
- cell.detailTextLabel.text = @"多媒体理论教室";
- break;
- case 2:
- cell.detailTextLabel.text = @"模拟器教室";
- break;
- case 3:
- cell.detailTextLabel.text = @"通用";
- break;
- case 4:
- cell.detailTextLabel.text = @"教具教室";
- break;
- default:
- break;
- }
- }else{
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
- }
-
- if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
- cell.detailTextLabel.numberOfLines = 0;
- cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
-
- }else{
- cell.detailTextLabel.numberOfLines = 1;
- cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
- }
-
- return cell;
- }
- #pragma mark 创建BottomBarButton
- -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
-
- float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
- float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
- for (int i=0; i<toolTitles.count; i++) {
- UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
- button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-kNavOffSet-SafeAreaBottomHeight, widthBtn, HeightBth);
- [button setTitle:toolTitles[i] forState:UIControlStateNormal];
- UIColor * color = defGreen;
- button.backgroundColor = color;
- [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- button.tag = 100+i;
-
- [self.view addSubview:button];
- }
- }
- -(void)btnClick:(UIButton *)sender{
-
- //定位
- LocServiceVC *vc = [[LocServiceVC alloc]init];
- vc.block = ^(double lng, double lat) {
- [self upDateAddressWithLng:lng lat:lat];
- };
- [self navPushHideTabbarToVC:vc];
- }
- -(void)upDateAddressWithLng:(CGFloat)lng lat:(CGFloat)lat{
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
- [dic setObject:self.dataSource[@"TR_ID"] forKey:@"id"];
- [dic setObject:[NSString stringWithFormat:@"%f",lng] forKey:@"trLng"];
- [dic setObject:[NSString stringWithFormat:@"%f",lat] forKey:@"trLat"];
-
- NSString *method = @"updateTheoryRoom";
-
- [MBProgressHUD showLoadToView:self.view];
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- [self showMsgByAlertVCWithString:@"位置上传失败,请重试"];
- return;
- }
- [self showMsgByAlertVCWithString:root[@"msg"]];
- }];
- }
- #pragma mark 弹出框提示
- - (void)showMsgByAlertVCWithString:(NSString *)str{
-
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:alertFind animated:true completion:nil];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|