You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
7.2 KiB
179 lines
7.2 KiB
![]()
2 years ago
|
//
|
||
|
// LocationModeViewController.m
|
||
|
// watch
|
||
|
//
|
||
|
// Created by xTT on 2017/7/17.
|
||
|
// Copyright © 2017年 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "LocationModeViewController.h"
|
||
|
|
||
|
@interface LocationModeViewController ()
|
||
|
|
||
|
@property (nonatomic ,strong) NSArray *timeArr;
|
||
|
|
||
|
@property (nonatomic ,strong) UIView *headerView;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation LocationModeViewController
|
||
|
|
||
|
@synthesize myDataSource = _myDataSource;
|
||
|
|
||
|
- (NSMutableArray *)myDataSource{
|
||
|
if (!_myDataSource) {
|
||
|
//_myDataSource = [[NSMutableArray alloc] initWithArray:@[@[@"省电模式",@"正常模式",@"高频模式"]]];
|
||
|
// MARK: 从后台获取值显示 update by lsz 2021-06-23
|
||
|
_myDataSource = [[NSMutableArray alloc] initWithArray:@[@[cUser.cDevice.location_model1,cUser.cDevice.location_model2,cUser.cDevice.location_model3]]];
|
||
|
}
|
||
|
return _myDataSource;
|
||
|
}
|
||
|
|
||
|
- (NSNumber *)locationMode{
|
||
|
if (!_locationMode) {
|
||
|
if ([cUser.cDevice.opLocationMode intValue] < 3) {
|
||
|
_locationMode = cUser.cDevice.location_interval2;
|
||
|
} else {
|
||
|
_locationMode = cUser.cDevice.opLocationMode;
|
||
|
}
|
||
|
}
|
||
|
return _locationMode;
|
||
|
}
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
self.zx_navTitle = @"定位模式";
|
||
|
[self zx_setRightBtnWithText:@"保存" clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
|
||
|
[self rightBarItemClick];
|
||
|
}];
|
||
|
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.view);
|
||
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
|
||
|
make.bottom.equalTo(self.view.mas_bottom);
|
||
|
}];
|
||
|
self.myTableView.tableHeaderView = self.headerView;
|
||
|
self.myTableView.tableHeaderView.height = Adapted(150);
|
||
|
self.timeArr = @[@[[NSString stringWithFormat:@":%@分钟/次", cUser.cDevice.location_interval1],
|
||
|
[NSString stringWithFormat:@":%@分钟/次", cUser.cDevice.location_interval2],
|
||
|
[NSString stringWithFormat:@":%@分钟/次", cUser.cDevice.location_interval3]]];
|
||
|
}
|
||
|
|
||
|
- (void)rightBarItemClick
|
||
|
{
|
||
|
WEAKSELF
|
||
|
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opLocationMode":self.locationMode}
|
||
|
success:^(id responseObject) {
|
||
|
cUser.cDevice.opLocationMode = weakSelf.locationMode;
|
||
|
[weakSelf goBack:nil];
|
||
|
} failure:^(id faiObject) {
|
||
|
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||
|
{
|
||
|
baseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"baseCell"];
|
||
|
if (!cell) {
|
||
|
cell = [[baseCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"baseCell"];
|
||
|
|
||
|
UIImageView *imageView = [[UIImageView alloc] initWithImage:[myHelper getImageWithName:@"未选中"]];
|
||
|
cell.accessoryView = imageView;
|
||
|
}
|
||
|
NSString *title = self.myDataSource[indexPath.section][indexPath.row];
|
||
|
cell.textLabel.text = [NSString stringWithFormat:@"%@%@",title,self.timeArr[indexPath.section][indexPath.row]];
|
||
|
|
||
|
UIImageView *imageView = (UIImageView *)cell.accessoryView;
|
||
|
imageView.image = nil;
|
||
|
if ([self.locationMode integerValue] == [cUser.cDevice.location_interval2 integerValue] && [title isEqualToString:cUser.cDevice.location_model2]) {
|
||
|
imageView.image = [myHelper getImageWithName:@"选中"];
|
||
|
}else if([self.locationMode integerValue] == [cUser.cDevice.location_interval1 integerValue] && [title isEqualToString:cUser.cDevice.location_model1]){
|
||
|
imageView.image = [myHelper getImageWithName:@"选中"];
|
||
|
}else if([self.locationMode integerValue] == [cUser.cDevice.location_interval3 integerValue] && [title isEqualToString:cUser.cDevice.location_model3]){
|
||
|
imageView.image = [myHelper getImageWithName:@"选中"];
|
||
|
}
|
||
|
return cell;
|
||
|
}
|
||
|
|
||
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
NSString *title = self.myDataSource[indexPath.section][indexPath.row];
|
||
|
if ([title isEqualToString:cUser.cDevice.location_model2]) {
|
||
|
self.locationMode = cUser.cDevice.location_interval2;
|
||
|
}else if ([title isEqualToString:cUser.cDevice.location_model1]) {
|
||
|
self.locationMode = cUser.cDevice.location_interval1;
|
||
|
}else if ([title isEqualToString:cUser.cDevice.location_model3]) {
|
||
|
self.locationMode = cUser.cDevice.location_interval3;
|
||
|
}
|
||
|
[tableView reloadData];
|
||
|
}
|
||
|
|
||
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||
|
if (section == self.myDataSource.count - 1) {
|
||
|
return 10 + 100 + 10;
|
||
|
}
|
||
|
return [super tableView:tableView heightForFooterInSection:section];
|
||
|
}
|
||
|
|
||
|
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||
|
if (section == self.myDataSource.count - 1) {
|
||
|
|
||
|
// UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((SWIDTH - 310 * FIX_SCREEN) / 2, 10 + 6,
|
||
|
// 310 * FIX_SCREEN, 100)];
|
||
|
// lable.text = @"温馨提示:建议选择省电模式!\n高频模式:定位频率较高\n正常模式:定位频率适中\n省电模式:定位频率较低";
|
||
|
// lable.numberOfLines = 0;
|
||
|
// lable.font = [UIFont systemFontOfSize:14];
|
||
|
// lable.textColor = [UIColor lightGrayColor];
|
||
|
// [view addSubview:lable];
|
||
|
}
|
||
|
return view;
|
||
|
}
|
||
|
|
||
|
- (UIView *)headerView
|
||
|
{
|
||
|
if(!_headerView)
|
||
|
{
|
||
|
_headerView = [UIView new];
|
||
|
_headerView.backgroundColor = UIColor.whiteColor;
|
||
|
_headerView.frame = CGRectMake(0, 0, ScreenWidth, Adapted(150));
|
||
|
|
||
|
UIImageView *iconImg = [UIImageView new];
|
||
|
iconImg.image = [UIImage imageNamed:@"LocationMode_icon"];
|
||
|
[_headerView addSubview: iconImg];
|
||
|
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.equalTo(_headerView);
|
||
|
make.top.equalTo(_headerView).offset(10);
|
||
|
make.size.mas_equalTo(iconImg.image.size);
|
||
|
}];
|
||
|
|
||
|
UILabel *lable = [[UILabel alloc] init];
|
||
|
lable.text = @"设置设备的定位模式:频次间隔越久,设备续航时间越长。";
|
||
|
lable.numberOfLines = 0;
|
||
|
lable.font = [UIFont systemFontOfSize:14];
|
||
|
//lable.textColor = [UIColor lightGrayColor];
|
||
|
[_headerView addSubview:lable];
|
||
|
[lable mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(_headerView).inset(15);
|
||
|
make.bottom.equalTo(_headerView.mas_bottom).inset(Adapted(20));
|
||
|
}];
|
||
|
}
|
||
|
return _headerView;
|
||
|
}
|
||
|
|
||
|
|
||
|
- (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
|