123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- //
- // JXSheBenListVc.m
- // shiku_im
- //
- // Created by 123 on 2020/5/26.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXSheBenListVc.h"
- #import "JXSheBeiCell.h"
- @interface JXSheBenListVc ()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
- @property (nonatomic,weak) UITableView *tableVIew;
- @property (nonatomic,strong) NSMutableArray *dataArr;
- @property (nonatomic,weak) UIView *titelView;
- @property (nonatomic,strong) MJRefreshHeaderView *header;
- @property (nonatomic,strong) NSIndexPath *RecordindexPath;
- @end
- @implementation JXSheBenListVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- [self defineNavBar:@"登陆设备管理" andRinghtBtnImg:@""];
- _dataArr=[NSMutableArray array];
- UIView *titelView=[[UIView alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_TOP+5)];
- titelView.backgroundColor=kRGBColor246;
-
-
- NSMutableAttributedString *hintString2=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"最近登录设备:你可以删除列表中的设备,删除后在该 设备登录微信需要进行身份验证"]];
- // NSRange range2=[[hintString2 string]rangeOfString:@"];
- // [hintString2 addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:range2];
- // [hintString2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12 weight:UIFontWeightSemibold] range:range2];
-
- UILabel *titleB=[[UILabel alloc]initWithFrame:CGRectMake(10, 8, JX_SCREEN_WIDTH-20, 60)];
- titleB.attributedText=hintString2;
-
- titleB.numberOfLines=0;
- [titelView addSubview:titleB];
- [self.view addSubview:titelView];
- self.titelView=titelView;
- _dataArr=[NSMutableArray array];
- [self createTableViewUI];
- // 加载最新数据
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- [SVProgressHUD show];
- [g_server getUserGetAllPhoneDeviceInformation:salt userID:g_server.myself.userId andToView:self];
-
-
- _header = [MJRefreshHeaderView header];
- _header.pullShowStr=@"刷新设备";
- _header.scrollView = self.tableVIew;
-
- __weak typeof(self) weakSelf = self;
- _header.beginRefreshingBlock = ^(MJRefreshBaseView *refreshView) {
- // 进入刷新状态就会回调这个Block
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- [SVProgressHUD show];
- [g_server getUserGetAllPhoneDeviceInformation:salt userID:g_server.myself.userId andToView:weakSelf];
-
- };
- _header.endStateChangeBlock = ^(MJRefreshBaseView *refreshView) {
- // 刷新完毕就会回调这个Block
- // NSLog(@"%@----刷新完毕", refreshView.class);
- };
- _header.refreshStateChangeBlock = ^(MJRefreshBaseView *refreshView, MJRefreshState state) {
- // 控件的刷新状态切换了就会调用这个block
- switch (state) {
- case MJRefreshStateNormal:
- // NSLog(@"%@----切换到:普通状态", refreshView.class);
- break;
-
- case MJRefreshStatePulling:
- // NSLog(@"%@----切换到:松开即可刷新的状态", refreshView.class);
- {
-
- }
- break;
-
- case MJRefreshStateRefreshing:
- // NSLog(@"%@----切换到:正在刷新状态", refreshView.class);
- break;
- default:
- break;
- }
- };
-
- }
- - (void)createTableViewUI{
-
- UITableView *tableVIew=[[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_titelView.frame), JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP-JX_SCREEN_TOP-5)];
- tableVIew.delegate=self;
- tableVIew.dataSource=self;
- [self.view addSubview:tableVIew];
- self.tableVIew=tableVIew;
- //tableVIew.separatorStyle=UITableViewCellSeparatorStyleNone;
- tableVIew.tableFooterView=[UIView new];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 74;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _dataArr.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- JXSheBeiCell *cell=[JXSheBeiCell cellWithTableView:tableView];
- shebeiModel *model=_dataArr[indexPath.row];
-
- cell.Model=model;
-
- cell.block = ^(UIButton *sender) {
-
- _RecordindexPath=indexPath;
-
- UIAlertView *aletShow=[[UIAlertView alloc]initWithTitle:@"提示" message:@"确认删除改设备?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
- [aletShow show];
-
- };
- return cell;
-
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
-
-
- shebeiModel *model=_dataArr[_RecordindexPath.row];
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
- [g_server getUserDeleteAllPhoneDeviceInformation:salt userID:g_server.myself.userId deviceName:model.deviceIMSI andToView:self];
-
- [_dataArr removeObjectAtIndex:_RecordindexPath.row];
- //错误的写法:
- NSIndexPath* path =[NSIndexPath indexPathForRow:_RecordindexPath.row inSection:0];
- NSMutableArray* deleteArray=[NSMutableArray arrayWithObject:path];
- [_tableVIew deleteRowsAtIndexPaths:deleteArray withRowAnimation:UITableViewRowAnimationFade];
- }
- //- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
- //
- //
- //
- //// NSIndexPath *indexPathxx =[NSIndexPath indexPathForRow:indexPath.row inSection:0];
- //// [_dataArr removeObjectAtIndex:indexPath.row];
- //// [tableView deleteRowsAtIndexPaths:@[indexPathxx] withRowAnimation:UITableViewRowAnimationFade];
- ////
- //}
- #pragma mark --- 请求成功
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [SVProgressHUD dismiss];
- [_header endRefreshing];
- // NSLog(@"dict: %@ --- arry: %@",dict ,array1 );
- if([aDownload.action isEqualToString:act_userdeviceLogdeleteDeviceLog])
- {
- // _dataArr=[shebeiModel mj_objectArrayWithKeyValuesArray:array1];
- }
- else if([aDownload.action isEqualToString:act_userdeviceLogGetAllDeviceLog])
- {
-
- _dataArr=[shebeiModel mj_objectArrayWithKeyValuesArray:array1];
- [_tableVIew reloadData];
- }
-
-
- }
-
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- [SVProgressHUD dismiss];
- [_header endRefreshing];
- NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
- if([errorCode isEqualToString:@"权限验证失败"])
- {
-
- }
-
- return [errorCode intValue];
- }
- @end
|