Files
yuyin_ios/SweetParty/主类/Mine/Controller/SPGiftMingxiVC.m
2025-08-08 11:05:33 +08:00

102 lines
2.5 KiB
Objective-C
Executable File

//
// SPGiftMingxiVC.m
// SweetParty
//
// Created by bj_szd on 2022/6/27.
//
#import "SPGiftMingxiVC.h"
#import "SPGiftMingxiCell.h"
@interface SPGiftMingxiVC ()
@end
@implementation SPGiftMingxiVC
- (void)viewDidLoad {
[super viewDidLoad];
[self createUI];
[self fetchData];
}
-(void)createUI {
[self showNaviBarWithTitle:@"礼物明细"];
[self.tableView registerNib:[UINib nibWithNibName:@"SPGiftMingxiCell" bundle:nil] forCellReuseIdentifier:@"SPGiftMingxiCell"];
self.tableView.rowHeight = 60;
[self showPullToRefresh];
[self showLoadMoreRefresh];
}
- (void)fetchData {
NSString *urlStr = @"";
if (self.type == 1) {
urlStr = @"api/user/get_receive_gift_list";
}else if (self.type == 2) {
urlStr = @"api/user/get_send_gift_list";
}
NSDictionary *params = @{@"page":@(self.page), @"page_limit":@(20), @"uid":C_string(self.userId), @"gift_from_type":@(self.gift_from_type)};
[AFNetworkRequset.shared postRequestWithParams:params Path:urlStr Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
if (self.page == 1) {
[self.dataArray removeAllObjects];
[self.tableView reloadData];
}
[self endRefresh];
NSArray *arr = [SPGiftMingxiModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"]];
[self.dataArray addObjectsFromArray:arr];
[self.tableView reloadData];
if (arr.count > 0) {
[self endFooterRefreshWithMore];
}else {
[self endFooterRefreshWithNoMore];
}
if (self.dataArray.count <= 0) {
[self showNoContentView];
} else {
[self hideNoContentView];
}
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)refreshFetchData {
self.page = 1;
[self fetchData];
}
- (void)fetchMoreData {
self.page ++;
[self fetchData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SPGiftMingxiCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SPGiftMingxiCell" forIndexPath:indexPath];
cell.selectionStyle = NO;
SPGiftMingxiModel *model = self.dataArray[indexPath.row];
cell.model = model;
return cell;
}
@end