|
|
|
//
|
|
|
|
// LocationModeViewController.m
|
|
|
|
// LekangGuard
|
|
|
|
//
|
|
|
|
// Created by ecell on 2022/12/10.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "LocationModeViewController.h"
|
|
|
|
|
|
|
|
@interface LocationModeViewController ()
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *imgArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,assign) NSInteger time;
|
|
|
|
|
|
|
|
@property (nonatomic ,assign) NSInteger level;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation LocationModeViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
|
|
self.imgArr = [NSMutableArray new];
|
|
|
|
self.zx_navTitle = GJText(@"定位模式");
|
|
|
|
[self zx_setRightBtnWithText:GJText(@"保存") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
|
|
|
|
[self SetLocationModel];
|
|
|
|
}];
|
|
|
|
NSArray *arr = @[GJText(@"高频模式"),GJText(@"正常模式"),GJText(@"省电模式")];
|
|
|
|
|
|
|
|
NSArray *timeArr = @[F(GJText(@":%ld分钟/次"), self.model.positioningThreeInterva),
|
|
|
|
F(GJText(@":%ld分钟/次"), self.model.positioningOneInterva),
|
|
|
|
F(GJText(@":%ld分钟/次"), self.model.positioningTwoInterva)];
|
|
|
|
|
|
|
|
UIView *bgView1 = [UICommon ui_view:CGRectMake(15, iPhoneX_NavHeight+15, SCREEN_WIDTH-30, Adapted(55)*arr.count) backgroundColor:KKWhiteColorColor cornerRadius:5 borderWidth:0 borderColor:KKWhiteColorColor];
|
|
|
|
[self.view addSubview:bgView1];
|
|
|
|
|
|
|
|
UIImageView *iconImg = [UICommon ui_imageView:CGRectZero fileName:@"LocationMode_icon"];
|
|
|
|
[bgView1 addSubview: iconImg];
|
|
|
|
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.centerX.equalTo(bgView1);
|
|
|
|
make.top.equalTo(bgView1).offset(10);
|
|
|
|
make.size.mas_equalTo(iconImg.image.size);
|
|
|
|
}];
|
|
|
|
|
|
|
|
UILabel *headerTitle = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:FontADA_(15) textColor:KKTextBlackColor text:@"" Radius:0];
|
|
|
|
headerTitle.text = GJText(@"设置设备的定位模式:频次间隔越久,设备续航时间越长。");
|
|
|
|
[bgView1 addSubview:headerTitle];
|
|
|
|
[headerTitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.equalTo(bgView1).inset(15);
|
|
|
|
make.bottom.equalTo(bgView1.mas_bottom).inset(Adapted(10));
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
UIView *bgView = [UICommon ui_view:CGRectMake(15, bgView1.bottom+15, SCREEN_WIDTH-30, Adapted(55)*arr.count) backgroundColor:KKWhiteColorColor cornerRadius:5 borderWidth:0 borderColor:KKWhiteColorColor];
|
|
|
|
[self.view addSubview:bgView];
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < arr.count; i++)
|
|
|
|
{
|
|
|
|
UIButton *titleBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(13) normalColor:KKTextBlackColor normalText:F(@"%@%@", arr[i],timeArr[i]) click:^(UIButton *btn) {
|
|
|
|
|
|
|
|
for (UIImageView *image in self.imgArr)
|
|
|
|
{
|
|
|
|
image.image = image.tag == btn.tag ? ImageName_(@"icon_selectImg_Yes") : ImageName_(@"");
|
|
|
|
}
|
|
|
|
if (btn.tag == 0)
|
|
|
|
{
|
|
|
|
self.time = self.model.positioningThreeInterva;
|
|
|
|
self.level = 3;
|
|
|
|
}
|
|
|
|
else if (btn.tag == 1)
|
|
|
|
{
|
|
|
|
self.time = self.model.positioningOneInterva;
|
|
|
|
self.level = 1;
|
|
|
|
}
|
|
|
|
else if (btn.tag == 2)
|
|
|
|
{
|
|
|
|
self.time = self.model.positioningTwoInterva;
|
|
|
|
self.level = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
}];
|
|
|
|
titleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
|
|
titleBtn.tag = i;
|
|
|
|
[bgView addSubview:titleBtn];
|
|
|
|
[titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.equalTo(bgView).offset(Adapted(10));
|
|
|
|
make.right.equalTo(bgView.mas_right);
|
|
|
|
make.top.equalTo(bgView).offset(i*Adapted(55));
|
|
|
|
make.height.mas_equalTo(Adapted(55));
|
|
|
|
}];
|
|
|
|
|
|
|
|
UIImage *img = ImageName_(@"icon_selectImg_Yes");
|
|
|
|
UIImageView *selectImg = [UICommon ui_imageView:CGRectZero fileName:@""];
|
|
|
|
selectImg.tag = i;
|
|
|
|
[bgView addSubview:selectImg];
|
|
|
|
[selectImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.right.equalTo(bgView.mas_right).inset(15);
|
|
|
|
make.centerY.equalTo(titleBtn);
|
|
|
|
make.size.mas_equalTo(CGSizeMake(Adapted(img.size.width), Adapted(img.size.height)));
|
|
|
|
}];
|
|
|
|
[self.imgArr addObject:selectImg];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i < arr.count-1)
|
|
|
|
{
|
|
|
|
UIImageView *line = [UIImageView new];
|
|
|
|
line.backgroundColor = KKLineColor;
|
|
|
|
[bgView addSubview:line];
|
|
|
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.equalTo(bgView).offset(15);
|
|
|
|
make.right.equalTo(bgView.mas_right);
|
|
|
|
make.top.equalTo(titleBtn.mas_bottom);
|
|
|
|
make.height.mas_equalTo(0.5);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NSInteger tags = 1;
|
|
|
|
if (self.model.positioningThreeInterva == APIManager.sharedManager.deviceModel.positioningInterval)
|
|
|
|
{
|
|
|
|
/// 高频
|
|
|
|
self.time = self.model.positioningThreeInterva;
|
|
|
|
tags = 0;
|
|
|
|
self.level = 3;
|
|
|
|
}
|
|
|
|
else if (self.model.positioningOneInterva == APIManager.sharedManager.deviceModel.positioningInterval)
|
|
|
|
{
|
|
|
|
/// 正常
|
|
|
|
self.time = self.model.positioningOneInterva;
|
|
|
|
tags = 1;
|
|
|
|
self.level = 1;
|
|
|
|
}
|
|
|
|
else if (self.model.positioningTwoInterva == APIManager.sharedManager.deviceModel.positioningInterval)
|
|
|
|
{
|
|
|
|
/// 省电
|
|
|
|
self.time = self.model.positioningTwoInterva;
|
|
|
|
tags = 2;
|
|
|
|
self.level = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (UIImageView *image in self.imgArr)
|
|
|
|
{
|
|
|
|
image.image = image.tag == tags ? ImageName_(@"icon_selectImg_Yes") : ImageName_(@"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark 定位模式修改
|
|
|
|
/// 定位模式修改
|
|
|
|
- (void)SetLocationModel
|
|
|
|
{
|
|
|
|
[UICommon MessageUpload:@"加载中"];
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
|
|
|
|
[[[APIManager sharedManager] APGET:F(@"%@/%ld/%@/%ld", LocationModel_URL,self.time,APIManager.sharedManager.deviceModel.imei,self.level) parameters:parameters resultClass:nil] subscribeNext:^(id _Nullable x) {
|
|
|
|
[UICommon HidenLoading];
|
|
|
|
[UICommon MessageSuccessText:@"保存成功"];
|
|
|
|
[self UpdataDeviceMsg];
|
|
|
|
[super updataNotificat];
|
|
|
|
AfterDispatch(0.5, ^{
|
|
|
|
self.isLoSuccess();
|
|
|
|
});
|
|
|
|
} error:^(NSError * _Nullable error) {
|
|
|
|
NSDictionary *dic = error.userInfo;
|
|
|
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)UpdataDeviceMsg
|
|
|
|
{
|
|
|
|
DeviceModel *model = APIManager.sharedManager.deviceModel;
|
|
|
|
model.positioningInterval = self.time;
|
|
|
|
[APIManager.sharedManager.cache setObject:model forKey:sDeviceKey];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
#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
|