RQProfileUserAndVipCell.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. //
  2. // RQProfileUserAndVipCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/4/26.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQProfileUserAndVipCell.h"
  9. @interface RQProfileUserAndVipCell () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
  10. @property (nonatomic, readwrite, strong) RQProfileUserAndVipItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIView *vipContentView;
  12. @property (weak, nonatomic) IBOutlet UIImageView *myBgImageView;
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *btnsViewToTop;
  14. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *headImagViewToTop;
  15. @property (weak, nonatomic) IBOutlet QMUIButton *settingBtn;
  16. @property (weak, nonatomic) IBOutlet QMUIButton *messageBtn;
  17. @property (weak, nonatomic) IBOutlet UIImageView *myHeadImageView;
  18. @property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
  19. @property (weak, nonatomic) IBOutlet QMUIButton *telePhoneBtn;
  20. @property (weak, nonatomic) IBOutlet QMUIButton *carTypeBtn;
  21. @property (weak, nonatomic) IBOutlet UIImageView *detailArrowImg;
  22. @property (weak, nonatomic) IBOutlet QMUIButton *schoolNameBtn;
  23. @property (nonatomic, readwrite, assign) CGFloat btnsViewHeight;
  24. @property (nonatomic, readwrite, assign) CGFloat headImageViewHeight;
  25. @property (nonatomic, readwrite, assign) CGFloat headImageViewCornerRadiusHeight;
  26. @property (nonatomic, readwrite, assign) BOOL isScrolling;
  27. @property (nonatomic, readwrite, strong) UICollectionView *vipCollectionView;
  28. @property (nonatomic, readwrite, strong) QMUICollectionViewPagingLayout *vipCollectionViewFlowLayout;
  29. @end
  30. @implementation RQProfileUserAndVipCell
  31. #pragma mark - PublicMethods
  32. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  33. static NSString *ID = @"RQProfileUserAndVipCell";
  34. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  35. RQProfileUserAndVipCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  36. if (!cell) cell = [self rq_viewFromXib];
  37. [cell.vipContentView addSubview:cell.vipCollectionView];
  38. CAShapeLayer *maskLayer = [CAShapeLayer layer];
  39. maskLayer.fillColor = [UIColor redColor].CGColor;
  40. maskLayer.lineWidth = 1;
  41. // CGFloat cellHeight = RQ_COMMON_MANAGER.APP_SWITCH? RQ_FIT_HORIZONTAL(158.f) : RQ_FIT_HORIZONTAL(328.f);
  42. CGFloat cellHeight = RQ_FIT_HORIZONTAL(328.f);
  43. CGFloat a = RQ_FIT_HORIZONTAL(22.f);
  44. CGFloat radius = (((RQ_SCREEN_WIDTH / 2.f) * (RQ_SCREEN_WIDTH / 2.f)) - (a * a)) / (2 * a);
  45. UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(RQ_SCREEN_WIDTH / 2.f, cellHeight - radius) radius:radius startAngle:0 endAngle:M_PI * 2 clockwise:YES];
  46. maskLayer.path = aPath.CGPath;
  47. cell.vipContentView.layer.mask = maskLayer;
  48. return cell;
  49. }
  50. - (void)bindViewModel:(RQProfileUserAndVipItemViewModel *)viewModel {
  51. self.viewModel = viewModel;
  52. @weakify(self);
  53. [[RACObserve(viewModel, userModel.photo) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSString *imageName) {
  54. @strongify(self);
  55. [self.myHeadImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.userModel.photo] placeholder:RQWebAvatarImagePlaceholder() options:RQWebImageOptionAutomatic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
  56. if(image) {
  57. image = [image qmui_imageResizedInLimitedSize:CGSizeMake(RQ_FIT_HORIZONTAL(70.f), RQ_FIT_HORIZONTAL(70.f)) resizingMode:QMUIImageResizingModeScaleAspectFill];
  58. image = [image qmui_imageWithBorderColor:UIColor.whiteColor borderWidth:1 cornerRadius:RQ_FIT_HORIZONTAL(70.f) / 2.f];
  59. self.myHeadImageView.image = image;
  60. }
  61. }];
  62. }];
  63. RAC(_userNameLabel, text) = [RACObserve(viewModel, userModel.nickName) takeUntil:self.rac_prepareForReuseSignal];
  64. RAC(_telePhoneBtn, rq_titleStr) = [RACObserve(viewModel, userModel.telphone) takeUntil:self.rac_prepareForReuseSignal];
  65. RAC(_carTypeBtn, rq_titleStr) = [RACObserve(viewModel, userModel.carType) takeUntil:self.rac_prepareForReuseSignal];
  66. RAC(_schoolNameBtn, rq_titleStr) = [[RACObserve(viewModel, userModel.schoolName) map:^id _Nullable(id _Nullable value) {
  67. if (RQObjectIsNil(viewModel.userModel.schInfo)) {
  68. // return RQStringIsNotEmpty(viewModel.userModel.schoolName)? viewModel.userModel.schoolName : @"未获取到驾校名称";
  69. return RQStringIsNotEmpty(viewModel.userModel.schoolName)? viewModel.userModel.schoolName : @"";
  70. } else {
  71. // return RQStringIsNotEmpty(viewModel.userModel.schInfo.name)? viewModel.userModel.schInfo.name : (RQStringIsNotEmpty(viewModel.userModel.schoolName)? viewModel.userModel.schoolName : @"未获取到驾校名称");
  72. return RQStringIsNotEmpty(viewModel.userModel.schInfo.name)? viewModel.userModel.schInfo.name : (RQStringIsNotEmpty(viewModel.userModel.schoolName)? viewModel.userModel.schoolName : @"");
  73. }
  74. }] takeUntil:self.rac_prepareForReuseSignal];
  75. }
  76. #pragma mark - SystemMethods
  77. - (void)awakeFromNib {
  78. [super awakeFromNib];
  79. [self btnsViewHeight];
  80. [self headImageViewCornerRadiusHeight];
  81. _headImagViewToTop.constant = RQ_APPLICATION_STATUS_BAR_HEIGHT + 16.f + (RQ_FIT_HORIZONTAL(20.f) * (17.f / 15.f)) + 16.f;
  82. _btnsViewToTop.constant = RQ_APPLICATION_STATUS_BAR_HEIGHT + 16.f;
  83. [_messageBtn setQmui_badgeInteger:14];
  84. self.myHeadImageView.layer.cornerRadius = self.headImageViewCornerRadiusHeight;
  85. CGFloat myWidth = RQ_SCREEN_WIDTH - 16 - 16 + 10;
  86. RACSignal *signal = [[RACSignal combineLatest:@[RACObserve(self.vipCollectionView, contentOffset), RACObserve(self, isScrolling)] reduce:^id (id _Nullable x, id _Nullable y) {
  87. if (!_isScrolling) {
  88. NSLog(@"%.f-----%f",self.vipCollectionView.contentOffset.x, round(self.vipCollectionView.contentOffset.x / myWidth));
  89. NSInteger a = round(self.vipCollectionView.contentOffset.x / myWidth);
  90. RQ_Profile_Module.profileSubject = a;
  91. switch (a) {
  92. case 0:
  93. self.myBgImageView.image = RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"科一科四 已开通") : RQImageNamed(@"科一科四");
  94. self.userNameLabel.textColor = RQ_VIP_Module.isSubject1Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor;
  95. [self.telePhoneBtn setTitleColor:RQ_VIP_Module.isSubject1Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  96. [self.telePhoneBtn setImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"手机-黑") : RQImageNamed(@"手机") forState:UIControlStateNormal];
  97. [self.carTypeBtn setTitleColor:RQ_VIP_Module.isSubject1Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  98. [self.carTypeBtn setImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"驾照类型-黑") : RQImageNamed(@"驾照类型") forState:UIControlStateNormal];
  99. [self.schoolNameBtn setTitleColor:RQ_VIP_Module.isSubject1Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  100. [self.schoolNameBtn setImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"公司-黑") : RQImageNamed(@"公司") forState:UIControlStateNormal];
  101. [self.detailArrowImg setImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"查看详情-黑") : RQImageNamed(@"查看详情")];
  102. [self.settingBtn setBackgroundImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"设置-黑") : RQImageNamed(@"设置") forState:UIControlStateNormal];
  103. [self.messageBtn setBackgroundImage:RQ_VIP_Module.isSubject1Vip? RQImageNamed(@"消息-黑") : RQImageNamed(@"消息") forState:UIControlStateNormal];
  104. break;
  105. case 1:
  106. self.myBgImageView.image = RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"科二 已开通") : RQImageNamed(@"科二");
  107. self.userNameLabel.textColor = RQ_VIP_Module.isSubject2Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor;
  108. [self.telePhoneBtn setTitleColor:RQ_VIP_Module.isSubject2Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  109. [self.telePhoneBtn setImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"手机-黑") : RQImageNamed(@"手机") forState:UIControlStateNormal];
  110. [self.carTypeBtn setTitleColor:RQ_VIP_Module.isSubject2Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  111. [self.carTypeBtn setImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"驾照类型-黑") : RQImageNamed(@"驾照类型") forState:UIControlStateNormal];
  112. [self.schoolNameBtn setTitleColor:RQ_VIP_Module.isSubject2Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  113. [self.schoolNameBtn setImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"公司-黑") : RQImageNamed(@"公司") forState:UIControlStateNormal];
  114. [self.detailArrowImg setImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"查看详情-黑") : RQImageNamed(@"查看详情")];
  115. [self.settingBtn setBackgroundImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"设置-黑") : RQImageNamed(@"设置") forState:UIControlStateNormal];
  116. [self.messageBtn setBackgroundImage:RQ_VIP_Module.isSubject2Vip? RQImageNamed(@"消息-黑") : RQImageNamed(@"消息") forState:UIControlStateNormal];
  117. break;
  118. case 2:
  119. self.myBgImageView.image = RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"科三 已开通") : RQImageNamed(@"科三");
  120. self.userNameLabel.textColor = RQ_VIP_Module.isSubject3Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor;
  121. [self.telePhoneBtn setTitleColor:RQ_VIP_Module.isSubject3Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  122. [self.telePhoneBtn setImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"手机-黑") : RQImageNamed(@"手机") forState:UIControlStateNormal];
  123. [self.carTypeBtn setTitleColor:RQ_VIP_Module.isSubject3Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  124. [self.carTypeBtn setImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"驾照类型-黑") : RQImageNamed(@"驾照类型") forState:UIControlStateNormal];
  125. [self.schoolNameBtn setTitleColor:RQ_VIP_Module.isSubject3Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  126. [self.schoolNameBtn setImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"公司-黑") : RQImageNamed(@"公司") forState:UIControlStateNormal];
  127. [self.detailArrowImg setImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"查看详情-黑") : RQImageNamed(@"查看详情")];
  128. [self.settingBtn setBackgroundImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"设置-黑") : RQImageNamed(@"设置") forState:UIControlStateNormal];
  129. [self.messageBtn setBackgroundImage:RQ_VIP_Module.isSubject3Vip? RQImageNamed(@"消息-黑") : RQImageNamed(@"消息") forState:UIControlStateNormal];
  130. break;
  131. case 3:
  132. self.myBgImageView.image = RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"科一科四 已开通") : RQImageNamed(@"科一科四");
  133. self.userNameLabel.textColor = RQ_VIP_Module.isSubject4Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor;
  134. [self.telePhoneBtn setTitleColor:RQ_VIP_Module.isSubject4Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  135. [self.telePhoneBtn setImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"手机-黑") : RQImageNamed(@"手机") forState:UIControlStateNormal];
  136. [self.carTypeBtn setTitleColor:RQ_VIP_Module.isSubject4Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  137. [self.carTypeBtn setImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"驾照类型-黑") : RQImageNamed(@"驾照类型") forState:UIControlStateNormal];
  138. [self.schoolNameBtn setTitleColor:RQ_VIP_Module.isSubject4Vip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  139. [self.schoolNameBtn setImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"公司-黑") : RQImageNamed(@"公司") forState:UIControlStateNormal];
  140. [self.detailArrowImg setImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"查看详情-黑") : RQImageNamed(@"查看详情")];
  141. [self.settingBtn setBackgroundImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"设置-黑") : RQImageNamed(@"设置") forState:UIControlStateNormal];
  142. [self.messageBtn setBackgroundImage:RQ_VIP_Module.isSubject4Vip? RQImageNamed(@"消息-黑") : RQImageNamed(@"消息") forState:UIControlStateNormal];
  143. break;
  144. case 4:
  145. self.myBgImageView.image = RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"科四 已开通") : RQImageNamed(@"科四");
  146. self.userNameLabel.textColor = RQ_VIP_Module.isSubjectAllVip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor;
  147. [self.telePhoneBtn setTitleColor:RQ_VIP_Module.isSubjectAllVip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  148. [self.telePhoneBtn setImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"手机-黑") : RQImageNamed(@"手机") forState:UIControlStateNormal];
  149. [self.carTypeBtn setTitleColor:RQ_VIP_Module.isSubjectAllVip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  150. [self.carTypeBtn setImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"驾照类型-黑") : RQImageNamed(@"驾照类型") forState:UIControlStateNormal];
  151. [self.schoolNameBtn setTitleColor:RQ_VIP_Module.isSubjectAllVip? RQ_MAIN_TEXT_COLOR_1 : UIColor.whiteColor forState:UIControlStateNormal];
  152. [self.schoolNameBtn setImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"公司-黑") : RQImageNamed(@"公司") forState:UIControlStateNormal];
  153. [self.detailArrowImg setImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"查看详情-黑") : RQImageNamed(@"查看详情")];
  154. [self.settingBtn setBackgroundImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"设置-黑") : RQImageNamed(@"设置") forState:UIControlStateNormal];
  155. [self.messageBtn setBackgroundImage:RQ_VIP_Module.isSubjectAllVip? RQImageNamed(@"消息-黑") : RQImageNamed(@"消息") forState:UIControlStateNormal];
  156. break;
  157. default:
  158. break;
  159. }
  160. }
  161. return @"";
  162. }] takeUntil:self.rac_prepareForReuseSignal];
  163. [signal subscribeNext:^(NSArray *allArr) {
  164. }];
  165. }
  166. - (void)layoutSubviews {
  167. [super layoutSubviews];
  168. @weakify(self)
  169. [self.vipCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  170. @strongify(self)
  171. make.top.mas_equalTo(self.myHeadImageView.mas_bottom).mas_offset(20);
  172. make.left.right.mas_equalTo(self.vipContentView);
  173. make.bottom.mas_equalTo(self.vipContentView.mas_bottom).mas_offset(12);
  174. // make.height.mas_equalTo(RQ_FIT_HORIZONTAL(169.f));
  175. }];
  176. }
  177. #pragma mark - PrivateMethods
  178. - (IBAction)settingAction:(id)sender {
  179. [RQ_APPDELEGATE.services pushViewModel:[[RQSettingViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil] animated:YES];
  180. }
  181. #pragma mark - UICollectionViewDatasource
  182. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  183. return 1;
  184. }
  185. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  186. return 5;
  187. }
  188. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  189. switch (indexPath.row) {
  190. case 0: {
  191. RQProfileSubjectOneVipCell *cell = [RQProfileSubjectOneVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  192. RQProfileVipItemViewModel *itemViewModel = [[RQProfileVipItemViewModel alloc] init];
  193. itemViewModel.profileSubject = indexPath.row;
  194. [cell bindViewModel:itemViewModel];
  195. return cell;
  196. }
  197. case 1: {
  198. RQProfileSubjectTwoVipCell *cell = [RQProfileSubjectTwoVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  199. RQProfileVipItemViewModel *itemViewModel = [[RQProfileVipItemViewModel alloc] init];
  200. itemViewModel.profileSubject = indexPath.row;
  201. [cell bindViewModel:itemViewModel];
  202. return cell;
  203. }
  204. case 2: {
  205. RQProfileSubjectThreeVipCell *cell = [RQProfileSubjectThreeVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  206. RQProfileVipItemViewModel *itemViewModel = [[RQProfileVipItemViewModel alloc] init];
  207. itemViewModel.profileSubject = indexPath.row;
  208. [cell bindViewModel:itemViewModel];
  209. return cell;
  210. }
  211. case 3: {
  212. RQProfileSubjectFourVipCell *cell = [RQProfileSubjectFourVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  213. RQProfileVipItemViewModel *itemViewModel = [[RQProfileVipItemViewModel alloc] init];
  214. itemViewModel.profileSubject = indexPath.row;
  215. [cell bindViewModel:itemViewModel];
  216. return cell;
  217. }
  218. default: {
  219. RQProfileVipCell *cell = [RQProfileVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  220. RQProfileVipItemViewModel *itemViewModel = [[RQProfileVipItemViewModel alloc] init];
  221. itemViewModel.profileSubject = indexPath.row;
  222. [cell bindViewModel:itemViewModel];
  223. return cell;
  224. }
  225. }
  226. }
  227. #pragma mark - UICollectionViewDelegate
  228. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  229. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  230. }
  231. #pragma mark - UICollectionViewDelegateFlowLayout
  232. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  233. CGSize size = CGSizeMake(CGRectGetWidth(self.vipCollectionView.bounds) - UIEdgeInsetsGetHorizontalValue(self.vipCollectionViewFlowLayout.sectionInset), CGRectGetHeight(self.vipCollectionView.bounds) - UIEdgeInsetsGetVerticalValue(self.vipCollectionViewFlowLayout.sectionInset));
  234. return size;
  235. }
  236. - (void)scrollViewDidScroll:(UIScrollView *)sender {
  237. self.isScrolling = YES;
  238. [NSObject cancelPreviousPerformRequestsWithTarget:self];
  239. [self performSelector:@selector(scrollViewDidEndScrollingAnimation:) withObject:sender afterDelay:0.1];
  240. }
  241. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
  242. self.isScrolling = NO;
  243. [NSObject cancelPreviousPerformRequestsWithTarget:self];
  244. }
  245. #pragma mark - LazyLoad
  246. - (CGFloat)btnsViewHeight {
  247. if (_btnsViewHeight == 0) _btnsViewHeight = (RQ_FIT_HORIZONTAL(60.f) - 16.f) / 2.f;
  248. return _btnsViewHeight;
  249. }
  250. - (CGFloat)headImageViewHeight {
  251. if (_headImageViewHeight == 0) _headImageViewHeight = (RQ_FIT_HORIZONTAL(70.f));
  252. return _headImageViewHeight;
  253. }
  254. - (CGFloat)headImageViewCornerRadiusHeight {
  255. if (_headImageViewCornerRadiusHeight == 0) _headImageViewCornerRadiusHeight = self.headImageViewHeight / 2.f;
  256. return _headImageViewCornerRadiusHeight;
  257. }
  258. - (UICollectionView *)vipCollectionView {
  259. if (!_vipCollectionView) {
  260. _vipCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_myHeadImageView.frame) + 20, RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(169.f)) collectionViewLayout:self.vipCollectionViewFlowLayout];
  261. _vipCollectionView.delegate = self;
  262. _vipCollectionView.dataSource = self;
  263. _vipCollectionView.showsHorizontalScrollIndicator = NO;
  264. _vipCollectionView.backgroundColor = UIColorClear;
  265. [_vipCollectionView registerNib:[UINib nibWithNibName:@"RQProfileVipCell" bundle:nil] forCellWithReuseIdentifier:@"RQProfileVipCell"];
  266. }
  267. return _vipCollectionView;
  268. }
  269. - (QMUICollectionViewPagingLayout *)vipCollectionViewFlowLayout {
  270. if (!_vipCollectionViewFlowLayout) {
  271. _vipCollectionViewFlowLayout = [[QMUICollectionViewPagingLayout alloc] initWithStyle:QMUICollectionViewPagingLayoutStyleDefault];
  272. _vipCollectionViewFlowLayout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
  273. _vipCollectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  274. _vipCollectionViewFlowLayout.allowsMultipleItemScroll = NO;
  275. }
  276. return _vipCollectionViewFlowLayout;
  277. }
  278. @end