174 lines
5.5 KiB
Objective-C
Executable File
174 lines
5.5 KiB
Objective-C
Executable File
//
|
||
// SPMineQianyueListVC.m
|
||
// SweetParty
|
||
//
|
||
// Created by bj_szd on 2022/6/8.
|
||
//
|
||
|
||
#import "SPMineQianyueListVC.h"
|
||
#import "SPMineQianyueListCell.h"
|
||
#import "YYVipChangeAlert.h"
|
||
|
||
@interface SPMineQianyueListVC ()
|
||
|
||
@end
|
||
|
||
@implementation SPMineQianyueListVC
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
|
||
[self showNaviBarWithTitle:@""];
|
||
[self onChangeNaviWhiteStyle];
|
||
[self.naviView.backBtn setImage:ImageNamed(@"whiteBack") forState:UIControlStateNormal];
|
||
|
||
[self createUI];
|
||
|
||
[self fetchData];
|
||
}
|
||
|
||
-(void)createUI {
|
||
UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"mine_qianyue_bg")];
|
||
[self.view insertSubview:bgImgV atIndex:0];
|
||
[bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.left.right.equalTo(self.view);
|
||
make.height.mas_equalTo(ScreenWidth/375*812);
|
||
}];
|
||
|
||
[self.tableView registerNib:[UINib nibWithNibName:@"SPMineQianyueListCell" bundle:nil] forCellReuseIdentifier:@"SPMineQianyueListCell"];
|
||
self.tableView.rowHeight = 85;
|
||
|
||
self.tableView.backgroundColor = HEXCOLOR(0xFFF7F7);
|
||
self.tableView.layer.cornerRadius = 10;
|
||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(294);
|
||
make.left.mas_equalTo(15);
|
||
make.right.mas_equalTo(-15);
|
||
make.bottom.mas_equalTo(-34);
|
||
}];
|
||
|
||
[self showPullToRefresh];
|
||
[self showLoadMoreRefresh];
|
||
}
|
||
|
||
- (void)fetchData {
|
||
NSDictionary *params = @{@"page":@(self.page), @"page_limit":@(10), @"uid":BJUserManager.userInfo.uid};
|
||
[AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/Contract/get_user_contract_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
||
if (self.page == 1) {
|
||
[self.dataArray removeAllObjects];
|
||
[self.tableView reloadData];
|
||
}
|
||
[self endRefresh];
|
||
|
||
NSArray *arr = [SPFocusFansModel 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 {
|
||
SPMineQianyueListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SPMineQianyueListCell" forIndexPath:indexPath];
|
||
cell.selectionStyle = NO;
|
||
SPFocusFansModel *model = self.dataArray[indexPath.row];
|
||
cell.model = model;
|
||
|
||
cell.focusBtnTopCon.constant = 7.5;
|
||
cell.jieyueBtn.hidden = NO;
|
||
WEAK_SELF
|
||
[cell.focusBtn buttonAddTaget:^(UIButton *btn) {
|
||
[weakSelf onRequestXuyue:model.id];
|
||
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
[cell.jieyueBtn buttonAddTaget:^(UIButton *btn) {
|
||
[weakSelf onRequestJieyue:model.id];
|
||
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
return cell;
|
||
}
|
||
|
||
- (void)onRequestXuyue:(NSString *)xuyueId {
|
||
NSDictionary *params = @{@"id":xuyueId};
|
||
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/Contract/user_renewal_contract_status" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
||
YYVipChangeAlert *view = LoadNib(@"YYVipChangeAlert");
|
||
view.frame = [UIScreen mainScreen].bounds;
|
||
view.titleLab.text = @"续约艺人";
|
||
view.contentLab.text = [NSString stringWithFormat:@"前三次免费续约,本次可花费%@金币续约7天,确定续约吗?", responseDic[@"data"][@"money"]];
|
||
[KEYWINDOW addSubview:view];
|
||
view.onCompleteBlock = ^{
|
||
[self onConfirm:xuyueId];
|
||
};
|
||
|
||
} Failure:^(id _Nonnull errorData) {
|
||
|
||
}];
|
||
}
|
||
|
||
- (void)onConfirm:(NSString *)xuyueId {
|
||
NSDictionary *params = @{@"id":xuyueId};
|
||
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/Contract/user_renewal_contract" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) {
|
||
[self refreshFetchData];
|
||
|
||
} Failure:^(id _Nonnull errorData) {
|
||
|
||
}];
|
||
}
|
||
|
||
- (void)onRequestJieyue:(NSString *)xuyueId {
|
||
YYVipChangeAlert *view = LoadNib(@"YYVipChangeAlert");
|
||
view.frame = [UIScreen mainScreen].bounds;
|
||
view.titleLab.text = @"解约艺人";
|
||
view.contentLab.text = @"确定解约吗?";
|
||
[KEYWINDOW addSubview:view];
|
||
view.onCompleteBlock = ^{
|
||
NSDictionary *params = @{@"id":xuyueId};
|
||
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/contract/user_cancel_contract" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) {
|
||
[self refreshFetchData];
|
||
|
||
} Failure:^(id _Nonnull errorData) {
|
||
|
||
}];
|
||
};
|
||
}
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
SPFocusFansModel *model = self.dataArray[indexPath.row];
|
||
[UIViewController goUserMainpageWith:model.uid withRid:@""];
|
||
}
|
||
|
||
@end
|