ソースを参照

1.模糊搜索接口修改等

huangxiaodong 8 ヶ月 前
コミット
dd771cc38f

+ 53 - 20
创维盒子/code/NAS/NasSearchViewController.m

@@ -37,6 +37,8 @@
 @property (nonatomic, strong)  NSMutableArray*didSelectListArr;//选中的数据
 @property (nonatomic, strong) searchListModel *curSearchLisyMod;
 @property (nonatomic, copy) NSString *searchKeyWord;//搜索关键字
+@property (nonatomic, strong) UIView *tableViewHead;
+@property (nonatomic, strong) UILabel *tableViewHeadLabel;
 @end
 
 @implementation NasSearchViewController
@@ -136,6 +138,25 @@
         make.bottom.mas_equalTo(0);
         make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
     }];
+    
+    self.tableView.hidden = YES;
+    _tableViewHead = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 30)];
+    _tableViewHead.backgroundColor = [UIColor whiteColor];
+    //self.tableView.tableHeaderView = _tableViewHead;
+    
+    _tableViewHeadLabel = [[UILabel alloc] init];
+    _tableViewHeadLabel.textColor = [UIColor hwColor:@"#0A132B"];
+    _tableViewHeadLabel.font = [UIFont systemFontOfSize:12.0];
+    _tableViewHeadLabel.text = NSLocalizedString(@"Search_Total_result",nil);
+    [_tableViewHead addSubview:_tableViewHeadLabel];
+    
+    [_tableViewHeadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15.0);
+        make.right.mas_equalTo(0.0);
+        make.top.mas_equalTo(0.0);
+        make.bottom.mas_equalTo(0.0);
+    }];
+    
 }
 
 
@@ -186,7 +207,7 @@
     if(!_curSearchLisyMod){
         return 0;
     }
-    return _curSearchLisyMod.data.count;
+    return _curSearchLisyMod.data.list.count;
 }
 
 - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -210,8 +231,8 @@
         
     }
     
