HMVideoControlView.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. //
  2. // HMVideoControlView.m
  3. // BuguLive
  4. //
  5. // Created by 范东 on 2018/12/27.
  6. // Copyright © 2018 xfg. All rights reserved.
  7. //
  8. #import "HMVideoControlView.h"
  9. #import "HMVideoSliderView.h"
  10. #import "PersonCenterModel.h"
  11. #import "CommentModel.h"
  12. #import "BogoShopKit.h"
  13. // 判断是否是iPhone X系列
  14. #define IS_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?\
  15. (\
  16. CGSizeEqualToSize(CGSizeMake(375, 812),[UIScreen mainScreen].bounds.size)\
  17. ||\
  18. CGSizeEqualToSize(CGSizeMake(812, 375),[UIScreen mainScreen].bounds.size)\
  19. ||\
  20. CGSizeEqualToSize(CGSizeMake(414, 896),[UIScreen mainScreen].bounds.size)\
  21. ||\
  22. CGSizeEqualToSize(CGSizeMake(896, 414),[UIScreen mainScreen].bounds.size))\
  23. :\
  24. NO)
  25. #define ADAPTATIONRATIO kScreenW / 750.0f
  26. #define TABBAR_HEIGHT (IS_iPhoneX ? 83.0f : 49.0f)
  27. @implementation HMVideoItemButton
  28. - (void)layoutSubviews {
  29. [super layoutSubviews];
  30. [self.imageView sizeToFit];
  31. [self.titleLabel sizeToFit];
  32. CGFloat width = self.frame.size.width;
  33. CGFloat height = self.frame.size.height;
  34. CGFloat imgW = self.imageView.frame.size.width;
  35. CGFloat imgH = self.imageView.frame.size.height;
  36. self.imageView.frame = CGRectMake((width - imgH) / 2, 0, imgW, imgH);
  37. CGFloat titleW = self.titleLabel.frame.size.width;
  38. CGFloat titleH = self.titleLabel.frame.size.height;
  39. self.titleLabel.frame = CGRectMake((width - titleW) / 2, height - titleH + 5, titleW, titleH);
  40. }
  41. @end
  42. @interface HMVideoControlView ()
  43. @property (nonatomic, strong) UIImageView *iconView;
  44. @property (nonatomic, strong) HMVideoItemButton *praiseBtn;
  45. @property (nonatomic, strong) HMVideoItemButton *shareBtn;
  46. @property (nonatomic, strong) HMVideoItemButton *oneOnOneBtn;
  47. @property (nonatomic, strong) HMVideoItemButton *giftBtn;
  48. @property (nonatomic, strong) UILabel *nameLabel;
  49. @property (nonatomic, strong) UILabel *contentLabel;
  50. @property (nonatomic, strong) HMVideoSliderView *sliderView;
  51. @property (nonatomic, strong) UIActivityIndicatorView *loadingView;
  52. @property (nonatomic, strong) UIButton *playBtn;
  53. @property (nonatomic, assign) int currentPage; //当前页数
  54. @property (nonatomic, assign) int has_next; //是否还有下一页1代表有
  55. @property (nonatomic, strong) NSMutableArray *dataArray;
  56. @property (nonatomic, strong) NSMutableDictionary *shareDict;
  57. @property (nonatomic, strong) PersonCenterModel *detailModel;
  58. @property (nonatomic, strong) UIButton *focusBtn;
  59. @property(nonatomic, strong) BogoVideoGoodControl *goodControl;
  60. @end
  61. @implementation HMVideoControlView
  62. - (instancetype)initWithIsPushed:(BOOL)isPushed {
  63. if (self = [super init]) {
  64. self.isPushed = isPushed;
  65. [self addSubview:self.coverImgView];
  66. [self addSubview:self.iconView];
  67. [self addSubview:self.praiseBtn];
  68. [self addSubview:self.commentBtn];
  69. [self addSubview:self.shareBtn];
  70. [self addSubview:self.oneOnOneBtn];
  71. if (![GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
  72. [self addSubview:self.giftBtn];
  73. }
  74. [self addSubview:self.nameLabel];
  75. [self addSubview:self.contentLabel];
  76. [self addSubview:self.sliderView];
  77. [self addSubview:self.loadingView];
  78. [self addSubview:self.playBtn];
  79. [self addSubview:self.commentButton];
  80. [self addSubview:self.moreBtn];
  81. [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.right.mas_equalTo(-20);
  83. make.top.mas_equalTo(kStatusBarHeight);
  84. make.width.mas_equalTo(40);
  85. make.height.mas_equalTo(kRealValue(30));
  86. }];
  87. [self.coverImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.edges.equalTo(self);
  89. }];
  90. CGFloat bottomM = TABBAR_HEIGHT + 64+50;
  91. if ([GlobalVariables sharedInstance].appModel.short_video.integerValue && !self.isPushed) {
  92. bottomM = TABBAR_HEIGHT;
  93. }
  94. if (self.isPushed){
  95. bottomM = TABBAR_HEIGHT;
  96. }
  97. [self.sliderView mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.right.equalTo(self);
  99. make.bottom.equalTo(self).offset(-bottomM);
  100. make.height.mas_equalTo(ADAPTATIONRATIO * 1.0f);
  101. }];
  102. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.equalTo(self).offset(ADAPTATIONRATIO * 30.0f);
  104. make.bottom.equalTo(self.sliderView).offset(-ADAPTATIONRATIO * 30.0f);
  105. make.width.mas_equalTo(ADAPTATIONRATIO * 504.0f);
  106. }];
  107. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.equalTo(self.contentLabel);
  109. make.bottom.equalTo(self.contentLabel.mas_top).offset(-ADAPTATIONRATIO * 20.0f);
  110. }];
  111. [self.oneOnOneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.right.equalTo(self).offset(-ADAPTATIONRATIO * 15.0f);
  113. make.bottom.equalTo(self.contentLabel.mas_bottom).offset(-ADAPTATIONRATIO * 10.0f);
  114. make.height.mas_equalTo(ADAPTATIONRATIO * 110.0f);
  115. }];
  116. if (![GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
  117. [self.giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.right.equalTo(self).offset(-ADAPTATIONRATIO * 25.0f);
  119. make.bottom.equalTo(self.nameLabel.mas_top).offset(-ADAPTATIONRATIO * 50.0f);
  120. // make.centerX.mas_equalTo()
  121. make.height.mas_equalTo(ADAPTATIONRATIO * 55.0f);
  122. }];
  123. [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  124. // make.right.equalTo(self).offset(-ADAPTATIONRATIO * 30.0f);
  125. make.centerX.mas_equalTo(self.giftBtn.mas_centerX);
  126. make.bottom.equalTo(self.giftBtn.mas_top).offset(-ADAPTATIONRATIO * 40.0f);
  127. make.height.mas_equalTo(ADAPTATIONRATIO * 110.0f);
  128. }];
  129. }else{
  130. [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  131. // make.right.equalTo(self).offset(-ADAPTATIONRATIO * 30.0f);
  132. make.right.equalTo(self).offset(-ADAPTATIONRATIO * 25.0f);
  133. make.bottom.equalTo(self.nameLabel.mas_top).offset(-ADAPTATIONRATIO * 90.0f);
  134. make.height.mas_equalTo(ADAPTATIONRATIO * 110.0f);
  135. }];
  136. }
  137. [self.commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.centerX.equalTo(self.shareBtn);
  139. make.bottom.equalTo(self.shareBtn.mas_top).offset(-ADAPTATIONRATIO * 45.0f);
  140. make.height.mas_equalTo(ADAPTATIONRATIO * 110.0f);
  141. }];
  142. [self.praiseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  143. make.centerX.equalTo(self.shareBtn);
  144. make.bottom.equalTo(self.commentBtn.mas_top).offset(-ADAPTATIONRATIO * 45.0f);
  145. make.height.mas_equalTo(ADAPTATIONRATIO * 110.0f);
  146. }];
  147. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  148. make.centerX.equalTo(self.shareBtn);
  149. make.bottom.equalTo(self.praiseBtn.mas_top).offset(-ADAPTATIONRATIO * 70.0f);
  150. make.width.height.mas_equalTo(ADAPTATIONRATIO * 100.0f);
  151. }];
  152. [self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) {
  153. make.center.equalTo(self);
  154. }];
  155. [self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  156. make.center.equalTo(self);
  157. }];
  158. [self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.left.equalTo(self).offset(10);
  160. make.top.equalTo(self.sliderView.mas_bottom).offset(10);
  161. make.right.equalTo(self);
  162. }];
  163. [self addSubview:self.focusBtn];
  164. [self.focusBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  165. make.centerX.equalTo(self.iconView);
  166. make.centerY.equalTo(self.iconView.mas_bottom);
  167. }];
  168. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controlViewDidClick:)];
  169. [self addGestureRecognizer:tap];
  170. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFocusStatus:) name:@"liveIsShowFollow" object:nil];
  171. }
  172. return self;
  173. }
  174. - (void)setModel:(SmallVideoListModel *)model {
  175. _model = model;
  176. if ([model.user_id isEqualToString:[[IMAPlatform sharedInstance].host imUserId]]) {
  177. self.giftBtn.hidden = YES;
  178. }else{
  179. self.giftBtn.hidden = NO;
  180. }
  181. self.sliderView.value = 0;
  182. //
  183. [self.coverImgView sd_setImageWithURL:[NSURL URLWithString:model.photo_image] placeholderImage:[UIImage imageNamed:@"placeholderimg"]];
  184. //
  185. self.nameLabel.text = [NSString stringWithFormat:@"@%@", model.nick_name];
  186. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:[UIImage imageNamed:@"placeholderimg"]];
  187. //
  188. self.contentLabel.text = model.content;
  189. //
  190. [self.praiseBtn setTitle:model.digg_count forState:UIControlStateNormal];
  191. [self.commentBtn setTitle:model.comment_count forState:UIControlStateNormal];
  192. // [self.shareBtn setTitle:model.share_num forState:UIControlStateNormal];
  193. if (![self.model.user_id isEqualToString:[BGIMLoginManager sharedInstance].loginParam.identifier]){
  194. [self.focusBtn setHidden:[model.has_focus isEqualToString:@"1"]];
  195. self.moreBtn.hidden = YES;
  196. }else{
  197. self.moreBtn.hidden = NO;
  198. self.focusBtn.hidden = NO;
  199. }
  200. [self loadNetDataWithPage:1];
  201. if (model.weibo_id.integerValue) {
  202. [self addPlayNumWithWeiBoId:model.weibo_id];
  203. }else{
  204. [self addPlayNumWithWeiBoId:model.id];
  205. }
  206. if (![GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
  207. if (StrValid(model.shop_id) && model.shop_title.length) {
  208. [self addSubview:self.goodControl];
  209. [self.goodControl.titleLabel setText:SafeStr(model.shop_title)];
  210. [self.goodControl mas_makeConstraints:^(MASConstraintMaker *make) {
  211. make.left.equalTo(self).offset(15);
  212. make.height.mas_equalTo(@30);
  213. make.bottom.equalTo(self.nameLabel.mas_top).offset(-30);
  214. make.right.lessThanOrEqualTo(self).offset(-60);
  215. }];
  216. }else{
  217. [self.goodControl removeFromSuperview];
  218. }
  219. }
  220. }
  221. - (void)changeFocusStatus:(NSNotification *)noti{
  222. NSDictionary *dict = noti.object;
  223. NSString *isShowFollow = dict[@"isShowFollow"];
  224. NSString *userId = dict[@"userId"];
  225. if ([userId isEqualToString:self.model.user_id]) {
  226. self.focusBtn.hidden = ![isShowFollow isEqualToString:@"1"];
  227. }
  228. }
  229. #pragma mark 加载详情数据
  230. -(void)loadNetDataWithPage:(int)page
  231. {
  232. NSMutableDictionary *MDict = [NSMutableDictionary new];
  233. [MDict setObject:@"weibo" forKey:@"ctl"];
  234. [MDict setObject:@"index" forKey:@"act"];
  235. [MDict setObject:@"xr" forKey:@"itype"];
  236. if (self.model.weibo_id.length)
  237. {
  238. [MDict setObject:self.model.weibo_id forKey:@"weibo_id"];
  239. }
  240. if (self.model.id.length)
  241. {
  242. [MDict setObject:self.model.id forKey:@"weibo_id"];
  243. }
  244. FWWeakify(self)
  245. [self.httpsManager POSTWithParameters:MDict SuccessBlock:^(NSDictionary *responseJson)
  246. {
  247. FWStrongify(self)
  248. _has_next = [responseJson toInt:@"has_next"];
  249. _currentPage = [responseJson toInt:@"page"];
  250. if (_currentPage == 1)
  251. {
  252. [_dataArray removeAllObjects];
  253. }
  254. if ([responseJson toInt:@"status"]== 1)
  255. {
  256. // self.praiseBtn.selected = [responseJson[@"info"][@"has_digg"] isEqual:@(1)];
  257. if ([responseJson[@"info"][@"has_digg"] isEqual:@(1)]) {
  258. _praiseBtn.selected = YES;
  259. }else{
  260. _praiseBtn.selected = NO;
  261. }
  262. [self.praiseBtn setTitle:responseJson[@"info"][@"digg_count"] forState:UIControlStateNormal];
  263. [self.commentBtn setTitle:responseJson[@"info"][@"comment_count"] forState:UIControlStateNormal];
  264. NSDictionary *shareD = [responseJson objectForKey:@"invite_info"];
  265. if (shareD && [shareD isKindOfClass:[NSDictionary class]]) {
  266. if ([shareD count])
  267. {
  268. if ([[shareD objectForKey:@"clickUrl"] length])
  269. {
  270. [self.shareDict setObject:[shareD objectForKey:@"clickUrl"] forKey:@"share_url"];
  271. }else
  272. {
  273. [self.shareDict setObject:@"" forKey:@"share_url"];
  274. }
  275. if ([[shareD objectForKey:@"content"] length])
  276. {
  277. [self.shareDict setObject:[shareD objectForKey:@"content"] forKey:@"share_content"];
  278. }else
  279. {
  280. [self.shareDict setObject:@"" forKey:@"share_content"];
  281. }
  282. if ([[shareD objectForKey:@"imageUrl"] length])
  283. {
  284. [self.shareDict setObject:[shareD objectForKey:@"imageUrl"] forKey:@"share_imageUrl"];
  285. }else
  286. {
  287. [self.shareDict setObject:@"" forKey:@"share_imageUrl"];
  288. }
  289. if ([[shareD objectForKey:@"title"] length])
  290. {
  291. [self.shareDict setObject:[shareD objectForKey:@"title"] forKey:@"share_title"];
  292. }else
  293. {
  294. [self.shareDict setObject:@"" forKey:@"share_title"];
  295. }
  296. }
  297. }
  298. _detailModel = [PersonCenterModel mj_objectWithKeyValues:responseJson];
  299. // [self.focusBtn setHidden:_detailModel.has_focus == 1];
  300. //动态
  301. NSArray *comment_listArray = [responseJson objectForKey:@"comment_list"];
  302. if (comment_listArray && [comment_listArray isKindOfClass:[NSArray class]])
  303. {
  304. if (comment_listArray.count)
  305. {
  306. for (NSDictionary *dict in comment_listArray)
  307. {
  308. CommentModel *CModel = [CommentModel mj_objectWithKeyValues:dict];
  309. [self.dataArray addObject:CModel];
  310. }
  311. }
  312. }
  313. }else
  314. {
  315. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  316. }
  317. } FailureBlock:^(NSError *error)
  318. {
  319. NSLog(@"error==%@",error);
  320. }];
  321. }
  322. #pragma mark 播放视频加1
  323. - (void)addPlayNumWithWeiBoId:(NSString *)weiBoId
  324. {
  325. NSMutableDictionary *MDict = [NSMutableDictionary new];
  326. [MDict setObject:@"weibo" forKey:@"ctl"];
  327. [MDict setObject:@"add_video_count" forKey:@"act"];
  328. [MDict setObject:@"xr" forKey:@"itype"];
  329. if (weiBoId.length)
  330. {
  331. [MDict setObject:weiBoId forKey:@"weibo_id"];
  332. }
  333. FWWeakify(self)
  334. [self.httpsManager POSTWithParameters:MDict SuccessBlock:^(NSDictionary *responseJson)
  335. {
  336. FWStrongify(self)
  337. if ([responseJson toInt:@"status"]== 1)
  338. {
  339. _detailModel.info.video_count = [responseJson toString:@"video_count"];
  340. NSMutableDictionary *postDict = [[NSMutableDictionary alloc]init];
  341. [postDict setObject:@"video" forKey:@"type"];
  342. [postDict setObject:[NSString stringWithFormat:@"%d",[responseJson toInt:@"video_count"]] forKey:@"count"];
  343. [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTableViewStatus" object:postDict];
  344. }else{
  345. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  346. }
  347. } FailureBlock:^(NSError *error)
  348. {
  349. NSLog(@"error==%@",error);
  350. }];
  351. }
  352. #pragma mark - Public Methods
  353. - (void)setProgress:(float)progress {
  354. self.sliderView.value = progress;
  355. }
  356. - (void)startLoading {
  357. [self.loadingView startAnimating];
  358. }
  359. - (void)stopLoading {
  360. [self.loadingView stopAnimating];
  361. }
  362. - (void)showPlayBtn {
  363. self.playBtn.hidden = NO;
  364. }
  365. - (void)hidePlayBtn {
  366. self.playBtn.hidden = YES;
  367. }
  368. #pragma mark - Action
  369. - (void)controlViewDidClick:(id)sender {
  370. if ([self.delegate respondsToSelector:@selector(controlViewDidClickSelf:)]) {
  371. [self.delegate controlViewDidClickSelf:self];
  372. }
  373. }
  374. - (void)iconDidClick:(id)sender {
  375. if (![GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
  376. if ([self.delegate respondsToSelector:@selector(controlViewDidClickIcon:)]) {
  377. [self.delegate controlViewDidClickIcon:self];
  378. }
  379. }
  380. }
  381. - (void)praiseBtnClick:(id)sender {
  382. if ([self.delegate respondsToSelector:@selector(controlViewDidClickPriase:)]) {
  383. [self.delegate controlViewDidClickPriase:self];
  384. }
  385. }
  386. - (void)commentBtnClick:(id)sender {
  387. if ([self.delegate respondsToSelector:@selector(controlViewDidClickComment:DataArray:)]) {
  388. [self.delegate controlViewDidClickComment:self DataArray:self.dataArray];
  389. }
  390. }
  391. - (void)oneOnOneBtnClick:(UIButton *)sender{
  392. [self showPlayBtn];
  393. if (self.delegate && [self.delegate respondsToSelector:@selector(controlViewDidClickOneOnOne:)]) {
  394. [self.delegate controlViewDidClickOneOnOne:self];
  395. }
  396. }
  397. - (void)shareBtnClick:(id)sender {
  398. if ([self.delegate respondsToSelector:@selector(controlViewDidClickShare:ShareDict:)]) {
  399. [self.delegate controlViewDidClickShare:self ShareDict:self.shareDict];
  400. }
  401. }
  402. -(void)giftBtnClick:(UIButton *)sender{
  403. if ([self.delegate respondsToSelector:@selector(controlViewDidClickGift:)]) {
  404. [self.delegate controlViewDidClickGift:self];
  405. }
  406. }
  407. - (void)setiIsPraise:(BOOL)isPraise diggcount:(nonnull NSString *)diggcount{
  408. // if (isPraise) {
  409. // [_praiseBtn setImage:[UIImage imageNamed:@"me_icon_star_selected"] forState:UIControlStateNormal];
  410. // }else{
  411. // [_praiseBtn setImage:[UIImage imageNamed:@"me_icon_star_normal"] forState:UIControlStateNormal];
  412. // }
  413. _praiseBtn.selected = isPraise;
  414. // self.praiseBtn.selected = isPraise;
  415. [self.praiseBtn setTitle:diggcount forState:UIControlStateNormal];
  416. }
  417. - (void)commentBtnAction{
  418. //点击了想撩TA按钮
  419. if ([self.delegate respondsToSelector:@selector(controlViewDidClickBottomComment:)]) {
  420. [self.delegate controlViewDidClickBottomComment:self];
  421. }
  422. }
  423. - (void)focusBtnAction{
  424. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  425. [dictM setObject:@"user" forKey:@"ctl"];
  426. [dictM setObject:@"follow" forKey:@"act"];
  427. [dictM setObject:[NSString stringWithFormat:@"%@",self.model.user_id] forKey:@"to_user_id"];
  428. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  429. {
  430. if ([responseJson toInt:@"status"] == 1)
  431. {
  432. int has_focus = [responseJson toInt:@"has_focus"];
  433. if ([responseJson toInt:@"status"] == 1)
  434. {
  435. if (has_focus == 1)//已关注
  436. {
  437. self.focusBtn.hidden = YES;
  438. }else if (has_focus == 0)//关注
  439. {
  440. self.focusBtn.hidden = NO;
  441. }
  442. self.model.has_focus = [NSString stringWithFormat:@"%@",[responseJson valueForKey:@"has_focus"]];
  443. }
  444. }
  445. } FailureBlock:^(NSError *error)
  446. {
  447. }];
  448. }
  449. #pragma mark - 懒加载
  450. - (UIImageView *)coverImgView {
  451. if (!_coverImgView) {
  452. _coverImgView = [UIImageView new];
  453. _coverImgView.contentMode = UIViewContentModeScaleAspectFill;
  454. _coverImgView.clipsToBounds = YES;
  455. }
  456. return _coverImgView;
  457. }
  458. - (UIImageView *)iconView {
  459. if (!_iconView) {
  460. _iconView = [UIImageView new];
  461. _iconView.layer.cornerRadius = ADAPTATIONRATIO * 50.0f;
  462. _iconView.layer.masksToBounds = YES;
  463. _iconView.layer.borderColor = [UIColor whiteColor].CGColor;
  464. _iconView.layer.borderWidth = 1.0f;
  465. _iconView.userInteractionEnabled = YES;
  466. UITapGestureRecognizer *iconTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iconDidClick:)];
  467. [_iconView addGestureRecognizer:iconTap];
  468. }
  469. return _iconView;
  470. }
  471. - (HMVideoItemButton *)praiseBtn {
  472. if (!_praiseBtn) {
  473. _praiseBtn = [HMVideoItemButton new];
  474. [_praiseBtn setImage:[UIImage imageNamed:@"me_icon_star_normal"] forState:UIControlStateNormal];
  475. [_praiseBtn setImage:[UIImage imageNamed:@"me_icon_star_selected"] forState:UIControlStateSelected];
  476. _praiseBtn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
  477. [_praiseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  478. [_praiseBtn addTarget:self action:@selector(praiseBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  479. }
  480. return _praiseBtn;
  481. }
  482. - (HMVideoItemButton *)commentBtn {
  483. if (!_commentBtn) {
  484. _commentBtn = [HMVideoItemButton new];
  485. [_commentBtn setImage:[UIImage imageNamed:@"me_icon_comment"] forState:UIControlStateNormal];
  486. _commentBtn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
  487. [_commentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  488. [_commentBtn addTarget:self action:@selector(commentBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  489. }
  490. return _commentBtn;
  491. }
  492. - (HMVideoItemButton *)shareBtn {
  493. if (!_shareBtn) {
  494. _shareBtn = [HMVideoItemButton new];
  495. [_shareBtn setImage:[UIImage imageNamed:@"me_icon_share"] forState:UIControlStateNormal];
  496. _shareBtn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
  497. [_shareBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  498. [_shareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  499. }
  500. return _shareBtn;
  501. }
  502. -(HMVideoItemButton *)giftBtn{
  503. if (!_giftBtn) {
  504. _giftBtn = [HMVideoItemButton new];
  505. [_giftBtn setImage:[UIImage imageNamed:@"mg_video_gift"] forState:UIControlStateNormal];
  506. _giftBtn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
  507. [_giftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  508. [_giftBtn addTarget:self action:@selector(giftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  509. if (kIsCheckingVersion())
  510. {
  511. _giftBtn.hidden = YES;
  512. }
  513. }
  514. return _giftBtn;
  515. }
  516. - (HMVideoItemButton *)oneOnOneBtn {
  517. if (!_oneOnOneBtn) {
  518. _oneOnOneBtn = [HMVideoItemButton new];
  519. [_oneOnOneBtn setImage:[UIImage imageNamed:@"me_icon_im_video"] forState:UIControlStateNormal];
  520. _oneOnOneBtn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
  521. [_oneOnOneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  522. [_oneOnOneBtn addTarget:self action:@selector(oneOnOneBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  523. }
  524. return _oneOnOneBtn;
  525. }
  526. - (UILabel *)nameLabel {
  527. if (!_nameLabel) {
  528. _nameLabel = [UILabel new];
  529. _nameLabel.textColor = [UIColor whiteColor];
  530. _nameLabel.font = [UIFont boldSystemFontOfSize:15.0f];
  531. _nameLabel.userInteractionEnabled = YES;
  532. UITapGestureRecognizer *nameTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iconDidClick:)];
  533. [_nameLabel addGestureRecognizer:nameTap];
  534. }
  535. return _nameLabel;
  536. }
  537. - (UILabel *)contentLabel {
  538. if (!_contentLabel) {
  539. _contentLabel = [UILabel new];
  540. _contentLabel.numberOfLines = 0;
  541. _contentLabel.textColor = [UIColor whiteColor];
  542. _contentLabel.font = [UIFont systemFontOfSize:14.0f];
  543. }
  544. return _contentLabel;
  545. }
  546. - (HMVideoSliderView *)sliderView {
  547. if (!_sliderView) {
  548. _sliderView = [HMVideoSliderView new];
  549. _sliderView.isHideSliderBlock = YES;
  550. _sliderView.sliderHeight = ADAPTATIONRATIO * 1.0f;
  551. _sliderView.maximumTrackTintColor = [UIColor grayColor];
  552. _sliderView.minimumTrackTintColor = [UIColor whiteColor];
  553. }
  554. return _sliderView;
  555. }
  556. - (UIActivityIndicatorView *)loadingView {
  557. if (!_loadingView) {
  558. _loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
  559. _loadingView.hidesWhenStopped = YES;
  560. }
  561. return _loadingView;
  562. }
  563. - (UIButton *)playBtn {
  564. if (!_playBtn) {
  565. _playBtn = [UIButton new];
  566. [_playBtn setImage:[UIImage imageNamed:@"me_icon_pause"] forState:UIControlStateNormal];
  567. _playBtn.userInteractionEnabled = NO;
  568. _playBtn.hidden = YES;
  569. }
  570. return _playBtn;
  571. }
  572. - (UIButton *)commentButton{
  573. if (!_commentButton) {
  574. _commentButton = [[UIButton alloc]initWithFrame:CGRectZero];
  575. [_commentButton setBackgroundColor:kClearColor];
  576. [_commentButton setTitle:ASLocalizedString(@"想撩TA,先评论")forState:UIControlStateNormal];
  577. [_commentButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
  578. _commentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  579. [_commentButton.titleLabel setTextColor:[kWhiteColor colorWithAlphaComponent:0.5]];
  580. _commentButton.hidden = YES;
  581. [_commentButton addTarget:self action:@selector(commentBtnAction) forControlEvents:UIControlEventTouchUpInside];
  582. }
  583. return _commentButton;
  584. }
  585. -(UIButton *)moreBtn{
  586. if (!_moreBtn) {
  587. _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  588. _moreBtn.frame = CGRectMake(kScreenW - kRealValue(10) - 64, kStatusBarHeight, kRealValue(44), kRealValue(44));
  589. [_moreBtn setImage:[UIImage imageNamed:@"video_more_Btn"] forState:UIControlStateNormal];
  590. [_moreBtn addTarget:self action:@selector(clickMoreBtn:) forControlEvents:UIControlEventTouchUpInside];
  591. _moreBtn.hidden = YES;
  592. }
  593. return _moreBtn;
  594. }
  595. -(void)clickMoreBtn:(UIButton *)sender{
  596. if ([self.delegate respondsToSelector:@selector(controlViewDidClickMoreBtn:)]) {
  597. [self.delegate controlViewDidClickMoreBtn:self];
  598. }
  599. }
  600. - (UIButton *)focusBtn{
  601. if (!_focusBtn) {
  602. _focusBtn = [[UIButton alloc]initWithFrame:CGRectZero];
  603. [_focusBtn setImage:[UIImage imageNamed:@"me_icon_focus"] forState:UIControlStateNormal];
  604. [_focusBtn addTarget:self action:@selector(focusBtnAction) forControlEvents:UIControlEventTouchUpInside];
  605. }
  606. return _focusBtn;
  607. }
  608. - (NSMutableDictionary *)shareDict{
  609. if (!_shareDict) {
  610. _shareDict = [NSMutableDictionary dictionary];
  611. }
  612. return _shareDict;
  613. }
  614. - (BogoVideoGoodControl *)goodControl{
  615. if (!_goodControl) {
  616. // _goodControl = [kShopKitBundle loadNibNamed:@"BogoVideoGoodControl" owner:self options:nil].firstObject;
  617. _goodControl = [kShopKitBundle loadNibNamed:@"BogoVideoGoodControl" owner:nil options:nil].lastObject;
  618. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toGoodDetailVC)];
  619. _goodControl.userInteractionEnabled = YES;
  620. [_goodControl addGestureRecognizer:tap];
  621. }
  622. return _goodControl;
  623. }
  624. - (void)toGoodDetailVC{
  625. if (self.model.model_id.integerValue == 1) {
  626. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.model.link_url]];
  627. }else{
  628. BogoGoodDetailViewController *detailVC = [[BogoGoodDetailViewController alloc]init];
  629. detailVC.gid = self.model.shop_id;
  630. [[AppDelegate sharedAppDelegate] pushViewController:detailVC animated:YES];
  631. }
  632. }
  633. @end