cdts/xdts-ios 3/TreeHole/Code/Features/Bottle/View/BottleReadView.m

1889 lines
88 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// BottleReadView.m
// TreeHole
//
// Created by on 2022/4/29.
//
#import "BottleReadView.h"
#import "MTAlertView.h"
#import "FSTextInputView.h"
#import "BottleService.h"
#import "MTActionSheet.h"
#import <V2TIMManager.h>
#import <IQKeyboardManager.h>
#import "BottlePhotoCollectionView.h"
#import "TZImagePickerController+MTImagePicker.h"
#import "ApplePayService.h"
#import "AudioPlayerView.h"
#import "MTChatRecordInputView.h"
#import "DDAudioManager.h"
#import "ProfileCardViewController.h"
#import "BottleDetialController.h"
@interface BottleReadView () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) PYImageView *genderImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *recommendButton;
@property (nonatomic, strong) UIButton *lastButton;
@property (nonatomic, strong) UIButton *nextButton;
@property (nonatomic, strong) UIButton *sendButton;
@property (nonatomic, strong) UIButton *closeButton;
@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) UIButton *abandonButton;
@property (nonatomic, strong) UIButton *buyButton;
@property (nonatomic, strong) UIButton *vipTipsButton;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *contentTypeLabel;
@property (nonatomic, strong) UILabel *contentNumberLabel;
@property (nonatomic, strong) FSTextInputView *contentInputView;
@property (nonatomic, strong) FSTextInputView *replyInputView; //
@property (nonatomic, assign) CGFloat replyInputMinHeight;
@property (nonatomic, assign) CGFloat replyInputMaxHeight;
@property (nonatomic, strong) BottleDetailInfo *detailInfo;
@property (nonatomic, strong) UIButton *reportButton;
@property (nonatomic, weak) MTAlertView *alertView;
@property (nonatomic, assign) BOOL didClickNext;
@property (nonatomic, assign) CGFloat originInputHeight;
@property (nonatomic, strong) BottleInfo *bottleInfo;
@property (nonatomic, strong) UIButton *tipsButton;
@property (nonatomic, assign) BOOL isAttach;
@property (nonatomic, assign) CGRect rectInWindow;
@property (nonatomic, strong) void(^shouldHideBottleAction)(BOOL);
@property (nonatomic, strong) UIView *contentBgImageView;
@property (nonatomic, strong) UIView *attachmentContentView;
@property (nonatomic, strong) BottleDetailInfo *lastDetailInfo;
@end
@implementation BottleReadView
- (void)layoutSubviews {
[super layoutSubviews];
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// self.qmui_shouldShowDebugColor = YES;
}
return self;
}
+ (instancetype)readView:(BOOL)ishome {
BottleReadView *views = [[BottleReadView alloc] init];
// view.width = SCREEN_WIDTH - FIX_SIZE(32.5) * 2;
views.width = SCREEN_WIDTH-FIX_SIZE(44);
// views.height = SCREEN_HEIGHT-50;
// views.y = 120;
WeakSelf(views);
UIImageView *contentBgImageView = [[UIImageView alloc] init];
contentBgImageView.image = ImageNamed(@"TH_bottleInfoCardBg");
contentBgImageView.width = views.width;
contentBgImageView.height = SCREEN_HEIGHT - NavigationContentTop - TabBarHeight - 150;
//(views.width * contentBgImageView.image.size.height / contentBgImageView.image.size.width) - TabBarHeight;
[views addSubview:contentBgImageView];
contentBgImageView.userInteractionEnabled = YES;
views.height = contentBgImageView.height-20;
contentBgImageView.qmui_left = FIX_SIZE(22);
views.contentBgImageView = contentBgImageView;
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.size = CGSizeMake(FIX_SIZE(32), FIX_SIZE(32));
backButton.x = FIX_SIZE(45);
backButton.y = FIX_SIZE(30);
[backButton setImage:ImageNamed(@"TH_bottle_alert_back_icon") forState:UIControlStateNormal];
backButton.hidden = YES;
[contentBgImageView addSubview:backButton];
views.backButton = backButton;
UILabel *contentTypeLabel = [[UILabel alloc] init];
contentTypeLabel.font = MT_FONT_BOLD_SIZE(30);
contentTypeLabel.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 1.0);
[contentTypeLabel sizeToFit];
contentTypeLabel.x = FIX_SIZE(20);
contentTypeLabel.y = FIX_SIZE(15);
[contentBgImageView addSubview:contentTypeLabel];
// contentTypeLabel.backgroundColor = [UIColor blueColor];
views.contentTypeLabel = contentTypeLabel;
UILabel *contentSubTypeLabel = [[UILabel alloc] init];
contentSubTypeLabel.font = MT_FONT_BOLD_SIZE(20);
contentSubTypeLabel.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 1.0);
[contentSubTypeLabel sizeToFit];
contentSubTypeLabel.x = contentTypeLabel.right + FIX_SIZE(4);
contentSubTypeLabel.centerY = contentTypeLabel.centerY;
[contentBgImageView addSubview:contentSubTypeLabel];
// contentSubTypeLabel.backgroundColor = [UIColor purpleColor];
contentSubTypeLabel.hidden = YES;
views.contentNumberLabel = contentSubTypeLabel;
PYImageView *genderImageView = [[PYImageView alloc] init];
genderImageView.width = FIX_SIZE(28);
genderImageView.height = FIX_SIZE(16);
genderImageView.y = FIX_SIZE(72);
genderImageView.x = contentTypeLabel.x;
[contentBgImageView addSubview:genderImageView];
views.genderImageView = genderImageView;
UIButton *reportButton = [UIButton buttonWithType:UIButtonTypeCustom];
[reportButton setTitle:@"举报" forState:UIControlStateNormal];
reportButton.size = CGSizeMake(FIX_SIZE(32), FIX_SIZE(25));
if ([UserService currentUser].is_manager) {
[reportButton setTitle:@"标为good瓶" forState:UIControlStateNormal];
reportButton.size = CGSizeMake(FIX_SIZE(62), FIX_SIZE(25));
[reportButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakviews dealBottle:@"good"];
}];
}else{
[reportButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"确认举报该内容";
config.cancelTitle = @"取消";
config.otherTitle = @"确认";
config.otherHandler = ^(MTAlertButton *button) {
[BottleService reportBottleWithBID:weakviews.detailInfo.bottle_id completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showSuccessWithStatus:@"举报成功"];
});
}
}];
};
}];
}];
}
reportButton.titleLabel.font = MT_FONT_REGULAR_SIZE(11);
[reportButton setTitleColor:COLOR_WITH_RGB(0x737373) forState:UIControlStateNormal];
reportButton.right = contentBgImageView.width - FIX_SIZE(20);
reportButton.centerY = genderImageView.centerY;
[contentBgImageView addSubview:reportButton];
views.reportButton = reportButton;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.x = genderImageView.right + FIX_SIZE(3);
titleLabel.width = reportButton.x - titleLabel.x - FIX_SIZE(10);
titleLabel.height = FIX_SIZE(26);
titleLabel.font = MT_FONT_REGULAR_SIZE(13);
titleLabel.textColor = COLOR_WITH_RGB(0xB3B3B3);
titleLabel.y = genderImageView.y;
// titleLabel.backgroundColor = [UIColor purpleColor];
[contentBgImageView addSubview:titleLabel];
titleLabel.height = genderImageView.height;
views.titleLabel = titleLabel;
UIButton *recommend = [UIButton buttonWithType:UIButtonTypeCustom];
// recommend.frame = CGRectMake(12, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
recommend.x = 12;
recommend.width = FIX_SIZE(77);
recommend.height = FIX_SIZE(32);
recommend.backgroundColor = [UIColor clearColor];
[recommend setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
recommend.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[recommend setTitle:@"上推荐?" forState:UIControlStateNormal];
if (ishome) {
[contentBgImageView addSubview:recommend];
}else
{
}
views.recommendButton = recommend;
// if([UserService currentUser].is_manager){
// detailInfo
UIButton *lastButton = [UIButton buttonWithType:UIButtonTypeCustom];
lastButton.width = FIX_SIZE(77);
lastButton.height = FIX_SIZE(32);
lastButton.backgroundColor = [UIColor clearColor];
[lastButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
lastButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[lastButton setTitle:@"上一个" forState:UIControlStateNormal];
if (ishome) {
lastButton.hidden = YES;
}else{
lastButton.hidden = NO;
[contentBgImageView addSubview:lastButton];
}
views.lastButton = lastButton;
// }
//
UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
nextButton.width = FIX_SIZE(77);
nextButton.height = FIX_SIZE(32);
nextButton.backgroundColor = [UIColor clearColor];
[nextButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
nextButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[nextButton setTitle:@"下一个" forState:UIControlStateNormal];
[contentBgImageView addSubview:nextButton];
views.nextButton = nextButton;
UIButton *sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
sendButton.width = FIX_SIZE(77);
sendButton.height = FIX_SIZE(32);
sendButton.backgroundColor = COLOR_WITH_RGB(0xFFBE00);
sendButton.layer.cornerRadius = FIX_SIZE(16);
sendButton.clipsToBounds = YES;
[sendButton setTitleColor:COLOR_WITH_RGB(0x040000) forState:UIControlStateNormal];
sendButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[sendButton setTitle:@"回应" forState:UIControlStateNormal];
sendButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:sendButton];
views.sendButton = sendButton;
nextButton.centerY = sendButton.centerY;
lastButton.centerY = sendButton.centerY;
recommend.centerY = sendButton.centerY;
if ([UserService currentUser].is_manager) {
int newCenterY = sendButton.centerY - 2;
UIButton *seBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
seBottleButton.width = FIX_SIZE(77);
seBottleButton.height = FIX_SIZE(32);
[seBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
seBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[seBottleButton setTitle:@" 普通瓶 " forState:UIControlStateNormal];
[seBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakviews dealBottle:@"normal"];
}];
seBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:seBottleButton];
[seBottleButton sizeToFit];
seBottleButton.centerY = newCenterY;
seBottleButton.left = FIX_SIZE(6);
int newLeft = seBottleButton.right;
UIButton *dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton.width = FIX_SIZE(46);
dealBottleButton.height = FIX_SIZE(32);
[dealBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealBottleButton setTitle:@" 标se瓶 " forState:UIControlStateNormal];
[dealBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakviews dealBottle:@"se"];
}];
dealBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealBottleButton];
[dealBottleButton sizeToFit];
dealBottleButton.centerY = newCenterY;
dealBottleButton.left = newLeft;
newLeft = dealBottleButton.right;
dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton.width = FIX_SIZE(46);
dealBottleButton.height = FIX_SIZE(32);
[dealBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealBottleButton setTitle:@" 下架 " forState:UIControlStateNormal];
[dealBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakviews dealBottle:@"undown"];
}];
dealBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealBottleButton];
[dealBottleButton sizeToFit];
dealBottleButton.centerY = newCenterY;
dealBottleButton.left = newLeft;
newLeft = dealBottleButton.right;
//
int YAdd = 24;
UIButton *dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton.width = FIX_SIZE(77);
dealAccountButton.height = FIX_SIZE(32);
[dealAccountButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealAccountButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealAccountButton setTitle:@" 处理瓶子 " forState:UIControlStateNormal];
[dealAccountButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
MTActionSheet *actionSheet = [[MTActionSheet alloc] initWithTitle:@"处理该瓶子标记为xx瓶子会把下架的瓶子再上架" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"下架该瓶子" otherButtonTitles:@"上架该瓶子", @"标记为普通瓶子", @"标记为Good瓶",
@"标记为se瓶", @"标记为porn瓶", @"标记为广告ad瓶", @"标记为adapp瓶", nil];
actionSheet.onClickAction = ^(MTActionSheet *sheet, NSInteger buttonIndex){
NSString *dealString = nil;
switch (buttonIndex) {
case 0:
dealString = @"undown";
break;
case 1:
dealString = @"normal";
break;
case 2:
dealString = @"normal";
break;
case 3:
dealString = @"good";
break;
case 4:
dealString = @"se";
break;
case 5:
dealString = @"porn";
break;
case 6:
dealString = @"ad";
break;
case 7:
dealString = @"adapp";
break;
default:
break;
}
if (dealString != nil) {
[weakviews dealBottle:dealString];
}else{
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.shouldBottomCancelButton = YES;
// config.title = @"处理瓶子失败";
// config.message = [NSString stringWithFormat:@"%ld号按钮不知道怎么处理", (long)buttonIndex];
// config.otherTitle = @"OK";
// }];
}
};
[actionSheet show];
}];
dealAccountButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealAccountButton];
[dealAccountButton sizeToFit];
dealAccountButton.centerY = sendButton.centerY + YAdd;
dealAccountButton.left = FIX_SIZE(6);
newLeft = dealAccountButton.right + 2;
dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton.width = FIX_SIZE(77);
dealAccountButton.height = FIX_SIZE(32);
[dealAccountButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealAccountButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealAccountButton setTitle:@" 处理账号 " forState:UIControlStateNormal];
[dealAccountButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[UserService dealUser:weakviews.detailInfo.user_id];
}];
dealAccountButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealAccountButton];
[dealAccountButton sizeToFit];
dealAccountButton.centerY = sendButton.centerY + YAdd;
dealAccountButton.left = newLeft;
newLeft = dealAccountButton.right + 2;
}
UIButton *abandonButton = [UIButton buttonWithType:UIButtonTypeCustom];
abandonButton.width = FIX_SIZE(87);
abandonButton.height = FIX_SIZE(40);
abandonButton.backgroundColor = [UIColor clearColor];
[abandonButton setTitleColor:COLOR_WITH_RGB(0x737373) forState:UIControlStateNormal];
abandonButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[abandonButton setTitle:@"放弃此瓶" forState:UIControlStateNormal];
abandonButton.bottom = contentBgImageView.height - FIX_SIZE(10);
[contentBgImageView addSubview:abandonButton];
views.abandonButton = abandonButton;
abandonButton.hidden = YES;
UIButton *buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
buyButton.height = FIX_SIZE(48);
buyButton.centerY = nextButton.centerY;
buyButton.backgroundColor = COLOR_WITH_RGB(0xFFBE00);
buyButton.layer.cornerRadius = FIX_SIZE(20);
buyButton.clipsToBounds = YES;
buyButton.titleLabel.font = MT_FONT_MEDIUM_SIZE(16);
[buyButton setTitleColor:COLOR_WITH_RGB(0x040000) forState:UIControlStateNormal];
[buyButton setTitle:@"开通VIP会员" forState:UIControlStateNormal];
buyButton.hidden = YES;
[contentBgImageView addSubview:buyButton];
views.buyButton = buyButton;
UIButton *vipTipsButton = [UIButton buttonWithType:UIButtonTypeCustom];
vipTipsButton.x = contentTypeLabel.x;
vipTipsButton.width = contentBgImageView.width - vipTipsButton.x * 2;
vipTipsButton.height = vipTipsButton.width / 2;
vipTipsButton.titleLabel.numberOfLines = 0;
vipTipsButton.titleLabel.textAlignment = NSTextAlignmentCenter;
vipTipsButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[vipTipsButton setTitleColor:COLOR_WITH_RGB(0xFFE8A1) forState:UIControlStateNormal];
[vipTipsButton setBackgroundImage:ImageNamed(@"pop_bottle_card") forState:UIControlStateNormal];
vipTipsButton.userInteractionEnabled = NO;
vipTipsButton.hidden = YES;
views.vipTipsButton = vipTipsButton;
FSTextInputView *replyInputView = [[FSTextInputView alloc] init];
replyInputView.x = FIX_SIZE(20);
replyInputView.width = contentBgImageView.width - replyInputView.x * 2;
replyInputView.textview.font = MT_FONT_REGULAR_SIZE(14);
views.replyInputMinHeight = FIX_SIZE(80);
views.replyInputMaxHeight = FIX_SIZE(120);
views.replyInputView = replyInputView;
UIView *lineView = [replyInputView addBottomSepetatorLineOffsetX:0];
lineView.y = 0;
replyInputView.placeHolderLabel.text = @"输入你想对Ta说的话";
replyInputView.placeHolderLabel.font = replyInputView.textview.font;
replyInputView.placeHolderLabel.textColor = COLOR_WITH_RGB(0x737373);
replyInputView.height = views.replyInputMinHeight;
replyInputView.padding = UIEdgeInsetsMake(10, 0, 10, 0);
[contentBgImageView insertSubview:replyInputView atIndex:0];
replyInputView.bottom = sendButton.y;
UILabel *timeLabel = [[UILabel alloc] init];
// timeLabel.hidden = YES;
timeLabel.height = FIX_SIZE(18);
timeLabel.x = replyInputView.x;
timeLabel.width = replyInputView.width;
timeLabel.bottom = replyInputView.y - FIX_SIZE(10);
timeLabel.font = MT_FONT_REGULAR_SIZE(11);
timeLabel.textColor = COLOR_WITH_RGB(0x737373);
[contentBgImageView addSubview:timeLabel];
views.timeLabel = timeLabel;
FSTextInputView *contentInputView = [[FSTextInputView alloc] init];
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineSpacing = 4;//
NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle };
contentInputView.textview.typingAttributes = attributes;
contentInputView.padding = UIEdgeInsetsZero;
contentInputView.backgroundColor = [UIColor clearColor];
contentInputView.x = timeLabel.x;
contentInputView.width = timeLabel.width;
contentInputView.y = titleLabel.bottom + FIX_SIZE(12);
contentInputView.textview.tintColor = COLOR_WITH_RGB(0xFFBE00);
contentInputView.height = timeLabel.y - FIX_SIZE(4) - contentInputView.y;
contentInputView.textview.font = contentInputView.placeHolderLabel.font = MT_FONT_REGULAR_SIZE(15);
contentInputView.textview.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.6);
contentInputView.placeHolderLabel.textColor = COLOR_WITH_RGB(0xC1C1C1);
contentInputView.textview.editable = NO;
[contentBgImageView addSubview:contentInputView];
views.contentInputView = contentInputView;
if ([UserService currentUser].is_manager) {
sendButton.right = contentInputView.right + FIX_SIZE(5);
nextButton.right = sendButton.x + FIX_SIZE(5);
}else{
sendButton.right = contentInputView.right;
nextButton.right = sendButton.x - FIX_SIZE(5);
lastButton.right = nextButton.x + FIX_SIZE(5);
}
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.titleLabel.font = [UIFont systemFontOfSize:13];
closeButton.layer.cornerRadius = FIX_SIZE(8);
closeButton.backgroundColor = [UIColor colorWithRed:165/255.0 green:113/255.0 blue:48/255.0 alpha:1];
closeButton.layer.masksToBounds = YES;
// [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
closeButton.titleLabel.textColor = HEX_COLOR(0x000000);
// closeButton.textAlignment = NSTextAlignmentCenter;
closeButton.titleLabel.font = MT_FONT_MEDIUM_SIZE(10);
if (ishome) {
closeButton.size = CGSizeMake(FIX_SIZE(28), FIX_SIZE(28));
closeButton.titleLabel.font = [UIFont systemFontOfSize:13];
closeButton.layer.cornerRadius = FIX_SIZE(8);
closeButton.backgroundColor = [UIColor colorWithRed:165/255.0 green:113/255.0 blue:48/255.0 alpha:1];
closeButton.backgroundColor = [UIColor clearColor];
closeButton.layer.masksToBounds = YES;
// [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
closeButton.titleLabel.textColor = HEX_COLOR(0x000000);
// closeButton.textAlignment = NSTextAlignmentCenter;
closeButton.titleLabel.font = MT_FONT_MEDIUM_SIZE(10);
[closeButton setImage:ImageNamed(@"TH_bottle_alert_close_icon") forState:UIControlStateNormal];
closeButton.hidden = NO;
// if ([UserService currentUser].vip_kind == 0 ||[UserService currentUser].vip_kind == -1){ //
// [closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// [closeButton setTitle:@"VIP" forState:UIControlStateNormal];
//
// closeButton.backgroundColor = [UIColor grayColor];
//
// }else{
//
// closeButton.size = CGSizeMake(FIX_SIZE(34), FIX_SIZE(16));
//
// if([UserService currentUser].vip_kind == 10){
// [closeButton setTitle:@"年VIP" forState:UIControlStateNormal];
//
// }else{
//
// [closeButton setTitle:@"VIP" forState:UIControlStateNormal];
//
// closeButton.hidden = NO;
// }
// }
}else{
[closeButton setImage:ImageNamed(@"TH_bottle_alert_close_icon") forState:UIControlStateNormal];
}
// [closeButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
// closeButton.backgroundColor = [UIColor redColor];
closeButton.right = contentBgImageView.width - FIX_SIZE(12.0);
closeButton.y = FIX_SIZE(12.0);
[contentBgImageView addSubview:closeButton];
views.closeButton = closeButton;
abandonButton.bottom = contentBgImageView.height - FIX_SIZE(10);
buyButton.bottom = abandonButton.y - FIX_SIZE(5);
buyButton.width = contentInputView.width;
abandonButton.centerX = buyButton.centerX = contentInputView.centerX;
[buyButton setBackgroundGradientColorWithBeginColorHex:0xFFBE00 endColorHex:0xFFECB4 gradientType:GradientColorTypeFromLeftToRight];
vipTipsButton.bottom = buyButton.y;
[contentBgImageView addSubview:vipTipsButton];
replyInputView.didChangeText = ^(FSTextInputView *inputView) {
UITextView *tempView = [[UITextView alloc] init];
tempView.font = inputView.textview.font;
tempView.width = inputView.textview.width;
tempView.text = inputView.textview.text;
tempView.attributedText = inputView.textview.attributedText;
[tempView sizeToFit];
CGFloat height = tempView.height + inputView.padding.top + inputView.padding.bottom;
height = MAX(height, weakviews.replyInputMinHeight);
height = MIN(height, weakviews.replyInputMaxHeight);
if (ABS(inputView.height - height) > 1) {
inputView.height = height;
inputView.bottom = sendButton.y;
timeLabel.bottom = replyInputView.y - FIX_SIZE(10);
contentInputView.height = timeLabel.y - FIX_SIZE(4) - contentInputView.y;
}
// [inputView.textview scrollRangeToVisible:inputView.textview.selectedRange];
};
return views;
}
+ (instancetype)showDetailWithBottleInfo:(BottleInfo *)bottleInfo Views:(UIView *)views isHome:(BOOL)ishome isAttach:(int)isAttach shouldHideBottleAction:(void(^)(bool shouldHide))shouldHideBottleAction {
BottleReadView *readView;
if (ishome) {
readView = [self readView:ishome];
readView.ishome = YES;
[[NSNotificationCenter defaultCenter] addObserver:readView selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
readView.shouldHideBottleAction = shouldHideBottleAction;
WeakSelf(readView);
MTAlertView *alertView;
if(!ishome){
alertView = [MTAlertView showAlertWithCustomView:readView];
}
WeakSelf(alertView);
if (ishome) {
[readView.closeButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
if ([UserService currentUser].vip_kind == 0 ||[UserService currentUser].vip_kind == -1){
// [weakalertView dismiss];
[ToastUtil showToast:@"您可以私聊送TA会员哦~"];
}else{
[ToastUtil showToast:@"VIP-小酒馆贵宾专属标识"];
}
}];
}else{
[weakalertView dismiss];
[readView.closeButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakalertView dismiss];
}];
}
alertView.didDismiss = ^(MTAlertView * alertView) {
if (weakreadView.dismissAction) {
weakreadView.dismissAction(weakreadView.didClickNext);
}
};
alertView.config.popupController.autoAdjustOffsetWhenKeyboardFrameChanged = NO;
readView.alertView = alertView;
[views addSubview:readView];
[readView loadDetaionInfo:bottleInfo isHome:ishome isNext:0 isAttach:isAttach bottleID:0 shouldHideBottleAction:shouldHideBottleAction];
[readView.recommendButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
// [SVProgressHUD showErrorWithStatus:@"优质瓶子才能上推荐,会员优先推荐哦~"];
[ToastUtil showToast:@"优质瓶子才能上推荐,会员优先推荐哦~"];
}];
[readView.lastButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
if([UserService currentUser].isVIP){
[weakreadView handleDidClickLastButton];
[weakreadView endEditing:YES];
[weakreadView.replyInputView clear];
weakreadView.lastDetailInfo = nil;
}else{
[ToastUtil showToast:@"尊贵的VIP才能使用此功能哦~"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[PYAppService showVipVC:@"vip_page"];
});
// [SVProgressHUD showErrorWithStatus:@"尊贵的VIP才能使用此功能哦~"];
}
}];
[readView.nextButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
weakreadView.lastDetailInfo = weakreadView.detailInfo;
NSLog(@"weakreadView.detailInfo===%d",weakreadView.detailInfo.bottle_id);
[weakreadView handleDidClickNextButton];
[weakreadView endEditing:YES];
[weakreadView.replyInputView clear];
}];
[readView.closeButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakreadView removeFromSuperview];
// [weakalertView dismiss];
}];
readView.rectInWindow = [readView convertRect:views.bounds toView:nil];
// CGRect frame = views.frame;
// readView.backgroundColor = [UIColor redColor];
CGFloat hotPartyViewH = 49;
CGFloat readViewTop = NavigationContentTop + 10 + hotPartyViewH + 10;
readView.frame = CGRectMake(0, readViewTop, SCREEN_WIDTH, SCREEN_HEIGHT - readViewTop - TabBarHeight);
readView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
return readView;
}else {
readView = [self readView];
readView.ishome = NO;
[[NSNotificationCenter defaultCenter] addObserver:readView
selector:@selector(keyboardWillChangeFrame:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
readView.shouldHideBottleAction = shouldHideBottleAction;
MTAlertView *alertView = [MTAlertView showAlertWithCustomView:readView];
WeakSelf(alertView);
WeakSelf(readView);
[readView.closeButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakalertView dismiss];
}];
alertView.didDismiss = ^(MTAlertView * alertView) {
if (weakreadView.dismissAction) {
weakreadView.dismissAction(weakreadView.didClickNext);
}
};
alertView.config.popupController.autoAdjustOffsetWhenKeyboardFrameChanged = NO;
readView.alertView = alertView;
[readView loadDetaionInfo:bottleInfo isHome:ishome isNext:0 isAttach:isAttach bottleID:0 shouldHideBottleAction:shouldHideBottleAction];
[readView.lastButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
if([UserService currentUser].isVIP){
[weakreadView handleDidClickLastButton];
[weakreadView endEditing:YES];
[weakreadView.replyInputView clear];
weakreadView.lastDetailInfo = nil;
}else{
[SVProgressHUD showErrorWithStatus:@"尊贵的VIP才能使用此功能哦~"];
[PYAppService showVipVC:@"vip_page"];
}
}];
[readView.nextButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
weakreadView.lastDetailInfo = weakreadView.detailInfo;
NSLog(@"12weakreadView.detailInfo==%d",weakreadView.detailInfo.bottle_id);
[weakreadView handleDidClickNextButton];
[weakreadView endEditing:YES];
[weakreadView.replyInputView clear];
}];
readView.rectInWindow = [readView convertRect:readView.bounds toView:nil];
return readView;
}
}
+ (instancetype)readView {
BottleReadView *view = [[BottleReadView alloc] init];
view.width = SCREEN_WIDTH - FIX_SIZE(32.5) * 2;
WeakSelf(view);
UIImageView *contentBgImageView = [[UIImageView alloc] init];
contentBgImageView.image = ImageNamed(@"TH_pop_bottle_bg");
contentBgImageView.width = view.width;
contentBgImageView.height = view.width * (contentBgImageView.image.size.height / contentBgImageView.image.size.width);
[view addSubview:contentBgImageView];
contentBgImageView.userInteractionEnabled = YES;
view.height = contentBgImageView.height;
view.contentBgImageView = contentBgImageView;
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.size = CGSizeMake(FIX_SIZE(32), FIX_SIZE(32));
backButton.x = FIX_SIZE(45);
backButton.y = FIX_SIZE(30);
[backButton setImage:ImageNamed(@"TH_bottle_alert_back_icon") forState:UIControlStateNormal];
backButton.hidden = YES;
[contentBgImageView addSubview:backButton];
view.backButton = backButton;
UILabel *contentTypeLabel = [[UILabel alloc] init];
contentTypeLabel.font = MT_FONT_BOLD_SIZE(30);
contentTypeLabel.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 1.0);
[contentTypeLabel sizeToFit];
contentTypeLabel.x = FIX_SIZE(20);
contentTypeLabel.y = FIX_SIZE(15);
[contentBgImageView addSubview:contentTypeLabel];
view.contentTypeLabel = contentTypeLabel;
UILabel *contentSubTypeLabel = [[UILabel alloc] init];
contentSubTypeLabel.font = MT_FONT_BOLD_SIZE(20);
contentSubTypeLabel.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 1.0);
[contentSubTypeLabel sizeToFit];
contentSubTypeLabel.x = contentTypeLabel.right + FIX_SIZE(4);
contentSubTypeLabel.centerY = contentTypeLabel.centerY;
[contentBgImageView addSubview:contentSubTypeLabel];
contentSubTypeLabel.hidden = YES;
view.contentNumberLabel = contentSubTypeLabel;
PYImageView *genderImageView = [[PYImageView alloc] init];
genderImageView.width = FIX_SIZE(28);
genderImageView.height = FIX_SIZE(16);
genderImageView.y = FIX_SIZE(63);
genderImageView.x = contentTypeLabel.x;
[contentBgImageView addSubview:genderImageView];
view.genderImageView = genderImageView;
UIButton *reportButton = [UIButton buttonWithType:UIButtonTypeCustom];
[reportButton setTitle:@"举报" forState:UIControlStateNormal];
reportButton.size = CGSizeMake(FIX_SIZE(32), FIX_SIZE(25));
if ([UserService currentUser].is_manager) {
[reportButton setTitle:@"标为good瓶" forState:UIControlStateNormal];
reportButton.size = CGSizeMake(FIX_SIZE(62), FIX_SIZE(25));
[reportButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakview dealBottle:@"good"];
}];
}else{
[reportButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"确认举报该内容";
config.cancelTitle = @"取消";
config.otherTitle = @"确认";
config.otherHandler = ^(MTAlertButton *button) {
[BottleService reportBottleWithBID:weakview.detailInfo.bottle_id completion:^(id _Nullable rsp, NSError * _Nullable error) {
NSLog(@"rsp===%@,error===%@",rsp,error);
if (!error) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showSuccessWithStatus:@"举报成功"];
});
}
}];
};
}];
}];
}
reportButton.titleLabel.font = MT_FONT_REGULAR_SIZE(11);
[reportButton setTitleColor:COLOR_WITH_RGB(0x737373) forState:UIControlStateNormal];
reportButton.right = contentBgImageView.width - FIX_SIZE(20);
reportButton.centerY = genderImageView.centerY;
[contentBgImageView addSubview:reportButton];
view.reportButton = reportButton;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.x = genderImageView.right + FIX_SIZE(3);
titleLabel.width = reportButton.x - titleLabel.x - FIX_SIZE(10);
titleLabel.height = FIX_SIZE(26);
titleLabel.font = MT_FONT_REGULAR_SIZE(13);
titleLabel.textColor = COLOR_WITH_RGB(0xB3B3B3);
titleLabel.y = genderImageView.y;
[contentBgImageView addSubview:titleLabel];
titleLabel.height = genderImageView.height;
view.titleLabel = titleLabel;
// if([UserService currentUser].is_manager){
// detailInfo
UIButton *lastButton = [UIButton buttonWithType:UIButtonTypeCustom];
lastButton.width = FIX_SIZE(77);
lastButton.height = FIX_SIZE(32);
lastButton.backgroundColor = [UIColor clearColor];
[lastButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
lastButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[lastButton setTitle:@"上一个" forState:UIControlStateNormal];
[contentBgImageView addSubview:lastButton];
view.lastButton = lastButton;
// }
//
UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
nextButton.width = FIX_SIZE(77);
nextButton.height = FIX_SIZE(32);
nextButton.backgroundColor = [UIColor clearColor];
[nextButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
nextButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[nextButton setTitle:@"下一个" forState:UIControlStateNormal];
[contentBgImageView addSubview:nextButton];
view.nextButton = nextButton;
UIButton *sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
sendButton.width = FIX_SIZE(77);
sendButton.height = FIX_SIZE(32);
sendButton.backgroundColor = COLOR_WITH_RGB(0xFFBE00);
sendButton.layer.cornerRadius = FIX_SIZE(16);
sendButton.clipsToBounds = YES;
[sendButton setTitleColor:COLOR_WITH_RGB(0x040000) forState:UIControlStateNormal];
sendButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[sendButton setTitle:@"回应" forState:UIControlStateNormal];
sendButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:sendButton];
view.sendButton = sendButton;
nextButton.centerY = sendButton.centerY;
lastButton.centerY = sendButton.centerY;
if ([UserService currentUser].is_manager) {
int newCenterY = sendButton.centerY - 2;
UIButton *seBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
seBottleButton.width = FIX_SIZE(77);
seBottleButton.height = FIX_SIZE(32);
[seBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
seBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[seBottleButton setTitle:@" 普通瓶 " forState:UIControlStateNormal];
[seBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakview dealBottle:@"normal"];
}];
seBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:seBottleButton];
[seBottleButton sizeToFit];
seBottleButton.centerY = newCenterY;
seBottleButton.left = FIX_SIZE(6);
int newLeft = seBottleButton.right;
UIButton *dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton.width = FIX_SIZE(46);
dealBottleButton.height = FIX_SIZE(32);
[dealBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealBottleButton setTitle:@" 标se瓶 " forState:UIControlStateNormal];
[dealBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakview dealBottle:@"se"];
}];
dealBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealBottleButton];
[dealBottleButton sizeToFit];
dealBottleButton.centerY = newCenterY;
dealBottleButton.left = newLeft;
newLeft = dealBottleButton.right;
dealBottleButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealBottleButton.width = FIX_SIZE(46);
dealBottleButton.height = FIX_SIZE(32);
[dealBottleButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealBottleButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealBottleButton setTitle:@" 下架 " forState:UIControlStateNormal];
[dealBottleButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[weakview dealBottle:@"undown"];
}];
dealBottleButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealBottleButton];
[dealBottleButton sizeToFit];
dealBottleButton.centerY = newCenterY;
dealBottleButton.left = newLeft;
newLeft = dealBottleButton.right;
//
int YAdd = 24;
UIButton *dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton.width = FIX_SIZE(77);
dealAccountButton.height = FIX_SIZE(32);
[dealAccountButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealAccountButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealAccountButton setTitle:@" 处理瓶子 " forState:UIControlStateNormal];
[dealAccountButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
MTActionSheet *actionSheet = [[MTActionSheet alloc] initWithTitle:@"处理该瓶子标记为xx瓶子会把下架的瓶子再上架" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"下架该瓶子" otherButtonTitles:@"上架该瓶子", @"标记为普通瓶子", @"标记为Good瓶",
@"标记为se瓶", @"标记为porn瓶", @"标记为广告ad瓶", @"标记为adapp瓶", nil];
actionSheet.onClickAction = ^(MTActionSheet *sheet, NSInteger buttonIndex){
NSString *dealString = nil;
switch (buttonIndex) {
case 0:
dealString = @"undown";
break;
case 1:
dealString = @"normal";
break;
case 2:
dealString = @"normal";
break;
case 3:
dealString = @"good";
break;
case 4:
dealString = @"se";
break;
case 5:
dealString = @"porn";
break;
case 6:
dealString = @"ad";
break;
case 7:
dealString = @"adapp";
break;
default:
break;
}
if (dealString != nil) {
[weakview dealBottle:dealString];
}else{
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.shouldBottomCancelButton = YES;
// config.title = @"处理瓶子失败";
// config.message = [NSString stringWithFormat:@"%ld号按钮不知道怎么处理", (long)buttonIndex];
// config.otherTitle = @"OK";
// }];
}
};
[actionSheet show];
}];
dealAccountButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealAccountButton];
[dealAccountButton sizeToFit];
dealAccountButton.centerY = sendButton.centerY + YAdd;
dealAccountButton.left = FIX_SIZE(6);
newLeft = dealAccountButton.right + 2;
dealAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
dealAccountButton.width = FIX_SIZE(77);
dealAccountButton.height = FIX_SIZE(32);
[dealAccountButton setTitleColor:COLOR_WITH_RGB(0xA5A5A5) forState:UIControlStateNormal];
dealAccountButton.titleLabel.font = MT_FONT_REGULAR_SIZE(12);
[dealAccountButton setTitle:@" 处理账号 " forState:UIControlStateNormal];
[dealAccountButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[UserService dealUser:weakview.detailInfo.user_id];
}];
dealAccountButton.bottom = contentBgImageView.height - FIX_SIZE(20);
[contentBgImageView addSubview:dealAccountButton];
[dealAccountButton sizeToFit];
dealAccountButton.centerY = sendButton.centerY + YAdd;
dealAccountButton.left = newLeft;
newLeft = dealAccountButton.right + 2;
}
UIButton *abandonButton = [UIButton buttonWithType:UIButtonTypeCustom];
abandonButton.width = FIX_SIZE(87);
abandonButton.height = FIX_SIZE(40);
abandonButton.backgroundColor = [UIColor clearColor];
[abandonButton setTitleColor:COLOR_WITH_RGB(0x737373) forState:UIControlStateNormal];
abandonButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[abandonButton setTitle:@"放弃此瓶" forState:UIControlStateNormal];
abandonButton.bottom = contentBgImageView.height - FIX_SIZE(10);
[contentBgImageView addSubview:abandonButton];
view.abandonButton = abandonButton;
abandonButton.hidden = YES;
UIButton *buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
buyButton.height = FIX_SIZE(48);
buyButton.centerY = nextButton.centerY;
buyButton.backgroundColor = COLOR_WITH_RGB(0xFFBE00);
buyButton.layer.cornerRadius = FIX_SIZE(20);
buyButton.clipsToBounds = YES;
buyButton.titleLabel.font = MT_FONT_MEDIUM_SIZE(16);
[buyButton setTitleColor:COLOR_WITH_RGB(0x040000) forState:UIControlStateNormal];
[buyButton setTitle:@"开通VIP会员" forState:UIControlStateNormal];
buyButton.hidden = YES;
[contentBgImageView addSubview:buyButton];
view.buyButton = buyButton;
UIButton *vipTipsButton = [UIButton buttonWithType:UIButtonTypeCustom];
vipTipsButton.x = contentTypeLabel.x;
vipTipsButton.width = contentBgImageView.width - vipTipsButton.x * 2;
vipTipsButton.height = vipTipsButton.width / 2;
vipTipsButton.titleLabel.numberOfLines = 0;
vipTipsButton.titleLabel.textAlignment = NSTextAlignmentCenter;
vipTipsButton.titleLabel.font = MT_FONT_REGULAR_SIZE(14);
[vipTipsButton setTitleColor:COLOR_WITH_RGB(0xFFE8A1) forState:UIControlStateNormal];
[vipTipsButton setBackgroundImage:ImageNamed(@"pop_bottle_card") forState:UIControlStateNormal];
vipTipsButton.userInteractionEnabled = NO;
vipTipsButton.hidden = YES;
view.vipTipsButton = vipTipsButton;
FSTextInputView *replyInputView = [[FSTextInputView alloc] init];
replyInputView.x = FIX_SIZE(20);
replyInputView.width = contentBgImageView.width - replyInputView.x * 2;
replyInputView.textview.font = MT_FONT_REGULAR_SIZE(14);
view.replyInputMinHeight = FIX_SIZE(80);
view.replyInputMaxHeight = FIX_SIZE(120);
view.replyInputView = replyInputView;
UIView *lineView = [replyInputView addBottomSepetatorLineOffsetX:0];
lineView.y = 0;
replyInputView.placeHolderLabel.text = @"输入你想对Ta说的话";
replyInputView.placeHolderLabel.font = replyInputView.textview.font;
replyInputView.placeHolderLabel.textColor = COLOR_WITH_RGB(0x737373);
replyInputView.height = view.replyInputMinHeight;
replyInputView.padding = UIEdgeInsetsMake(10, 0, 10, 0);
[contentBgImageView insertSubview:replyInputView atIndex:0];
replyInputView.bottom = sendButton.y;
UILabel *timeLabel = [[UILabel alloc] init];
// timeLabel.hidden = YES;
timeLabel.height = FIX_SIZE(18);
timeLabel.x = replyInputView.x;
timeLabel.width = replyInputView.width;
timeLabel.bottom = replyInputView.y - FIX_SIZE(10);
timeLabel.font = MT_FONT_REGULAR_SIZE(11);
timeLabel.textColor = COLOR_WITH_RGB(0x737373);
[contentBgImageView addSubview:timeLabel];
view.timeLabel = timeLabel;
FSTextInputView *contentInputView = [[FSTextInputView alloc] init];
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineSpacing = 4;//
NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle };
contentInputView.textview.typingAttributes = attributes;
contentInputView.padding = UIEdgeInsetsZero;
contentInputView.backgroundColor = [UIColor clearColor];
contentInputView.x = timeLabel.x;
contentInputView.width = timeLabel.width;
contentInputView.y = titleLabel.bottom + FIX_SIZE(12);
contentInputView.textview.tintColor = COLOR_WITH_RGB(0xFFBE00);
contentInputView.height = timeLabel.y - FIX_SIZE(4) - contentInputView.y;
contentInputView.textview.font = contentInputView.placeHolderLabel.font = MT_FONT_REGULAR_SIZE(15);
contentInputView.textview.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.6);
contentInputView.placeHolderLabel.textColor = COLOR_WITH_RGB(0xC1C1C1);
contentInputView.textview.editable = NO;
[contentBgImageView addSubview:contentInputView];
view.contentInputView = contentInputView;
if ([UserService currentUser].is_manager) {
sendButton.right = contentInputView.right + FIX_SIZE(5);
nextButton.right = sendButton.x + FIX_SIZE(5);
}else{
sendButton.right = contentInputView.right;
nextButton.right = sendButton.x - FIX_SIZE(5);
lastButton.right = nextButton.x + FIX_SIZE(5);
}
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.size = CGSizeMake(FIX_SIZE(28), FIX_SIZE(28));
[closeButton setImage:ImageNamed(@"TH_bottle_alert_close_icon") forState:UIControlStateNormal];
closeButton.right = contentBgImageView.width - FIX_SIZE(12.0);
closeButton.y = FIX_SIZE(12.0);
[contentBgImageView addSubview:closeButton];
view.closeButton = closeButton;
abandonButton.bottom = contentBgImageView.height - FIX_SIZE(10);
buyButton.bottom = abandonButton.y - FIX_SIZE(5);
buyButton.width = contentInputView.width;
abandonButton.centerX = buyButton.centerX = contentInputView.centerX;
[buyButton setBackgroundGradientColorWithBeginColorHex:0xFFBE00 endColorHex:0xFFECB4 gradientType:GradientColorTypeFromLeftToRight];
vipTipsButton.bottom = buyButton.y;
[contentBgImageView addSubview:vipTipsButton];
replyInputView.didChangeText = ^(FSTextInputView *inputView) {
UITextView *tempView = [[UITextView alloc] init];
tempView.font = inputView.textview.font;
tempView.width = inputView.textview.width;
tempView.text = inputView.textview.text;
tempView.attributedText = inputView.textview.attributedText;
[tempView sizeToFit];
CGFloat height = tempView.height + inputView.padding.top + inputView.padding.bottom;
height = MAX(height, weakview.replyInputMinHeight);
height = MIN(height, weakview.replyInputMaxHeight);
if (ABS(inputView.height - height) > 1) {
inputView.height = height;
inputView.bottom = sendButton.y;
timeLabel.bottom = replyInputView.y - FIX_SIZE(10);
contentInputView.height = timeLabel.y - FIX_SIZE(4) - contentInputView.y;
}
// [inputView.textview scrollRangeToVisible:inputView.textview.selectedRange];
};
return view;
}
- (void)handleDidClickLastButton {
self.didClickNext = NO;
NSLog(@"点击上一个bottle_id==%d,mj_keyValues%@",self.lastDetailInfo.bottle_id,[self.bottleInfo mj_keyValues]);
[self loadDetaionInfo:self.bottleInfo isHome:self.ishome isNext:0 isAttach:self.isAttach bottleID:self.lastDetailInfo.bottle_id shouldHideBottleAction:nil];
}
- (void)handleDidClickNextButton {
self.didClickNext = YES;
NSLog(@"点击下一个bottle_id==%d,mj_keyValues%@",self.lastDetailInfo.bottle_id,[self.bottleInfo mj_keyValues]);
[self loadNextDetaionInfo:self.bottleInfo isHome:self.ishome isNext:1 isAttach:self.isAttach bottleID:0 shouldHideBottleAction:nil];
}
+ (instancetype)showDetailWithBottleInfo:(BottleInfo *)bottleInfo Views:(UIView *)views isHome:(BOOL)ishome shouldHideBottleAction:(void(^)(bool shouldHide))shouldHideBottleAction {
return [self showDetailWithBottleInfo:bottleInfo Views:(UIView *)views isHome:ishome isAttach:0 shouldHideBottleAction:shouldHideBottleAction];
}
+ (void)showDetailWithAttach {
[self showDetailWithBottleInfo:nil Views:nil isHome:NO isAttach:1 shouldHideBottleAction:nil];
}
- (void)loadLastDetaionInfo:(BottleInfo *)bottleInfo isHome:(BOOL)ishome isNext:(int)isNext isAttach:(int)isAttach bottleID:(int)bottleID shouldHideBottleAction:(void(^)(bool shouldHide))shouldHideBottleAction {
self.bottleInfo = bottleInfo;
self.isAttach = isAttach;
BottleReadView *readView = self;
if (self.didClickNext) {
readView.lastButton.hidden = NO;
}else{
readView.lastButton.hidden = YES;
}
if ([UserService currentUser].is_manager > 0){
readView.lastButton.hidden = YES;
readView.recommendButton.hidden = YES;
// if (bottleInfo)
}
// readView.timeLabel.hidden = YES;
[SVProgressHUD showWithStatus:nil];
int loadSecond = 0.3;
if (isNext > 0) {
// loadSecond = 1.0;
}
/* (id
id232
id233
id234
id238
id235
id236
id237
**/
// bottleID = 234;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(loadSecond * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showWithStatus:nil];
[BottleService getBottleDetailInfoWithBID:bottleInfo.ID bottleType:bottleInfo.typeInfo.bottle_type isHome:ishome isNext:isNext isAttach:isAttach bottleID:0 completion:^(BottleDetailInfo * _Nullable detailInfo) {
[SVProgressHUD dismiss];
void (^action)(void) = ^{
if (isAttach) {
[readView.alertView dismiss];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
2023-07-27 18:25:18 +08:00
config.message = @"您关注的人最近发布的瓶子被看完了,您可以多关注一些同好哦~";
config.otherTitle = @"前往关注附近同好";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeToNearPage" object:nil];
};
2023-07-27 09:20:00 +08:00
}];
});
return;
} else {
if (ishome) {
[readView removeFromSuperview];
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @" 更多推荐瓶子正在来的路上\n酒馆派对正在火热进行中🔥\n快去参与派对查看更多的瓶子吧~";
config.otherTitle = @"查看更多瓶子";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
BottleDetialController *deDetial = [[BottleDetialController alloc]init];
[QMUIHelper.visibleViewController.navigationController pushViewController:deDetial animated:YES];
// if (self.didLockMoreBottle) {
// self.didLockMoreBottle();
//
// }
};
}];
if (isNext) {
}else{
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
// config.otherTitle = @"OK";
// config.otherHandler = ^(MTAlertButton *button) {
// [readView.alertView dismiss];
// };
// }];
}
}else{
if (isNext) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"小酒馆里所有的瓶子都被看完啦";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}else{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}
}
return;
}
};
if (!detailInfo) {
action();
}
[self updateUIWithDetailInfo:detailInfo];
}];
});
}
- (void)loadNextDetaionInfo:(BottleInfo *)bottleInfo isHome:(BOOL)ishome isNext:(int)isNext isAttach:(int)isAttach bottleID:(int)bottleID shouldHideBottleAction:(void(^)(bool shouldHide))shouldHideBottleAction {
self.bottleInfo = bottleInfo;
self.isAttach = isAttach;
BottleReadView *readView = self;
if (self.didClickNext) {
readView.lastButton.hidden = NO;
}else{
readView.lastButton.hidden = YES;
}
if ([UserService currentUser].is_manager > 0){
readView.lastButton.hidden = YES;
readView.recommendButton.hidden = YES;
// if (bottleInfo)
}
// readView.timeLabel.hidden = YES;
[SVProgressHUD showWithStatus:nil];
int loadSecond = 0.3;
if (isNext > 0) {
// loadSecond = 1.0;
}
/* (id
id232
id233
id234
id238
id235
id236
id237
**/
// bottleID = 234;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(loadSecond * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showWithStatus:nil];
[BottleService getBottleDetailInfoWithBID:bottleInfo.ID bottleType:bottleInfo.typeInfo.bottle_type isHome:ishome isNext:isNext isAttach:isAttach bottleID:0 completion:^(BottleDetailInfo * _Nullable detailInfo) {
[SVProgressHUD dismiss];
void (^action)(void) = ^{
if (isAttach) {
[readView.alertView dismiss];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
2023-07-27 18:25:18 +08:00
config.message = @"您关注的人最近发布的瓶子被看完了,您可以多关注一些同好哦~";
config.otherTitle = @"前往关注附近同好";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeToNearPage" object:nil];
};
2023-07-27 09:20:00 +08:00
}];
});
return;
} else {
if (ishome) {
[readView removeFromSuperview];
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @" 更多推荐瓶子正在来的路上\n酒馆派对正在火热进行中🔥\n快去参与派对查看更多的瓶子吧~";
config.otherTitle = @"查看更多瓶子";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
BottleDetialController *deDetial = [[BottleDetialController alloc]init];
[QMUIHelper.visibleViewController.navigationController pushViewController:deDetial animated:YES];
// if (self.didLockMoreBottle) {
// self.didLockMoreBottle();
//
// }
};
}];
if (isNext) {
}else{
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
// config.otherTitle = @"OK";
// config.otherHandler = ^(MTAlertButton *button) {
// [readView.alertView dismiss];
// };
// }];
}
}else{
if (isNext) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"小酒馆里所有的瓶子都被看完啦";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}else{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}
}
return;
}
};
if (!detailInfo) {
action();
}
[self updateUIWithDetailInfo:detailInfo];
}];
});
}
- (void)loadDetaionInfo:(BottleInfo *)bottleInfo isHome:(BOOL)ishome isNext:(int)isNext isAttach:(int)isAttach bottleID:(int)bottleID shouldHideBottleAction:(void(^)(bool shouldHide))shouldHideBottleAction {
self.bottleInfo = bottleInfo;
self.isAttach = isAttach;
BottleReadView *readView = self;
if (self.didClickNext) {
readView.lastButton.hidden = NO;
}else{
readView.lastButton.hidden = YES;
}
if ([UserService currentUser].is_manager > 0){
readView.lastButton.hidden = YES;
readView.recommendButton.hidden = YES;
// if (bottleInfo)
}
// readView.timeLabel.hidden = YES;
[SVProgressHUD showWithStatus:nil];
int loadSecond = 0.3;
if (isNext > 0) {
// loadSecond = 1.0;
}
/* (id
id232
id233
id234
id238
id235
id236
id237
**/
// bottleID = 234;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(loadSecond * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showWithStatus:nil];
[BottleService getBottleDetailInfoWithBID:bottleInfo.ID bottleType:bottleInfo.typeInfo.bottle_type isHome:ishome isNext:isNext isAttach:isAttach bottleID:bottleInfo.bottle_id completion:^(BottleDetailInfo * _Nullable detailInfo) {
[SVProgressHUD dismiss];
void (^action)(void) = ^{
if (isAttach) {
[readView.alertView dismiss];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
2023-07-27 18:25:18 +08:00
config.message = @"您关注的人最近发布的瓶子被看完了,您可以多关注一些同好哦~";
config.otherTitle = @"前往关注附近同好";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeToNearPage" object:nil];
};
2023-07-27 09:20:00 +08:00
}];
});
return;
} else {
if (ishome) {
[readView removeFromSuperview];
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @" 更多推荐瓶子正在来的路上\n酒馆派对正在火热进行中🔥\n快去参与派对查看更多的瓶子吧~";
config.otherTitle = @"查看更多瓶子";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
BottleDetialController *deDetial = [[BottleDetialController alloc]init];
[QMUIHelper.visibleViewController.navigationController pushViewController:deDetial animated:YES];
// if (self.didLockMoreBottle) {
// self.didLockMoreBottle();
//
// }
};
}];
if (isNext) {
}else{
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
// config.otherTitle = @"OK";
// config.otherHandler = ^(MTAlertButton *button) {
// [readView.alertView dismiss];
// };
// }];
}
}else{
if (isNext) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"小酒馆里所有的瓶子都被看完啦";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}else{
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.message = @"这个类型的瓶子你已经看完啦,换一个类型的瓶子看吧";
config.otherTitle = @"OK";
config.otherHandler = ^(MTAlertButton *button) {
[readView.alertView dismiss];
};
}];
}
}
return;
}
};
if (!detailInfo) {
action();
}
[self updateUIWithDetailInfo:detailInfo];
}];
});
}
- (BOOL)isExchangeBottle{
if ([self.detailInfo isExchangePhotos] || [self.detailInfo isExchangeVoice] || [self.detailInfo isExchangeSecret]){
return true;
}
return false;
}
- (void)gotoUserProfile {
[PYAppService pushViewControllerAnimated:[[ProfileCardViewController alloc] initWithUserID:self.detailInfo.user_id]];
}
- (void)updateUIWithDetailInfo:(BottleDetailInfo *)detailInfo {
[[DDAudioManager shareInstance] stopPlay];
BottleReadView *readView = self;
WeakSelf(readView);
self.detailInfo = detailInfo;
readView.genderImageView.image = [User genderImageWithGenderStr:detailInfo.gender_str];
readView.timeLabel.text = detailInfo.bottle_create_time;
if ([UserService currentUser].is_manager > 0) {
readView.reportButton.hidden = [detailInfo.user_operation_tag isEqualToString:@"good"];
readView.timeLabel.text = [NSString stringWithFormat:@"%@,%@", detailInfo.bottle_create_time, detailInfo.manager_info];
readView.timeLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc] initWithTarget:weakreadView action:@selector(gotoUserProfile)];
[readView.timeLabel addGestureRecognizer:ges];
}
NSLog(@"detailInfo.manager_info%@",detailInfo.manager_info);
readView.titleLabel.text = detailInfo.user_des;
readView.contentTypeLabel.text = detailInfo.bottle_type_name ?: @" ";
[readView.contentTypeLabel sizeToFit];
readView.contentNumberLabel.x = readView.contentTypeLabel.right + FIX_SIZE(4);
readView.contentNumberLabel.text = [NSString stringWithFormat:@"No.%d", detailInfo.bottle_num];
[readView.contentNumberLabel sizeToFit];
readView.contentNumberLabel.bottom = readView.contentTypeLabel.bottom;
readView.contentInputView.textview.text = detailInfo.content;
//
readView.contentInputView.height = self.timeLabel.y - FIX_SIZE(4) - self.contentInputView.y;
[self.attachmentContentView removeFromSuperview];
self.attachmentContentView = nil;
[self.sendButton setTitle:@"回应" forState:UIControlStateNormal];
if ([detailInfo hasAttachement]) {
UIView *attachmentContentView = [[UIView alloc] init];
self.attachmentContentView = attachmentContentView;
attachmentContentView.x = _genderImageView.x;
attachmentContentView.width = _reportButton.right - attachmentContentView.x;
UIView *attachementView = nil;
if ([detailInfo isPhotoAttachement]) {
BottlePhotoCollectionView *photoCollectionView = [BottlePhotoCollectionView collectionView];
photoCollectionView.width = attachmentContentView.width;
photoCollectionView.delegate = self;
photoCollectionView.dataSource = self;
[attachmentContentView addSubview:photoCollectionView];
attachementView = photoCollectionView;
// readView.contentInputView.height = self.timeLabel.y - FIX_SIZE(4) - self.contentInputView.y - 30;
} else if ([detailInfo isVoiceAttachement]) {
AudioPlayerView *audioPlayerView = [[AudioPlayerView alloc] initWithFrame:CGRectZero];
[audioPlayerView updateWithAudioUrl:detailInfo.voice seconds:detailInfo.voice_sec];
audioPlayerView.checkCanPlay = ^BOOL(AudioPlayerView * _Nonnull view) {
if (detailInfo.can_see) {
return YES;
} else {
[SVProgressHUD showInfoWithStatus:detailInfo.block_see_tips];
return NO;
}
};
[attachmentContentView addSubview:audioPlayerView];
attachementView = audioPlayerView;
// readView.contentInputView.height = self.timeLabel.y - FIX_SIZE(4) - self.contentInputView.y - 10;
}
// UILabel *attachementTipsLabel = [[UILabel alloc] init];
// attachementTipsLabel.width = attachmentContentView.width;
// attachementTipsLabel.height = FIX_SIZE(25);
// attachementTipsLabel.textColor = COLOR_WITH_RGB(0xA5A5A5);
// attachementTipsLabel.font = MT_FONT_REGULAR_SIZE(12);
// attachementTipsLabel.y = attachementView.bottom + FIX_SIZE(4);
// attachementTipsLabel.text = detailInfo.extra_des;
// [attachementTipsLabel sizeToFit];
// [attachmentContentView addSubview:attachementTipsLabel];
attachmentContentView.height = attachementView.bottom;
CGFloat maxInputViewHeight = _timeLabel.y - readView.contentInputView.y - attachmentContentView.height - FIX_SIZE(10);
[readView.contentInputView.textview sizeToFit];
readView.contentInputView.height = MIN(readView.contentInputView.textview.height + readView.contentInputView.padding.top + readView.contentInputView.padding.bottom, maxInputViewHeight);
attachmentContentView.y = readView.contentInputView.bottom + FIX_SIZE(8);
[readView.contentBgImageView insertSubview:attachmentContentView belowSubview:readView.contentInputView];
}
self.replyInputView.userInteractionEnabled = !detailInfo.disable_reply_edit;
self.replyInputView.textview.contentOffset = CGPointZero;
self.replyInputView.placeHolderLabel.text = detailInfo.reply_edit_placehold.length > 0 ? detailInfo.reply_edit_placehold : @"输入你想对Ta说的话";
if ([self isExchangeBottle]) {
[self.sendButton setTitle:@"交换" forState:UIControlStateNormal];
} else if ([detailInfo isShellPhotos]) {
[self.sendButton setTitle:detailInfo.price_des forState:UIControlStateNormal];
}
[readView.sendButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
__block NSString *imageURL = nil;
__block NSString *voiceURL = nil;
__block int voiceSec = 0;
void (^reply)(void) = ^{
[BottleService recordReplyBottleWithBID:detailInfo.bottle_id replyContent:weakreadView.replyInputView.content imageURL:imageURL voiceURL:voiceURL voiceSec:voiceSec completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
if ([weakreadView isExchangeBottle]) { //
// 11
// 0.5
2023-07-27 18:25:18 +08:00
[weakreadView.alertView dismiss];
2023-07-27 09:20:00 +08:00
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
User *user = [[User alloc] init];
user.im_user_id = detailInfo.im_user_id;
user.gender_str = detailInfo.gender_str;
user.nickname = detailInfo.nick_name;
[PYAppService chatWithUser:user];
[ToastUtil showToast:@"彼此交换成功,请查收"];
[weakreadView removeFromSuperview];
2023-07-27 18:25:18 +08:00
2023-07-27 09:20:00 +08:00
});
return;
}
//IM
[SVProgressHUD showSuccessWithStatus:@"回应成功"];
[weakreadView endEditing:YES];
[weakreadView.replyInputView clear];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakreadView handleDidClickNextButton];
});
// NSString *content = [NSString stringWithFormat:@"%@\n-----------\n%@", detailInfo.content, weakreadView.replyInputView.content];
// [[V2TIMManager sharedInstance] sendC2CTextMessage:content to:detailInfo.im_user_id succ:^{
//
// } fail:^(int code, NSString *desc) {
//
// }];
}
}];
};
if (detailInfo.isExchangePhotos) { //
TZImagePickerController *picker = [TZImagePickerController mt_imagePickerWithMaxImagesCount:1 didFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
if (photos.count > 0) {
[SVProgressHUD showWithStatus:nil];
[PYHTTPManager uploadFileWithScene:AliOSSUploadSceneBottlePhoto data:compressImageToDataIfNeed(photos[0]) completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
imageURL = rsp;
reply();
}
}];
}
}];
[[PYAppService currentNavigationController] presentViewController:picker animated:YES completion:nil];
return;
} else if (detailInfo.isShellPhotos) { //
[ApplePayService startBottlePay:detailInfo.iap_id isFastBuy:YES bottleID:detailInfo.bottle_id];
return;
} else if (detailInfo.isExchangeVoice) { //
MTChatRecordInputView *voiceRecordView = [[MTChatRecordInputView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, FIX_SIZE(218) + homeIndicatorHeight())];
zhPopupController *popupVC = [MTAlertView showActionSheetWithCustomView:voiceRecordView];
WeakSelf(popupVC);
voiceRecordView.backgroundColor = BG_COLOR;
voiceRecordView.completion = ^(NSString *path, int second) {
[SVProgressHUD showWithStatus:nil];
[PYHTTPManager uploadFileWithScene:AliOSSUploadSceneBottleVoice data:[NSData dataWithContentsOfFile:path] completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
[weakpopupVC dismiss];
voiceURL = rsp;
voiceSec = second;
reply();
}
}];
};
return;
}
if (weakreadView.replyInputView.content.length <= 0) {
if (![weakreadView.replyInputView.textview isFirstResponder]) {
[weakreadView.replyInputView.textview becomeFirstResponder];
return;
}
[SVProgressHUD showInfoWithStatus:@"回应内容不能为空"];
return;
}
if ([PYAppService showUploadAvatarAlertIfNeed]) {
return;
}
reply();
}];
//#if DEBUG && 1
// readView.contentInputView.textview.text = @"网上认识了一个男生,挺喜欢的,第一次见面就好像很久不见,第一次见面他牵我手了,我没拒绝,后面送我回家准备亲我,但是我拒绝了,然后第二次见面,我们就亲了。我其实没有想到我会这么快妥协,因为我自己本身是一个挺理智的人吧,后面他想做更亲密的行为,我拒绝了,因为我觉得这个过程太快了,我真的都还不是很了解他这个人,所以我无法说服自己,我们平时微信很少聊天,见面就是去酒店,他也说他想结婚,其实我也想,但是我真的对他这个人的有很多疑惑的点的我也不知道我是不是只是他满足私欲的工具人,所以很纠结,这感情要不要继续,如果一个男生真的喜欢你,也是应该会尊重你自己的感受的吧,但是我心里真的很没有安全感,我不知道我应该怎么办了";
// detailInfo.need_vip = YES;
// detailInfo.vip_des = @"为保障回应内容的质量 秘密、相亲、心事等";
//#endif
if (self.shouldHideBottleAction) {
self.shouldHideBottleAction(detailInfo.need_vip == 0);
}
WeakSelf(self);
readView.sendButton.hidden = readView.nextButton.hidden = NO;
readView.vipTipsButton.hidden = YES;
readView.buyButton.hidden = YES;
readView.abandonButton.hidden = YES;
[readView.tipsButton removeFromSuperview];
if (detailInfo.need_vip) {
readView.lastButton.hidden = YES;
readView.sendButton.hidden = readView.nextButton.hidden = YES;
readView.vipTipsButton.hidden = NO;
readView.buyButton.hidden = NO;
readView.contentInputView.textview.userInteractionEnabled = NO;
[readView.vipTipsButton setTitle:detailInfo.vip_des forState:UIControlStateNormal];
[[NSNotificationCenter defaultCenter] addObserver:weakself selector:@selector(onBuyVIPSuccess) name:BuyVIPSuccessNotification object:nil];
[readView.buyButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[PYAppService showVipVC:@"vip_bottle"];
}];
if (detailInfo.vip_bottle == 1) { //
readView.abandonButton.hidden = NO;
[readView.abandonButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) {
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.title = detailInfo.alert_title;
config.message = detailInfo.alert_content;
config.cancelTitle = @"放弃Ta";
config.cancelHandler = ^(MTAlertButton *button) {
[PYHTTPManager postWithPath:@"readbottle" params:@{
@"bottle_id": @(detailInfo.bottle_id)
} callback:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
[weakself handleDidClickNextButton];
}
}];
};
config.otherTitle = @"开通VIP";
config.otherHandler = ^(MTAlertButton *button) {
[PYAppService showVipVC:@"vip_bottle_twice"];
//[PYAppService buyTryVIP];
};
}];
}];
}
// detailInfo.vip_promotion_des = @"限量特惠啊啊啊";
if (detailInfo.vip_promotion_des.length > 0) {
UIButton *tipsButton = [UIButton buttonWithType:UIButtonTypeCustom];
tipsButton.userInteractionEnabled = NO;
[tipsButton setTitle:detailInfo.vip_promotion_des forState:UIControlStateNormal];
tipsButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, FIX_SIZE(4), 0);
tipsButton.titleLabel.font = MT_FONT_REGULAR_SIZE(11);
[tipsButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[tipsButton sizeToFit];
tipsButton.width += FIX_SIZE(8);
UIImage *bgImage = [[UIImage imageNamed:@"TH_discount_tag_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 25, 10, 10) resizingMode:UIImageResizingModeStretch];
[tipsButton setBackgroundImage:bgImage forState:UIControlStateNormal];
tipsButton.y = readView.buyButton.y - FIX_SIZE(10);
tipsButton.x = readView.buyButton.centerX;
[readView.buyButton.superview addSubview:tipsButton];
self.tipsButton = tipsButton;
}
}
if (detailInfo.isShellPhotos) { //
[[NSNotificationCenter defaultCenter] addObserver:weakself selector:@selector(onBuyBottleSuccess) name:BuyBottleSuccessNotification object:nil];
}
}
- (void)onBuyBottleSuccess{
[SVProgressHUD dismiss];
User *user = [[User alloc] init];
user.im_user_id = self.detailInfo.im_user_id;
user.nickname = self.detailInfo.nick_name;
user.gender_str = self.detailInfo.gender_str;
[PYAppService chatWithUser:user];
[ToastUtil showToast:@"购买成功"];
}
- (void)dealBottle:(NSString *)operation{
[BottleService dealBottleWithBID:self.detailInfo.bottle_id operation:operation completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ToastUtil showToast:[NSString stringWithFormat:@"处理瓶子操作:%@", operation]];
});
}
}];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)onBuyVIPSuccess {
//
self.didClickNext = NO;
[self loadDetaionInfo:self.bottleInfo isHome:NO isNext:NO isAttach:self.isAttach bottleID:self.bottleInfo.ID shouldHideBottleAction:nil];
}
- (void)keyboardWillChangeFrame:(NSNotification *)noti {
NSDictionary *userInfo = noti.userInfo;
CGRect keyboardRect = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
BOOL isShow = keyboardRect.origin.y < SCREEN_HEIGHT;
CGFloat offsetY = keyboardRect.origin.y - CGRectGetMaxY(self.rectInWindow);
if (isShow) {
self.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, offsetY);
} else {
self.transform = CGAffineTransformIdentity;
}
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.detailInfo.images.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
BottlePhotoCollectionCell *cell = (BottlePhotoCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:BottlePhotoCollectionCellReuseID forIndexPath:indexPath];
cell.photoImageView.imageUrl = self.detailInfo.images[indexPath.item];
cell.bottle_id = self.detailInfo.bottle_id;
NSMutableArray* mImagersArray = [NSMutableArray arrayWithArray:self.detailInfo.images];
cell.deleClickBlock = ^(NSString * _Nonnull imgURL) {
[mImagersArray removeObject:imgURL];
self.detailInfo.images = [mImagersArray copy];
[collectionView reloadData];
};
return cell;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.detailInfo.can_see > 0){
//
[PYAppService showImageBrowserWithImageURLs:self.detailInfo.images index:indexPath.item];
}else{
[SVProgressHUD showInfoWithStatus:self.detailInfo.block_see_tips];
}
}
@end