// // YOUPAILZMessageGuideVC.m // MSYOUPAI // // Created by CY on 2022/3/23. // Copyright © 2022 MS. All rights reserved. // #import "YOUPAILZMessageGuideVC.h" @interface YOUPAILZMessageGuideVC () @property (nonatomic,weak)UIView *guideV; @property (nonatomic,weak)UIView *guideSendV; @property (nonatomic,weak)UIView *frontV; @property (nonatomic,weak)UIScrollView *scrollView; @property (nonatomic,strong)NSArray *leftMessages; @property (nonatomic,assign)NSInteger leftMessageIndex; @property (nonatomic,assign)NSInteger sendMessageCount; @property (nonatomic,weak) UIButton *sendBtn; @property (nonatomic,strong) NSMutableArray *messageMoneyBtns; @property (nonatomic, weak) UIImageView *tipImgV; @property (nonatomic, weak) UILabel *tipL; @end @implementation YOUPAILZMessageGuideVC - (void)viewDidLoad { [super viewDidLoad]; self.sendMessageCount = 0; self.leftMessageIndex = 0; self.messageMoneyBtns = [NSMutableArray array]; self.leftMessages = @[@"欢迎来到相语欢颜",@"在相语欢颜,每回复一条消息,都可以获得现金,现金可无门槛提现哦",@"快回复消息试试?",@"回复消息越及时,得到的现金也越多",@"通过真人认证后,所获得的现金将翻倍",@"通过头像审核,才可开始获得现金哦,你准备好了吗?"]; self.title = @"官方客服"; self.navigationItem.rightBarButtonItems = @[[UIBarButtonItem itemWithTarget:self action:@selector(youpaifuserSetClick) image:[UIImage imageNamed:@"vqu_images_IM_im_details"]]]; [self youpaifinitUI]; [self youpaifinitGuideView]; } - (void)youpaifinitUI{ UIView *footerV = [[UIView alloc] init]; footerV.backgroundColor = [UIColor whiteColor]; [self.view addSubview:footerV]; [footerV mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.left.right.offset(0.0f); make.height.offset(55.0f + 47.0f + SafeHeight); }]; //修改inputview 按钮 注释 by leo UIButton *recordBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [recordBtn setImage:[UIImage imageNamed:@"vqu_images_IM_im_record"] forState:UIControlStateNormal]; [footerV addSubview:recordBtn]; UIButton *sayHiBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [sayHiBtn setImage:[UIImage imageNamed:@"vqu_images_IM_im_sayhi"] forState:UIControlStateNormal]; [footerV addSubview:sayHiBtn]; UIButton *photoBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [photoBtn setImage:[UIImage imageNamed:@"vqu_images_IM_photo"] forState:UIControlStateNormal]; [footerV addSubview:photoBtn]; UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [giftBtn setImage:[UIImage imageNamed:@"vqu_images_IM_gift"] forState:UIControlStateNormal]; [footerV addSubview:giftBtn]; UIButton *videoBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [videoBtn setImage:[UIImage imageNamed:@"vqu_images_IM_video1"] forState:UIControlStateNormal]; [footerV addSubview:videoBtn]; NSArray *footBtns = @[photoBtn,videoBtn,giftBtn,sayHiBtn]; CGFloat midSpacing = (KScreenWidth - (23.0f * footBtns.count)) / footBtns.count; [footBtns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:midSpacing leadSpacing:midSpacing / 2 tailSpacing:midSpacing / 2]; [footBtns mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.offset(-SafeHeight-12.0f); make.height.offset(23.0f); }]; [recordBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.offset(16.0f); make.size.mas_offset(CGSizeMake(23.0f, 23.0f)); }]; UIView *sendV = [[UIView alloc] init]; [footerV addSubview:sendV]; [sendV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(44.0f); make.right.offset(-12.0f); make.centerY.equalTo(recordBtn); make.height.offset(39.0f); }]; UIButton *sendBtn = [UIButton buttonWithType:UIButtonTypeCustom]; sendBtn.backgroundColor = LZ7C69FEColor; [sendBtn setTitle:@"发送" forState:UIControlStateNormal]; [sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; sendBtn.titleLabel.font = LCFont(16.0f); sendBtn.layer.cornerRadius = 19.5f; sendBtn.clipsToBounds = YES; [sendV addSubview:sendBtn]; sendBtn.userInteractionEnabled = NO; [sendBtn performSelector:@selector(setUserInteractionEnabled:) withObject:@(YES) afterDelay:1.0f]; self.sendBtn = sendBtn; [sendBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.top.bottom.offset(0.0f); make.width.offset(64.0f); }]; UILabel *textL = [[UILabel alloc] init]; textL.font = LCFont14; textL.textColor = LZ273145Color; NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init]; paraStyle01.firstLineHeadIndent = 16;//首行缩进 NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@"好的" attributes:@{NSParagraphStyleAttributeName:paraStyle01}]; textL.attributedText = attrText; textL.backgroundColor = LZF7F8FAColor; textL.layer.cornerRadius = 19.5f; textL.clipsToBounds = YES; [sendV addSubview:textL]; [textL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.offset(0.0f); make.right.equalTo(sendBtn.mas_left).offset(-12.0f); }]; } - (void)youpaifinitGuideView{ UIView *guideV = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; guideV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f]; [[UIApplication sharedApplication].keyWindow addSubview:guideV]; self.guideV = guideV; guideV.mj_x = KScreenWidth; [UIView animateWithDuration:0.3f animations:^{ guideV.mj_x = 0.0f; }]; UIView *sendV = [[UIView alloc] init]; [guideV addSubview:sendV]; self.guideSendV = sendV; [sendV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(44.0f); make.right.offset(-12.0f); make.bottom.offset(-55.0f); make.height.offset(39.0f); }]; UIButton *sendBtn = [UIButton buttonWithType:UIButtonTypeCustom]; sendBtn.backgroundColor = LZ7C69FEColor; [sendBtn setTitle:@"发送" forState:UIControlStateNormal]; [sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; sendBtn.titleLabel.font = LCFont(16.0f); sendBtn.layer.cornerRadius = 19.5f; sendBtn.clipsToBounds = YES; [sendBtn addTarget:self action:@selector(youpaifsendBtnClick) forControlEvents:UIControlEventTouchUpInside]; [sendV addSubview:sendBtn]; [sendBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.top.bottom.offset(0.0f); make.width.offset(64.0f); }]; UILabel *textL = [[UILabel alloc] init]; textL.font = LCFont14; textL.textColor = LZ273145Color; NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init]; paraStyle01.firstLineHeadIndent = 16;//首行缩进 NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@"好的" attributes:@{NSParagraphStyleAttributeName:paraStyle01}]; textL.attributedText = attrText; textL.backgroundColor = [UIColor whiteColor]; textL.layer.cornerRadius = 19.5f; textL.clipsToBounds = YES; [sendV addSubview:textL]; [textL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.offset(0.0f); make.right.equalTo(sendBtn.mas_left).offset(-12.0f); }]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight - (55.0f + 47.0f + SafeHeight + NavBarHeight))]; [guideV addSubview:scrollView]; self.scrollView = scrollView; UIImageView *tipImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_tip_2"]]; [guideV addSubview:tipImgV]; self.tipImgV = tipImgV; [tipImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-12.0f); make.bottom.equalTo(sendV.mas_top).offset(-12.0f); make.size.mas_offset(CGSizeMake(192, 45)); }]; UILabel *tipL = [[UILabel alloc] init]; tipL.textColor = [UIColor whiteColor]; tipL.font = LCFont(14.0f); tipL.text = @"点击”发送“回复获得现金"; [tipImgV addSubview:tipL]; self.tipL = tipL; [tipL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.offset(10.0f); make.centerX.equalTo(tipImgV); }]; [self youpaifSendLeftMessageCount:3]; } - (void)youpaifSendLeftMessageCount:(NSInteger)count{ for (NSInteger i = 0; i < count; i ++) { [self performSelector:@selector(youpaifSendLeftMessage) withObject:nil afterDelay:i * 0.3f]; } } - (void)youpaifSendLeftMessage{ UIView *messageV = [[UIView alloc] init]; [self.scrollView addSubview:messageV]; [messageV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(16.0f); if (self.frontV == nil) { make.top.offset(14.0f); }else{ make.top.equalTo(self.frontV.mas_bottom).offset(14.0f); } }]; UIImageView *avatarImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_service"]]; [messageV addSubview:avatarImgV]; [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_offset(CGSizeMake(40.0f, 40.0f)); make.top.left.offset(0.0f); }]; UIView *contentV = [[UIView alloc] init]; contentV.backgroundColor = [UIColor whiteColor]; contentV.layer.cornerRadius = 10.0f; contentV.clipsToBounds = YES; [messageV addSubview:contentV]; [contentV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(avatarImgV.mas_right).offset(10.0f); make.top.offset(0.0f); make.right.offset(0.0f); make.width.lessThanOrEqualTo(KScreenWidth - 132.0f); make.height.greaterThanOrEqualTo(40.0f); }]; UILabel *contentL = [[UILabel alloc] init]; contentL.text = self.leftMessages[self.leftMessageIndex]; contentL.textColor = LZ273145Color; contentL.font = LCFont14; contentL.numberOfLines = 0; [contentV addSubview:contentL]; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.offset(10.0f); make.right.bottom.offset(-10.0f); }]; UIButton *priBtnButton = [UIButton buttonWithType:UIButtonTypeCustom]; priBtnButton.adjustsImageWhenHighlighted = NO; [priBtnButton setImage:[UIImage imageNamed:@"vqu_images_im_coin"] forState:UIControlStateNormal]; priBtnButton.titleLabel.font = LCFont12; [priBtnButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [priBtnButton setTitle:@"回复消息可获得现金" forState:UIControlStateNormal]; [messageV addSubview:priBtnButton]; [self.messageMoneyBtns addObject:priBtnButton]; [priBtnButton mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.offset(0.0f); make.left.equalTo(avatarImgV.mas_right).offset(10.0f); make.height.offset(16.0f); make.top.equalTo(contentV.mas_bottom).offset(6.0f); }]; self.leftMessageIndex ++; self.frontV = messageV; [self.scrollView layoutIfNeeded]; self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(messageV.frame) + 100.0f); CGFloat offset = self.scrollView.contentSize.height - self.scrollView.bounds.size.height; if (offset > 0){ [self.scrollView setContentOffset:CGPointMake(0, offset) animated:YES]; } } - (void)youpaifsendBtnClick{ [self youpaifSendRightMessage]; if (self.sendMessageCount == 0) { [self youpaifSendLeftMessageCount:3]; self.sendBtn.userInteractionEnabled = NO; [self.sendBtn performSelector:@selector(setUserInteractionEnabled:) withObject:@(YES) afterDelay:1.0f]; }else if (self.sendMessageCount == 1){ self.guideSendV.hidden = YES; for (UIButton *btn in self.messageMoneyBtns) { [btn setTitle:@"+0.65元" forState:UIControlStateNormal]; } UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 120.0f, 56.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; [confirmBtn setTitle:@"返回列表" forState:UIControlStateNormal]; [confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; confirmBtn.titleLabel.font = LCFont(20.0f); confirmBtn.layer.cornerRadius = 28.0f; confirmBtn.clipsToBounds = YES; [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.guideV addSubview:confirmBtn]; [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.offset(- SafeHeight - 32.0f); make.centerX.equalTo(self.guideV); make.size.mas_offset(CGSizeMake(KScreenWidth - 120.0f, 56.0f)); }]; UIImageView *touchImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_touch"]]; [self.guideV addSubview:touchImgV]; [touchImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(confirmBtn.mas_right); make.bottom.offset(-SafeHeight-9.5f); make.size.mas_offset(CGSizeMake(43.5, 54)); }]; self.tipImgV.image = [UIImage imageNamed:@"vqu_images_im_tip_3"]; [self.tipImgV mas_remakeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(confirmBtn); make.bottom.equalTo(confirmBtn.mas_top).offset(-12.0f); make.size.mas_offset(CGSizeMake(295, 45)); }]; self.tipL.text = @"恭喜你完成新手引导 点击按钮返回消息页面"; } self.sendMessageCount ++; } - (void)youpaifconfirmBtnClick{ [LCSaveData saveGuideHiddenState:YES]; [self.navigationController popViewControllerAnimated:YES]; [UIView animateWithDuration:0.3f animations:^{ self.guideV.mj_x = KScreenWidth; }completion:^(BOOL finished) { if (finished) { [self.guideV removeFromSuperview]; } }]; } - (void)youpaifSendRightMessage{ UIView *messageV = [[UIView alloc] init]; [self.scrollView addSubview:messageV]; [messageV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(KScreenWidth - 110.0f - 16.0f); make.height.offset(40.0f); if (self.frontV == nil) { make.top.offset(14.0f); }else{ make.top.equalTo(self.frontV.mas_bottom).offset(14.0f); } make.width.offset(110.0f); }]; UIImageView *avatarImgV = [[UIImageView alloc] init]; avatarImgV.contentMode = UIViewContentModeScaleAspectFill; [avatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar]]; avatarImgV.layer.cornerRadius = 10.0f; avatarImgV.clipsToBounds = YES; avatarImgV.backgroundColor = [UIColor whiteColor]; [messageV addSubview:avatarImgV]; [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_offset(CGSizeMake(40.0f, 40.0f)); make.right.top.offset(0.0f); }]; UIView *contentV = [[UIView alloc] init]; contentV.backgroundColor = LZ7C69FEColor; contentV.layer.cornerRadius = 10.0f; contentV.clipsToBounds = YES; [messageV addSubview:contentV]; [contentV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(avatarImgV.mas_left).offset(-10.0f); make.top.offset(0.0f); make.left.offset(0.0f); make.bottom.offset(0.0f); }]; UILabel *contentL = [[UILabel alloc] init]; contentL.text = @"好的"; contentL.textColor = [UIColor whiteColor]; contentL.font = LCFont14; [contentV addSubview:contentL]; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(contentV); }]; self.frontV = messageV; [self.scrollView layoutIfNeeded]; self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(messageV.frame) + 100.0f); CGFloat offset = self.scrollView.contentSize.height - self.scrollView.bounds.size.height; if (offset > 0){ [self.scrollView setContentOffset:CGPointMake(0, offset) animated:YES]; } } - (void)youpaifuserSetClick{ } @end