-    if(row < _curSearchLisyMod.data.count){
-        searchDataModel* dataModel = _curSearchLisyMod.data[row];
+    if(row < _curSearchLisyMod.data.list.count){
+        searchDataModel* dataModel = _curSearchLisyMod.data.list[row];
         cell.curNASFileAudioDataModel = (NASFileAudioDataModel*)dataModel;
         
         KWeakSelf
@@ -231,8 +252,8 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
     NSInteger row = indexPath.row;
-    if(row < _curSearchLisyMod.data.count){
-        NASFileAndFolderDataModel* dataModel = _curSearchLisyMod.data[row];
+    if(row < _curSearchLisyMod.data.list.count){
+        NASFileAndFolderDataModel* dataModel = _curSearchLisyMod.data.list[row];
         
         if([dataModel.type isEqualToString:@"dir"])
         {
@@ -293,7 +314,7 @@
 }
 
 - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
-    NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
+    NSString *text = NSLocalizedString(@"Search_nodata_tip",nil);
     
     NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
                                  NSForegroundColorAttributeName: HW999999Color};
@@ -418,8 +439,8 @@
 
 - (void)userCheckFilePreviewByRow:(NSInteger)row
 {
-    if(row < _curSearchLisyMod.data.count){
-        NASFileAudioDataModel* dataModel = _curSearchLisyMod.data[row];
+    if(row < _curSearchLisyMod.data.list.count){
+        NASFileAudioDataModel* dataModel = _curSearchLisyMod.data.list[row];
         
         if(dataModel.isSelectType){
             [_didSelectListArr removeObject:dataModel];
@@ -440,7 +461,7 @@
     
     [_didSelectListArr removeAllObjects];
     
-    for (NASFileAudioDataModel* dataModel in _curSearchLisyMod.data) {
+    for (NASFileAudioDataModel* dataModel in _curSearchLisyMod.data.list) {
         
         if(!button.selected){
             dataModel.isSelectType = button.selected;
@@ -586,7 +607,8 @@
     [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
     
     KWeakSelf
-    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"search" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"search1" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        weakSelf.tableView.hidden = NO;
         [weakSelf.tableView.mj_footer endRefreshing];
         [weakSelf removeNewIndicatorHaveStr];
         searchListModel *model = [[searchListModel alloc] initWithDictionary:responseObject error:nil];;
@@ -594,7 +616,7 @@
         if(model && model.status == 0){
             [self handelNetDataAfterFilterDataBy:model];
             
-            if (model.data.count < pageSizeNum) {
+            if (model.data.list.count < pageSizeNum) {
                 [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
             }
             else{
@@ -605,6 +627,7 @@
         }
         
     } failure:^(NSError * _Nonnull error) {
+        weakSelf.tableView.hidden = NO;
         [weakSelf.tableView.mj_footer endRefreshing];
         [weakSelf removeNewIndicatorHaveStr];
         if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
@@ -627,17 +650,27 @@
 #pragma mark 分页数据组装
 - (void)handelNetDataAfterFilterDataBy:(searchListModel*)model
 {
-    if(_curSearchLisyMod && _curSearchLisyMod.data ){
-        NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curSearchLisyMod.data];//旧数据
-        [handelDataArr addObjectsFromArray:model.data];//新数据
+    if(_curSearchLisyMod && _curSearchLisyMod.data.list ){
+        NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curSearchLisyMod.data.list];//旧数据
+        [handelDataArr addObjectsFromArray:model.data.list];//新数据
 
-        _curSearchLisyMod.data = (NSArray<searchDataModel>*)handelDataArr;
+        _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)handelDataArr;
     }
     else{
         _curSearchLisyMod = model;
+        
+        if (_curSearchLisyMod.data.total == 0) {
+            self.tableView.tableHeaderView = nil;
+        }
+        else{
+            self.tableView.tableHeaderView = _tableViewHead;
+            
+            NSString *str = [[NSString alloc] initWithFormat:@"%@(%ld)",NSLocalizedString(@"Search_Total_result",nil),_curSearchLisyMod.data.total];
+            _tableViewHeadLabel.text = str;
+        }
     }
 
-    if(_curSearchLisyMod.data.count == 0 ){
+    if(_curSearchLisyMod.data.list.count == 0 ){
         self.tableView.mj_footer.hidden = YES;
     }
     else{
@@ -754,13 +787,13 @@
 - (void)deleteNetDataByDeleteSucFun
 {
     NSMutableArray *afterFilterArr = [NSMutableArray new];
-    for (searchDataModel *model in _curSearchLisyMod.data) {
+    for (searchDataModel *model in _curSearchLisyMod.data.list) {
         if (!model.isSelectType) {
             [afterFilterArr addObject:model];
         }
     }
     
-    _curSearchLisyMod.data = (NSArray<searchDataModel>*)afterFilterArr;
+    _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)afterFilterArr;
     
     [self.tableView reloadData];
 }
@@ -773,13 +806,13 @@
     }
     
     NSMutableArray *afterFilterArr = [NSMutableArray new];
-    for (searchDataModel *model in _curSearchLisyMod.data) {
+    for (searchDataModel *model in _curSearchLisyMod.data.list) {
         if (![model.path isEqualToString:filePath]) {
             [afterFilterArr addObject:model];
         }
     }
     
-    _curSearchLisyMod.data = (NSArray<searchDataModel>*)afterFilterArr;
+    _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)afterFilterArr;
     [self.tableView reloadData];
 }
 

+ 6 - 1
创维盒子/code/NAS/model/searchListModel.h

@@ -23,8 +23,13 @@ NS_ASSUME_NONNULL_BEGIN
 @end
 
 @protocol searchDataModel;
+@interface searchListTotaModel : SuperModel
+@property (nonatomic, assign) NSInteger total;
+@property (nonatomic, strong) NSArray<searchDataModel>* list;
+@end
+
 @interface searchListModel : SuperModel
-@property (nonatomic, strong) NSArray<searchDataModel>* data;
+@property (nonatomic, strong) searchListTotaModel* data;
 @end
 
 NS_ASSUME_NONNULL_END

+ 5 - 0
创维盒子/code/NAS/model/searchListModel.m

@@ -10,6 +10,11 @@
 @implementation searchDataModel
 
 @end
+
+@implementation searchListTotaModel
+
+@end
+
 @implementation searchListModel
 
 @end

+ 2 - 0
创维盒子/code/zh-Hans.lproj/Localizable.strings

@@ -664,6 +664,8 @@
 
 //1.4.5
 "Search_nas_title"      = "搜索";
+"Search_Total_result"      = "搜索结果";
+"Search_nodata_tip"      = "暂无搜索结果~";
 "cloudPhone_restart_box_title"      = "重启盒子";
 "cloudPhone_restart_box_tip"      = "你确定要重启盒子?";
 "cloudPhone_restart_box_msg"      = "重启设备过程中功能将暂时无法使用?";