201 lines
6.6 KiB
Mathematica
201 lines
6.6 KiB
Mathematica
|
|
//
|
||
|
|
// THHomeViewController.m
|
||
|
|
// TreeHole
|
||
|
|
//
|
||
|
|
// Created by iOS on 2023/1/31.
|
||
|
|
//
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "THHomeViewController.h"
|
||
|
|
//#import "BottleDetialController.h"
|
||
|
|
#import "THHomeHotPartyView.h"
|
||
|
|
#import "THBottleInfoCardContainerView.h"
|
||
|
|
|
||
|
|
#import "BottleTypePickerViewController.h"
|
||
|
|
#import "BottlePublishViewController.h"
|
||
|
|
#import "BottleDetialController.h"
|
||
|
|
#import "BottleReadView.h"
|
||
|
|
|
||
|
|
|
||
|
|
@interface THHomeViewController ()
|
||
|
|
|
||
|
|
@property(nonatomic, strong)UIScrollView *scrollView;
|
||
|
|
@property(nonatomic, strong)THHomeHotPartyView *hotPartyView;
|
||
|
|
@property(nonatomic, strong)THBottleInfoCardContainerView *bottleCardView;
|
||
|
|
|
||
|
|
@property(nonatomic, strong)NSMutableArray *bottleIds;
|
||
|
|
///上一个
|
||
|
|
@property(nonatomic, strong)THBottleInfoModel *preBottleInfoModel;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation THHomeViewController
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#pragma mark - Request
|
||
|
|
///首页推荐酒瓶
|
||
|
|
- (void)requstHomeRecommendBottle {
|
||
|
|
WeakSelf(self);
|
||
|
|
[THNetworkInterfaceService requestRecommendBottleIdsWithPageSize:1 complete:^(NSArray * _Nullable responseArrayData, NSError * _Nullable err) {
|
||
|
|
NSLog(@"首页推荐酒瓶===%@", responseArrayData);
|
||
|
|
if (!responseArrayData.count) {
|
||
|
|
//弹窗-查看更多
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
[weakself.bottleIds removeAllObjects];
|
||
|
|
[weakself.bottleIds addObjectsFromArray:responseArrayData];
|
||
|
|
|
||
|
|
NSString *firstId = responseArrayData.firstObject;
|
||
|
|
//根据id获取详情
|
||
|
|
[THNetworkInterfaceService requestRecommendBottleInfoWithBottleId:firstId complete:^(NSDictionary * _Nullable responseDicData, NSError * _Nullable err) {
|
||
|
|
NSLog(@"首页推荐酒瓶===%@", responseDicData);
|
||
|
|
// weakself.preBottleInfoModel = weakself.bottleCardView.infoModel;
|
||
|
|
THBottleInfoModel *infoModel = [THBottleInfoModel yy_modelWithDictionary:responseDicData];
|
||
|
|
weakself.bottleCardView.infoModel = infoModel;
|
||
|
|
}];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
///参与派对人数
|
||
|
|
- (void)requestHotPartyNumber {
|
||
|
|
WeakSelf(self);
|
||
|
|
[PYHTTPManager postWithPath:@"bottlecount" params:nil callback:^(id _Nullable rsp, NSError * _Nullable error) {
|
||
|
|
|
||
|
|
CGFloat count = [rsp[@"count"] floatValue];
|
||
|
|
|
||
|
|
if (count >= 10000) {
|
||
|
|
weakself.hotPartyView.numberStr = [NSString stringWithFormat:@"%.2f万次参与",count/10000.0];
|
||
|
|
}else{
|
||
|
|
weakself.hotPartyView.numberStr = [NSString stringWithFormat:@"%f次参与",count];
|
||
|
|
}
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//MARK: - Click
|
||
|
|
|
||
|
|
///酒柜页面
|
||
|
|
- (void)toBottleGroupsVC {
|
||
|
|
BottleDetialController *deDetial = [[BottleDetialController alloc]init];
|
||
|
|
[self.navigationController pushViewController:deDetial animated:YES];
|
||
|
|
}
|
||
|
|
|
||
|
|
///发布
|
||
|
|
- (void)toChooseBottleTypeAndPublishVC {
|
||
|
|
WeakSelf(self);
|
||
|
|
BottleTypePickerViewController *picker = [BottleTypePickerViewController pickerViewControllerWithCompletion:^(BottleTypePickerViewController * _Nonnull picker, BottleTypeInfo * _Nonnull info) {
|
||
|
|
[picker.navigationController dismissViewControllerAnimated:NO completion:^{
|
||
|
|
BottlePublishViewController *publishVC = [[BottlePublishViewController alloc] init];
|
||
|
|
publishVC.info = info;
|
||
|
|
publishVC.publishSucceedAction = ^{
|
||
|
|
// if (weakself.info.left_bottle_num > 0) {
|
||
|
|
// weakself.info.left_bottle_num --;
|
||
|
|
// [weakself reloadHurlBottoleButtonBadge];
|
||
|
|
// }
|
||
|
|
};
|
||
|
|
[weakself.navigationController presentViewController:[[PYNavigationViewController alloc] initWithRootViewController:publishVC] animated:YES completion:nil];
|
||
|
|
}];
|
||
|
|
}];
|
||
|
|
THNavigationController *nav = [[THNavigationController alloc] initWithRootViewController:picker];
|
||
|
|
[[PYAppService currentNavigationController] presentViewController:nav animated:YES completion:nil];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//MARK: - Life
|
||
|
|
- (void)didInitialize {
|
||
|
|
[super didInitialize];
|
||
|
|
// init 时做的事情请写在这里
|
||
|
|
|
||
|
|
self.hidesBottomBarWhenPushed = NO;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)initSubviews {
|
||
|
|
[super initSubviews];
|
||
|
|
// 对 subviews 的初始化写在这里
|
||
|
|
|
||
|
|
UIImageView *bgImgView = [UIImageView creatViewInSuperView:self.view];
|
||
|
|
bgImgView.frame = self.view.bounds;
|
||
|
|
bgImgView.image = UIImageMake(@"TH_BaseLocalBg");
|
||
|
|
|
||
|
|
_scrollView = [UIScrollView creatViewInSuperView:self.view];
|
||
|
|
|
||
|
|
WeakSelf(self);
|
||
|
|
///酒馆派对火热进行中...
|
||
|
|
_hotPartyView = [THHomeHotPartyView creatViewInSuperView:_scrollView];
|
||
|
|
_hotPartyView.backgroundColor = UIColorMakeWhiteAlpha(0.18);
|
||
|
|
_hotPartyView.layer.cornerRadius = 8;
|
||
|
|
[_hotPartyView addTapWithAction:^{
|
||
|
|
[weakself toBottleGroupsVC];
|
||
|
|
}];
|
||
|
|
|
||
|
|
_bottleCardView = [THBottleInfoCardContainerView creatViewInSuperView:_scrollView];
|
||
|
|
// _bottleCardView.qmui_shouldShowDebugColor = YES;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
// 对 self.view 的操作写在这里
|
||
|
|
[self requstHomeRecommendBottle];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewWillAppear:(BOOL)animated {
|
||
|
|
[super viewWillAppear:animated];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewDidAppear:(BOOL)animated {
|
||
|
|
[super viewDidAppear:animated];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
||
|
|
[super viewWillDisappear:animated];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewDidDisappear:(BOOL)animated {
|
||
|
|
[super viewDidDisappear:animated];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)viewDidLayoutSubviews {
|
||
|
|
[super viewDidLayoutSubviews];
|
||
|
|
|
||
|
|
self.scrollView.frame = self.view.bounds;
|
||
|
|
|
||
|
|
self.hotPartyView.frame = CGRectMake(18, self.qmui_navigationBarMaxYInViewCoordinator + 8, self.view.qmui_width - 18 * 2, 49);
|
||
|
|
|
||
|
|
self.bottleCardView.frame = CGRectMake(18, self.hotPartyView.qmui_bottom + 8, self.view.qmui_width - 18 * 2, self.view.qmui_height - self.hotPartyView.qmui_bottom - 8 - TabBarHeight - 30);
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setupNavigationItems {
|
||
|
|
[super setupNavigationItems];
|
||
|
|
self.title = @"基地推荐TEST";
|
||
|
|
|
||
|
|
WeakSelf(self);
|
||
|
|
QMUIButton *leftItemBtn = [[QMUIButton alloc] qmui_initWithImage:[UIImageMake(@"TH_chat_bottle_icon") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] title:@""];
|
||
|
|
[leftItemBtn addTapWithAction:^{
|
||
|
|
[BottleReadView showDetailWithAttach];
|
||
|
|
}];
|
||
|
|
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftItemBtn];
|
||
|
|
|
||
|
|
QMUIButton *rightItemBtn = [[QMUIButton alloc] qmui_initWithImage:[UIImageMake(@"TH_navItemBottlePublic") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] title:@""];
|
||
|
|
[rightItemBtn addTapWithAction:^{
|
||
|
|
[weakself toChooseBottleTypeAndPublishVC];
|
||
|
|
}];
|
||
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightItemBtn];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//MARK: - Get&Set
|
||
|
|
- (NSMutableArray *)bottleIds {
|
||
|
|
if (_bottleIds) {
|
||
|
|
_bottleIds = [NSMutableArray array];
|
||
|
|
}
|
||
|
|
return _bottleIds;
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|