YOUPAILZMessageGuideVC.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. //
  2. // YOUPAILZMessageGuideVC.m
  3. // MSYOUPAI
  4. //
  5. // Created by CY on 2022/3/23.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZMessageGuideVC.h"
  9. @interface YOUPAILZMessageGuideVC ()
  10. @property (nonatomic,weak)UIView *guideV;
  11. @property (nonatomic,weak)UIView *guideSendV;
  12. @property (nonatomic,weak)UIView *frontV;
  13. @property (nonatomic,weak)UIScrollView *scrollView;
  14. @property (nonatomic,strong)NSArray *leftMessages;
  15. @property (nonatomic,assign)NSInteger leftMessageIndex;
  16. @property (nonatomic,assign)NSInteger sendMessageCount;
  17. @property (nonatomic,weak) UIButton *sendBtn;
  18. @property (nonatomic,strong) NSMutableArray <UIButton *> *messageMoneyBtns;
  19. @property (nonatomic, weak) UIImageView *tipImgV;
  20. @property (nonatomic, weak) UILabel *tipL;
  21. @end
  22. @implementation YOUPAILZMessageGuideVC
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.sendMessageCount = 0;
  26. self.leftMessageIndex = 0;
  27. self.messageMoneyBtns = [NSMutableArray array];
  28. self.leftMessages = @[@"欢迎来到相语欢颜",@"在相语欢颜,每回复一条消息,都可以获得现金,现金可无门槛提现哦",@"快回复消息试试?",@"回复消息越及时,得到的现金也越多",@"通过真人认证后,所获得的现金将翻倍",@"通过头像审核,才可开始获得现金哦,你准备好了吗?"];
  29. self.title = @"官方客服";
  30. self.navigationItem.rightBarButtonItems = @[[UIBarButtonItem itemWithTarget:self action:@selector(youpaifuserSetClick) image:[UIImage imageNamed:@"vqu_images_IM_im_details"]]];
  31. [self youpaifinitUI];
  32. [self youpaifinitGuideView];
  33. }
  34. - (void)youpaifinitUI{
  35. UIView *footerV = [[UIView alloc] init];
  36. footerV.backgroundColor = [UIColor whiteColor];
  37. [self.view addSubview:footerV];
  38. [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.bottom.left.right.offset(0.0f);
  40. make.height.offset(55.0f + 47.0f + SafeHeight);
  41. }];
  42. //修改inputview 按钮 注释 by leo
  43. UIButton *recordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  44. [recordBtn setImage:[UIImage imageNamed:@"vqu_images_IM_im_record"] forState:UIControlStateNormal];
  45. [footerV addSubview:recordBtn];
  46. UIButton *sayHiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  47. [sayHiBtn setImage:[UIImage imageNamed:@"vqu_images_IM_im_sayhi"] forState:UIControlStateNormal];
  48. [footerV addSubview:sayHiBtn];
  49. UIButton *photoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  50. [photoBtn setImage:[UIImage imageNamed:@"vqu_images_IM_photo"] forState:UIControlStateNormal];
  51. [footerV addSubview:photoBtn];
  52. UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  53. [giftBtn setImage:[UIImage imageNamed:@"vqu_images_IM_gift"] forState:UIControlStateNormal];
  54. [footerV addSubview:giftBtn];
  55. UIButton *videoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [videoBtn setImage:[UIImage imageNamed:@"vqu_images_IM_video1"] forState:UIControlStateNormal];
  57. [footerV addSubview:videoBtn];
  58. NSArray <UIButton *> *footBtns = @[photoBtn,videoBtn,giftBtn,sayHiBtn];
  59. CGFloat midSpacing = (KScreenWidth - (23.0f * footBtns.count)) / footBtns.count;
  60. [footBtns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:midSpacing leadSpacing:midSpacing / 2 tailSpacing:midSpacing / 2];
  61. [footBtns mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.bottom.offset(-SafeHeight-12.0f);
  63. make.height.offset(23.0f);
  64. }];
  65. [recordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.top.offset(16.0f);
  67. make.size.mas_offset(CGSizeMake(23.0f, 23.0f));
  68. }];
  69. UIView *sendV = [[UIView alloc] init];
  70. [footerV addSubview:sendV];
  71. [sendV mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.offset(44.0f);
  73. make.right.offset(-12.0f);
  74. make.centerY.equalTo(recordBtn);
  75. make.height.offset(39.0f);
  76. }];
  77. UIButton *sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  78. sendBtn.backgroundColor = LZ7C69FEColor;
  79. [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
  80. [sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  81. sendBtn.titleLabel.font = LCFont(16.0f);
  82. sendBtn.layer.cornerRadius = 19.5f;
  83. sendBtn.clipsToBounds = YES;
  84. [sendV addSubview:sendBtn];
  85. sendBtn.userInteractionEnabled = NO;
  86. [sendBtn performSelector:@selector(setUserInteractionEnabled:) withObject:@(YES) afterDelay:1.0f];
  87. self.sendBtn = sendBtn;
  88. [sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.right.top.bottom.offset(0.0f);
  90. make.width.offset(64.0f);
  91. }];
  92. UILabel *textL = [[UILabel alloc] init];
  93. textL.font = LCFont14;
  94. textL.textColor = LZ273145Color;
  95. NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init];
  96. paraStyle01.firstLineHeadIndent = 16;//首行缩进
  97. NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@"好的" attributes:@{NSParagraphStyleAttributeName:paraStyle01}];
  98. textL.attributedText = attrText;
  99. textL.backgroundColor = LZF7F8FAColor;
  100. textL.layer.cornerRadius = 19.5f;
  101. textL.clipsToBounds = YES;
  102. [sendV addSubview:textL];
  103. [textL mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.left.top.bottom.offset(0.0f);
  105. make.right.equalTo(sendBtn.mas_left).offset(-12.0f);
  106. }];
  107. }
  108. - (void)youpaifinitGuideView{
  109. UIView *guideV = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  110. guideV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  111. [[UIApplication sharedApplication].keyWindow addSubview:guideV];
  112. self.guideV = guideV;
  113. guideV.mj_x = KScreenWidth;
  114. [UIView animateWithDuration:0.3f animations:^{
  115. guideV.mj_x = 0.0f;
  116. }];
  117. UIView *sendV = [[UIView alloc] init];
  118. [guideV addSubview:sendV];
  119. self.guideSendV = sendV;
  120. [sendV mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.offset(44.0f);
  122. make.right.offset(-12.0f);
  123. make.bottom.offset(-55.0f);
  124. make.height.offset(39.0f);
  125. }];
  126. UIButton *sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  127. sendBtn.backgroundColor = LZ7C69FEColor;
  128. [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
  129. [sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  130. sendBtn.titleLabel.font = LCFont(16.0f);
  131. sendBtn.layer.cornerRadius = 19.5f;
  132. sendBtn.clipsToBounds = YES;
  133. [sendBtn addTarget:self action:@selector(youpaifsendBtnClick) forControlEvents:UIControlEventTouchUpInside];
  134. [sendV addSubview:sendBtn];
  135. [sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.right.top.bottom.offset(0.0f);
  137. make.width.offset(64.0f);
  138. }];
  139. UILabel *textL = [[UILabel alloc] init];
  140. textL.font = LCFont14;
  141. textL.textColor = LZ273145Color;
  142. NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init];
  143. paraStyle01.firstLineHeadIndent = 16;//首行缩进
  144. NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@"好的" attributes:@{NSParagraphStyleAttributeName:paraStyle01}];
  145. textL.attributedText = attrText;
  146. textL.backgroundColor = [UIColor whiteColor];
  147. textL.layer.cornerRadius = 19.5f;
  148. textL.clipsToBounds = YES;
  149. [sendV addSubview:textL];
  150. [textL mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.left.top.bottom.offset(0.0f);
  152. make.right.equalTo(sendBtn.mas_left).offset(-12.0f);
  153. }];
  154. UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight - (55.0f + 47.0f + SafeHeight + NavBarHeight))];
  155. [guideV addSubview:scrollView];
  156. self.scrollView = scrollView;
  157. UIImageView *tipImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_tip_2"]];
  158. [guideV addSubview:tipImgV];
  159. self.tipImgV = tipImgV;
  160. [tipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.right.offset(-12.0f);
  162. make.bottom.equalTo(sendV.mas_top).offset(-12.0f);
  163. make.size.mas_offset(CGSizeMake(192, 45));
  164. }];
  165. UILabel *tipL = [[UILabel alloc] init];
  166. tipL.textColor = [UIColor whiteColor];
  167. tipL.font = LCFont(14.0f);
  168. tipL.text = @"点击”发送“回复获得现金";
  169. [tipImgV addSubview:tipL];
  170. self.tipL = tipL;
  171. [tipL mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.top.offset(10.0f);
  173. make.centerX.equalTo(tipImgV);
  174. }];
  175. [self youpaifSendLeftMessageCount:3];
  176. }
  177. - (void)youpaifSendLeftMessageCount:(NSInteger)count{
  178. for (NSInteger i = 0; i < count; i ++) {
  179. [self performSelector:@selector(youpaifSendLeftMessage) withObject:nil afterDelay:i * 0.3f];
  180. }
  181. }
  182. - (void)youpaifSendLeftMessage{
  183. UIView *messageV = [[UIView alloc] init];
  184. [self.scrollView addSubview:messageV];
  185. [messageV mas_makeConstraints:^(MASConstraintMaker *make) {
  186. make.left.offset(16.0f);
  187. if (self.frontV == nil) {
  188. make.top.offset(14.0f);
  189. }else{
  190. make.top.equalTo(self.frontV.mas_bottom).offset(14.0f);
  191. }
  192. }];
  193. UIImageView *avatarImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_service"]];
  194. [messageV addSubview:avatarImgV];
  195. [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  197. make.top.left.offset(0.0f);
  198. }];
  199. UIView *contentV = [[UIView alloc] init];
  200. contentV.backgroundColor = [UIColor whiteColor];
  201. contentV.layer.cornerRadius = 10.0f;
  202. contentV.clipsToBounds = YES;
  203. [messageV addSubview:contentV];
  204. [contentV mas_makeConstraints:^(MASConstraintMaker *make) {
  205. make.left.equalTo(avatarImgV.mas_right).offset(10.0f);
  206. make.top.offset(0.0f);
  207. make.right.offset(0.0f);
  208. make.width.lessThanOrEqualTo(KScreenWidth - 132.0f);
  209. make.height.greaterThanOrEqualTo(40.0f);
  210. }];
  211. UILabel *contentL = [[UILabel alloc] init];
  212. contentL.text = self.leftMessages[self.leftMessageIndex];
  213. contentL.textColor = LZ273145Color;
  214. contentL.font = LCFont14;
  215. contentL.numberOfLines = 0;
  216. [contentV addSubview:contentL];
  217. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  218. make.left.top.offset(10.0f);
  219. make.right.bottom.offset(-10.0f);
  220. }];
  221. UIButton *priBtnButton = [UIButton buttonWithType:UIButtonTypeCustom];
  222. priBtnButton.adjustsImageWhenHighlighted = NO;
  223. [priBtnButton setImage:[UIImage imageNamed:@"vqu_images_im_coin"] forState:UIControlStateNormal];
  224. priBtnButton.titleLabel.font = LCFont12;
  225. [priBtnButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  226. [priBtnButton setTitle:@"回复消息可获得现金" forState:UIControlStateNormal];
  227. [messageV addSubview:priBtnButton];
  228. [self.messageMoneyBtns addObject:priBtnButton];
  229. [priBtnButton mas_makeConstraints:^(MASConstraintMaker *make) {
  230. make.bottom.offset(0.0f);
  231. make.left.equalTo(avatarImgV.mas_right).offset(10.0f);
  232. make.height.offset(16.0f);
  233. make.top.equalTo(contentV.mas_bottom).offset(6.0f);
  234. }];
  235. self.leftMessageIndex ++;
  236. self.frontV = messageV;
  237. [self.scrollView layoutIfNeeded];
  238. self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(messageV.frame) + 100.0f);
  239. CGFloat offset = self.scrollView.contentSize.height - self.scrollView.bounds.size.height;
  240. if (offset > 0){
  241. [self.scrollView setContentOffset:CGPointMake(0, offset) animated:YES];
  242. }
  243. }
  244. - (void)youpaifsendBtnClick{
  245. [self youpaifSendRightMessage];
  246. if (self.sendMessageCount == 0) {
  247. [self youpaifSendLeftMessageCount:3];
  248. self.sendBtn.userInteractionEnabled = NO;
  249. [self.sendBtn performSelector:@selector(setUserInteractionEnabled:) withObject:@(YES) afterDelay:1.0f];
  250. }else if (self.sendMessageCount == 1){
  251. self.guideSendV.hidden = YES;
  252. for (UIButton *btn in self.messageMoneyBtns) {
  253. [btn setTitle:@"+0.65元" forState:UIControlStateNormal];
  254. }
  255. UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  256. [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 120.0f, 56.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  257. [confirmBtn setTitle:@"返回列表" forState:UIControlStateNormal];
  258. [confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  259. confirmBtn.titleLabel.font = LCFont(20.0f);
  260. confirmBtn.layer.cornerRadius = 28.0f;
  261. confirmBtn.clipsToBounds = YES;
  262. [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
  263. [self.guideV addSubview:confirmBtn];
  264. [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  265. make.bottom.offset(- SafeHeight - 32.0f);
  266. make.centerX.equalTo(self.guideV);
  267. make.size.mas_offset(CGSizeMake(KScreenWidth - 120.0f, 56.0f));
  268. }];
  269. UIImageView *touchImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_im_touch"]];
  270. [self.guideV addSubview:touchImgV];
  271. [touchImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  272. make.right.equalTo(confirmBtn.mas_right);
  273. make.bottom.offset(-SafeHeight-9.5f);
  274. make.size.mas_offset(CGSizeMake(43.5, 54));
  275. }];
  276. self.tipImgV.image = [UIImage imageNamed:@"vqu_images_im_tip_3"];
  277. [self.tipImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  278. make.centerX.equalTo(confirmBtn);
  279. make.bottom.equalTo(confirmBtn.mas_top).offset(-12.0f);
  280. make.size.mas_offset(CGSizeMake(295, 45));
  281. }];
  282. self.tipL.text = @"恭喜你完成新手引导 点击按钮返回消息页面";
  283. }
  284. self.sendMessageCount ++;
  285. }
  286. - (void)youpaifconfirmBtnClick{
  287. [LCSaveData saveGuideHiddenState:YES];
  288. [self.navigationController popViewControllerAnimated:YES];
  289. [UIView animateWithDuration:0.3f animations:^{
  290. self.guideV.mj_x = KScreenWidth;
  291. }completion:^(BOOL finished) {
  292. if (finished) {
  293. [self.guideV removeFromSuperview];
  294. }
  295. }];
  296. }
  297. - (void)youpaifSendRightMessage{
  298. UIView *messageV = [[UIView alloc] init];
  299. [self.scrollView addSubview:messageV];
  300. [messageV mas_makeConstraints:^(MASConstraintMaker *make) {
  301. make.left.offset(KScreenWidth - 110.0f - 16.0f);
  302. make.height.offset(40.0f);
  303. if (self.frontV == nil) {
  304. make.top.offset(14.0f);
  305. }else{
  306. make.top.equalTo(self.frontV.mas_bottom).offset(14.0f);
  307. }
  308. make.width.offset(110.0f);
  309. }];
  310. UIImageView *avatarImgV = [[UIImageView alloc] init];
  311. avatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  312. [avatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar]];
  313. avatarImgV.layer.cornerRadius = 10.0f;
  314. avatarImgV.clipsToBounds = YES;
  315. avatarImgV.backgroundColor = [UIColor whiteColor];
  316. [messageV addSubview:avatarImgV];
  317. [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  318. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  319. make.right.top.offset(0.0f);
  320. }];
  321. UIView *contentV = [[UIView alloc] init];
  322. contentV.backgroundColor = LZ7C69FEColor;
  323. contentV.layer.cornerRadius = 10.0f;
  324. contentV.clipsToBounds = YES;
  325. [messageV addSubview:contentV];
  326. [contentV mas_makeConstraints:^(MASConstraintMaker *make) {
  327. make.right.equalTo(avatarImgV.mas_left).offset(-10.0f);
  328. make.top.offset(0.0f);
  329. make.left.offset(0.0f);
  330. make.bottom.offset(0.0f);
  331. }];
  332. UILabel *contentL = [[UILabel alloc] init];
  333. contentL.text = @"好的";
  334. contentL.textColor = [UIColor whiteColor];
  335. contentL.font = LCFont14;
  336. [contentV addSubview:contentL];
  337. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  338. make.center.equalTo(contentV);
  339. }];
  340. self.frontV = messageV;
  341. [self.scrollView layoutIfNeeded];
  342. self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(messageV.frame) + 100.0f);
  343. CGFloat offset = self.scrollView.contentSize.height - self.scrollView.bounds.size.height;
  344. if (offset > 0){
  345. [self.scrollView setContentOffset:CGPointMake(0, offset) animated:YES];
  346. }
  347. }
  348. - (void)youpaifuserSetClick{
  349. }
  350. @end