|
|
@@ -12,8 +12,9 @@
|
|
|
#import "YRMineCell.h"
|
|
|
#import "YRWebVC.h"
|
|
|
#import "NSString+secri.h"
|
|
|
+#import "YRLoginManager.h"
|
|
|
|
|
|
-@interface YRMineVC ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
+@interface YRMineVC ()<UITableViewDelegate,UITableViewDataSource,UIPopoverListViewDelegate,UIPopoverListViewDataSource>
|
|
|
|
|
|
@property(strong,nonatomic)YRTableView *tableView;
|
|
|
|
|
|
@@ -26,11 +27,8 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#pragma mark --- 服务器获取配置
|
|
|
-(void)getDataFromServer
|
|
|
{
|
|
|
@@ -55,7 +53,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}];
|
|
|
|
|
|
call.requestHeaders[@"authentication"] = [YRUserInfo shareManager].token;
|
|
|
@@ -111,17 +108,29 @@
|
|
|
|
|
|
if (model.viewType == 0) {//原生
|
|
|
|
|
|
- YRBaseVC *VC = (YRBaseVC *)[[NSClassFromString(model.desVC) alloc]init];
|
|
|
+ if ([model.iosWidget isEqualToString:@"company"]) {
|
|
|
+ /**
|
|
|
+ 切换公司
|
|
|
+ */
|
|
|
+ [self selectCompanyToChange];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- if (!VC) {//出现异常
|
|
|
+ else{
|
|
|
+ YRBaseVC *VC = (YRBaseVC *)[[NSClassFromString(model.desVC) alloc]init];
|
|
|
+
|
|
|
+ if (!VC) {//出现异常
|
|
|
+
|
|
|
+ VC = [YRBaseVC new];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- VC = [YRBaseVC new];
|
|
|
+ VC.title = model.name;
|
|
|
|
|
|
+ [self.navigationController pushViewController:VC animated:YES];
|
|
|
}
|
|
|
|
|
|
- VC.title = model.name;
|
|
|
|
|
|
- [self.navigationController pushViewController:VC animated:YES];
|
|
|
|
|
|
}else{//网页
|
|
|
|
|
|
@@ -218,6 +227,90 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark --- 切换公司
|
|
|
+-(void)selectCompanyToChange
|
|
|
+{
|
|
|
+ CGFloat xWidth = self.view.bounds.size.width - 33;
|
|
|
+ CGFloat yHeight = 300.0f;
|
|
|
+ CGFloat yOffset = (self.view.bounds.size.height - yHeight)/2.0f;
|
|
|
+ UIPopoverListView *companyPopList = [[UIPopoverListView alloc] initWithFrame:CGRectMake(10, yOffset, xWidth, yHeight) isDateView:NO];
|
|
|
+ companyPopList.isCannotClickBackGround = YES;
|
|
|
+ companyPopList.delegate = self;
|
|
|
+ companyPopList.datasource = self;
|
|
|
+ [companyPopList setTitle:@"公司"];
|
|
|
+ [companyPopList show];
|
|
|
+}
|
|
|
+
|
|
|
+- (UITableViewCell *)popoverListView:(UIPopoverListView *)popoverListView
|
|
|
+ cellForIndexPath:(NSIndexPath *)indexPath
|
|
|
+{
|
|
|
+ static NSString *identifier = @"cell";
|
|
|
+
|
|
|
+ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
|
|
|
+ reuseIdentifier:identifier];
|
|
|
+
|
|
|
+ NSArray *companyArr = [[YRUserInfo shareManager].userInfo objectForKey:@"companyArray"];
|
|
|
+
|
|
|
+ NSDictionary *companyDic = [companyArr objectAtIndex:indexPath.row];
|
|
|
+
|
|
|
+ cell.textLabel.text = [companyDic objectForKey:@"name"];
|
|
|
+
|
|
|
+ cell.textLabel.font = FONT_SIZE(13);
|
|
|
+
|
|
|
+ return cell;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSInteger)popoverListView:(UIPopoverListView *)popoverListView
|
|
|
+ numberOfRowsInSection:(NSInteger)section
|
|
|
+{
|
|
|
+ NSArray *companyArr = [[YRUserInfo shareManager].userInfo objectForKey:@"companyArray"];
|
|
|
+
|
|
|
+ return [companyArr count];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)popoverListView:(UIPopoverListView *)popoverListView
|
|
|
+ didSelectIndexPath:(NSIndexPath *)indexPath
|
|
|
+{
|
|
|
+ NSArray *companyArr = [[YRUserInfo shareManager].userInfo objectForKey:@"companyArray"];
|
|
|
+
|
|
|
+ NSDictionary *companyDic = [companyArr objectAtIndex:indexPath.row];
|
|
|
+
|
|
|
+ [self loginCompanyAction:companyDic];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (NSInteger)numberOfSectionsInUIPopoverListView:(UIPopoverListView *)tableView
|
|
|
+{
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSString *)popoverListView:(UIPopoverListView *)popoverListView titleForHeaderInSection:(NSInteger)section {
|
|
|
+ return nil;
|
|
|
+}
|
|
|
+
|
|
|
+- (CGFloat)popoverListView:(UIPopoverListView *)popoverListView
|
|
|
+ heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
+{
|
|
|
+ return 30.0f;
|
|
|
+}
|
|
|
+
|
|
|
+-(void)loginCompanyAction:(NSDictionary *)dic
|
|
|
+{
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
+
|
|
|
+ [YRLoginManager companyLoginWithCompanyInfo:dic success:^(SwitchCompanyResponse * _Nullable response) {
|
|
|
+
|
|
|
+ [MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
+
|
|
|
+ [self.tableView reloadData];
|
|
|
+
|
|
|
+ } failure:^(SwitchCompanyResponse * _Nullable response, NSError * _Nullable error) {
|
|
|
+
|
|
|
+ //提示错误信息
|
|
|
+ [YRShowMessageFromNavi showDropViewWithMessage:response.responseHeader.message ToNavi:self.navigationController withColor:nil];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark --- 设置页面
|
|
|
-(void)setUpUI
|
|
|
{
|
|
|
@@ -240,6 +333,19 @@
|
|
|
|
|
|
}else{
|
|
|
|
|
|
+ NSDictionary *dic = @{
|
|
|
+ @"androidWidget":@"",
|
|
|
+ @"androidWidget":@"",
|
|
|
+ @"icon":@"icon_setting",
|
|
|
+ @"id_p":@2,
|
|
|
+ @"initialized" : @2,
|
|
|
+ @"iosWidget" : @"company",
|
|
|
+ @"name" : @"公司",
|
|
|
+ @"viewType" : @0,
|
|
|
+ @"webURL" : @"",
|
|
|
+ };
|
|
|
+ [self.dataArr addObject:[YRMineModel mj_objectWithKeyValues:dic]];
|
|
|
+
|
|
|
for (id obj in homeConfigArr) {
|
|
|
|
|
|
[self.dataArr addObject:[YRMineModel mj_objectWithKeyValues:obj]];
|