Commit ee26073f authored by zhangguangyi's avatar zhangguangyi

add friend list

parent 837aa30b
...@@ -3,4 +3,17 @@ ...@@ -3,4 +3,17 @@
uuid = "05A8EC5D-3D7B-4194-AF9F-73A026E946A1" uuid = "05A8EC5D-3D7B-4194-AF9F-73A026E946A1"
type = "0" type = "0"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "5D196504-A57E-4C19-8980-1EA44BF9CEDF"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>
...@@ -24,7 +24,8 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -24,7 +24,8 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
@property(nonatomic,strong)ZJFriendModel *friendModel; @property(nonatomic,strong)ZJFriendModel *friendModel;
@property(nonatomic,copy)NSString *timeString; @property(nonatomic,copy)NSString *timeString;
@property(nonatomic,strong)NSDictionary *weekSetting;
@property(nonatomic,strong)NSArray *ids;
@end @end
...@@ -75,6 +76,8 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -75,6 +76,8 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
[self.dataArray addObject:model]; [self.dataArray addObject:model];
} }
self.weekSetting = @{@"monday":@"1",@"tuesday":@"1",@"wednesday":@"1",@"thursday":@"1",@"friday":@"1",@"saturday":@"1",@"sunday":@"1"};
[self.tableView reloadData]; [self.tableView reloadData];
} }
...@@ -93,24 +96,55 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -93,24 +96,55 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
-(void)saveButtonAction:(UIButton *)sender -(void)saveButtonAction:(UIButton *)sender
{ {
NSLog(@"%@",self.weekSetting);
if (self.friendModel == nil) {
[MBProgressHUD showMessage:@"请选择关心的人"];
return;
}
if (self.timeString.length == 0) { if (self.timeString.length == 0) {
[MBProgressHUD showMessage:@"请选择时间"]; [MBProgressHUD showMessage:@"请选择时间"];
return; return;
} }
if (self.weekSetting.allKeys.count == 0) {
[MBProgressHUD showMessage:@"请选择重复时间"];
return;
}
NSMutableDictionary *dict = @{}.mutableCopy; NSMutableDictionary *dict = @{}.mutableCopy;
// @{@"typeId":@"1", @"status":sender.selected?@"1":@"0", @"friendId":[NSString stringWithFormat:@"%ld", (long)model.friendId], @"id":[NSString stringWithFormat:@"%ld", (long)model.id]}
dict[@"typeId"] = @(self.model.id); dict[@"typeId"] = @(self.model.id);
dict[@"friendId"] = self.friendModel.id; dict[@"friendId"] = self.friendModel.friendUid;
dict[@"remindTime"] = self.timeString; dict[@"remindTime"] = self.timeString;
dict[@"weekSetting"] = @""; dict[@"weekSetting"] = self.weekSetting;
NSString *json = [self convertToJsonData:dict];
NSLog(@"%@",json);
[[TQNetworkTools shared] postWithBodyAction:userRemindInfoSet parameters:@{} body:dict success:^(NSDictionary * _Nonnull response) { [[TQNetworkTools shared] postWithBodyAction:userRemindInfoSet parameters:@{} body:dict success:^(NSDictionary * _Nonnull response) {
if ([response[@"status"] intValue] == 200) {
[MBProgressHUD showMessage:@"添加成功"];
[self.navigationController popViewControllerAnimated:YES];
}
} failure:^(NSError * _Nonnull error) { } failure:^(NSError * _Nonnull error) {
}]; }];
} }
- (NSString *)convertToJsonData:(NSDictionary *)dict{
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString;
if (!jsonData) {
NSLog(@"%@",error);
}else{
jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
}
NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
NSRange range = {0,jsonString.length};
//去掉字符串中的空格
[mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
NSRange range2 = {0,mutStr.length};
//去掉字符串中的换行符
[mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
return mutStr;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
ZJReminderCateAddCell *cell = [tableView dequeueReusableCellWithIdentifier:ZJReminderCateAddCellID]; ZJReminderCateAddCell *cell = [tableView dequeueReusableCellWithIdentifier:ZJReminderCateAddCellID];
...@@ -128,6 +162,7 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -128,6 +162,7 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
{ {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
__weak typeof(self) weakSelf = self;
switch (indexPath.row) { switch (indexPath.row) {
case 0: case 0:
{// 关心的人 {// 关心的人
...@@ -156,7 +191,6 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -156,7 +191,6 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
break; break;
case 3: case 3:
{// 提醒时间 {// 提醒时间
__weak typeof(self) weakSelf = self;
QFTimePickerView *pickerView = [[QFTimePickerView alloc] initDatePackerWithStartHour:@"00" endHour:@"24" period:1 response:^(NSString *str) { QFTimePickerView *pickerView = [[QFTimePickerView alloc] initDatePackerWithStartHour:@"00" endHour:@"24" period:1 response:^(NSString *str) {
if ([str containsString:@"时"] && [str containsString:@"分"]) { if ([str containsString:@"时"] && [str containsString:@"分"]) {
weakSelf.timeString = [str stringByReplacingOccurrencesOfString:@"时" withString:@""]; weakSelf.timeString = [str stringByReplacingOccurrencesOfString:@"时" withString:@""];
...@@ -174,6 +208,31 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID"; ...@@ -174,6 +208,31 @@ static NSString * const ZJReminderFooterViewID = @"ZJReminderFooterViewID";
case 4: case 4:
{// 重复 {// 重复
ZJReminderTimeController *vc = [ZJReminderTimeController new]; ZJReminderTimeController *vc = [ZJReminderTimeController new];
vc.timeBlock = ^(NSDictionary * _Nonnull times, NSArray * _Nonnull ids) {
weakSelf.weekSetting = times;
weakSelf.ids = ids;
NSString *repStr = @"";
NSArray *weeks = @[@"一",@"二",@"三",@"四",@"五",@"六",@"日"];
NSInteger idx = 0;
NSInteger count = 0;
for (NSString *item in ids) {
if ([item isEqualToString:@"1"]) {
repStr = [repStr stringByAppendingFormat:@" 周%@",weeks[idx]];
count ++;
}
idx ++;
}
if (count == 7) {
repStr = @"每天";
}
if (weakSelf.dataArray.count) {
ZJChooseIcon *model = self.dataArray[4];
model.subName = repStr;
[weakSelf.tableView reloadData];
}
};
vc.ids = self.ids;;
[self.navigationController pushViewController:vc animated:YES]; [self.navigationController pushViewController:vc animated:YES];
} }
break; break;
......
...@@ -33,6 +33,13 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID"; ...@@ -33,6 +33,13 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID";
return _dataArray; return _dataArray;
} }
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self requestData];
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
...@@ -44,7 +51,6 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID"; ...@@ -44,7 +51,6 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID";
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor]; self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];
[self setupUI]; [self setupUI];
[self requestData];
} }
-(void)setupUI -(void)setupUI
...@@ -78,7 +84,7 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID"; ...@@ -78,7 +84,7 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID";
}else{ }else{
NSLog(@"添加提醒"); NSLog(@"添加提醒");
ZJReminderCateAddController *vc = [ZJReminderCateAddController new]; ZJReminderCateAddController *vc = [ZJReminderCateAddController new];
vc.model = self.model; vc.model = weakSelf.model;
[weakSelf.navigationController pushViewController:vc animated:YES]; [weakSelf.navigationController pushViewController:vc animated:YES];
} }
}; };
...@@ -117,10 +123,14 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID"; ...@@ -117,10 +123,14 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID";
{ {
if (self.model == nil) return; if (self.model == nil) return;
[[TQNetworkTools shared] getWithAction:userRemindInfo parameters:@{@"typeId":@(self.model.id)} success:^(id _Nonnull response) { [[TQNetworkTools shared] getWithAction:userRemindInfo parameters:@{@"typeId":@(self.model.id)} success:^(id _Nonnull response) {
if([response[@"status"] integerValue] == 200){
if([[response objectForKey:@"status"] integerValue] == 200){ [self.dataArray removeAllObjects];
if ([response[@"result"][@"data"] isKindOfClass:[NSArray class]]) {
for (NSDictionary *dict in response[@"result"][@"data"]) {
ZJReminder *model = [ZJReminder yy_modelWithJSON:dict];
[self.dataArray addObject:model];
}
}
}else{ }else{
[MBProgressHUD showError:[NSString stringWithFormat:@"%@", response[@"msg"]] toView:self.view]; [MBProgressHUD showError:[NSString stringWithFormat:@"%@", response[@"msg"]] toView:self.view];
} }
...@@ -144,6 +154,11 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID"; ...@@ -144,6 +154,11 @@ static NSString *ZJReminderMainCellID = @"ZJReminderMainCellID";
[cell.deleteBtn addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside]; [cell.deleteBtn addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];
cell.deleteBtn.hidden = !self.isManger; cell.deleteBtn.hidden = !self.isManger;
if (self.dataArray.count) {
ZJReminder *model = self.dataArray[indexPath.row];
cell.model = model;
}
return cell; return cell;
} }
......
...@@ -12,6 +12,14 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZJReminderTimeController : UIViewController @interface ZJReminderTimeController : UIViewController
@property(nonatomic,copy)void (^timeBlock)(NSDictionary *times,NSArray *ids);
// 选取参数
@property(nonatomic,strong)NSArray *ids;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -68,17 +68,50 @@ static NSString * const ZJReminderTimeCellID = @"ZJReminderTimeCellID"; ...@@ -68,17 +68,50 @@ static NSString * const ZJReminderTimeCellID = @"ZJReminderTimeCellID";
-(void)buttonAction:(UIButton *)sender -(void)buttonAction:(UIButton *)sender
{ {
NSLog(@"确定"); NSLog(@"确定");
NSMutableDictionary *dict = @{}.mutableCopy;
NSMutableArray *idsArr = @[].mutableCopy;
NSInteger idx = 0;
for (ZJReminderTime *model in self.dataArray) {
if (model.choose) {
dict[model.key] = @"1";
[idsArr addObject:@"1"];
}else{
dict[model.key] = @"0";
[idsArr addObject:@"0"];
}
idx ++;
}
if (self.timeBlock) {
self.timeBlock(dict,idsArr);
}
[self.navigationController popViewControllerAnimated:YES];
} }
-(void)requestData -(void)requestData
{ {
[self.dataArray removeAllObjects]; [self.dataArray removeAllObjects];
NSArray *res = @[@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六",@"星期日"]; NSArray *res = @[@{@"key":@"monday",@"name":@"每周一"},
for (NSString *name in res) { @{@"key":@"tuesday",@"name":@"每周二"},
ZJReminderTime *model = [ZJReminderTime new]; @{@"key":@"wednesday",@"name":@"每周三"},
model.name = name; @{@"key":@"thursday",@"name":@"每周四"},
model.choose = YES; @{@"key":@"friday",@"name":@"每周五"},
@{@"key":@"saturday",@"name":@"每周六"},
@{@"key":@"sunday",@"name":@"每周日"}];
NSInteger idx = 0;
for (NSDictionary *dict in res) {
ZJReminderTime *model = [ZJReminderTime yy_modelWithJSON:dict];
if (self.ids.count == res.count) {
NSString *tag = self.ids[idx];
if ([tag isEqualToString:@"1"]) {
model.choose = YES;
}else{
model.choose = NO;
}
}else{
model.choose = YES;
}
[self.dataArray addObject:model]; [self.dataArray addObject:model];
idx ++;
} }
[self.tableView reloadData]; [self.tableView reloadData];
......
...@@ -224,19 +224,20 @@ ...@@ -224,19 +224,20 @@
if (component == 0) { if (component == 0) {
selectedHour = hourArray[row]; selectedHour = hourArray[row];
if ([selectedHour isEqualToString:[hourArray lastObject]]) { // if ([selectedHour isEqualToString:[hourArray lastObject]]) {
[pickerView selectRow:0 inComponent:1 animated:YES]; // [pickerView selectRow:0 inComponent:1 animated:YES];
selectedMin = @"00"; // selectedMin = @"00";
} // }
// [pickerView reloadComponent:1]; // [pickerView reloadComponent:1];
} else { } else {
if ([selectedHour isEqualToString:[hourArray lastObject]]) { selectedMin = minArray[row];
[pickerView selectRow:0 inComponent:1 animated:YES]; // if ([selectedHour isEqualToString:[hourArray lastObject]]) {
selectedMin = @"00"; // [pickerView selectRow:0 inComponent:1 animated:YES];
} else { // selectedMin = @"00";
selectedMin = minArray[row]; // } else {
} // selectedMin = minArray[row];
// }
} }
} }
@end @end
...@@ -13,8 +13,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -13,8 +13,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZJReminder : NSObject @interface ZJReminder : NSObject
@property(nonatomic,assign)BOOL choose; @property(nonatomic,copy)NSString *headImage;
@property(nonatomic,copy)NSString *name;
@property(nonatomic,assign)NSInteger countdownSecond;
@property(nonatomic,assign)NSInteger friendId;
@property(nonatomic,assign)NSInteger id;
@property(nonatomic,assign)NSInteger status;
@end @end
...@@ -23,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,copy)NSString *name; @property(nonatomic,copy)NSString *name;
@property(nonatomic,copy)NSString *key;
@property(nonatomic,assign)BOOL choose; @property(nonatomic,assign)BOOL choose;
@end @end
......
...@@ -10,10 +10,13 @@ ...@@ -10,10 +10,13 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class ZJReminder;
@interface ZJReminderMainCell : UITableViewCell @interface ZJReminderMainCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn; @property (weak, nonatomic) IBOutlet UIButton *deleteBtn;
@property(nonatomic,strong)ZJReminder *model;
@end @end
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// //
#import "ZJReminderMainCell.h" #import "ZJReminderMainCell.h"
#import "ZJReminder.h"
@interface ZJReminderMainCell () @interface ZJReminderMainCell ()
...@@ -43,4 +44,23 @@ ...@@ -43,4 +44,23 @@
// Configure the view for the selected state // Configure the view for the selected state
} }
-(void)setModel:(ZJReminder *)model
{
_model = model;
[self.icon sd_setImageWithURL:[NSURL URLWithString:model.headImage] placeholderImage:[UIImage imageNamed:@"map_card_profile"]];
self.phone.text = model.name;
self.timeLabel.text = [self getMMSSFromSS:[NSString stringWithFormat:@"%ld",model.countdownSecond]];
}
-(NSString *)getMMSSFromSS:(NSString *)totalTime{
NSInteger seconds = [totalTime integerValue];
NSString *str_hour = [NSString stringWithFormat:@"%02ld",seconds/3600];
NSString *str_minute = [NSString stringWithFormat:@"%02ld",(seconds%3600)/60];
// NSString *str_second = [NSString stringWithFormat:@"%02ld",seconds%60];
NSString *format_time = [NSString stringWithFormat:@"%@时%@分",str_hour,str_minute];
return format_time;
}
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment