Commit 581856b7 authored by 石光辉's avatar 石光辉
parents 57e9a2ab 77059212
......@@ -23,16 +23,21 @@
#import "QGRefreshNomalHeader.h"
#import "QGDefaultView.h"
#import "QGBasePopView.h"
#import "QGRecommendCell.h"
//Tool
#import "QGApplicationOpenURL.h"
#import "QGCardRequestApi.h"
#import "QGBlankNoteRequest.h"
@interface QGCardViewController ()
///首页数据模型
@property (nonatomic, strong) QGCardHomeModel * cardDataModel;
/**
推荐数组
*/
@property (nonatomic, strong) NSMutableArray *recommendListArray;
@end
@implementation QGCardViewController
......@@ -48,7 +53,7 @@
[super viewDidAppear:animated];
//如果有数据则默默刷新 否则下拉刷新
if (self.cardDataModel) {
[self requestData];
[self requestAllData];
}
else
{
......@@ -90,20 +95,19 @@
@weakify(self);
QGRefreshNomalHeader *header = [self.tableView addHeaderRefreshOnlyWithHandle:^(BOOL isRefresh) {
@strongify(self);
[self requestData];
[self requestAllData];
}];
header.isExclusionStatusBar = YES;
}
///网络请求
- (void)requestData
- (void)requestAllData
{
// http://yapi.quantgroups.com/mock/187/vcc/user-center/api/tab/blanknote/status
@weakify(self);
NSString * urlString = [QGCardRequestApi urlWithIndex:QGCardRequestServerMethodBlanknoteStatus];
NSDictionary * parameters = @{@"type":@"137"};
[[QGMainNetwork shareManager] GET:urlString parameters:parameters success:^(id _Nonnull responseObject) {
QGBatchOperationManager * manager = [[QGBatchOperationManager alloc]initWithSerial:NO];
[manager GET:urlString networkClassName:NSStringFromClass([QGMainNetwork class]) parameters:parameters success:^(id _Nonnull responseObject) {
@strongify(self);
if ([QGBaseNetwork checkBusinessCodeAndCodeWithResponseObjectObject:responseObject]) {
NSDictionary * dataDic = responseObject[@"data"];
......@@ -127,7 +131,6 @@
}
[self.tableView endHeaderRefreshWithBlock:nil];
[self.tableView reloadData];
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
@strongify(self);
[self.tableView endHeaderRefreshWithBlock:nil];
......@@ -138,12 +141,34 @@
view.viewType = QGDefaultViewTypeBadNetwork;
}];
//附属请求
//请求推荐列表
NSString * recommendUrlString = [QGBlankNoteRequest urlWithIndex:BlankNoteRequestServerMethod3CRecommendListV3];
[manager GET:recommendUrlString networkClassName:NSStringFromClass([QGMainNetwork class]) parameters:nil success:^(id _Nonnull responseObject) {
@strongify(self);
[self recommendListRequetsSuccessWithDic:responseObject];
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
}];
}
///推荐信息请求成功
- (void)recommendListRequetsSuccessWithDic:(NSArray *)responseObject {
NSArray *spuListsArray = responseObject;
self.recommendListArray = [NSMutableArray arrayWithCapacity:0];
for (NSDictionary *dic in spuListsArray) {
QGDigitalListModel *listModel = [[QGDigitalListModel alloc] initWithDic:dic];
[self.recommendListArray addObject:listModel];
}
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.cardDataModel ? 2 : 0;
return self.cardDataModel ? 3 : 0;
}
......@@ -159,6 +184,10 @@
case 1:
numberOfRows = self.cardDataModel.loanBanner.count > 0 ? 1 : 0;
break;
//为你推荐
case 2:
numberOfRows = ceil(self.recommendListArray.count / 2.0);
break;
default:
break;
}
......@@ -185,6 +214,12 @@
[self bannerClickBlock:index];
};
return cell;
}
break;
//为你推荐
case 2:
{
return [self getRecommendCellTableView:tableView cellForRowAtIndexPath:indexPath];
}
break;
......@@ -293,6 +328,24 @@
}
///为你推荐
- (UITableViewCell *)getRecommendCellTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
QGRecommendCell *cell = (QGRecommendCell *) [self getCellFromNibName:NSStringFromClass([QGRecommendCell class]) dequeueTableView:tableView];
NSInteger location = indexPath.row * 2;
NSInteger length = 2;
//可能会出现最后一行只有一个的情况
if (location + length > self.recommendListArray.count) {
length = 1;
}
cell.listArray = [self.recommendListArray subarrayWithRange:NSMakeRange(location, length)];
__weak typeof(self) weakSelf = self;
cell.itemClickBlock = ^(QGDigitalListModel *listModel) {
[weakSelf jumpGoodsDetailVCWithProductId:listModel.defaultProductId];
};
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger heightForRow = CGFLOAT_MIN;
......@@ -305,6 +358,19 @@
case 1:
heightForRow = [QGCardBannerCell cellHeight];
break;
case 2:
{
CGFloat width = (MAINSCREEN_WIDTH - 1) / 2;
CGFloat itemHeight = 0;
//3c
if (MAINSCREEN_WIDTH == 320) {
itemHeight = width * 1.3;
} else {
itemHeight = width * 1.2;
}
heightForRow = itemHeight + 1;
}
break;
default:
break;
}
......@@ -316,13 +382,41 @@
if (section == 0) {
return CGFLOAT_MIN;
}
//为你推荐
else if (section == 2)
{
return 76 + 10;
}
return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * view = [UIView creatViewWithSuperView:nil backgroundColor:[UIColor moduleSeparatorColorF7F7]];
return view;
//为你推荐
if (section == 2) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MAINSCREEN_WIDTH, 76 + 10)];
view.backgroundColor = [UIColor whiteColor];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MAINSCREEN_WIDTH, 10)];
topView.backgroundColor = [UIColor colorWithHexString:@"F4F4F4"];
[view addSubview:topView];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10 + 30, 100, 25)];
titleLabel.font = [UIFont qg_regularFontOfSize:18];
titleLabel.textColor = [UIColor textColor3333];
titleLabel.text = @"为你推荐";
[view addSubview:titleLabel];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(view.frame) - .5, MAINSCREEN_WIDTH, .5)];
lineView.backgroundColor = [UIColor colorWithHexString:@"D4D4D4"];
[view addSubview:lineView];
return view;
}
else
{
UIView * view = [UIView creatViewWithSuperView:nil backgroundColor:[UIColor moduleSeparatorColorF7F7]];
return view;
}
}
......@@ -465,6 +559,11 @@
}
}
//商品详情
- (void)jumpGoodsDetailVCWithProductId:(NSString *)productId {
[Mediator performTarget:[QGMediatorClassTools QGClassNameWithHeaderType:QGHeaderTypeQGCommodityDetailVC] parameters:@{@"skuId" : productId} handlerBlock:nil];
}
/*
#pragma mark - Navigation
......
......@@ -14,6 +14,10 @@
@property (nonatomic, copy)NSString *token;
/// 重置密码类型 “body”:活体,“code”:短信
@property (nonatomic, copy)NSString *resetType;
///身份证号
@property (nonatomic, copy)NSString *idCard;
///姓名
@property (nonatomic, copy)NSString *name;
@end
......@@ -34,6 +34,7 @@
//创建header
UILabel *titleLable = [UILabel creatLabelWithSuperView:self.tableHeaderView title:@"短信验证成功,请设置新登录密码" titleFontSize:[UIFont qg_mediumFontOfSize:18] textColor:[UIColor textColor3333] alignment:NSTextAlignmentLeft];
//如果是活体认证修改密码
if ([self.resetType isEqualToString:@"body"]) {
titleLable.text = @"刷脸验证成功,请设置新登录密码";
}
......@@ -64,11 +65,26 @@
return;
}
//请求连接根据短信或者活体验证
NSString *url;
NSMutableDictionary *parame = [[NSMutableDictionary alloc]init];
[parame setObject:self.firstPassword forKey:@"password"];
//此处区分短验和活体
NSString *url = [QGLoginRequestApi urlWithQGLoginRequestServerMethod:([self.resetType isEqualToString:@"code"]?QGLoginRequestServerMethodSetNewPasswordCode:QGLoginRequestServerMethodSetNewPasswordBody)];
if ([self.resetType isEqualToString:@"body"]) {
[parame setObject:self.phoneNumberStr forKey:@"phone"];
[parame setObject:self.name forKey:@"name"];
[parame setObject:self.idCard forKey:@"idCard"];
//活体
url = [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodSetNewPasswordBody];
}else{
//短验
url = [QGLoginRequestApi urlWithQGLoginRequestServerMethod:QGLoginRequestServerMethodSetNewPasswordCode];
}
NSMutableDictionary *header = [[NSMutableDictionary alloc] initWithCapacity:1];
if (![QGUserInfo sharedUserInfo].login) {
......@@ -229,7 +245,8 @@
self.phoneNumberStr = [param objectForKey:@"phoneNumberStr"];
self.token = [param objectForKey:@"token"];
self.resetType = [param objectForKey:@"resetType"];
self.name = [param objectForKey:@"name"];
self.idCard = [param objectForKey:@"idCard"];
}
@end
......@@ -147,10 +147,20 @@
msg = success;
}
*/
@weakify(self);
self.megliveSuccessBlock = ^(NSDictionary * _Nonnull successDic) {
@strongify(self);
[Mediator performTarget:[QGMediatorClassTools QGClassNameWithHeaderType:QGHeaderTypeQGSucceedRetrieceSetNewPasswordViewController] parameters:@{@"phoneNumberStr":self.phoneNumberStr, @"token":[successDic valueForKeyPath:@"data.token"],@"resetType":@"body"} handlerBlock:self.callBackBlock];
NSMutableDictionary *parame = [[NSMutableDictionary alloc] init];
[parame setObject:self.identityCardNum forKey:@"idCard"];
[parame setObject:self.nameStr forKey:@"name"];
[parame setObject:self.phoneNumberStr forKey:@"phoneNumberStr"];
[parame setObject:@"body" forKey:@"resetType"];
[parame setObject:[successDic valueForKeyPath:@"data.token"] forKey:@"token"];
[Mediator performTarget:[QGMediatorClassTools QGClassNameWithHeaderType:QGHeaderTypeQGSucceedRetrieceSetNewPasswordViewController] parameters:parame handlerBlock:self.callBackBlock];
};
}
......@@ -185,7 +195,7 @@
QGQGVerifyFaceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cardCell"];
if (!cell) {
cell = [[QGQGVerifyFaceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cardCell" cellTitle:@"身份证号" placeHolder:@"请输入本人18位身份证号"];
cell = [[QGQGVerifyFaceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cardCell" cellTitle:@"身份证号" placeHolder:@"请输入本人身份证号"];
}
@weakify(self)
......
......@@ -95,7 +95,8 @@
- (void)userProtocol {
// NSString *url = [QGRequestCenter urlWithIndex:QGRequestServerMethodUserAgreement];
// [self pushWebViewControllerWithUrlString:url title:@"用户协议"];
// [self pushWebViewControllerWithUrlString:@"http://pages.xyqb.com/fa-lv-xie-yi/" title:@"用户协议"];
[self navigationToWeb:@"http://pages.xyqb.com/fa-lv-xie-yi/"];
}
#pragma mark - UITableViewDataSource
......
......@@ -47,51 +47,6 @@
@implementation QGCustomTabBar
#pragma mark - -----------------以下两个方法解决ios12.1tabbar图标位移问题,如以后IOS12.1解决则可移除--------------
/**
* 用 block 重写某个 class 的指定方法
* @param targetClass 要重写的 class
* @param targetSelector 要重写的 class 里的实例方法,注意如果该方法不存在于 targetClass 里,则什么都不做
* @param implementationBlock 该 block 必须返回一个 block,返回的 block 将被当成 targetSelector 的新实现,所以要在内部自己处理对 super 的调用,以及对当前调用方法的 self 的 class 的保护判断(因为如果 targetClass 的 targetSelector 是继承自父类的,targetClass 内部并没有重写这个方法,则我们这个函数最终重写的其实是父类的 targetSelector,所以会产生预期之外的 class 的影响,例如 targetClass 传进来 UIButton.class,则最终可能会影响到 UIView.class),implementationBlock 的参数里第一个为你要修改的 class,也即等同于 targetClass,第二个参数为你要修改的 selector,也即等同于 targetSelector,第三个参数是 targetSelector 原本的实现,由于 IMP 可以直接当成 C 函数调用,所以可利用它来实现“调用 super”的效果,但由于 targetSelector 的参数个数、参数类型、返回值类型,都会影响 IMP 的调用写法,所以这个调用只能由业务自己写。
*/
CG_INLINE BOOL
OverrideImplementation(Class targetClass, SEL targetSelector, id (^implementationBlock)(Class originClass, SEL originCMD, IMP originIMP)) {
Method originMethod = class_getInstanceMethod(targetClass, targetSelector);
if (!originMethod) {
return NO;
}
IMP originIMP = method_getImplementation(originMethod);
method_setImplementation(originMethod, imp_implementationWithBlock(implementationBlock(targetClass, targetSelector, originIMP)));
return YES;
}
+ (void)load {
/* 这个问题是 iOS 12.1 Beta 2 的问题,只要 UITabBar 是磨砂的,并且 push viewController 时 hidesBottomBarWhenPushed = YES 则手势返回的时候就会触发。
出现这个现象的直接原因是 tabBar 内的按钮 UITabBarButton 被设置了错误的 frame,frame.size 变为 (0, 0) 导致的。如果12.1正式版Apple修复了这个bug可以移除调这段代码(来源于QMUIKit的处理方式)*/
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (@available(iOS 12.1, *)) {
OverrideImplementation(NSClassFromString(@"UITabBarButton"), @selector(setFrame:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP originIMP) {
return ^(UIView *selfObject, CGRect firstArgv) {
if ([selfObject isKindOfClass:originClass]) {
// 如果发现即将要设置一个 size 为空的 frame,则屏蔽掉本次设置
if (!CGRectIsEmpty(selfObject.frame) && CGRectIsEmpty(firstArgv)) {
NSLog(@"tabbar = %@",NSStringFromCGRect(firstArgv));
return;
}
}
// call super
void (*originSelectorIMP)(id, SEL, CGRect);
originSelectorIMP = (void (*)(id, SEL, CGRect))originIMP;
originSelectorIMP(selfObject, originCMD, firstArgv);
};
});
}
});
}
- (instancetype)initWithBarItems:(NSArray <QGTabBarItemModel *>*)barItems
{
......
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