ClassDetailVC.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. //
  2. // ClassDetailVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/12/13.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "ClassDetailVC.h"
  9. #import "LocServiceVC.h"
  10. @interface ClassDetailVC ()
  11. @end
  12. @implementation ClassDetailVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.navigationItem.title = @"理论教室详情";
  16. [self setSegmentControllWithTitles:@[@"基本信息"] isBttomBar:NO];
  17. [Tools permissionValidationWithID:@"1246" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  18. if (isCan) {
  19. [self createBottomBarWithtoolTitles:@[@"重置教室位置"]];
  20. }
  21. }];
  22. }
  23. -(void)setData{
  24. self.headImgStr = self.dataSource[@"EI_PHOTO_PATH"];
  25. _keysArr = @[
  26. @[@"所属机构",@"JXMC"],
  27. @[@"教室名称",@"TR_NAME"],
  28. @[@"最大人数(个)",@"TR_STUNUM"],
  29. @[@"教室地址",@"TR_ADDRESS"],
  30. @[@"开课时间",@"TR_STARTTIME"],
  31. @[@"下课时间",@"TR_ENDTIME"],
  32. @[@"教室类型",@"TR_TYPE"],
  33. @[@"教室面积(m2)",@"TR_AREA"]
  34. ];
  35. [super setData];
  36. }
  37. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  38. //这里返回的cell是第一个tableview的。下面对于key的判定isequal和contains的区别在于 一个是独有,一个是共有
  39. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  40. if (!cell) {
  41. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  42. }
  43. NSString * key = _keysArr[indexPath.row][1];
  44. cell.textLabel.text = _keysArr[indexPath.row][0];
  45. if ([key isEqualToString:@"TR_TYPE"]){
  46. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  47. switch ([status integerValue]) {
  48. case 1:
  49. cell.detailTextLabel.text = @"多媒体理论教室";
  50. break;
  51. case 2:
  52. cell.detailTextLabel.text = @"模拟器教室";
  53. break;
  54. case 3:
  55. cell.detailTextLabel.text = @"通用";
  56. break;
  57. case 4:
  58. cell.detailTextLabel.text = @"教具教室";
  59. break;
  60. default:
  61. break;
  62. }
  63. }else{
  64. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
  65. }
  66. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  67. cell.detailTextLabel.numberOfLines = 0;
  68. cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
  69. }else{
  70. cell.detailTextLabel.numberOfLines = 1;
  71. cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
  72. }
  73. return cell;
  74. }
  75. #pragma mark 创建BottomBarButton
  76. -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
  77. float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
  78. float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
  79. for (int i=0; i<toolTitles.count; i++) {
  80. UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
  81. button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-kNavOffSet-SafeAreaBottomHeight, widthBtn, HeightBth);
  82. [button setTitle:toolTitles[i] forState:UIControlStateNormal];
  83. UIColor * color = defGreen;
  84. button.backgroundColor = color;
  85. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  86. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  87. button.tag = 100+i;
  88. [self.view addSubview:button];
  89. }
  90. }
  91. -(void)btnClick:(UIButton *)sender{
  92. //定位
  93. LocServiceVC *vc = [[LocServiceVC alloc]init];
  94. vc.block = ^(double lng, double lat) {
  95. [self upDateAddressWithLng:lng lat:lat];
  96. };
  97. [self navPushHideTabbarToVC:vc];
  98. }
  99. -(void)upDateAddressWithLng:(CGFloat)lng lat:(CGFloat)lat{
  100. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  101. [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
  102. [dic setObject:self.dataSource[@"TR_ID"] forKey:@"id"];
  103. [dic setObject:[NSString stringWithFormat:@"%f",lng] forKey:@"trLng"];
  104. [dic setObject:[NSString stringWithFormat:@"%f",lat] forKey:@"trLat"];
  105. NSString *method = @"updateTheoryRoom";
  106. [MBProgressHUD showLoadToView:self.view];
  107. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  108. [MBProgressHUD hideHUDForView:self.view];
  109. if (!root) {
  110. [self showMsgByAlertVCWithString:@"位置上传失败,请重试"];
  111. return;
  112. }
  113. [self showMsgByAlertVCWithString:root[@"msg"]];
  114. }];
  115. }
  116. #pragma mark 弹出框提示
  117. - (void)showMsgByAlertVCWithString:(NSString *)str{
  118. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
  119. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
  120. [self presentViewController:alertFind animated:true completion:nil];
  121. }
  122. - (void)didReceiveMemoryWarning {
  123. [super didReceiveMemoryWarning];
  124. // Dispose of any resources that can be recreated.
  125. }
  126. /*
  127. #pragma mark - Navigation
  128. // In a storyboard-based application, you will often want to do a little preparation before navigation
  129. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  130. // Get the new view controller using [segue destinationViewController].
  131. // Pass the selected object to the new view controller.
  132. }
  133. */
  134. @end