| | |
| | | #import "MBProgressHUD+Add.h" |
| | | #import "LoginPage.h" |
| | | #import "GloriaLabel.h" |
| | | #import "XZPickView.h" |
| | | #import "MusicSetPage.h" |
| | | |
| | | @interface MinePage () |
| | | @interface MinePage ()<XZPickViewDelegate, XZPickViewDataSource> |
| | | { |
| | | UISwitch *switchButton; |
| | | GloriaLabel* _TitleLabel; |
| | | GloriaLabel* _SulvLabel; |
| | | GloriaLabel* _IsUpLoadLabel; |
| | | GloriaLabel* _MusicLabel; |
| | | UIImageView * icon_refresh; |
| | | UIImageView * icon_data; |
| | | UIImageView * icon_police; |
| | | } |
| | | |
| | | @property(nonatomic,strong) UITableView * tableView; |
| | | @property (nonatomic, strong) NSMutableArray *dataArray; |
| | | @property (nonatomic,strong) XZPickView * pickView; |
| | | |
| | | @property (nonatomic,copy) NSDictionary * dateDic; |
| | | @property (nonatomic,strong) NSString * is_open_upload; |
| | | @property (nonatomic,strong) NSString * weekStr; |
| | | @property (nonatomic, strong) NSDate *selectDate; |
| | | @property (nonatomic, assign) NSInteger currentSelectDay; |
| | | |
| | | @end |
| | | |
| | | @implementation MinePage |
| | | |
| | | // 确定操作处理 |
| | | -(void)pickView:(XZPickView *)pickerView confirmButtonClick:(UIButton *)button{ |
| | | |
| | | NSInteger left = [pickerView selectedRowInComponent:0]; |
| | | self.selectDate = [self.dateDic[@"week"] objectAtIndex:left]; |
| | | self.weekStr = self.dateDic[@"week"][left]; |
| | | self.weekStr = [self.weekStr substringWithRange:NSMakeRange(0,[self.weekStr length]-1)]; |
| | | [self update_refresh_frequency]; |
| | | } |
| | | |
| | | -(void)update_refresh_frequency |
| | | { |
| | | //[UserDefault stringForKey:@"user_id"] |
| | | NSString *path = [[NSString alloc] initWithFormat:UPDATE_USERINFO]; |
| | | |
| | | NSMutableDictionary *param = [[NSMutableDictionary alloc] init]; |
| | | |
| | | //['refresh_frequency', 'video', 'is_open_upload'] |
| | | [param setValue:[UserDefault stringForKey:@"user_id"] forKey:@"user_id"]; |
| | | [param setValue:@"refresh_frequency" forKey:@"field"]; |
| | | [param setValue:self.weekStr forKey:@"value"]; |
| | | |
| | | MPWeakSelf(self); |
| | | [NetworkSingleton networkingGetMethod:param urlName:path success:^(id responseBody) |
| | | { |
| | | MPStrongSelf(self); |
| | | BaseResModel * resModel = [Global toBaseModel:responseBody]; |
| | | |
| | | if(resModel.code == 0) |
| | | { |
| | | [UserDefault setObject:self.weekStr forKey:@"refresh_frequency"]; |
| | | [UserDefault synchronize]; |
| | | |
| | | [self.tableView reloadData]; |
| | | [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | } |
| | | else |
| | | { |
| | | [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | } |
| | | } |
| | | failure:^(NSString *error) |
| | | { |
| | | |
| | | [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | }]; |
| | | } |
| | | |
| | | -(void)update_is_open_upload |
| | | { |
| | | //[UserDefault stringForKey:@"user_id"] |
| | | NSString *path = [[NSString alloc] initWithFormat:UPDATE_USERINFO]; |
| | | |
| | | NSMutableDictionary *param = [[NSMutableDictionary alloc] init]; |
| | | |
| | | //['refresh_frequency', 'video', 'is_open_upload'] |
| | | [param setValue:[UserDefault stringForKey:@"user_id"] forKey:@"user_id"]; |
| | | [param setValue:@"is_open_upload" forKey:@"field"]; // 1 上传 0 不传 |
| | | [param setValue:self.is_open_upload forKey:@"value"]; |
| | | |
| | | MPWeakSelf(self); |
| | | [NetworkSingleton networkingGetMethod:param urlName:path success:^(id responseBody) |
| | | { |
| | | MPStrongSelf(self); |
| | | BaseResModel * resModel = [Global toBaseModel:responseBody]; |
| | | |
| | | if(resModel.code == 0) |
| | | { |
| | | [UserDefault setObject:self.is_open_upload forKey:@"is_open_upload"]; |
| | | [UserDefault synchronize]; |
| | | |
| | | [self.tableView reloadData]; |
| | | [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | } |
| | | else |
| | | { |
| | | [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | } |
| | | } |
| | | failure:^(NSString *error) |
| | | { |
| | | |
| | | [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | }]; |
| | | } |
| | | |
| | | -(NSInteger)pickerView:(XZPickView *)pickerView numberOfRowsInComponent:(NSInteger)component{ |
| | | |
| | | //时间 |
| | | return [self.dateDic[@"week"] count]; |
| | | } |
| | | |
| | | -(void)pickerView:(XZPickView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component |
| | | { |
| | | self.currentSelectDay = [pickerView selectedRowInComponent:0]; |
| | | //[pickerView pickReloadComponent:1]; |
| | | self.weekStr = self.dateDic[@"week"][row]; |
| | | |
| | | } |
| | | |
| | | -(NSString *)pickerView:(XZPickView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component |
| | | { |
| | | return self.dateDic[@"week"][row]; |
| | | } |
| | | |
| | | -(NSInteger)numberOfComponentsInPickerView:(XZPickView *)pickerView{ |
| | | return 1; |
| | | } |
| | | |
| | | #pragma mark - |
| | | |
| | | |
| | | - (NSDictionary *)LHGetStartTime |
| | | { |
| | | NSMutableArray *weekStrArr = [NSMutableArray array]; |
| | | [weekStrArr addObject:@"10秒"]; |
| | | [weekStrArr addObject:@"20秒"]; |
| | | [weekStrArr addObject:@"30秒"]; |
| | | NSDictionary *resultDic = @{@"week" : weekStrArr}; |
| | | return resultDic; |
| | | } |
| | | |
| | | |
| | | #pragma mark - getter methods |
| | | |
| | | -(XZPickView *)pickView |
| | | { |
| | | if(!_pickView){ |
| | | _pickView = [[XZPickView alloc]initWithFrame:kScreenBounds title:@"请选择"]; |
| | | _pickView.delegate = self; |
| | | _pickView.dataSource = self; |
| | | } |
| | | return _pickView; |
| | | } |
| | | |
| | | |
| | | - (UITableView *)tableView |
| | | { |
| | |
| | | self.navigationItem.title = @"设置"; |
| | | |
| | | self.tableView.hidden = NO; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | [super didReceiveMemoryWarning]; |
| | | // Dispose of any resources that can be recreated. |
| | | } |
| | | |
| | | //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; |
| | | //{ |
| | | // return 50; |
| | | //} |
| | | // |
| | | //- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; // custom view for header. will be adjusted to default or specified header height |
| | | //{ |
| | | // UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)]; |
| | | // |
| | | // view.backgroundColor = [UIColor clearColor]; |
| | | // |
| | | //// UIButton *quitLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| | | //// quitLoginBtn.frame =CGRectMake(30, 50, SCREEN_WIDTH-60, 40); |
| | | //// [quitLoginBtn.layer setMasksToBounds:YES]; |
| | | //// [quitLoginBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径 |
| | | //// quitLoginBtn.backgroundColor = RgbColor(84, 76, 155);/////色值自己改一下 |
| | | //// [quitLoginBtn setTitle:@"退出当前账号" forState:UIControlStateNormal]; |
| | | //// quitLoginBtn.userInteractionEnabled = YES; |
| | | //// [quitLoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
| | | //// [quitLoginBtn addTarget:self action:@selector(exitLoginAction) forControlEvents:UIControlEventTouchUpInside]; |
| | | //// [view addSubview:quitLoginBtn]; |
| | | // |
| | | // return view; |
| | | //} |
| | | |
| | | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView |
| | | { |
| | |
| | | { |
| | | case 0: |
| | | { |
| | | UIImageView * icon_refresh = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_refresh.image = [UIImage imageNamed:@"icon_refresh"]; |
| | | [cell.contentView addSubview:icon_refresh]; |
| | | if(icon_refresh==nil) |
| | | { |
| | | icon_refresh = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_refresh.image = [UIImage imageNamed:@"icon_refresh"]; |
| | | [cell.contentView addSubview:icon_refresh]; |
| | | } |
| | | |
| | | GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50, 15,SCREEN_WIDTH/2, 30)]; |
| | | _TitleLabel.font = [UIFont systemFontOfSize:14]; |
| | | _TitleLabel.textAlignment = UITextAlignmentLeft; |
| | | _TitleLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _TitleLabel.text = @"刷新率:"; |
| | | [cell.contentView addSubview:_TitleLabel]; |
| | | if(_TitleLabel == nil) |
| | | { |
| | | _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50, 15,SCREEN_WIDTH/2, 30)]; |
| | | _TitleLabel.font = [UIFont systemFontOfSize:14]; |
| | | _TitleLabel.textAlignment = UITextAlignmentLeft; |
| | | _TitleLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _TitleLabel.text = @"刷新率:"; |
| | | [cell.contentView addSubview:_TitleLabel]; |
| | | } |
| | | |
| | | |
| | | UITextField*userPhoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-40-110, 8, 110, 44)]; |
| | | userPhoneTextField.font = [UIFont fontWithName:@"Arial" size:14]; |
| | | userPhoneTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入设置时间"attributes:@{ NSForegroundColorAttributeName:kUIColorFromRGB(0x00b744)}]; |
| | | userPhoneTextField.delegate = self; |
| | | [userPhoneTextField setValue:RgbColor(149, 149, 150) forKeyPath:@"_placeholderLabel.textColor"]; |
| | | //userPhoneTextField.layer.borderColor = [RgbColor(213, 213, 213) CGColor]; |
| | | userPhoneTextField.textColor = RgbColor(149, 149, 150); |
| | | userPhoneTextField.keyboardType = UIKeyboardTypeNumberPad; |
| | | userPhoneTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; |
| | | // 设置一个空白blankView,15.0就是这块View的宽度width,也是光标的位置,根据你自己的需要设定大小 |
| | | UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(userPhoneTextField.frame.origin.x,userPhoneTextField.frame.origin.y,10.0, userPhoneTextField.frame.size.height)]; |
| | | userPhoneTextField.leftView = blankView; |
| | | userPhoneTextField.leftViewMode =UITextFieldViewModeAlways; |
| | | [cell.contentView addSubview:userPhoneTextField]; |
| | | if(_SulvLabel == nil) |
| | | { |
| | | _SulvLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-60, 15,SCREEN_WIDTH/2, 30)]; |
| | | _SulvLabel.font = [UIFont systemFontOfSize:14]; |
| | | _SulvLabel.textAlignment = UITextAlignmentLeft; |
| | | _SulvLabel.textColor = kUIColorFromRGB(0x595959); |
| | | [cell.contentView addSubview:_SulvLabel]; |
| | | } |
| | | |
| | | GloriaLabel* _MiaoLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-40, 15,20, 30)]; |
| | | _MiaoLabel.font = [UIFont systemFontOfSize:14]; |
| | | _MiaoLabel.textAlignment = UITextAlignmentLeft; |
| | | _MiaoLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _MiaoLabel.text = @"秒"; |
| | | [cell.contentView addSubview:_MiaoLabel]; |
| | | |
| | | _SulvLabel.text = [NSString stringWithFormat:@"%@秒",[UserDefault stringForKey:@"refresh_frequency"]]; |
| | | } |
| | | break; |
| | | case 1: |
| | | { |
| | | UIImageView * icon_data = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_data.image = [UIImage imageNamed:@"icon_data"]; |
| | | [cell.contentView addSubview:icon_data]; |
| | | if(icon_data==nil) |
| | | { |
| | | icon_data = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_data.image = [UIImage imageNamed:@"icon_data"]; |
| | | [cell.contentView addSubview:icon_data]; |
| | | } |
| | | |
| | | |
| | | GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50, 15,SCREEN_WIDTH/2, 30)]; |
| | | _TitleLabel.font = [UIFont systemFontOfSize:14]; |
| | | _TitleLabel.textAlignment = UITextAlignmentLeft; |
| | | _TitleLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _TitleLabel.text = @"是否上传数据"; |
| | | [cell.contentView addSubview:_TitleLabel]; |
| | | |
| | | switchButton = [[UISwitch alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-60, 15, 20, 10)]; |
| | | [switchButton setOn:YES]; |
| | | [switchButton addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged]; |
| | | [cell.contentView addSubview:switchButton]; |
| | | |
| | | if(_IsUpLoadLabel==nil) |
| | | { |
| | | _IsUpLoadLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50, 15,SCREEN_WIDTH/2, 30)]; |
| | | _IsUpLoadLabel.font = [UIFont systemFontOfSize:14]; |
| | | _IsUpLoadLabel.textAlignment = UITextAlignmentLeft; |
| | | _IsUpLoadLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _IsUpLoadLabel.text = @"是否上传数据"; |
| | | [cell.contentView addSubview:_IsUpLoadLabel]; |
| | | } |
| | | |
| | | if(switchButton == nil) |
| | | { |
| | | switchButton = [[UISwitch alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-60, 15, 20, 10)]; |
| | | [switchButton setOn:[[UserDefault stringForKey:@"is_open_upload"] intValue] == 1? YES:NO]; |
| | | [switchButton addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged]; |
| | | [cell.contentView addSubview:switchButton]; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case 2: |
| | | { |
| | | UIImageView * icon_police = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_police.image = [UIImage imageNamed:@"icon_police"]; |
| | | [cell.contentView addSubview:icon_police]; |
| | | if(icon_police==nil) |
| | | { |
| | | icon_police = [[UIImageView alloc] initWithFrame:CGRectMake(20, 22, 15, 15)]; |
| | | icon_police.image = [UIImage imageNamed:@"icon_police"]; |
| | | [cell.contentView addSubview:icon_police]; |
| | | } |
| | | |
| | | GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50,15,SCREEN_WIDTH/2, 30)]; |
| | | _TitleLabel.font = [UIFont systemFontOfSize:14]; |
| | | _TitleLabel.textAlignment = UITextAlignmentLeft; |
| | | _TitleLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _TitleLabel.text = @"报警铃音"; |
| | | [cell.contentView addSubview:_TitleLabel]; |
| | | if(_MusicLabel==nil) |
| | | { |
| | | _MusicLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(50,15,SCREEN_WIDTH/2, 30)]; |
| | | _MusicLabel.font = [UIFont systemFontOfSize:14]; |
| | | _MusicLabel.textAlignment = UITextAlignmentLeft; |
| | | _MusicLabel.textColor = kUIColorFromRGB(0x595959); |
| | | _MusicLabel.text = @"报警铃音"; |
| | | [cell.contentView addSubview:_MusicLabel]; |
| | | } |
| | | |
| | | |
| | | UIImageView * icon_line = [[UIImageView alloc] initWithFrame:CGRectMake(20, 59, SCREEN_WIDTH, 1)]; |
| | | icon_line.image = [UIImage imageNamed:@"icon_line"]; |
| | |
| | | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
| | | NSInteger index = [indexPath row]; |
| | | |
| | | |
| | | // 跳转酒店备用界面 |
| | | // 跳转选择酒店 |
| | | //HotelSelPage* page = [[HotelSelPage alloc] initIsFirstPage:NO]; |
| | | //page.bSelRoom = 2; |
| | | // 跳转界面 |
| | | //BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:page]; |
| | | //[self presentViewController:baseNav animated:YES completion:nil]; |
| | | //[self showActionForPhoto]; |
| | | if(index == 0) |
| | | { |
| | | NSLog(@"%s",__func__); |
| | | self.dateDic = [self LHGetStartTime]; |
| | | self.weekStr = self.dateDic[@"week"][0]; |
| | | [self.pickView reloadData]; |
| | | //[self.userNumPickView selectRow:0 inComponent:0 animated:NO]; |
| | | [[UIApplication sharedApplication].keyWindow addSubview:self.pickView]; |
| | | [self.pickView show]; |
| | | } |
| | | else if(index == 2) |
| | | { |
| | | |
| | | // 跳转酒店备用界面 |
| | | MusicSetPage* page = [[MusicSetPage alloc] initIsFirstPage:NO]; |
| | | // 跳转界面 |
| | | BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:page]; |
| | | [self presentViewController:baseNav animated:YES completion:nil]; |
| | | } |
| | | } |
| | | |
| | | - (void)switchAction |
| | |
| | | BOOL isButtonOn = [switchButton isOn]; |
| | | if (isButtonOn) |
| | | { |
| | | //showSwitchValue.text = @"是"; |
| | | self.is_open_upload = @"1"; |
| | | } |
| | | else |
| | | { |
| | | //showSwitchValue.text = @"否"; |
| | | self.is_open_upload = @"0"; |
| | | } |
| | | |
| | | [self update_is_open_upload]; |
| | | } |
| | | |
| | | #pragma mark - custom function begin |