560 lines
21 KiB
Mathematica
560 lines
21 KiB
Mathematica
|
|
//
|
|||
|
|
// BottleViewController.m
|
|||
|
|
// TreeHole
|
|||
|
|
//
|
|||
|
|
// Created by mambaxie on 2022/4/27.
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
#import "BottleViewController.h"
|
|||
|
|
#import "ProfileViewController.h"
|
|||
|
|
#import "BottleCollectionCell.h"
|
|||
|
|
#import "BottleTypePickerViewController.h"
|
|||
|
|
#import "BottleService.h"
|
|||
|
|
#import "BottlePublishViewController.h"
|
|||
|
|
#import "BottleReadView.h"
|
|||
|
|
#import "MessageNotificationListViewController.h"
|
|||
|
|
#import "WZLBadgeImport.h"
|
|||
|
|
#import <UserNotifications/UNUserNotificationCenter.h>
|
|||
|
|
#import <UserNotifications/UNNotificationSettings.h>
|
|||
|
|
#import <GTSDK/GeTuiSdk.h> // GetuiSdk头文件
|
|||
|
|
#define OpenAppDayFlag @"notificationAlertDateFlag"
|
|||
|
|
#define NotificationAlertFlag @"notificationAlertFlag"
|
|||
|
|
|
|||
|
|
#import "BottleDetialController.h"
|
|||
|
|
|
|||
|
|
//#import <SDCycleScrollView.h>
|
|||
|
|
//#import "THHomeHotPartyView.h"
|
|||
|
|
|
|||
|
|
@interface BottleViewController () //<SDCycleScrollViewDelegate>
|
|||
|
|
|
|||
|
|
@property (nonatomic, strong) HomeBottleInfo *info;
|
|||
|
|
|
|||
|
|
@property (nonatomic, strong) UIButton *hurlBottleButton;
|
|||
|
|
|
|||
|
|
@property (nonatomic, strong) UIButton *getBottleButton;
|
|||
|
|
@property (nonatomic, assign) NSTimeInterval disappearTime;
|
|||
|
|
|
|||
|
|
|
|||
|
|
///---
|
|||
|
|
//@property(nonatomic, strong)SDCycleScrollView *bannerView;
|
|||
|
|
//@property(nonatomic, strong)THHomeHotPartyView *hotPartyView;
|
|||
|
|
|
|||
|
|
@end
|
|||
|
|
|
|||
|
|
@implementation BottleViewController
|
|||
|
|
|
|||
|
|
|
|||
|
|
- (void)creatSubViews {
|
|||
|
|
|
|||
|
|
UIImageView *bgImgView = [UIImageView creatViewInSuperView:self.view];
|
|||
|
|
bgImgView.frame = self.view.bounds;
|
|||
|
|
bgImgView.image = UIImageMake(@"TH_BaseLocalBg");
|
|||
|
|
///导航条设置
|
|||
|
|
|
|||
|
|
///banner
|
|||
|
|
// [self bannerView];
|
|||
|
|
///酒馆派对火热进行中...
|
|||
|
|
// _hotPartyView = [THHomeHotPartyView creatViewInSuperView:self.view];
|
|||
|
|
// _hotPartyView.backgroundColor = UIColorMakeWithHex(@"#29253E");
|
|||
|
|
///酒瓶详细内容展示: 种类
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/*
|
|||
|
|
///首页推荐酒瓶
|
|||
|
|
- (void)requstHomeRecommendBottle {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
///参与派对人数
|
|||
|
|
- (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];
|
|||
|
|
}
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
*/
|
|||
|
|
#pragma mark - QMUI
|
|||
|
|
/*
|
|||
|
|
- (void)setupNavigationItems {
|
|||
|
|
[super setupNavigationItems];
|
|||
|
|
self.title = @"基地推荐";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)didInitialize {
|
|||
|
|
[super didInitialize];
|
|||
|
|
|
|||
|
|
self.hidesBottomBarWhenPushed = NO;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewDidLayoutSubviews {
|
|||
|
|
[super viewDidLayoutSubviews];
|
|||
|
|
|
|||
|
|
CGFloat layout_X = 17;
|
|||
|
|
CGFloat bannerViewW = self.view.qmui_width - layout_X * 2;
|
|||
|
|
//self.qmui_navigationBarMaxYInViewCoordinator
|
|||
|
|
// self.bannerView.frame = CGRectMake(layout_X, NavigationContentTopConstant + 5, bannerViewW, (bannerViewW)*0.45-5);
|
|||
|
|
|
|||
|
|
// self.hotPartyView.frame = CGRectMake(layout_X, self.bannerView.qmui_bottom + 5, bannerViewW, 49);
|
|||
|
|
self.hotPartyView.frame = CGRectMake(layout_X, NavigationContentTopConstant + 5, bannerViewW, 49);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
-(SDCycleScrollView *)bannerView{
|
|||
|
|
if (!_bannerView) {
|
|||
|
|
_bannerView = [SDCycleScrollView creatViewInSuperView:self.view];
|
|||
|
|
_bannerView.localizationImageNamesGroup = @[@"nearbyBanner00",@"nearbyBanner01",@"nearbyBanner02"];
|
|||
|
|
_bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
|
|||
|
|
_bannerView.autoScrollTimeInterval = 3;
|
|||
|
|
_bannerView.currentPageDotColor = COLOR_WITH_RGB(0xFFFFFF);
|
|||
|
|
_bannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
|||
|
|
_bannerView.pageDotColor =COLOR_WITH_RGB_A(0x000000, 0.7);
|
|||
|
|
// _cycleScrollView.showPageControl
|
|||
|
|
// UIPageControlContentView
|
|||
|
|
_bannerView.delegate = self;
|
|||
|
|
_bannerView.backgroundColor = [UIColor whiteColor];
|
|||
|
|
_bannerView.layer.cornerRadius = 8;
|
|||
|
|
_bannerView.layer.masksToBounds = YES;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return _bannerView;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// SDCycleScrollViewDelegate
|
|||
|
|
///点击图片回调
|
|||
|
|
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
|||
|
|
NSArray* dataArray = @[
|
|||
|
|
@{@"title":@"产品介绍",
|
|||
|
|
@"urlStr":@"https://iquanpai.com/app-h5/4_141.html"},
|
|||
|
|
@{@"title":@"文明公约",
|
|||
|
|
@"urlStr":@"https://iquanpai.com/app-h5/4_142.html"},
|
|||
|
|
@{@"title":@"精选推荐",
|
|||
|
|
@"urlStr":@"https://iquanpai.com/app-h5/4_143.html"}
|
|||
|
|
];
|
|||
|
|
NSDictionary* dataDict = dataArray[index];
|
|||
|
|
[PYAppService openWebVCWithTitle:dataDict[@"title"] url:dataDict[@"urlStr"]];
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
#pragma mark - OldCode
|
|||
|
|
- (void)viewDidLoad {
|
|||
|
|
[super viewDidLoad];
|
|||
|
|
[self startLoading];
|
|||
|
|
// [BottleService getHomeBottleInfoWithCompletion:^(HomeBottleInfo * _Nullable info) {
|
|||
|
|
NSLog(@"self.info 1111111:%@",self.info);
|
|||
|
|
// self.info = info;
|
|||
|
|
// [self endLoading:nil];
|
|||
|
|
// [self setupUI];
|
|||
|
|
// }];
|
|||
|
|
[self creatSubViews];
|
|||
|
|
|
|||
|
|
|
|||
|
|
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|||
|
|
leftBtn.frame = CGRectMake(0, 0, FIX_SIZE(24), FIX_SIZE(24));
|
|||
|
|
[leftBtn setImage:ImageNamed(@"TH_chat_bottle_icon") forState:UIControlStateNormal];
|
|||
|
|
[leftBtn addTarget:self action:@selector(getBottle) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
|
|||
|
|
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
|
|||
|
|
|
|||
|
|
|
|||
|
|
UIButton *navBottleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|||
|
|
navBottleBtn.frame = CGRectMake(0, 0, FIX_SIZE(64), FIX_SIZE(29));
|
|||
|
|
[navBottleBtn setImage:ImageNamed(@"TH_navItemBottlePublic") forState:UIControlStateNormal];
|
|||
|
|
[navBottleBtn addTarget:self action:@selector(hurlBottleBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
|
|||
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:navBottleBtn];
|
|||
|
|
|
|||
|
|
#pragma mark -- 为什么这里要再重复写一个?
|
|||
|
|
// [self refreshHomeBottleData];
|
|||
|
|
|
|||
|
|
[self creatTopUI];
|
|||
|
|
|
|||
|
|
[self initNotificationAlert];
|
|||
|
|
|
|||
|
|
// 总结:UIApplicationWillEnterForegroundNotification:只有回到前台,启动 app 不算UIApplicationDidBecomeActiveNotification:回到前台 + 启动 app如果两条通知都监听,那么 UIApplicationWillEnterForegroundNotification 是要早于 UIApplicationDidBecomeActiveNotification。
|
|||
|
|
|
|||
|
|
|
|||
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive) name:UIApplicationWillEnterForegroundNotification object:nil];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
-(void)creatTopUI
|
|||
|
|
{
|
|||
|
|
UIButton *topView = [[UIButton alloc]init];
|
|||
|
|
[self.view addSubview:topView];
|
|||
|
|
topView.frame = CGRectMake(FIX_SIZE(22), NAVIGATION_BAR_HEIGHT, SCREEN_WIDTH-FIX_SIZE(45), 49);
|
|||
|
|
topView.backgroundColor = COLOR_WITH_RGB(0x29253E);
|
|||
|
|
[topView addTarget:self action:@selector(topClick) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
topView.layer.cornerRadius = 8;
|
|||
|
|
topView.layer.masksToBounds = YES;
|
|||
|
|
|
|||
|
|
UIImageView *icon = [[UIImageView alloc]init];
|
|||
|
|
[topView addSubview:icon];
|
|||
|
|
// icon.frame = CGRectMake(12, 10, 30, 20);
|
|||
|
|
icon.sd_layout.leftSpaceToView(topView, 10).centerYEqualToView(topView).widthIs(16).heightIs(16);
|
|||
|
|
icon.image = [UIImage imageNamed:@"TH_hotFile"];
|
|||
|
|
|
|||
|
|
UILabel *title = [[UILabel alloc]init];
|
|||
|
|
[topView addSubview:title];
|
|||
|
|
title.sd_layout.centerYEqualToView(topView).heightIs(21).leftSpaceToView(icon, 3);
|
|||
|
|
[title setSingleLineAutoResizeWithMaxWidth:220];
|
|||
|
|
title.text = @"酒馆派对火热进行中......";
|
|||
|
|
title.textColor = [UIColor whiteColor];
|
|||
|
|
title.font = [UIFont systemFontOfSize:15];
|
|||
|
|
|
|||
|
|
UIButton *arrow = [UIButton buttonWithType:UIButtonTypeCustom];
|
|||
|
|
[topView addSubview:arrow];
|
|||
|
|
arrow.sd_layout.rightSpaceToView(topView, 9).centerYEqualToView(topView).widthIs(18).heightIs(18);
|
|||
|
|
[arrow setImage:[UIImage imageNamed:@"TH_hotArrow"] forState:UIControlStateNormal];
|
|||
|
|
|
|||
|
|
|
|||
|
|
UILabel *countLab = [[UILabel alloc]init];
|
|||
|
|
[topView addSubview:countLab];
|
|||
|
|
// countLab.frame = CGRectMake(SCREEN_WIDTH-130, 10, 120, 18);
|
|||
|
|
countLab.sd_layout.rightSpaceToView(arrow, 1).centerYEqualToView(topView).heightIs(17);
|
|||
|
|
[countLab setSingleLineAutoResizeWithMaxWidth:120];
|
|||
|
|
// countLab.text = @"0次参与";
|
|||
|
|
countLab.textColor = [UIColor whiteColor];
|
|||
|
|
countLab.font = [UIFont systemFontOfSize:12];
|
|||
|
|
|
|||
|
|
[PYHTTPManager postWithPath:@"bottlecount" params:nil callback:^(id _Nullable rsp, NSError * _Nullable error) {
|
|||
|
|
|
|||
|
|
// UILabel *countLab = [[UILabel alloc]init];
|
|||
|
|
// [topView addSubview:countLab];
|
|||
|
|
//// countLab.frame = CGRectMake(SCREEN_WIDTH-130, 10, 120, 18);
|
|||
|
|
// countLab.sd_layout.rightSpaceToView(arrow, 1).centerYEqualToView(topView).heightIs(17);
|
|||
|
|
// [countLab setSingleLineAutoResizeWithMaxWidth:120];
|
|||
|
|
//// countLab.text = @"153.8w+次参与";
|
|||
|
|
// countLab.textColor = [UIColor whiteColor];
|
|||
|
|
// countLab.font = [UIFont systemFontOfSize:12];
|
|||
|
|
//
|
|||
|
|
// NSLog(@"rspCount===%@",rsp[@"count"]);
|
|||
|
|
|
|||
|
|
float count = [rsp[@"count"] floatValue];
|
|||
|
|
|
|||
|
|
if (count>=10000) {
|
|||
|
|
countLab.text = [NSString stringWithFormat:@"%.2f万次参与",count/10000.0];
|
|||
|
|
}else{
|
|||
|
|
countLab.text = [NSString stringWithFormat:@"%f次参与",count];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
-(void)topClick
|
|||
|
|
{
|
|||
|
|
BottleDetialController *deDetial = [[BottleDetialController alloc]init];
|
|||
|
|
|
|||
|
|
[self.navigationController pushViewController:deDetial animated:YES];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)onAppDidBecomeActive{
|
|||
|
|
if ([[PYAppService currentViewController] isKindOfClass:[BottleViewController class]]) {
|
|||
|
|
[self refreshHomeBottleData]; // 刷新数据
|
|||
|
|
// [self reloadMsgBadge];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)initNotificationAlert {
|
|||
|
|
NSDate *nowDate = [NSDate date];
|
|||
|
|
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|||
|
|
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
|
|||
|
|
NSString *strDate = [dateFormatter stringFromDate:nowDate];
|
|||
|
|
NSLog(@"%@", strDate);
|
|||
|
|
|
|||
|
|
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
|||
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|||
|
|
// 获取状态
|
|||
|
|
UNAuthorizationStatus authorizationStatus = settings.authorizationStatus;
|
|||
|
|
|
|||
|
|
//一天一次
|
|||
|
|
NSString *dateFlag = [[NSUserDefaults standardUserDefaults] objectForKey:OpenAppDayFlag];
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:strDate forKey:OpenAppDayFlag];
|
|||
|
|
|
|||
|
|
if (authorizationStatus == UNAuthorizationStatusNotDetermined) {
|
|||
|
|
if ([dateFlag isEqualToString:strDate]) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
NSNumber *flag = [[NSUserDefaults standardUserDefaults] objectForKey:NotificationAlertFlag];
|
|||
|
|
if (flag.intValue == 0){
|
|||
|
|
|
|||
|
|
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
|
|||
|
|
config.title = @"开通消息推送?";
|
|||
|
|
config.message = @"开通后第一时间收到Ta的消息";
|
|||
|
|
config.cancelTitle = @"下次";
|
|||
|
|
config.cancelHandler =^(MTAlertButton *button) {
|
|||
|
|
//第3天再提示
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(-2) forKey:NotificationAlertFlag];
|
|||
|
|
};
|
|||
|
|
config.otherTitle = @"允许";
|
|||
|
|
config.otherHandler = ^(MTAlertButton *button) {
|
|||
|
|
[self registNotification];
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(1) forKey:NotificationAlertFlag];
|
|||
|
|
};
|
|||
|
|
}];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flag.intValue < 0){
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(flag.intValue + 1) forKey:NotificationAlertFlag];
|
|||
|
|
}
|
|||
|
|
}else if (authorizationStatus == UNAuthorizationStatusDenied){
|
|||
|
|
if ([dateFlag isEqualToString:strDate]) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
NSNumber *flag = [[NSUserDefaults standardUserDefaults] objectForKey:NotificationAlertFlag];
|
|||
|
|
if (flag.intValue < 0){
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(flag.intValue + 1) forKey:NotificationAlertFlag];
|
|||
|
|
}else if (flag.intValue > 0){
|
|||
|
|
//第5天再提示
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(-4) forKey:NotificationAlertFlag];
|
|||
|
|
}else{
|
|||
|
|
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
|
|||
|
|
config.title = @"不错过Ta的消息";
|
|||
|
|
config.message = @"打开推送,畅快聊";
|
|||
|
|
config.cancelTitle = @"下次";
|
|||
|
|
config.cancelHandler =^(MTAlertButton *button) {
|
|||
|
|
//第3天再提示
|
|||
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(-4) forKey:NotificationAlertFlag];
|
|||
|
|
};
|
|||
|
|
config.otherTitle = @"OK";
|
|||
|
|
config.otherHandler = ^(MTAlertButton *button) {
|
|||
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|||
|
|
};
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
[self registNotification];
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 向苹果后台请求 DeviceToken
|
|||
|
|
- (void)registNotification
|
|||
|
|
{
|
|||
|
|
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
|
|||
|
|
{
|
|||
|
|
[[UIApplication sharedApplication] registerUserNotificationSettings:
|
|||
|
|
[UIUserNotificationSettings settingsForTypes:
|
|||
|
|
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)
|
|||
|
|
categories:nil]];
|
|||
|
|
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
|
|||
|
|
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 注册远程通知
|
|||
|
|
[GeTuiSdk registerRemoteNotification: (UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|||
|
|
[super viewWillAppear:animated];
|
|||
|
|
|
|||
|
|
[self refreshHomeBottleData];
|
|||
|
|
|
|||
|
|
// [self reloadMsgBadge];
|
|||
|
|
[self reloadHurlBottoleButtonBadge];
|
|||
|
|
if (self.disappearTime > 0) {
|
|||
|
|
// 从其它tab切换回瓶子tab,如果间隔时间超过5分钟,自动刷新瓶子tab(有loading)
|
|||
|
|
if ([[NSDate date] timeIntervalSince1970] - self.disappearTime > 60 * 5) { // 5分钟
|
|||
|
|
[self refreshHomeBottleData]; // 刷新数据
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
self.disappearTime = 0;
|
|||
|
|
|
|||
|
|
|
|||
|
|
[self getNoticeCount];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
-(void)getNoticeCount
|
|||
|
|
{
|
|||
|
|
[UserService getUserInfoWithCompletion:^(User * _Nonnull user) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewDidDisappear:(BOOL)animated {
|
|||
|
|
[super viewDidDisappear:animated];
|
|||
|
|
|
|||
|
|
if ([PYAppService selectedTabItemIndex] != 1) {
|
|||
|
|
self.disappearTime = [[NSDate date] timeIntervalSince1970];
|
|||
|
|
} else {
|
|||
|
|
self.disappearTime = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)reloadMsgBadge {
|
|||
|
|
[LoginService launchAppToHomeWithCompletion:^(id _Nullable rsp, NSError * _Nullable error) {
|
|||
|
|
if (!error) {
|
|||
|
|
int unreadCount = [rsp[@"unread_notice"] intValue];
|
|||
|
|
self.getBottleButton.badgeCenterOffset = CGPointMake(-FIX_SIZE(5), FIX_SIZE(5));
|
|||
|
|
if (unreadCount > 0) {
|
|||
|
|
[self.getBottleButton showBadgeWithStyle:WBadgeStyleNumber value:unreadCount animationType:WBadgeAnimTypeNone];
|
|||
|
|
} else {
|
|||
|
|
[self.getBottleButton clearBadge];
|
|||
|
|
}
|
|||
|
|
[PYAppService showBadgeOnTabBarItemAtIndex:1 number:unreadCount];
|
|||
|
|
|
|||
|
|
|
|||
|
|
[PYAppService appConfig].is_wallet_notice = [rsp[@"is_wallet_notice"] intValue];
|
|||
|
|
[PYAppService appConfig].wallet_des = rsp[@"wallet_des"];
|
|||
|
|
if ([ProfileViewController shouldShowBadge]) {
|
|||
|
|
[PYAppService showBadgeOnTabBarItemAtIndex:0 number:-1];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (BOOL)isSupportContentScrollView {
|
|||
|
|
return YES;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//- (void)setupUI {
|
|||
|
|
// self.contentScrollView.alwaysBounceVertical = NO;
|
|||
|
|
// self.contentScrollView.alwaysBounceHorizontal = NO;
|
|||
|
|
// self.contentScrollView.showsVerticalScrollIndicator = NO;
|
|||
|
|
// self.contentScrollView.showsHorizontalScrollIndicator = NO;
|
|||
|
|
// self.contentScrollView.backgroundColor = [UIColor clearColor];
|
|||
|
|
// self.contentScrollView.contentInset = UIEdgeInsetsZero;
|
|||
|
|
// self.contentScrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - TAB_BAR_HEIGHT);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// 捞瓶子
|
|||
|
|
- (void)getBottle {
|
|||
|
|
[BottleReadView showDetailWithAttach];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
-(void)hurlBottleBtnClick{
|
|||
|
|
WeakSelf(self);
|
|||
|
|
if ([PYAppService showUploadAvatarAlertIfNeed]) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
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];
|
|||
|
|
}];
|
|||
|
|
}];
|
|||
|
|
PYNavigationViewController *nav = [[PYNavigationViewController alloc] initWithRootViewController:picker];
|
|||
|
|
[[PYAppService currentNavigationController] presentViewController:nav animated:YES completion:nil];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)reloadHurlBottoleButtonBadge {
|
|||
|
|
int number = self.info.left_bottle_num;
|
|||
|
|
[self.hurlBottleButton setBadgeFont:MT_FONT_MEDIUM_SIZE(13)];
|
|||
|
|
[self.hurlBottleButton setBadgeCenterOffset:CGPointMake(-FIX_SIZE(15), FIX_SIZE(15))];
|
|||
|
|
[self.hurlBottleButton setBadgeBgColor:THEME_COLOR];
|
|||
|
|
if (number < 0) {
|
|||
|
|
[self.hurlBottleButton showCustomBadgeWithContent:@"∞"];
|
|||
|
|
} else if (number > 0) {
|
|||
|
|
[self.hurlBottleButton showNumberBadgeWithValue:number];
|
|||
|
|
} else if (number == 0) {
|
|||
|
|
[self.hurlBottleButton showCustomBadgeWithContent:@"0"];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)refreshHomeBottleData {
|
|||
|
|
// [SVProgressHUD showWithStatus:nil];
|
|||
|
|
|
|||
|
|
[BottleService getHomeBottleInfoWithCompletion:^(HomeBottleInfo * _Nullable info) {
|
|||
|
|
[self endLoading:nil];
|
|||
|
|
if (info.bottleInfos.count <= 0) {
|
|||
|
|
[SVProgressHUD showErrorWithStatus:@"暂时没有新的瓶子啦"];
|
|||
|
|
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
|
|||
|
|
config.message = @" 更多推荐瓶子正在来的路上\n酒馆派对正在火热进行中🔥\n快去参与派对查看更多的瓶子吧~";
|
|||
|
|
config.otherTitle = @"查看更多瓶子";
|
|||
|
|
config.otherHandler = ^(MTAlertButton *button) {
|
|||
|
|
[self topClick];
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}];
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (info.toast_msg.length > 0) {
|
|||
|
|
[ToastUtil showToast:info.toast_msg];
|
|||
|
|
}
|
|||
|
|
// [SVProgressHUD dismiss];
|
|||
|
|
self.info = info;
|
|||
|
|
|
|||
|
|
NSLog(@"self.info==%@",self.info);
|
|||
|
|
|
|||
|
|
[self craetGoodBottal];
|
|||
|
|
|
|||
|
|
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
-(void)craetGoodBottal
|
|||
|
|
{
|
|||
|
|
// BottleInfo *info = self.info.bottleInfos[0];
|
|||
|
|
//
|
|||
|
|
// NSLog(@"首页是的%@",[info mj_keyValues]);
|
|||
|
|
|
|||
|
|
#pragma mark -- 不知道为什么要创建那么多?
|
|||
|
|
self.info.bottleInfos = [self.info.bottleInfos subarrayWithRange:NSMakeRange(0, 1)];
|
|||
|
|
|
|||
|
|
for (BottleInfo *info in self.info.bottleInfos) {
|
|||
|
|
|
|||
|
|
if (info.cover.length > 0) { // 有瓶子
|
|||
|
|
BottleReadView *readView = [BottleReadView showDetailWithBottleInfo:info Views:self.view isHome:YES shouldHideBottleAction:^(bool shouldHide) {
|
|||
|
|
|
|||
|
|
// [self.view addSubview:readView];
|
|||
|
|
|
|||
|
|
if (shouldHide) {
|
|||
|
|
info.cover = nil;
|
|||
|
|
// [collectionView reloadItemsAtIndexPaths:@[indexPath]];
|
|||
|
|
}
|
|||
|
|
}];
|
|||
|
|
readView.ishome = YES;
|
|||
|
|
// readView.qmui_top = self.bannerView.qmui_bottom + 5;
|
|||
|
|
[readView setDidLockMoreBottle:^{
|
|||
|
|
|
|||
|
|
[self topClick];
|
|||
|
|
|
|||
|
|
}];
|
|||
|
|
|
|||
|
|
// readView.dismissAction = ^(BOOL didClickNext) {
|
|||
|
|
//
|
|||
|
|
// if (didClickNext) {
|
|||
|
|
// [self refreshHomeBottleData];
|
|||
|
|
// }
|
|||
|
|
// };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
@end
|
|||
|
|
|
|||
|
|
|
|||
|
|
|