123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- //
- // TerminalListVC.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/8/3.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "TerminalListVC.h"
- #import "TerminalListCell.h"
- #import "TerminalListCell2.h"
- #import "SportPathVC.h"
- #import "Ter_SendMsg.h"
- @interface TerminalListVC ()<UITableViewDataSource,UITableViewDelegate>
- @property(nonatomic,strong)UITableView *tableView;
- @end
- @implementation TerminalListVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"终端列表";
- [self goBackByNavigation];
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet) style:UITableViewStyleGrouped];
- _tableView.dataSource = self;
- _tableView.delegate = self;
- [self.view addSubview:_tableView];
- _tableView.backgroundColor = KBackGroundColor;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
-
- }
- #pragma mark tableview代理
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
-
- return self.dataArr.count;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return 1;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
-
- return 15;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
-
- return .1f;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *str = _dataArr[indexPath.section][@"TDI_TERMTYPE"];
- if ([str isEqualToString:@"1"]) {
- return 108;
- }else{
- return 70;
- }
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSString *str = _dataArr[indexPath.section][@"TDI_TERMTYPE"];
- if ([str isEqualToString:@"1"]) {//计时终端类型(1:车载计程计时终端; 2:课堂教学计时终端; 3:模拟训练计时终端;)
- TerminalListCell *cell = [TerminalListCell cellForTableView:tableView];
- cell.dic = _dataArr[indexPath.section];
- NSString *sim = [NSString stringWithFormat:@"%@",_dataArr[indexPath.section][@"TDI_SIM"]];
- cell.clickBlock = ^(NSNumber *type) {
- switch ([type integerValue]) {
- case 1:
- {
- [Tools permissionValidationWithID:@"92" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- showMsgByAlert(self, failureStr);
- }
- return;
-
- }
- SportPathVC *vc = [[SportPathVC alloc]init];
- vc.carNum = _dataArr[indexPath.section][@"TCO_LICNUM"];
- vc.simStr = sim;
- vc.deviceId = _dataArr[indexPath.section][@"TDI_ID"];
- [self navPushHideTabbarToVC:vc];
-
- }];
- }
- break;
- case 2:
- {
- [Tools permissionValidationWithID:@"1263" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- showMsgByAlert(self, failureStr);
- }
- return;
-
- }
-
- Ter_SendMsg *vc = [[Ter_SendMsg alloc]init];
- vc.sim = sim;
- [self navPushHideTabbarToVC:vc];
-
- }];
- }
- break;
- case 3:
- {
- [Tools permissionValidationWithID:@"1265" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- showMsgByAlert(self, failureStr);
- }
- return;
-
- }
-
- [self removeMacWarningWithSim:sim];
-
- }];
-
- }
- break;
- case 4:
- {
- [Tools permissionValidationWithID:@"2037" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- showMsgByAlert(self, failureStr);
- }
- return;
-
- }
- [self captureVideoWithSim:sim];
-
- }];
- }
- break;
- case 5:
- {
- if (self.block) {
- self.block([NSString stringWithFormat:@"%d",(int)indexPath.section]);
- }
- [self.navigationController popViewControllerAnimated:YES];
- }
- break;
-
- default:
- break;
- }
- };
- return cell;
- }
-
- TerminalListCell2 *cell = [TerminalListCell2 cellForTableView:tableView];
- cell.dic = _dataArr[indexPath.section];
- return cell;
- }
- #pragma mark - 网络请求
- -(void)captureVideoWithSim:(NSString *)simStr{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:simStr forKey:@"sim"];
-
- NSString *method = @"captureVideo";
- [MBProgressHUD showLoadToView:self.view];
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- ShowMsg(@"解除失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- ShowMsg(@"操作成功");
- }];
- }
- -(void)removeMacWarningWithSim:(NSString *)simStr{
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:@"" forKey:@"schoolId"];//这里要求传空,报警删除全部
- // [dic setObject:@"" forKey:@"mwId"];
- // [dic setObject:@"" forKey:@"kind"];
- [dic setObject:simStr forKey:@"sim"];
- NSString *method = @"removeMacWarning";
- [MBProgressHUD showLoadToView:self.view];
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- ShowMsg(@"解除失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
- ShowMsg(@"操作成功");
- }];
- }
- - (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
|